[llvm] [BOLT][AArch64] Refuse to run retpoline insertion pass (PR #196179)

Amina Chabane via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 13:59:09 PDT 2026


https://github.com/Amichaxx created https://github.com/llvm/llvm-project/pull/196179

RetpolineInsertion (`--insert-retpolines`) is specific to X86, but currently rejects non-X86 targets with an assert. For consistency, this should be an error message.

- Add a non-X86 guard
- Add the error message to unsupported-passes.test

>From 5eed99f5d24cdc1fc6c7c73ad63f7c0f70e851f8 Mon Sep 17 00:00:00 2001
From: Amichaxx <amina.chabane at arm.com>
Date: Wed, 6 May 2026 20:45:43 +0000
Subject: [PATCH] [BOLT][AArch64] Refuse to run retpoline insertion pass

RetpolineInsertion (`--insert-retpolines`) is specific to X86, but currently rejects non-X86
targets with an assert. For consistency, this should be an error
message.

- Add a non-X86 guard
- Add the error message to unsupported-passes.test
---
 bolt/lib/Passes/RetpolineInsertion.cpp    | 6 ++++--
 bolt/test/AArch64/unsupported-passes.test | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/bolt/lib/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp
index bda26206e16c3..68d3e4cf570e3 100644
--- a/bolt/lib/Passes/RetpolineInsertion.cpp
+++ b/bolt/lib/Passes/RetpolineInsertion.cpp
@@ -271,8 +271,10 @@ Error RetpolineInsertion::runOnFunctions(BinaryContext &BC) {
   if (!opts::InsertRetpolines)
     return Error::success();
 
-  assert(BC.isX86() &&
-         "retpoline insertion not supported for target architecture");
+  if (!BC.isX86()) {
+    BC.errs() << "BOLT-ERROR: " << getName() << " is specific to X86\n";
+    exit(1);
+  }
 
   assert(BC.HasRelocations && "retpoline mode not supported in non-reloc");
 
diff --git a/bolt/test/AArch64/unsupported-passes.test b/bolt/test/AArch64/unsupported-passes.test
index ef3e434c4ba06..23063be0f8c8d 100644
--- a/bolt/test/AArch64/unsupported-passes.test
+++ b/bolt/test/AArch64/unsupported-passes.test
@@ -16,8 +16,10 @@ CHECK-INDIRECT-CALL-PROMOTION: BOLT-ERROR: indirect-call-promotion is supported
 // Passes specific to X86 arch
 RUN: not llvm-bolt %t -o %t.bolt --cmov-conversion 2>&1 | FileCheck %s --check-prefix=CHECK-CMOV-CONV
 RUN: not llvm-bolt %t -o %t.bolt --reg-reassign 2>&1 | FileCheck %s --check-prefix=CHECK-REG-REASSIGN
+RUN: not llvm-bolt %t -o %t.bolt --insert-retpolines 2>&1 | FileCheck %s --check-prefix=CHECK-RETPOLINE
 CHECK-CMOV-CONV: BOLT-ERROR: CMOV conversion is supported only on X86
 CHECK-REG-REASSIGN: BOLT-ERROR: reg-reassign is supported only on X86
+CHECK-RETPOLINE: BOLT-ERROR: retpoline-insertion is specific to X86
 
 RUN: not llvm-bolt %t -o %t.bolt split-functions --split-strategy=cdsplit 2>&1 | FileCheck %s --check-prefix=CHECK-CDSPLIT
 CHECK-CDSPLIT: BOLT-ERROR: CDSplit is not supported with LongJmp. Try with '--compact-code-model'



More information about the llvm-commits mailing list