Skip to content

[JumpThreading] jumpthreading can create phi arguments for lifetime intrinsics #167733

@topperc

Description

@topperc

Running opt -passes=jump-threading on this test fails with llvm.lifetime.start/end can only be used on alloca or poison

; ModuleID = 'reduced.ll'                                                        
source_filename = "reduced.ll"                                                   
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"                  
target triple = "riscv64-unknown-linux-gnu"                                      
                                                                                 
define void @widget(i1 %arg) {                                                   
bb:                                                                              
  br i1 %arg, label %bb1, label %bb2                                             
                                                                                 
bb1:                                              ; preds = %bb                  
  %call = tail call <vscale x 2 x i32> @llvm.vp.zext.nxv2i32.nxv2i8(<vscale x 2 x i8> zeroinitializer, <vscale x 2 x i1> zeroinitializer, i32 0)
  br label %bb2                                                                  
                                                                                 
bb2:                                              ; preds = %bb1, %bb            
  %alloca = alloca [4 x [4 x i32]], align 8                                      
  br i1 %arg, label %bb3, label %bb4                                             
                                                                                 
bb3:                                              ; preds = %bb2                 
  br label %bb4                                                                  
                                                                                 
bb4:                                              ; preds = %bb3, %bb2           
  call void @llvm.lifetime.start.p0(ptr %alloca)                                 
  ret void                                                                       
}                                                                                
                                                                                 
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <vscale x 2 x i32> @llvm.vp.zext.nxv2i32.nxv2i8(<vscale x 2 x i8>, <vscale x 2 x i1>, i32) #0
                                                                                 
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(ptr captures(none)) #1                      
                                                                                 
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }

https://godbolt.org/z/1jWaY6qoW

Test cases is a reduced from output from our downstream compiler where we accidentally moved an alloca out of the entry block. I haven't seen this failure from an upstream compiler.

CC: @nikic

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions