3838#include " llvm/IR/CallingConv.h"
3939#include " llvm/IR/DataLayout.h"
4040#include " llvm/IR/InlineAsm.h"
41+ #include " llvm/IR/Instruction.h"
4142#include " llvm/IR/IntrinsicInst.h"
4243#include " llvm/IR/Intrinsics.h"
4344#include " llvm/IR/Type.h"
@@ -5772,34 +5773,21 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
57725773 Attrs = AllocAlignAttrEmitter.TryEmitAsCallSiteAttribute (Attrs);
57735774
57745775 if (CGM.getCodeGenOpts ().CallGraphSection ) {
5775- // Create operand bundle only for indirect calls, not for all
5776- if (callOrInvoke && *callOrInvoke && (*callOrInvoke)->isIndirectCall ()) {
5777-
5778- assert ((TargetDecl && TargetDecl->getFunctionType () ||
5779- Callee.getAbstractInfo ().getCalleeFunctionProtoType ()) &&
5780- " cannot find callsite type" );
5781-
5782- QualType CST;
5783- if (TargetDecl && TargetDecl->getFunctionType ())
5784- CST = QualType (TargetDecl->getFunctionType (), 0 );
5785- else if (const auto *FPT =
5786- Callee.getAbstractInfo ().getCalleeFunctionProtoType ())
5787- CST = QualType (FPT, 0 );
5788-
5789- if (!CST.isNull ()) {
5790- auto *TypeIdMD = CGM.CreateMetadataIdentifierGeneralized (CST);
5791- auto *TypeIdMDVal =
5792- llvm::MetadataAsValue::get (getLLVMContext (), TypeIdMD);
5793- BundleList.emplace_back (" type" , TypeIdMDVal);
5794- }
5795-
5796- // Set type identifier metadata of indirect calls for call graph section.
5797- if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
5798- // Type id metadata is set only for C/C++ contexts.
5799- if (isCXXDeclType (FD)) {
5800- CGM.CreateFunctionTypeMetadataForIcall (FD->getType (), *callOrInvoke);
5801- }
5802- }
5776+ assert ((TargetDecl && TargetDecl->getFunctionType () ||
5777+ Callee.getAbstractInfo ().getCalleeFunctionProtoType ()) &&
5778+ " cannot find callsite type" );
5779+ QualType CST;
5780+ if (TargetDecl && TargetDecl->getFunctionType ())
5781+ CST = QualType (TargetDecl->getFunctionType (), 0 );
5782+ else if (const auto *FPT =
5783+ Callee.getAbstractInfo ().getCalleeFunctionProtoType ())
5784+ CST = QualType (FPT, 0 );
5785+
5786+ if (!CST.isNull ()) {
5787+ auto *TypeIdMD = CGM.CreateMetadataIdentifierGeneralized (CST);
5788+ auto *TypeIdMDVal =
5789+ llvm::MetadataAsValue::get (getLLVMContext (), TypeIdMD);
5790+ BundleList.emplace_back (" type" , TypeIdMDVal);
58035791 }
58045792 }
58055793
@@ -5817,8 +5805,18 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
58175805 CI->getCalledFunction ()->getName ().starts_with (" _Z4sqrt" )) {
58185806 SetSqrtFPAccuracy (CI);
58195807 }
5820- if (callOrInvoke)
5808+ if (callOrInvoke) {
58215809 *callOrInvoke = CI;
5810+ if (CGM.getCodeGenOpts ().CallGraphSection ) {
5811+ // Set type identifier metadata of indirect calls for call graph section.
5812+ if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
5813+ // Type id metadata is set only for C/C++ contexts.
5814+ if (isCXXDeclType (FD)) {
5815+ CGM.CreateFunctionTypeMetadataForIcall (FD->getType (), *callOrInvoke);
5816+ }
5817+ }
5818+ }
5819+ }
58225820
58235821 // If this is within a function that has the guard(nocf) attribute and is an
58245822 // indirect call, add the "guard_nocf" attribute to this call to indicate that
0 commit comments