Skip to content

Commit fb21dc6

Browse files
committed
[FnSpecialization] Refactor CallUsersT to contain Idx/Constant pairs
In the future we won't know the Function at the time of insertion, so need to store and index so we can look up the Argument later.
1 parent fc70c01 commit fb21dc6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@
9595
namespace llvm {
9696
struct Spec;
9797

98-
struct SpecSig;
99-
10098
// Map of potential specializations for each function.
10199
using SpecMap = DenseMap<Function *, SmallVector<unsigned>>;
102100

103-
using CallUserT = SmallMapVector<CallBase *, std::pair<SpecSig, Function *>, 4>;
101+
using CallUserT = SmallMapVector<
102+
CallBase *,
103+
std::pair<SmallVector<std::pair<unsigned, Constant *>, 4>, Function *>, 4>;
104104

105105
// Just a shorter abbreviation to improve indentation.
106106
using Cost = InstructionCost;

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Cost InstCostVisitor::getCodeSizeSavingsForUser(Instruction *User, Value *Use,
245245
LLVM_DEBUG(dbgs() << "FnSpecialization: Function called: "
246246
<< F->getName() << " argument number: " << Idx
247247
<< "\n");
248-
(*CallUsers)[CI].first.Args.push_back({F->getArg(Idx), C});
248+
(*CallUsers)[CI].first.push_back({Idx, C});
249249
(*CallUsers)[CI].second = F;
250250
return true;
251251
} else {
@@ -1139,7 +1139,9 @@ bool FunctionSpecializer::findSpecializations(
11391139
// Since the function might not yet be known when processing the
11401140
// constants due to a function pointer, wait to extract the argument
11411141
// pointer at a given index.
1142-
SpecSig NewS = CU.second.first;
1142+
SpecSig NewS;
1143+
for (auto &P : CU.second.first)
1144+
NewS.Args.push_back({NewF->getArg(P.first), P.second});
11431145

11441146
Spec CallSpec(NewF, /*CallSite*/ CU.first, NewS,
11451147
/*Status*/ CallSiteStatusT::AWAITING_PARENT);

0 commit comments

Comments
 (0)