]> granicus.if.org Git - clang/commit
[CodeGen] Suppress emission of lifetime markers if a label has been seen
authorAkira Hatanaka <ahatanaka@apple.com>
Wed, 25 Jan 2017 22:55:13 +0000 (22:55 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Wed, 25 Jan 2017 22:55:13 +0000 (22:55 +0000)
commitf7afaaadc366d1d39cd35b64a24ab1df6b94fe60
treee795ba73d5fa4aa095fc612f618742fd3a0ce3d2
parent771d6cd1aef9c943cb44cab164fbb3487b3037c4
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293106 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/lifetime2.c