Skip to content

Commit 1494d88

Browse files
authored
[AMDGPU] Always Inline preserved analyses (llvm#91198)
When replacing all uses, the structural-hash of the IR can change, so keep track of changes using Changed variable and return it to pass manager.
1 parent 643c383 commit 1494d88

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AMDGPUAlwaysInline : public ModulePass {
4242

4343
void getAnalysisUsage(AnalysisUsage &AU) const override {
4444
AU.setPreservesAll();
45-
}
45+
}
4646
};
4747

4848
} // End anonymous namespace
@@ -89,6 +89,7 @@ recursivelyVisitUsers(GlobalValue &GV,
8989
static bool alwaysInlineImpl(Module &M, bool GlobalOpt) {
9090
std::vector<GlobalAlias*> AliasesToRemove;
9191

92+
bool Changed = false;
9293
SmallPtrSet<Function *, 8> FuncsToAlwaysInline;
9394
SmallPtrSet<Function *, 8> FuncsToNoInline;
9495
Triple TT(M.getTargetTriple());
@@ -98,6 +99,7 @@ static bool alwaysInlineImpl(Module &M, bool GlobalOpt) {
9899
if (TT.getArch() == Triple::amdgcn &&
99100
A.getLinkage() != GlobalValue::InternalLinkage)
100101
continue;
102+
Changed = true;
101103
A.replaceAllUsesWith(F);
102104
AliasesToRemove.push_back(&A);
103105
}
@@ -153,7 +155,7 @@ static bool alwaysInlineImpl(Module &M, bool GlobalOpt) {
153155
for (Function *F : FuncsToNoInline)
154156
F->addFnAttr(Attribute::NoInline);
155157

156-
return !FuncsToAlwaysInline.empty() || !FuncsToNoInline.empty();
158+
return Changed || !FuncsToAlwaysInline.empty() || !FuncsToNoInline.empty();
157159
}
158160

159161
bool AMDGPUAlwaysInline::runOnModule(Module &M) {
@@ -166,6 +168,6 @@ ModulePass *llvm::createAMDGPUAlwaysInlinePass(bool GlobalOpt) {
166168

167169
PreservedAnalyses AMDGPUAlwaysInlinePass::run(Module &M,
168170
ModuleAnalysisManager &AM) {
169-
alwaysInlineImpl(M, GlobalOpt);
170-
return PreservedAnalyses::all();
171+
const bool Changed = alwaysInlineImpl(M, GlobalOpt);
172+
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
171173
}

0 commit comments

Comments
 (0)