
Following the previous patch which adds the "extend lifetimes" flag without (almost) any functionality, this patch adds the real feature by allowing Clang to emit fake uses. These are emitted as a new form of cleanup, set for variable addresses, which just emits a fake use intrinsic when the variable falls out of scope. The code for achieving this is simple, with most of the logic centered on determining whether to emit a fake use for a given address, and on ensuring that fake uses are ignored in a few cases. Co-authored-by: Stephen Tozer <stephen.tozer@sony.com>
17 lines
563 B
C
17 lines
563 B
C
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -fextend-variable-liveness -o - %s | FileCheck %s
|
|
|
|
// Clang adjusts the line numbers of returns based on the line numbers of
|
|
// dominating stores to %retval; we test that fake use intrinsics do not affect
|
|
// this, and the return is given the correct line.
|
|
|
|
// CHECK: define{{.*}}@main
|
|
// CHECK: call void (...) @llvm.fake.use(i32
|
|
// CHECK-NEXT: ret i32{{.*}}!dbg ![[MDINDEX:[0-9]*]]
|
|
// CHECK: ![[MDINDEX]] = !DILocation(line: [[# @LINE + 5]]
|
|
int main()
|
|
{
|
|
volatile int a = 1;
|
|
int b = a + 2;
|
|
return b;
|
|
}
|