[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / semantic-interposition.c
blob243bd41d9dae8f65bce841b74f86e1fe55ec981d
1 /// -fno-semantic-interposition is the default and local aliases (via dso_local) are allowed.
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -mrelocation-model pic -pic-level 1 %s -o - | FileCheck %s --check-prefixes=CHECK,NOMETADATA
4 /// -fsemantic-interposition sets a module metadata.
5 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -mrelocation-model pic -pic-level 1 -fsemantic-interposition %s -o - | FileCheck %s --check-prefixes=PREEMPT,METADATA
7 /// Traditional half-baked behavior: interprocedural optimizations are allowed
8 /// but local aliases are not used.
9 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -mrelocation-model pic -pic-level 1 -fhalf-no-semantic-interposition %s -o - | FileCheck %s --check-prefixes=PREEMPT,NOMETADATA
11 // CHECK: @var = global i32 0, align 4
12 // CHECK: @ext_var = external global i32, align 4
13 // CHECK: @ifunc = ifunc i32 (), ptr @ifunc_resolver
14 // CHECK: define dso_local i32 @func()
15 // CHECK: declare i32 @ext()
17 // PREEMPT: @var = global i32 0, align 4
18 // PREEMPT: @ext_var = external global i32, align 4
19 // PREEMPT: @ifunc = ifunc i32 (), ptr @ifunc_resolver
20 // PREEMPT: define i32 @func()
21 // PREEMPT: declare i32 @ext()
23 // METADATA: !{{[0-9]+}} = !{i32 1, !"SemanticInterposition", i32 1}
24 // NOMETADATA-NOT: "SemanticInterposition"
26 int var;
27 extern int ext_var;
29 int ifunc(void) __attribute__((ifunc("ifunc_resolver")));
31 int func(void) { return 0; }
32 int ext(void);
34 static void *ifunc_resolver(void) { return func; }
36 int foo(void) {
37 return var + ext_var + ifunc() + func() + ext();