summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-01-25 22:55:13 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-01-25 22:55:13 +0000
commitfdcd18b4c90ba59dcb8bd7b8267e61f6e0f016eb (patch)
tree8d5f9d462037999812255bea4f69f91158002c96 /clang/lib/CodeGen/CodeGenFunction.h
parent1f5f06435d5a8958127faf454dbe2205d2fc2b73 (diff)
downloadbcm5719-llvm-fdcd18b4c90ba59dcb8bd7b8267e61f6e0f016eb.tar.gz
bcm5719-llvm-fdcd18b4c90ba59dcb8bd7b8267e61f6e0f016eb.zip
[CodeGen] Suppress emission of lifetime markers if a label has been seen
in the current lexical scope. clang currently emits the lifetime.start marker of a variable when the variable comes into scope even though a variable's lifetime starts at the entry of the block with which it is associated, according to the C standard. This normally doesn't cause any problems, but in the rare case where a goto jumps backwards past the variable declaration to an earlier point in the block (see the test case added to lifetime2.c), it can cause mis-compilation. To prevent such mis-compiles, this commit conservatively disables emitting lifetime variables when a label has been seen in the current block. This problem was discussed on cfe-dev here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html rdar://problem/30153946 Differential Revision: https://reviews.llvm.org/D27680 llvm-svn: 293106
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 82ab5c3781e..8d7fd3f80ba 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -212,6 +212,13 @@ public:
/// value. This is invalid iff the function has no return value.
Address ReturnValue;
+ /// Return true if a label was seen in the current scope.
+ bool hasLabelBeenSeenInCurrentScope() const {
+ if (CurLexicalScope)
+ return CurLexicalScope->hasLabels();
+ return !LabelMap.empty();
+ }
+
/// AllocaInsertPoint - This is an instruction in the entry block before which
/// we prefer to insert allocas.
llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
@@ -620,6 +627,10 @@ public:
rescopeLabels();
}
+ bool hasLabels() const {
+ return !Labels.empty();
+ }
+
void rescopeLabels();
};
OpenPOWER on IntegriCloud