-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
Description
The lowering in
llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Lines 7554 to 7555 in 0cc6b46
case Intrinsic::lifetime_start: | |
case Intrinsic::lifetime_end: { |
So if you have something like this:
define i64 @test(i1 %c, ptr %p) {
%a = alloca i64
%b = alloca i64
%sel.b = select i1 %c, ptr %b, ptr %a
call void @llvm.lifetime.start(i64 8, ptr %a)
store i64 1, ptr %a
call void @llvm.lifetime.end(i64 8, ptr %sel.b)
call void @llvm.lifetime.start(i64 8, ptr %b)
store i64 2, ptr %b
store ptr %b, ptr %p ; prevent store from being optimized away
%v = load i64, ptr %a
call void @llvm.lifetime.end(i64 8, ptr %b)
ret i64 %v
}
Then the lifetime.end on %sel.b
will be lowered to a lifetime.end on both %a
and %b
. However, assuming %c
is true at runtime, it only ends the lifetime of %b
and the overall IR is well-defined.
The final assembly is incorrect as a result of stack coloring:
movq $1, -8(%rsp)
movq $2, -8(%rsp)
leaq -8(%rsp), %rax
movq %rax, (%rsi)
movq -8(%rsp), %rax
retq