Skip to content

Commit 82d3fcc

Browse files
committed
[BOLT] Use opts::Verbosity in PointerAuthCFIAnalyzer
1 parent 276e74a commit 82d3fcc

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

bolt/lib/Passes/PointerAuthCFIAnalyzer.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
using namespace llvm;
3030

31+
namespace opts {
32+
extern llvm::cl::opt<unsigned> Verbosity;
33+
} // namespace opts
34+
3135
namespace llvm {
3236
namespace bolt {
3337

@@ -43,9 +47,10 @@ bool PointerAuthCFIAnalyzer::runOnFunction(BinaryFunction &BF) {
4347
// Not all functions have .cfi_negate_ra_state in them. But if one does,
4448
// we expect psign/pauth instructions to have the hasNegateRAState
4549
// annotation.
46-
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
47-
<< BF.getPrintName()
48-
<< ": ptr sign/auth inst without .cfi_negate_ra_state\n";
50+
if (opts::Verbosity >= 1)
51+
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
52+
<< BF.getPrintName()
53+
<< ": ptr sign/auth inst without .cfi_negate_ra_state\n";
4954
std::lock_guard<std::mutex> Lock(IgnoreMutex);
5055
BF.setIgnored();
5156
return false;
@@ -65,20 +70,22 @@ bool PointerAuthCFIAnalyzer::runOnFunction(BinaryFunction &BF) {
6570
if (BC.MIB->isPSignOnLR(Inst)) {
6671
if (RAState) {
6772
// RA signing instructions should only follow unsigned RA state.
68-
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
69-
<< BF.getPrintName()
70-
<< ": ptr signing inst encountered in Signed RA state\n";
73+
if (opts::Verbosity >= 1)
74+
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
75+
<< BF.getPrintName()
76+
<< ": ptr signing inst encountered in Signed RA state\n";
7177
std::lock_guard<std::mutex> Lock(IgnoreMutex);
7278
BF.setIgnored();
7379
return false;
7480
}
7581
} else if (BC.MIB->isPAuthOnLR(Inst)) {
7682
if (!RAState) {
7783
// RA authenticating instructions should only follow signed RA state.
78-
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
79-
<< BF.getPrintName()
80-
<< ": ptr authenticating inst encountered in Unsigned RA "
81-
"state\n";
84+
if (opts::Verbosity >= 1)
85+
BC.outs() << "BOLT-INFO: inconsistent RAStates in function "
86+
<< BF.getPrintName()
87+
<< ": ptr authenticating inst encountered in Unsigned RA "
88+
"state\n";
8289
std::lock_guard<std::mutex> Lock(IgnoreMutex);
8390
BF.setIgnored();
8491
return false;

bolt/test/AArch64/pacret-cfi-incorrect.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
1010
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
11-
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads | FileCheck %s --check-prefix=CHECK-BOLT
11+
# RUN: llvm-bolt %t.exe -o %t.exe.bolt -v=1 --no-threads | FileCheck %s --check-prefix=CHECK-BOLT
1212

1313
# CHECK-BOLT: BOLT-INFO: inconsistent RAStates in function foo: ptr authenticating inst encountered in Unsigned RA state
1414
# CHECK-BOLT: BOLT-INFO: inconsistent RAStates in function bar: ptr signing inst encountered in Signed RA state

0 commit comments

Comments
 (0)