diff options
author | Vitaly Buka <vitalybuka@google.com> | 2016-10-26 05:42:30 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2016-10-26 05:42:30 +0000 |
commit | 64c80b4e39bbd4dc2b1b3b9b0a1be1eaa3f9c7ed (patch) | |
tree | 08b054a179032bb7f70f45d94dbaad494310ddad /clang/lib/CodeGen/CodeGenFunction.h | |
parent | f202365910b9c20a30e26f449dbf6f9b49cf774a (diff) | |
download | bcm5719-llvm-64c80b4e39bbd4dc2b1b3b9b0a1be1eaa3f9c7ed.tar.gz bcm5719-llvm-64c80b4e39bbd4dc2b1b3b9b0a1be1eaa3f9c7ed.zip |
[CodeGen] Don't emit lifetime intrinsics for some local variables
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
llvm-svn: 285176
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 123c04027ef..7a6fd93052b 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -21,6 +21,7 @@ #include "CodeGenModule.h" #include "CodeGenPGO.h" #include "EHScopeStack.h" +#include "VarBypassDetector.h" #include "clang/AST/CharUnits.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" @@ -141,6 +142,10 @@ public: LoopInfoStack LoopStack; CGBuilderTy Builder; + // Stores variables for which we can't generate correct lifetime markers + // because of jumps. + VarBypassDetector Bypasses; + /// \brief CGBuilder insert helper. This function is called after an /// instruction is created using Builder. void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, |