aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGCall.cpp
diff options
context:
space:
mode:
authorNecip Fazil Yildiran <necip@google.com>2024-04-03 15:33:17 -0700
committerprabhukr <prabhukr@google.com>2024-04-03 15:33:17 -0700
commit36ba1e0681626e42bd2ab29e59c414aa8db662e3 (patch)
tree33586c605ee13c1ace4ee8b66899c558fc3e2aee /clang/lib/CodeGen/CGCall.cpp
parent029e1d751503268e3d8b01db769e710835c3010d (diff)
downloadllvm-users/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-3.zip
llvm-users/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-3.tar.gz
llvm-users/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-3.tar.bz2
[𝘀𝗽𝗿] changes to main this commit is based onusers/Prabhuk/sprmain.asmprintercallgraphsection-emit-call-graph-section-3
Created using spr 1.3.6-beta.1 [skip ci]
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index f12765b..51133b0 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5681,6 +5681,28 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
AllocAlignAttrEmitter AllocAlignAttrEmitter(*this, TargetDecl, CallArgs);
Attrs = AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
+ if (CGM.getCodeGenOpts().CallGraphSection) {
+ // FIXME: create operand bundle only for indirect calls, not for all
+
+ assert((TargetDecl && TargetDecl->getFunctionType() ||
+ Callee.getAbstractInfo().getCalleeFunctionProtoType()) &&
+ "cannot find callsite type");
+
+ QualType CST;
+ if (TargetDecl && TargetDecl->getFunctionType())
+ CST = QualType(TargetDecl->getFunctionType(), 0);
+ else if (const auto *FPT =
+ Callee.getAbstractInfo().getCalleeFunctionProtoType())
+ CST = QualType(FPT, 0);
+
+ if (!CST.isNull()) {
+ auto *TypeIdMD = CGM.CreateMetadataIdentifierGeneralized(CST);
+ auto *TypeIdMDVal =
+ llvm::MetadataAsValue::get(getLLVMContext(), TypeIdMD);
+ BundleList.emplace_back("type", TypeIdMDVal);
+ }
+ }
+
// Emit the actual call/invoke instruction.
llvm::CallBase *CI;
if (!InvokeDest) {