[PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 16 17:48:45 PDT 2016


vitalybuka created this revision.
vitalybuka added a reviewer: eugenis.
vitalybuka added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Current generation of lifetime intrinsics does not handle cases like:
  {
    char x;
  l1:
    bar(&x, 1);
  }
  goto l1;

Intrinsics were be generated like this:
  %x = alloca i8, align 1
  call void @llvm.lifetime.start(i64 1, i8* nonnull %x)
  br label %l1
l1:
  %call = call i32 @bar(i8* nonnull %x, i32 1)
  call void @llvm.lifetime.end(i64 1, i8* nonnull %x)
  br label %l1

So the second time bar was called for x which is marked as dead.
Lifetime markers here are misleading so it's better to remove them at all.
This type of bypasses are rare, e.g. code detects just 8 functions building
clang (2329 targets).

PR28267

https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24693.71719.patch
Type: text/x-patch
Size: 17397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160917/f9f108b7/attachment-0001.bin>


More information about the cfe-commits mailing list