This patch attempts to fix the bug discussed here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html
This patch fixes the bug by moving the lifetime.start of a variable to the beginning of its lexical scope.
int move_lifetime_start(int a) {
int *p = 0;
// This patch moves lifetime.start for "i" to the beginning of the function.
label1:
if (p) {
foo2(*p); // The storage of "i" has to be kept alive when goto jumps to label1.
return 0;
}
int i = 999; // lifetime.start for "i" used to be inserted here.
if (a != 2) {
p = &i;
goto label1;
}
return -1;
}