Skip to content

Commit eafe4ee

Browse files
committed
[BOLT] Rename isLoad/isStore to mayLoad/mayStore
As discussed in D159266, for some instructions it's impossible to know statically if they will load/store (e.g., predicated instructions). Therefore, mayLoad/mayStore are more appropriate names.
1 parent 76f040b commit eafe4ee

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ class MCPlusBuilder {
613613

614614
virtual bool isMoveMem2Reg(const MCInst &Inst) const { return false; }
615615

616-
virtual bool isLoad(const MCInst &Inst) const {
616+
virtual bool mayLoad(const MCInst &Inst) const {
617617
return Info->get(Inst.getOpcode()).mayLoad();
618618
}
619619

620-
virtual bool isStore(const MCInst &Inst) const {
620+
virtual bool mayStore(const MCInst &Inst) const {
621621
return Info->get(Inst.getOpcode()).mayStore();
622622
}
623623

bolt/lib/Core/DynoStats.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ DynoStats getDynoStats(BinaryFunction &BF) {
215215
}
216216
}
217217

218-
if (BC.MIB->isStore(Instr)) {
218+
if (BC.MIB->mayStore(Instr)) {
219219
Stats[DynoStats::STORES] += BBExecutionCount;
220220
}
221-
if (BC.MIB->isLoad(Instr)) {
221+
if (BC.MIB->mayLoad(Instr)) {
222222
Stats[DynoStats::LOADS] += BBExecutionCount;
223223
}
224224
if (!BC.MIB->isCall(Instr))

bolt/lib/Passes/ShrinkWrapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ bool ShrinkWrapping::perform(bool HotOnly) {
19601960
for (const auto &Instr : *BB) {
19611961
if (BC.MIB->isPseudo(Instr))
19621962
continue;
1963-
if (BC.MIB->isStore(Instr))
1963+
if (BC.MIB->mayStore(Instr))
19641964
TotalStoreInstrs += BBExecCount;
19651965
TotalInstrs += BBExecCount;
19661966
}

bolt/lib/Passes/StokeInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void StokeInfo::checkInstr(const BinaryFunction &BF, StokeFuncInfo &FuncInfo) {
7575
if (IsPush)
7676
FuncInfo.StackOut = true;
7777

78-
if (MIB->isStore(It) && !IsPush && !IsRipAddr)
78+
if (MIB->mayStore(It) && !IsPush && !IsRipAddr)
7979
FuncInfo.HeapOut = true;
8080

8181
if (IsRipAddr)

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
268268
Inst.getOpcode() == AArch64::LDRXui);
269269
}
270270

271-
bool isLoad(const MCInst &Inst) const override {
271+
bool mayLoad(const MCInst &Inst) const override {
272272
return isLDRB(Inst) || isLDRH(Inst) || isLDRW(Inst) || isLDRX(Inst);
273273
}
274274

275275
bool isLoadFromStack(const MCInst &Inst) const {
276-
if (!isLoad(Inst))
276+
if (!mayLoad(Inst))
277277
return false;
278278
for (const MCOperand &Operand : useOperands(Inst)) {
279279
if (!Operand.isReg())
@@ -680,7 +680,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
680680
PCRelBase = DefBaseAddr;
681681
// Match LOAD to load the jump table (relative) target
682682
const MCInst *DefLoad = UsesAdd[2];
683-
assert(isLoad(*DefLoad) &&
683+
assert(mayLoad(*DefLoad) &&
684684
"Failed to match indirect branch load pattern! (1)");
685685
assert((ScaleValue != 1LL || isLDRB(*DefLoad)) &&
686686
"Failed to match indirect branch load pattern! (2)");
@@ -1013,7 +1013,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
10131013
return true;
10141014
}
10151015

1016-
bool isStore(const MCInst &Inst) const override { return false; }
1016+
bool mayStore(const MCInst &Inst) const override { return false; }
10171017

10181018
bool createDirectCall(MCInst &Inst, const MCSymbol *Target, MCContext *Ctx,
10191019
bool IsTailCall) override {

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
350350
}
351351
}
352352

353-
bool isLoad(const MCInst &Inst) const override {
353+
bool mayLoad(const MCInst &Inst) const override {
354354
if (isPop(Inst))
355355
return true;
356356

@@ -363,7 +363,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
363363
return MCII.mayLoad();
364364
}
365365

366-
bool isStore(const MCInst &Inst) const override {
366+
bool mayStore(const MCInst &Inst) const override {
367367
if (isPush(Inst))
368368
return true;
369369

@@ -1755,7 +1755,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
17551755
// - Non-stack loads are prohibited (generally unsafe)
17561756
// - Stack loads are OK if AllowStackMemOp is true
17571757
// - Stack loads with RBP are OK if AllowBasePtrStackMemOp is true
1758-
if (isLoad(Inst)) {
1758+
if (mayLoad(Inst)) {
17591759
// If stack memory operands are not allowed, no loads are allowed
17601760
if (!AllowStackMemOp)
17611761
return false;
@@ -2190,7 +2190,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
21902190
MCInst &CurInst = *Itr++;
21912191
const MCInstrDesc &Desc = Info->get(CurInst.getOpcode());
21922192
if (Desc.hasDefOfPhysReg(CurInst, MethodRegNum, *RegInfo)) {
2193-
if (!isLoad(CurInst))
2193+
if (!mayLoad(CurInst))
21942194
return false;
21952195
if (std::optional<X86MemOperand> MO =
21962196
evaluateX86MemoryOperand(CurInst)) {

0 commit comments

Comments
 (0)