-   Notifications  You must be signed in to change notification settings 
- Fork 15k
Open
Open
Copy link
Description
In the program below, the allocation a and allocation b have overlapping
 live ranges, so it should be impossible to observe them having the same
 address. Nevertheless StackColoring merges stack slots for a and b. This
 is incorrect since addresses of those allocations might be captured by g.
define void @f() { start: %a = alloca [1000 x i8], align 1 %b = alloca [1000 x i8], align 1 call void @llvm.lifetime.start.p0(i64 1000, ptr %a) call void @llvm.lifetime.start.p0(i64 1000, ptr %b) call void @g(ptr %a) call void @llvm.lifetime.end.p0(i64 1000, ptr %a) call void @g(ptr %b) call void @llvm.lifetime.end.p0(i64 1000, ptr %b) ret void } declare void @g(ptr %n)$ llc-21 a.ll -print-before=stack-coloring -print-after=stack-coloring # Machine code for function f: IsSSA, TracksLiveness Frame Objects:  fi#0: size=1000, align=1, at location [SP+8]  fi#1: size=1000, align=1, at location [SP+8] <snip> # *** IR Dump After Merge disjoint stack slots (stack-coloring) ***: # Machine code for function f: IsSSA, TracksLiveness Frame Objects:  fi#0: size=1000, align=1, at location [SP+8]  fi#1: dead <snip>This is caused by stackcoloring-lifetime-start-on-first-use (the default) where
 stack coloring shrinks live range towards first use.