Skip to content

Commit 675b01a

Browse files
authored
[BOLT][AArch64][instr] Remove instructions on saving and restoring NZCV (#156994)
Remove the `NZCV` save and restore instructions from instrumentation sequence because the instructions used for getting counter address, counter increment and stack push/pop won't impact `NZCV`. And with this, we can use `X1` to do counter increment and remove the two instructions that saves and later restores `X2`.
1 parent ab26257 commit 675b01a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,21 +2517,17 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
25172517
createInstrIncMemory(const MCSymbol *Target, MCContext *Ctx, bool IsLeaf,
25182518
unsigned CodePointerSize) const override {
25192519
unsigned int I = 0;
2520-
InstructionListType Instrs(10);
2520+
InstructionListType Instrs(6);
25212521

25222522
createPushRegisters(Instrs[I++], AArch64::X0, AArch64::X1);
2523-
getSystemFlag(Instrs[I++], AArch64::X1);
25242523
InstructionListType Addr = materializeAddress(Target, Ctx, AArch64::X0);
25252524
assert(Addr.size() == 2 && "Invalid Addr size");
25262525
std::copy(Addr.begin(), Addr.end(), Instrs.begin() + I);
25272526
I += Addr.size();
2528-
storeReg(Instrs[I++], AArch64::X2, AArch64::SP);
2529-
InstructionListType Insts = createIncMemory(AArch64::X0, AArch64::X2);
2527+
InstructionListType Insts = createIncMemory(AArch64::X0, AArch64::X1);
25302528
assert(Insts.size() == 2 && "Invalid Insts size");
25312529
std::copy(Insts.begin(), Insts.end(), Instrs.begin() + I);
25322530
I += Insts.size();
2533-
loadReg(Instrs[I++], AArch64::X2, AArch64::SP);
2534-
setSystemFlag(Instrs[I++], AArch64::X1);
25352531
createPopRegisters(Instrs[I++], AArch64::X0, AArch64::X1);
25362532
return Instrs;
25372533
}

0 commit comments

Comments
 (0)