Skip to content

Commit 35cf13d

Browse files
committed
[BOLT] Review changes
- rename kSigned/kUnsigned to kRASigned/kRAUnsigned - const& in MarkRAStates - spelling - change flag to hidden
1 parent 532c150 commit 35cf13d

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

bolt/include/bolt/Core/MCPlus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class MCAnnotation {
7272
kLabel, /// MCSymbol pointing to this instruction.
7373
kSize, /// Size of the instruction.
7474
kDynamicBranch, /// Jit instruction patched at runtime.
75-
kSigned, /// Inst is in a range where RA is signed.
76-
kUnsigned, /// Inst is in a range where RA is unsigned.
75+
kRASigned, /// Inst is in a range where RA is signed.
76+
kRAUnsigned, /// Inst is in a range where RA is unsigned.
7777
kRememberState, /// Inst has rememberState CFI.
7878
kRestoreState, /// Inst has restoreState CFI.
7979
kNegateState, /// Inst has OpNegateRAState CFI.

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,21 @@ bool MCPlusBuilder::hasRestoreState(const MCInst &Inst) const {
187187
}
188188

189189
void MCPlusBuilder::setRASigned(MCInst &Inst) const {
190-
assert(!hasAnnotation(Inst, MCAnnotation::kSigned));
191-
setAnnotationOpValue(Inst, MCAnnotation::kSigned, true);
190+
assert(!hasAnnotation(Inst, MCAnnotation::kRASigned));
191+
setAnnotationOpValue(Inst, MCAnnotation::kRASigned, true);
192192
}
193193

194194
bool MCPlusBuilder::isRASigned(const MCInst &Inst) const {
195-
return hasAnnotation(Inst, MCAnnotation::kSigned);
195+
return hasAnnotation(Inst, MCAnnotation::kRASigned);
196196
}
197197

198198
void MCPlusBuilder::setRAUnsigned(MCInst &Inst) const {
199-
assert(!hasAnnotation(Inst, MCAnnotation::kUnsigned));
200-
setAnnotationOpValue(Inst, MCAnnotation::kUnsigned, true);
199+
assert(!hasAnnotation(Inst, MCAnnotation::kRAUnsigned));
200+
setAnnotationOpValue(Inst, MCAnnotation::kRAUnsigned, true);
201201
}
202202

203203
bool MCPlusBuilder::isRAUnsigned(const MCInst &Inst) const {
204-
return hasAnnotation(Inst, MCAnnotation::kUnsigned);
204+
return hasAnnotation(Inst, MCAnnotation::kRAUnsigned);
205205
}
206206

207207
bool MCPlusBuilder::isRAStateUnknown(const MCInst &Inst) const {

bolt/lib/Passes/InsertNegateRAStatePass.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ void InsertNegateRAState::inferUnknownStates(BinaryFunction &BF) {
9292
bool FirstIter = true;
9393
MCInst PrevInst;
9494
for (BinaryBasicBlock &BB : BF) {
95-
for (auto It = BB.begin(); It != BB.end(); ++It) {
96-
97-
MCInst &Inst = *It;
95+
for (MCInst &Inst : BB) {
9896
if (BC.MIB->isCFI(Inst))
9997
continue;
10098

bolt/lib/Passes/MarkRAStates.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
3535

3636
BinaryContext &BC = BF.getBinaryContext();
3737

38-
for (BinaryBasicBlock &BB : BF) {
39-
for (auto It = BB.begin(); It != BB.end(); ++It) {
40-
MCInst &Inst = *It;
38+
for (const BinaryBasicBlock &BB : BF) {
39+
for (const MCInst &Inst : BB) {
4140
if ((BC.MIB->isPSignOnLR(Inst) ||
4241
(BC.MIB->isPAuthOnLR(Inst) && !BC.MIB->isPAuthAndRet(Inst))) &&
4342
!BC.MIB->hasNegateRAState(Inst)) {
@@ -58,9 +57,7 @@ bool MarkRAStates::runOnFunction(BinaryFunction &BF) {
5857
RAStateStack.push(RAState);
5958

6059
for (BinaryBasicBlock &BB : BF) {
61-
for (auto It = BB.begin(); It != BB.end(); ++It) {
62-
63-
MCInst &Inst = *It;
60+
for (MCInst &Inst : BB) {
6461
if (BC.MIB->isCFI(Inst))
6562
continue;
6663

@@ -150,7 +147,7 @@ Error MarkRAStates::runOnFunctions(BinaryContext &BC) {
150147
BC.outs() << "BOLT-INFO: MarkRAStates ran on " << Total
151148
<< " functions. Ignored " << FunctionsIgnored << " functions "
152149
<< format("(%.2lf%%)", (100.0 * FunctionsIgnored) / Total)
153-
<< " because of CFI inconsistencies.\n";
150+
<< " because of CFI inconsistencies\n";
154151
}
155152

156153
return Error::success();

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ cl::opt<bool>
283283
UpdateBranchProtection("update-branch-protection",
284284
cl::desc("Rewrites pac-ret DWARF CFI instructions "
285285
"(AArch64-only, on by default)"),
286-
cl::init(true), cl::cat(BoltOptCategory));
286+
cl::init(true), cl::Hidden, cl::cat(BoltCategory));
287287
} // namespace opts
288288

289289
namespace llvm {

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ void RewriteInstance::disassembleFunctions() {
35263526
if (!opts::UpdateBranchProtection) {
35273527
BC->errs()
35283528
<< "BOLT-ERROR: --update-branch-protection is set to false, but "
3529-
<< Function.getPrintName() << " contains .cfi-negate-ra-state.\n";
3529+
<< Function.getPrintName() << " contains .cfi-negate-ra-state\n";
35303530
exit(1);
35313531
}
35323532
}

bolt/test/AArch64/negate-ra-state-disallow.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
33
# RUN: not llvm-bolt %t.exe -o %t.exe.bolt --update-branch-protection=false 2>&1 | FileCheck %s
44

5-
# CHECK: BOLT-ERROR: --update-branch-protection is set to false, but foo contains .cfi-negate-ra-state.
5+
# CHECK: BOLT-ERROR: --update-branch-protection is set to false, but foo contains .cfi-negate-ra-state
66

77
.text
88
.globl foo

0 commit comments

Comments
 (0)