Skip to content
Snippets Groups Projects
  • Vitaly Buka's avatar
    ef66d4d5
    [CodeGen] Don't emit lifetime intrinsics for some local variables · ef66d4d5
    Vitaly Buka authored
    Summary:
    Current generation of lifetime intrinsics does not handle cases like:
    
    ```
      {
        char x;
      l1:
        bar(&x, 1);
      }
      goto l1;
    
    ```
    We will get code 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
    
    Reviewers: eugenis
    
    Subscribers: beanz, mgorny, cfe-commits
    
    Differential Revision: https://reviews.llvm.org/D24693
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285176 91177308-0d34-0410-b5e6-96231b3b80d8
    ef66d4d5
    History
    [CodeGen] Don't emit lifetime intrinsics for some local variables
    Vitaly Buka authored
    Summary:
    Current generation of lifetime intrinsics does not handle cases like:
    
    ```
      {
        char x;
      l1:
        bar(&x, 1);
      }
      goto l1;
    
    ```
    We will get code 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
    
    Reviewers: eugenis
    
    Subscribers: beanz, mgorny, cfe-commits
    
    Differential Revision: https://reviews.llvm.org/D24693
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285176 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.