[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?

Alexey Samsonov samsonov at google.com
Mon Dec 17 06:59:55 PST 2012


I'm working on ASan option that uses llvm.lifetime intrinsics to detect
use-after-scope bugs. In short, the idea is to
insert calls into ASan runtime that would mark the memory as "addressable"
or "unaddressable".
I see the following problem with the following "trivial" basic block:

for.body.lr.ph.i:                                 ; preds = %for.body.i310
  call void @llvm.lifetime.start(i64 24, i8* %174)
  call void @llvm.lifetime.start(i64 4, i8* %175)
  call void @llvm.lifetime.start(i64 24, i8* %176)
  br label %for.body.i318

r134182 by Rafael explicitly allows simplifycfg pass to merge this block
into its successor, and drop "side-effect free" lifetime.start
intrinsics. However, llvm.lifetime.end intrinsics for the same memory are
preserved, which is not only weird, but triggers ASan false positives:
1) function goes into for-loop with local variable declared in it
2) llvm.lifetime.end() at the end of the loop allows ASan to mark this
memory as unaddressable
3) at the next loop iteration access to this memory will be reported as

Shouldn't simplifycfg somehow preserve / move lifetime intrinsics in its

Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/146a6732/attachment.html>

More information about the llvm-dev mailing list