Skip to content

Commit 28baeb8

Browse files
committed
Fixes
1 parent fb5c4a8 commit 28baeb8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,11 @@ void SplitGraph::Node::visitAllDependencies(
486486
/// in \p Callees.
487487
///
488488
/// \returns true if there was metadata and it was parsed correctly. false if
489-
/// there was no MD or if it contained unknown entries.
489+
/// there was no MD or if it contained unknown entries and parsing failed.
490+
/// If this returns false, \p Callees will contain incomplete information
491+
/// and must not be used.
490492
static bool handleCalleesMD(const Instruction &I,
491-
SmallVectorImpl<Function *> &Callees) {
493+
SetVector<Function *> &Callees) {
492494
auto *MD = I.getMetadata(LLVMContext::MD_callees);
493495
if (!MD)
494496
return false;
@@ -497,7 +499,7 @@ static bool handleCalleesMD(const Instruction &I,
497499
Function *Callee = mdconst::extract_or_null<Function>(Op);
498500
if (!Callee)
499501
return false;
500-
Callees.push_back(Callee);
502+
Callees.insert(Callee);
501503
}
502504

503505
return true;
@@ -540,7 +542,7 @@ void SplitGraph::buildGraph(CallGraph &CG) {
540542
Fn.printAsOperand(dbgs());
541543
dbgs() << " - analyzing function\n");
542544

543-
SmallVector<Function *> KnownCallees;
545+
SetVector<Function *> KnownCallees;
544546
bool HasUnknownIndirectCall = false;
545547
for (const auto &Inst : instructions(Fn)) {
546548
// look at all calls without a direct callee.
@@ -559,6 +561,9 @@ void SplitGraph::buildGraph(CallGraph &CG) {
559561

560562
if (handleCalleesMD(Inst, KnownCallees))
561563
continue;
564+
// If we failed to parse any !callees MD, or some was missing,
565+
// the entire KnownCallees list is now unreliable.
566+
KnownCallees.clear();
562567

563568
// Everything else is handled conservatively. If we fall into the
564569
// conservative case don't bother analyzing further.

0 commit comments

Comments
 (0)