llvm-project/clang/test/CodeGen/fake-use-landingpad.c
Wolfgang Pieb 4424c44c8c [Clang] Add fake use emission to Clang with -fextend-lifetimes (#110102)
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>
2025-01-28 12:30:31 +00:00

15 lines
415 B
C

// RUN: %clang_cc1 %s -emit-llvm -fextend-variable-liveness -fexceptions -o - | FileCheck %s --implicit-check-not="landingpad {"
// Check that fake uses do not mistakenly cause a landing pad to be generated when
// exceptions are enabled.
extern void bar(int);
void foo(int p) {
int a = 17;
bar(a);
}
// CHECK: define {{.*}} @foo
// CHECK-NOT: personality
// CHECK: call void (...) @llvm.fake.use