Skip to content

Commit fb5c4a8

Browse files
committed
Comments, minor refactor
1 parent c2ea211 commit fb5c4a8

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void SplitGraph::Node::visitAllDependencies(
488488
/// \returns true if there was metadata and it was parsed correctly. false if
489489
/// there was no MD or if it contained unknown entries.
490490
static bool handleCalleesMD(const Instruction &I,
491-
SmallVector<Function *> &Callees) {
491+
SmallVectorImpl<Function *> &Callees) {
492492
auto *MD = I.getMetadata(LLVMContext::MD_callees);
493493
if (!MD)
494494
return false;
@@ -541,29 +541,32 @@ void SplitGraph::buildGraph(CallGraph &CG) {
541541
dbgs() << " - analyzing function\n");
542542

543543
SmallVector<Function *> KnownCallees;
544-
545-
bool HasIndirectCall = false;
544+
bool HasUnknownIndirectCall = false;
546545
for (const auto &Inst : instructions(Fn)) {
547546
// 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+
}
556559

557-
if (handleCalleesMD(Inst, KnownCallees))
558-
continue;
560+
if (handleCalleesMD(Inst, KnownCallees))
561+
continue;
559562

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;
564567
}
565568

566-
if (HasIndirectCall) {
569+
if (HasUnknownIndirectCall) {
567570
LLVM_DEBUG(dbgs() << " indirect call found\n");
568571
FnsWithIndirectCalls.push_back(&Fn);
569572
} else if (!KnownCallees.empty())

0 commit comments

Comments
 (0)