Skip to content

Commit 8cd8c68

Browse files
committed
fix tests
1 parent a782dae commit 8cd8c68

File tree

4 files changed

+814
-787
lines changed

4 files changed

+814
-787
lines changed

llvm/lib/Transforms/IPO/MSSAArgPromotion.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ getPromotionCandidates(FunctionAnalysisManager &FAM, Argument *PtrArg,
457457
ArgAlign = std::max(ArgAlign, InstAlign);
458458
}
459459

460+
// Check if the parameter has an explicit alignment attribute that's
461+
// insufficient for the loads/stores. If the parameter has an explicit
462+
// alignment guarantee that's less than what we need, we cannot promote.
463+
if (auto ParamAlign = PtrArg->getParamAlign()) {
464+
if (ParamAlign.value() < ArgAlign) {
465+
LLVM_DEBUG(dbgs() << " - insufficient alignment guarantee (param has "
466+
<< ParamAlign.value().value() << ", need "
467+
<< ArgAlign.value() << ")\n");
468+
return false;
469+
}
470+
}
471+
460472
Candidates.emplace_back(PtrArg, ValueTy, ArgAlign);
461473
if (NumLoads + NumStores) {
462474
auto &C = Candidates.back();
@@ -1265,6 +1277,14 @@ static Function *promoteArguments(Function *F, FunctionAnalysisManager &FAM) {
12651277
if (CB == nullptr || !CB->isCallee(&U)) // [1]
12661278
return nullptr;
12671279

1280+
// Must have matching function type (no bitcasts or type mismatches).
1281+
if (CB->getCalledFunction() != F)
1282+
return nullptr;
1283+
1284+
// Don't promote if there are recursive calls.
1285+
if (CB->getParent()->getParent() == F)
1286+
return nullptr;
1287+
12681288
// Can't change signature of musttail callee
12691289
if (CB->isMustTailCall())
12701290
return nullptr;

0 commit comments

Comments
 (0)