Files
llvm-tms34010/clang/test/CodeGen/call-graph-section-internal.cpp
Prabhu Rajasekaran c311656883 [clang][llvm]Uncorrelate CFI and Callgraph related type metadata annotations (#204266)
When -fexperimental-call-graph-section flag is set, it adds type
metadata to all the functions whose addresses are taken and does not
have local linkage. When this flag is set along with CFI, the type
metadata is added to all the vtable functions including destructors.
This changes which functions are to be treated as CFI functions and
includes such vtable entries to become part of the CFI check jumptables.

To disambiguate intentions of CFI and callgraph mechanisms, this patch
renames metadata set by callgraph mechanism to !callgraph
(MD_callgraph). This prevents inflating the list of CFI functions when
callgraph section is enabled along with CFI.
2026-06-30 18:47:04 -07:00

38 lines
925 B
C++

// RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
// Check that we do not generate callee_type metadata for indirect calls
// to functions with internal linkage (e.g., types in anonymous namespaces),
// as their callgraph metadata identifiers are distinct MDNodes instead of
// generalized strings, which would fail the LLVM Verifier.
namespace {
class a;
class b {
public:
virtual void c(a);
};
class a {
public:
b &e;
void d() { e.c(*this); }
};
void b::c(a) {}
void f() {
a *g = nullptr;
g->d();
}
} // namespace
void test() {
f();
}
// CHECK-LABEL: define {{.*}} void @{{.*}}1a1dEv
// CHECK: %[[VFN:.*]] = getelementptr inbounds ptr, ptr %{{.*}}, i{{[0-9]+}} 0
// CHECK: %[[FP:.*]] = load ptr, ptr %[[VFN]], align {{[0-9]+}}
// CHECK: call void %[[FP]]({{.*}})
// CHECK-NOT: !callee_type
// CHECK: ret void