Skip to content

Commit fc70c01

Browse files
committed
[FnSpecialization] Allow chains to form when collapsing PHI nodes
1 parent 841a08e commit fc70c01

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ class InstCostVisitor : public InstVisitor<InstCostVisitor, Constant *> {
228228
LLVM_ABI Cost getCodeSizeSavingsForArg(Argument *A, Constant *C,
229229
CallUserT *CallUsers = nullptr);
230230

231-
LLVM_ABI Cost getCodeSizeSavingsFromPendingPHIs();
231+
LLVM_ABI Cost
232+
getCodeSizeSavingsFromPendingPHIs(CallUserT *CallUsers = nullptr);
232233

233234
LLVM_ABI Cost getLatencySavingsForKnownConstants();
234235

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,14 @@ Constant *InstCostVisitor::findConstantFor(Value *V) const {
154154
return KnownConstants.lookup(V);
155155
}
156156

157-
Cost InstCostVisitor::getCodeSizeSavingsFromPendingPHIs() {
157+
Cost InstCostVisitor::getCodeSizeSavingsFromPendingPHIs(CallUserT *CallUsers) {
158158
Cost CodeSize;
159159
while (!PendingPHIs.empty()) {
160160
Instruction *Phi = PendingPHIs.pop_back_val();
161161
// The pending PHIs could have been proven dead by now.
162162
if (isBlockExecutable(Phi->getParent()))
163-
CodeSize += getCodeSizeSavingsForUser(Phi);
163+
CodeSize +=
164+
getCodeSizeSavingsForUser(Phi, nullptr, nullptr, CallUsers, nullptr);
164165
}
165166
return CodeSize;
166167
}
@@ -1116,7 +1117,7 @@ bool FunctionSpecializer::findSpecializations(
11161117
Score += getInliningBonus(A.Formal, A.Actual);
11171118
}
11181119

1119-
CodeSize += Visitor.getCodeSizeSavingsFromPendingPHIs();
1120+
CodeSize += Visitor.getCodeSizeSavingsFromPendingPHIs(&CallUsers);
11201121
CurrentChain.insert(F);
11211122

11221123
for (auto &CU : CallUsers) {

0 commit comments

Comments
 (0)