@@ -930,28 +930,29 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
930930 if (MI.hasDelaySlot () && !delaySlotSupported (*&MI))
931931 return ;
932932
933+ DIType *AllocSiteTy = cast_or_null<DIType>(MI.getHeapAllocMarker ());
934+
933935 // If this is a direct call, find the callee's subprogram.
934936 // In the case of an indirect call find the register that holds
935937 // the callee.
936938 const MachineOperand &CalleeOp = TII->getCalleeOperand (MI);
937- if (!CalleeOp.isGlobal () &&
938- (!CalleeOp.isReg () || !CalleeOp.getReg ().isPhysical ()))
939- continue ;
940939
941940 unsigned CallReg = 0 ;
942941 const DISubprogram *CalleeSP = nullptr ;
943942 const Function *CalleeDecl = nullptr ;
944- if (CalleeOp.isReg ()) {
945- CallReg = CalleeOp.getReg ();
946- if (!CallReg)
947- continue ;
948- } else {
943+ if (CalleeOp.isReg () && CalleeOp.getReg ().isPhysical ()) {
944+ CallReg = CalleeOp.getReg (); // might be zero
945+ } else if (CalleeOp.isGlobal ()) {
949946 CalleeDecl = dyn_cast<Function>(CalleeOp.getGlobal ());
950- if (!CalleeDecl || !CalleeDecl->getSubprogram ())
951- continue ;
952- CalleeSP = CalleeDecl->getSubprogram ();
947+ if (CalleeDecl)
948+ CalleeSP = CalleeDecl->getSubprogram (); // might be nullptr
953949 }
954950
951+ // Omit DIE if we can't tell where the call goes *and* we don't want to
952+ // add metadata to it.
953+ if (CalleeSP == nullptr && CallReg == 0 && AllocSiteTy == nullptr )
954+ continue ;
955+
955956 // TODO: Omit call site entries for runtime calls (objc_msgSend, etc).
956957
957958 bool IsTail = TII->isTailCall (MI);
@@ -986,7 +987,7 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
986987 << (IsTail ? " [IsTail]" : " " ) << " \n " );
987988
988989 DIE &CallSiteDIE = CU.constructCallSiteEntryDIE (
989- ScopeDIE, CalleeSP, IsTail, PCAddr, CallAddr, CallReg);
990+ ScopeDIE, CalleeSP, IsTail, PCAddr, CallAddr, CallReg, AllocSiteTy );
990991
991992 // Optionally emit call-site-param debug info.
992993 if (emitDebugEntryValues ()) {
0 commit comments