Skip to content

Commit 6a06c8b

Browse files
authored
[BOLT][AArch64] Refuse to run ThreeWayBranch pass (#193252)
On AArch64, `--three-way-branch` produces a crash as it is not implemented. This patch adds a guard and updates relevant test(s).
1 parent 5673b02 commit 6a06c8b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

bolt/lib/Passes/ThreeWayBranch.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ void ThreeWayBranch::runOnFunction(BinaryFunction &Function) {
148148
}
149149

150150
Error ThreeWayBranch::runOnFunctions(BinaryContext &BC) {
151+
if (!BC.isX86()) {
152+
BC.errs() << "BOLT-ERROR: " << getName() << " is supported only on X86\n";
153+
exit(1);
154+
}
155+
151156
for (auto &It : BC.getBinaryFunctions()) {
152157
BinaryFunction &Function = It.second;
153158
if (!shouldRunOnFunction(Function))

bolt/test/AArch64/unsupported-passes.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
RUN: %clang %cflags %p/../Inputs/hello.c -o %t -Wl,-q,-z,undefs
66
RUN: not llvm-bolt %t -o %t.bolt --frame-opt=all 2>&1 | FileCheck %s --check-prefix=CHECK-FRAME-OPT
7+
RUN: not llvm-bolt %t -o %t.bolt --three-way-branch 2>&1 | FileCheck %s --check-prefix=CHECK-THREE-WAY
78

89
CHECK-FRAME-OPT: BOLT-ERROR: frame-optimizer is supported only on X86
10+
CHECK-THREE-WAY: BOLT-ERROR: three way branch is supported only on X86
911

1012
RUN: not llvm-bolt %t -o %t.bolt split-functions --split-strategy=cdsplit 2>&1 | FileCheck %s --check-prefix=CHECK-CDSPLIT
1113
CHECK-CDSPLIT: BOLT-ERROR: CDSplit is not supported with LongJmp. Try with '--compact-code-model'

0 commit comments

Comments
 (0)