@@ -488,7 +488,7 @@ void SplitGraph::Node::visitAllDependencies(
488
488
// / \returns true if there was metadata and it was parsed correctly. false if
489
489
// / there was no MD or if it contained unknown entries.
490
490
static bool handleCalleesMD (const Instruction &I,
491
- SmallVector <Function *> &Callees) {
491
+ SmallVectorImpl <Function *> &Callees) {
492
492
auto *MD = I.getMetadata (LLVMContext::MD_callees);
493
493
if (!MD)
494
494
return false ;
@@ -541,29 +541,32 @@ void SplitGraph::buildGraph(CallGraph &CG) {
541
541
dbgs () << " - analyzing function\n " );
542
542
543
543
SmallVector<Function *> KnownCallees;
544
-
545
- bool HasIndirectCall = false ;
544
+ bool HasUnknownIndirectCall = false ;
546
545
for (const auto &Inst : instructions (Fn)) {
547
546
// look at all calls without a direct callee.
548
- if (const auto *CB = dyn_cast<CallBase>(&Inst);
549
- CB && !CB->getCalledFunction ()) {
550
- // inline assembly can be ignored, unless InlineAsmIsIndirectCall is
551
- // true.
552
- if (CB->isInlineAsm ()) {
553
- LLVM_DEBUG (dbgs () << " found inline assembly\n " );
554
- continue ;
555
- }
547
+ const auto *CB = dyn_cast<CallBase>(&Inst);
548
+ if (!CB || CB->getCalledFunction ())
549
+ continue ;
550
+
551
+ // inline assembly can be ignored, unless InlineAsmIsIndirectCall is
552
+ // true.
553
+ if (CB->isInlineAsm ()) {
554
+ if (InlineAsmIsIndirectCall)
555
+ HasUnknownIndirectCall = true ;
556
+ LLVM_DEBUG (dbgs () << " found inline assembly\n " );
557
+ continue ;
558
+ }
556
559
557
- if (handleCalleesMD (Inst, KnownCallees))
558
- continue ;
560
+ if (handleCalleesMD (Inst, KnownCallees))
561
+ continue ;
559
562
560
- // everything else is handled conservatively.
561
- HasIndirectCall = true ;
562
- break ;
563
- }
563
+ // Everything else is handled conservatively. If we fall into the
564
+ // conservative case don't bother analyzing further.
565
+ HasUnknownIndirectCall = true ;
566
+ break ;
564
567
}
565
568
566
- if (HasIndirectCall ) {
569
+ if (HasUnknownIndirectCall ) {
567
570
LLVM_DEBUG (dbgs () << " indirect call found\n " );
568
571
FnsWithIndirectCalls.push_back (&Fn);
569
572
} else if (!KnownCallees.empty ())
0 commit comments