Skip to content

Commit

Permalink
[FuncSpec] Handle ssa_copy intrinsic calls in InstCostVisitor
Browse files Browse the repository at this point in the history
Look through ssa_copy intrinsic calls when computing codesize bonus for
a specialization.

Also remove redundant logic to skip computing codesize bonus for
ssa_copy intrinsics, now these are considered zero-cost by TTI
(in PR#75294).
  • Loading branch information
hazzlim committed Oct 30, 2024
1 parent 340cd4e commit 64b91de
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ Cost InstCostVisitor::estimateBasicBlocks(
continue;

for (Instruction &I : *BB) {
// Disregard SSA copies.
if (auto *II = dyn_cast<IntrinsicInst>(&I))
if (II->getIntrinsicID() == Intrinsic::ssa_copy)
continue;
// If it's a known constant we have already accounted for it.
if (KnownConstants.contains(&I))
continue;
Expand Down Expand Up @@ -402,6 +398,14 @@ Constant *InstCostVisitor::visitFreezeInst(FreezeInst &I) {
}

Constant *InstCostVisitor::visitCallBase(CallBase &I) {
assert(LastVisited != KnownConstants.end() && "Invalid iterator!");

// Look through calls to ssa_copy intrinsics.
if (auto *II = dyn_cast<IntrinsicInst>(&I);
II && II->getIntrinsicID() == Intrinsic::ssa_copy) {
return LastVisited->second;
}

Function *F = I.getCalledFunction();
if (!F || !canConstantFoldCallTo(&I, F))
return nullptr;
Expand Down

0 comments on commit 64b91de

Please sign in to comment.