Fix https://github.com/llvm/llvm-project/issues/56356
For following test case:
extern int bar(char *A, int n); void goto_bypass(void) { { char x; l1: bar(&x, 1); } goto l1; }
And using clang -cc1 -O2 -S -emit-llvm to compile it.
In the past, due to the existence of bypassed label, the lifetime
intrinsic would not be generated. This was also the cause of pr56356.
In this patch, if the variable is bypassed, we do variable
allocation, emit lifetime-start intrinsic and record the lifetime-start
intrinsic in LexicalScope. Then When emitting the bypass label, we emit
the lifetime instrinsic again to make sure the lifetime of the bypassed
variable is start again. Address sanitizer will capture these lifetime
intrinsics and instrument poison and unpoison code. Finally pr56356 can
be resolved.
Here is the new llvm-ir of the test case above.
define dso_local void @goto_bypass() local_unnamed_addr #0 { entry: %x = alloca i8, align 1 call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %x) #3 br label %l1 l1: ; preds = %l1, %entry call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %x) #3 %call = call i32 @bar(ptr noundef nonnull %x, i32 noundef 1) #3 call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %x) #3 br label %l1 }
LifetimeStartMarkers -> BypassedLifetimeStartMarkers
and below
if I read this correctly this is not any start marker