Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AArch64][PAC] Support BLRA* instructions in SLS Hardening pass #97605

Merged
merged 7 commits into from
Jul 6, 2024

Conversation

atrosinenko
Copy link
Contributor

Make SLS Hardening pass handle BLRA* instructions the same way it handles BLR. The thunk names have the form

__llvm_slsblr_thunk_xN            for BLR thunks
__llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
__llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear thunk function's name lookup and parse the name instead.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 3, 2024

@llvm/pr-subscribers-backend-aarch64

Author: Anatoly Trosinenko (atrosinenko)

Changes

Make SLS Hardening pass handle BLRA* instructions the same way it handles BLR. The thunk names have the form

__llvm_slsblr_thunk_xN            for BLR thunks
__llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
__llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear thunk function's name lookup and parse the name instead.


Patch is 23.27 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/97605.diff

2 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64SLSHardening.cpp (+222-104)
  • (added) llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir (+210)
diff --git a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
index feb166f30127a..d93fe2a875845 100644
--- a/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
+++ b/llvm/lib/Target/AArch64/AArch64SLSHardening.cpp
@@ -13,6 +13,7 @@
 
 #include "AArch64InstrInfo.h"
 #include "AArch64Subtarget.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/CodeGen/IndirectThunks.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -23,6 +24,7 @@
 #include "llvm/IR/DebugLoc.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Target/TargetMachine.h"
 #include <cassert>
 
@@ -32,17 +34,103 @@ using namespace llvm;
 
 #define AARCH64_SLS_HARDENING_NAME "AArch64 sls hardening pass"
 
-static const char SLSBLRNamePrefix[] = "__llvm_slsblr_thunk_";
+// Common name prefix of all thunks generated by this pass.
+//
+// The generic form is
+// __llvm_slsblr_thunk_xN            for BLR thunks
+// __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
+// __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks
+static constexpr StringRef CommonNamePrefix = "__llvm_slsblr_thunk_";
 
 namespace {
 
-// Set of inserted thunks: bitmask with bits corresponding to
-// indexes in SLSBLRThunks array.
-typedef uint32_t ThunksSet;
+struct ThunkKind {
+  enum ThunkKindId {
+    ThunkBR,
+    ThunkBRAA,
+    ThunkBRAB,
+    ThunkBRAAZ,
+    ThunkBRABZ,
+  };
+
+  ThunkKindId Id;
+  StringRef NameInfix;
+  bool HasXmOperand;
+  bool NeedsPAuth;
+
+  // Opcode to perform indirect jump from inside the thunk.
+  unsigned BROpcode;
+
+  static const ThunkKind BR;
+  static const ThunkKind BRAA;
+  static const ThunkKind BRAB;
+  static const ThunkKind BRAAZ;
+  static const ThunkKind BRABZ;
+};
+
+// Set of inserted thunks.
+class ThunksSet {
+public:
+  static constexpr unsigned NumXRegisters = 32;
+
+  // Given Xn register, returns n.
+  static unsigned indexOfXReg(Register Xn);
+  // Given n, returns Xn register.
+  static Register xRegByIndex(unsigned N);
+
+  ThunksSet &operator|=(const ThunksSet &Other) {
+    BLRThunks |= Other.BLRThunks;
+    BLRAAZThunks |= Other.BLRAAZThunks;
+    BLRABZThunks |= Other.BLRABZThunks;
+    for (unsigned I = 0; I < NumXRegisters; ++I)
+      BLRAAThunks[I] |= Other.BLRAAThunks[I];
+    for (unsigned I = 0; I < NumXRegisters; ++I)
+      BLRABThunks[I] |= Other.BLRABThunks[I];
+
+    return *this;
+  }
+
+  bool get(ThunkKind::ThunkKindId Kind, Register Xn, Register Xm) {
+    uint32_t XnBit = 1u << indexOfXReg(Xn);
+    return getBitmask(Kind, Xm) & XnBit;
+  }
+
+  void set(ThunkKind::ThunkKindId Kind, Register Xn, Register Xm) {
+    uint32_t XnBit = 1u << indexOfXReg(Xn);
+    getBitmask(Kind, Xm) |= XnBit;
+  }
+
+private:
+  // Bitmasks representing operands used, with n-th bit corresponding to Xn
+  // register operand. If the instruction has a second operand (Xm), an array
+  // of bitmasks is used, indexed by m.
+  // Indexes corresponding to the forbidden x16, x17 and x30 registers are
+  // always unset, for simplicity there are no holes.
+  uint32_t BLRThunks = 0;
+  uint32_t BLRAAZThunks = 0;
+  uint32_t BLRABZThunks = 0;
+  uint32_t BLRAAThunks[NumXRegisters] = {};
+  uint32_t BLRABThunks[NumXRegisters] = {};
+
+  uint32_t &getBitmask(ThunkKind::ThunkKindId Kind, Register Xm) {
+    switch (Kind) {
+    case ThunkKind::ThunkBR:
+      return BLRThunks;
+    case ThunkKind::ThunkBRAAZ:
+      return BLRAAZThunks;
+    case ThunkKind::ThunkBRABZ:
+      return BLRABZThunks;
+    case ThunkKind::ThunkBRAA:
+      return BLRAAThunks[indexOfXReg(Xm)];
+    case ThunkKind::ThunkBRAB:
+      return BLRABThunks[indexOfXReg(Xm)];
+    }
+  }
+};
 
 struct SLSHardeningInserter : ThunkInserter<SLSHardeningInserter, ThunksSet> {
 public:
-  const char *getThunkPrefix() { return SLSBLRNamePrefix; }
+  const char *getThunkPrefix() { return CommonNamePrefix.data(); }
   bool mayUseThunk(const MachineFunction &MF) {
     // FIXME: ComdatThunks is only accumulated until the first thunk is created.
     ComdatThunks &= !MF.getSubtarget<AArch64Subtarget>().hardenSlsNoComdat();
@@ -69,6 +157,57 @@ struct SLSHardeningInserter : ThunkInserter<SLSHardeningInserter, ThunksSet> {
 
 } // end anonymous namespace
 
+const ThunkKind ThunkKind::BR = {ThunkBR, "", false, false, AArch64::BR};
+const ThunkKind ThunkKind::BRAA = {ThunkBRAA, "aa_", true, true, AArch64::BRAA};
+const ThunkKind ThunkKind::BRAB = {ThunkBRAB, "ab_", true, true, AArch64::BRAB};
+const ThunkKind ThunkKind::BRAAZ = {ThunkBRAAZ, "aaz_", false, true,
+                                    AArch64::BRAAZ};
+const ThunkKind ThunkKind::BRABZ = {ThunkBRABZ, "abz_", false, true,
+                                    AArch64::BRABZ};
+
+static const ThunkKind *getThunkKind(unsigned OriginalOpcode) {
+  switch (OriginalOpcode) {
+  case AArch64::BLR:
+  case AArch64::BLRNoIP:
+    return &ThunkKind::BR;
+  case AArch64::BLRAA:
+    return &ThunkKind::BRAA;
+  case AArch64::BLRAB:
+    return &ThunkKind::BRAB;
+  case AArch64::BLRAAZ:
+    return &ThunkKind::BRAAZ;
+  case AArch64::BLRABZ:
+    return &ThunkKind::BRABZ;
+  }
+  return nullptr;
+}
+
+static bool isBLR(const MachineInstr &MI) {
+  return getThunkKind(MI.getOpcode()) != nullptr;
+}
+
+unsigned ThunksSet::indexOfXReg(Register Reg) {
+  assert(AArch64::GPR64RegClass.contains(Reg));
+  assert(Reg != AArch64::X16 && Reg != AArch64::X17 && Reg != AArch64::LR);
+
+  // Most Xn registers have consequent ids, except for FP and XZR.
+  unsigned Result = (unsigned)Reg - (unsigned)AArch64::X0;
+  if (Reg == AArch64::FP)
+    Result = 29;
+  else if (Reg == AArch64::XZR)
+    Result = 31;
+
+  assert(Result < NumXRegisters && "Internal register numbering changed");
+  assert(AArch64::GPR64RegClass.getRegister(Result).id() == Reg &&
+         "Internal register numbering changed");
+
+  return Result;
+}
+
+Register ThunksSet::xRegByIndex(unsigned N) {
+  return AArch64::GPR64RegClass.getRegister(N);
+}
+
 static void insertSpeculationBarrier(const AArch64Subtarget *ST,
                                      MachineBasicBlock &MBB,
                                      MachineBasicBlock::iterator MBBI,
@@ -105,22 +244,6 @@ ThunksSet SLSHardeningInserter::insertThunks(MachineModuleInfo &MMI,
   return ExistingThunks;
 }
 
-static bool isBLR(const MachineInstr &MI) {
-  switch (MI.getOpcode()) {
-  case AArch64::BLR:
-  case AArch64::BLRNoIP:
-    return true;
-  case AArch64::BLRAA:
-  case AArch64::BLRAB:
-  case AArch64::BLRAAZ:
-  case AArch64::BLRABZ:
-    llvm_unreachable("Currently, LLVM's code generator does not support "
-                     "producing BLRA* instructions. Therefore, there's no "
-                     "support in this pass for those instructions.");
-  }
-  return false;
-}
-
 bool SLSHardeningInserter::hardenReturnsAndBRs(MachineModuleInfo &MMI,
                                                MachineBasicBlock &MBB) {
   const AArch64Subtarget *ST =
@@ -140,62 +263,56 @@ bool SLSHardeningInserter::hardenReturnsAndBRs(MachineModuleInfo &MMI,
   return Modified;
 }
 
-static const unsigned NumPermittedRegs = 29;
-static const struct ThunkNameAndReg {
-  const char* Name;
-  Register Reg;
-} SLSBLRThunks[NumPermittedRegs] = {
-  { "__llvm_slsblr_thunk_x0",  AArch64::X0},
-  { "__llvm_slsblr_thunk_x1",  AArch64::X1},
-  { "__llvm_slsblr_thunk_x2",  AArch64::X2},
-  { "__llvm_slsblr_thunk_x3",  AArch64::X3},
-  { "__llvm_slsblr_thunk_x4",  AArch64::X4},
-  { "__llvm_slsblr_thunk_x5",  AArch64::X5},
-  { "__llvm_slsblr_thunk_x6",  AArch64::X6},
-  { "__llvm_slsblr_thunk_x7",  AArch64::X7},
-  { "__llvm_slsblr_thunk_x8",  AArch64::X8},
-  { "__llvm_slsblr_thunk_x9",  AArch64::X9},
-  { "__llvm_slsblr_thunk_x10",  AArch64::X10},
-  { "__llvm_slsblr_thunk_x11",  AArch64::X11},
-  { "__llvm_slsblr_thunk_x12",  AArch64::X12},
-  { "__llvm_slsblr_thunk_x13",  AArch64::X13},
-  { "__llvm_slsblr_thunk_x14",  AArch64::X14},
-  { "__llvm_slsblr_thunk_x15",  AArch64::X15},
-  // X16 and X17 are deliberately missing, as the mitigation requires those
-  // register to not be used in BLR. See comment in ConvertBLRToBL for more
-  // details.
-  { "__llvm_slsblr_thunk_x18",  AArch64::X18},
-  { "__llvm_slsblr_thunk_x19",  AArch64::X19},
-  { "__llvm_slsblr_thunk_x20",  AArch64::X20},
-  { "__llvm_slsblr_thunk_x21",  AArch64::X21},
-  { "__llvm_slsblr_thunk_x22",  AArch64::X22},
-  { "__llvm_slsblr_thunk_x23",  AArch64::X23},
-  { "__llvm_slsblr_thunk_x24",  AArch64::X24},
-  { "__llvm_slsblr_thunk_x25",  AArch64::X25},
-  { "__llvm_slsblr_thunk_x26",  AArch64::X26},
-  { "__llvm_slsblr_thunk_x27",  AArch64::X27},
-  { "__llvm_slsblr_thunk_x28",  AArch64::X28},
-  { "__llvm_slsblr_thunk_x29",  AArch64::FP},
-  // X30 is deliberately missing, for similar reasons as X16 and X17 are
-  // missing.
-  { "__llvm_slsblr_thunk_x31",  AArch64::XZR},
-};
+static SmallString<32> createThunkName(const ThunkKind &Kind, Register Xn,
+                                       Register Xm) {
+  unsigned N = ThunksSet::indexOfXReg(Xn);
+  if (!Kind.HasXmOperand)
+    return formatv("{0}{1}x{2}", CommonNamePrefix, Kind.NameInfix, N);
+
+  unsigned M = ThunksSet::indexOfXReg(Xm);
+  return formatv("{0}{1}x{2}_x{3}", CommonNamePrefix, Kind.NameInfix, N, M);
+}
 
-unsigned getThunkIndex(Register Reg) {
-  for (unsigned I = 0; I < NumPermittedRegs; ++I)
-    if (SLSBLRThunks[I].Reg == Reg)
-      return I;
-  llvm_unreachable("Unexpected register");
+static const ThunkKind &parseThunkName(StringRef ThunkName, Register &Xn,
+                                       Register &Xm) {
+  assert(ThunkName.starts_with(CommonNamePrefix) &&
+         "Should be filtered out by ThunkInserter");
+  // Thunk name suffix, such as "x1" or "aa_x2_x3".
+  StringRef NameSuffix = ThunkName.drop_front(CommonNamePrefix.size());
+
+  // Parse thunk kind based on thunk name infix.
+  const ThunkKind &Kind = *StringSwitch<const ThunkKind *>(NameSuffix)
+                               .StartsWith("aa_", &ThunkKind::BRAA)
+                               .StartsWith("ab_", &ThunkKind::BRAB)
+                               .StartsWith("aaz_", &ThunkKind::BRAAZ)
+                               .StartsWith("abz_", &ThunkKind::BRABZ)
+                               .Default(&ThunkKind::BR);
+
+  auto ParseRegName = [](StringRef Name) {
+    assert(Name.starts_with("x") && "xN register name expected");
+    unsigned N;
+    bool Fail = Name.drop_front(1).getAsInteger(/*Radix=*/10, N);
+    assert(!Fail && N < 32 && "Unexpected register");
+    return ThunksSet::xRegByIndex(N);
+  };
+
+  // For example, "x1" or "x2_x3".
+  StringRef RegsStr = NameSuffix.drop_front(Kind.NameInfix.size());
+  StringRef XnStr, XmStr;
+  std::tie(XnStr, XmStr) = RegsStr.split('_');
+
+  // Parse register operands.
+  Xn = ParseRegName(XnStr);
+  Xm = Kind.HasXmOperand ? ParseRegName(XmStr) : AArch64::NoRegister;
+
+  return Kind;
 }
 
 void SLSHardeningInserter::populateThunk(MachineFunction &MF) {
   // FIXME: How to better communicate Register number, rather than through
   // name and lookup table?
-  assert(MF.getName().starts_with(getThunkPrefix()));
-  auto ThunkIt = llvm::find_if(
-      SLSBLRThunks, [&MF](auto T) { return T.Name == MF.getName(); });
-  assert(ThunkIt != std::end(SLSBLRThunks));
-  Register ThunkReg = ThunkIt->Reg;
+  Register Xn, Xm;
+  const ThunkKind &Kind = parseThunkName(MF.getName(), Xn, Xm);
 
   const TargetInstrInfo *TII =
       MF.getSubtarget<AArch64Subtarget>().getInstrInfo();
@@ -220,13 +337,19 @@ void SLSHardeningInserter::populateThunk(MachineFunction &MF) {
   //  __llvm_slsblr_thunk_xN:
   //      BR xN
   //      barrierInsts
-  Entry->addLiveIn(ThunkReg);
-  // MOV X16, ThunkReg == ORR X16, XZR, ThunkReg, LSL #0
+  Entry->addLiveIn(Xn);
+  // MOV X16, Reg == ORR X16, XZR, Reg, LSL #0
   BuildMI(Entry, DebugLoc(), TII->get(AArch64::ORRXrs), AArch64::X16)
       .addReg(AArch64::XZR)
-      .addReg(ThunkReg)
+      .addReg(Xn)
       .addImm(0);
-  BuildMI(Entry, DebugLoc(), TII->get(AArch64::BR)).addReg(AArch64::X16);
+  auto &Builder =
+      BuildMI(Entry, DebugLoc(), TII->get(Kind.BROpcode)).addReg(AArch64::X16);
+  if (Xm != AArch64::NoRegister) {
+    Entry->addLiveIn(Xm);
+    Builder.addReg(Xm);
+  }
+
   // Make sure the thunks do not make use of the SB extension in case there is
   // a function somewhere that will call to it that for some reason disabled
   // the SB extension locally on that function, even though it's enabled for
@@ -273,40 +396,31 @@ void SLSHardeningInserter::convertBLRToBL(
 
   MachineInstr &BLR = *MBBI;
   assert(isBLR(BLR));
-  unsigned BLOpcode;
-  Register Reg;
-  bool RegIsKilled;
-  switch (BLR.getOpcode()) {
-  case AArch64::BLR:
-  case AArch64::BLRNoIP:
-    BLOpcode = AArch64::BL;
-    Reg = BLR.getOperand(0).getReg();
-    assert(Reg != AArch64::X16 && Reg != AArch64::X17 && Reg != AArch64::LR);
-    RegIsKilled = BLR.getOperand(0).isKill();
-    break;
-  case AArch64::BLRAA:
-  case AArch64::BLRAB:
-  case AArch64::BLRAAZ:
-  case AArch64::BLRABZ:
-    llvm_unreachable("BLRA instructions cannot yet be produced by LLVM, "
-                     "therefore there is no need to support them for now.");
-  default:
-    llvm_unreachable("unhandled BLR");
-  }
+  const ThunkKind &Kind = *getThunkKind(BLR.getOpcode());
+
+  unsigned NumRegOperands = Kind.HasXmOperand ? 2 : 1;
+  assert(BLR.getNumExplicitOperands() == NumRegOperands &&
+         "Expected one or two register inputs");
+  Register Xn = BLR.getOperand(0).getReg();
+  Register Xm =
+      Kind.HasXmOperand ? BLR.getOperand(1).getReg() : AArch64::NoRegister;
+
   DebugLoc DL = BLR.getDebugLoc();
 
   MachineFunction &MF = *MBBI->getMF();
   MCContext &Context = MBB.getParent()->getContext();
   const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
-  unsigned ThunkIndex = getThunkIndex(Reg);
-  StringRef ThunkName = SLSBLRThunks[ThunkIndex].Name;
+
+  auto ThunkName = createThunkName(Kind, Xn, Xm);
   MCSymbol *Sym = Context.getOrCreateSymbol(ThunkName);
-  if (!(Thunks & (1u << ThunkIndex))) {
-    Thunks |= 1u << ThunkIndex;
-    createThunkFunction(MMI, ThunkName, ComdatThunks);
+
+  if (!Thunks.get(Kind.Id, Xn, Xm)) {
+    StringRef TargetAttrs = Kind.NeedsPAuth ? "+pauth" : "";
+    Thunks.set(Kind.Id, Xn, Xm);
+    createThunkFunction(MMI, ThunkName, ComdatThunks, TargetAttrs);
   }
 
-  MachineInstr *BL = BuildMI(MBB, MBBI, DL, TII->get(BLOpcode)).addSym(Sym);
+  MachineInstr *BL = BuildMI(MBB, MBBI, DL, TII->get(AArch64::BL)).addSym(Sym);
 
   // Now copy the implicit operands from BLR to BL and copy other necessary
   // info.
@@ -337,9 +451,13 @@ void SLSHardeningInserter::convertBLRToBL(
   // Now copy over the implicit operands from the original BLR
   BL->copyImplicitOps(MF, BLR);
   MF.moveCallSiteInfo(&BLR, BL);
-  // Also add the register called in the BLR as being used in the called thunk.
-  BL->addOperand(MachineOperand::CreateReg(Reg, false /*isDef*/, true /*isImp*/,
-                                           RegIsKilled /*isKill*/));
+  // Also add the register operands of the original BLR* instruction
+  // as being used in the called thunk.
+  for (unsigned OpIdx = 0; OpIdx < NumRegOperands; ++OpIdx) {
+    MachineOperand &Op = BLR.getOperand(OpIdx);
+    BL->addOperand(MachineOperand::CreateReg(Op.getReg(), /*isDef=*/false,
+                                             /*isImp=*/true, Op.isKill()));
+  }
   // Remove BLR instruction
   MBB.erase(MBBI);
 }
diff --git a/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir b/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir
new file mode 100644
index 0000000000000..bdeba53e25071
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir
@@ -0,0 +1,210 @@
+# RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \
+# RUN:     -start-before aarch64-sls-hardening -o - %s \
+# RUN:     -asm-verbose=0 \
+# RUN: | FileCheck %s \
+# RUN:     --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 \
+# RUN:     --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 \
+# RUN:     --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 \
+# RUN:     --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+
+# Pointer Authentication extension introduces more branch-with-link instructions
+# for the BLR SLS hardening to handle, namely BLRAA, BLRAB, BLRAAZ and BLRABZ.
+# Unlike the non-authenticating BLR instruction, BLRAA and BLRAB accept two
+# register operands (almost 900 combinations for each instruction).
+# For that reason, it is not practical to create all possible thunks.
+
+# Check that the BLR SLS hardening transforms BLRA* instructions into
+# unconditional BL calls to the correct thunk functions.
+# Check that only relevant thunk functions are generated.
+--- |
+  define void @test_instructions() #0 {
+  entry:
+    ret void
+  }
+
+  define void @test_no_redef() #0 {
+  entry:
+    ret void
+  }
+
+  define void @test_regs() #0 {
+  entry:
+    ret void
+  }
+
+  attributes #0 = { "target-features"="+pauth,+harden-sls-blr" }
+...
+
+# Test that all BLRA* instructions are handled.
+---
+name:            test_instructions
+tracksRegLiveness: true
+body:             |
+  bb.0.entry:
+    liveins: $lr, $x0, $x1, $x2, $x3
+
+    BLRAA $x0, $x1, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAB $x1, $x2, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAAZ $x2, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRABZ $x3, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    RET undef $lr
+...
+
+# Test that the same thunk function is not created twice.
+---
+name:            test_no_redef
+tracksRegLiveness: true
+body:             |
+  bb.0.entry:
+    liveins: $lr, $x0, $x1, $x2, $x3, $x4
+
+    ; thunk used by @test_instructions
+    BLRAB $x1, $x2, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+
+    ; thunk used by this function twice
+    BLRAB $x3, $x4, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAB $x3, $x4, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+
+    RET undef $lr
+...
+
+# Test that all xN registers (except x16, x17, x30 and xzr) are handled.
+---
+name:            test_regs
+tracksRegLiveness: true
+body:             |
+  bb.0.entry:
+    liveins: $lr, $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15, $x16, $x17, $x18, $x19, $x20, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28, $fp
+
+    BLRAA $x0, $x1, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x2, $x3, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x4, $x5, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x6, $x7, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x8, $x9, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x10, $x11, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x12, $x13, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x14, $x15, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    ; skipping x16 and x17
+    BLRAA $x18, $x19, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x20, $x21, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x22, $x23, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x24, $x25, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x26, $x27, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    BLRAA $x28, $fp, implicit-def $lr, implicit $sp, implicit-def $sp, implicit-def $w0
+    RET undef $lr
+...
+
+# CHECK-LABEL: test_instructions:
+# CHECK-NEXT:    .cfi_startproc
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_aa_x0_x1
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_ab_x1_x2
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_aaz_x2
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_abz_x3
+# CHECK-NEXT:    ret
+
+# CHECK-LABEL: test_no_redef:
+# CHECK-NEXT:    .cfi_startproc
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_ab_x1_x2
+# CHECK-NEXT:    bl      __llvm_slsblr_thunk_ab_x3_x4
...
[truncated]

@atrosinenko atrosinenko force-pushed the users/atrosinenko/aarch64-sls-hardening branch 2 times, most recently from 29d6b44 to 0247af9 Compare July 4, 2024 14:26
@atrosinenko atrosinenko force-pushed the users/atrosinenko/pauth-sls-hardening branch from b389284 to f49c32c Compare July 4, 2024 14:42
@atrosinenko atrosinenko force-pushed the users/atrosinenko/aarch64-sls-hardening branch from 0247af9 to 28a8541 Compare July 4, 2024 16:22
@atrosinenko atrosinenko force-pushed the users/atrosinenko/pauth-sls-hardening branch from f49c32c to 84e7eb3 Compare July 4, 2024 16:22
Copy link
Collaborator

@kbeyls kbeyls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this mostly looks good to me.
I've only added very minor comments; feel free to disagree with them.

llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
Base automatically changed from users/atrosinenko/aarch64-sls-hardening to main July 5, 2024 10:12
Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.
@atrosinenko atrosinenko force-pushed the users/atrosinenko/pauth-sls-hardening branch from 3261fb1 to 38d720b Compare July 5, 2024 10:16
Copy link
Contributor Author

@atrosinenko atrosinenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review @kbeyls, I updated a few straightforward places. I need a bit more time to think how to update the comments better.

llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@kovdan01 kovdan01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with very minor comments, so I'm OK with merging this when @kbeyls gives his final approval.

llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@atrosinenko atrosinenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbeyls I updated the comments describing the changes made to the machine code, now I expect them to be up-to-date.

llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
llvm/lib/Target/AArch64/AArch64SLSHardening.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@kbeyls kbeyls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@atrosinenko
Copy link
Contributor Author

This time, the failing test

TEST 'lldb-api :: functionalities/fork/concurrent_vfork/TestConcurrentVFork.py'

seems unrelated to this PR.

@atrosinenko atrosinenko merged commit 88b2629 into main Jul 6, 2024
7 checks passed
@atrosinenko atrosinenko deleted the users/atrosinenko/pauth-sls-hardening branch July 6, 2024 10:36
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-rel-x86-64 running on ml-opt-rel-x86-64-b1 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/185/builds/1311

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /b/ml-opt-rel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /b/ml-opt-rel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /b/ml-opt-rel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x000055f538d00fb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x3d0cfb8)
 #1 0x000055f538cfe39c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f8241d3d140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
 #3 0x000055f537cab391 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x2cb7391)
 #4 0x000055f535f319a4 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x000055f537c98147 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #6 0x000055f538298319 llvm::FPPassManager::runOnFunction(llvm::Function&) (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x32a4319)
 #7 0x000055f538298551 llvm::FPPassManager::runOnModule(llvm::Module&) (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x32a4551)
 #8 0x000055f53829913b llvm::legacy::PassManagerImpl::run(llvm::Module&) (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x32a513b)
 #9 0x000055f535a8c471 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x000055f5359872ce main (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0x9932ce)
#11 0x00007f8241829d0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d0a)
#12 0x000055f535a82a9a _start (/b/ml-opt-rel-x86-64-b1/build/bin/llc+0xa8ea9a)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/ml-opt-rel-x86-64-b1/build/bin/FileCheck /b/ml-opt-rel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-devrel-x86-64 running on ml-opt-devrel-x86-64-b2 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/175/builds/1307

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /b/ml-opt-devrel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /b/ml-opt-devrel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /b/ml-opt-devrel-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x000056373d5b1a08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0x3d9ea08)
 #1 0x000056373d5aedec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f2dde041140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
 #3 0x000056373c551ea1 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0x2d3eea1)
 #4 0x000056373a7d84d4 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x000056373c53ec57 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #6 0x000056373cb48d69 llvm::FPPassManager::runOnFunction(llvm::Function&) (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0x3335d69)
 #7 0x000056373cb48fa1 llvm::FPPassManager::runOnModule(llvm::Module&) (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0x3335fa1)
 #8 0x000056373cb49b8b llvm::legacy::PassManagerImpl::run(llvm::Module&) (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0x3336b8b)
 #9 0x000056373a332fa1 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x000056373a22bc5e main (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0xa18c5e)
#11 0x00007f2dddb19d0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d0a)
#12 0x000056373a3295ca _start (/b/ml-opt-devrel-x86-64-b1/build/bin/llc+0xb165ca)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/ml-opt-devrel-x86-64-b1/build/bin/FileCheck /b/ml-opt-devrel-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-gcc-ubuntu running on sie-linux-worker3 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/174/builds/1200

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x0000562ec66e7c4f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x3dc4c4f)
 #1 0x0000562ec66e5194 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f86a2bbc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x0000562ec565f645 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x2d3c645)
 #4 0x0000562ec38b0ec7 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x0000562ec564daf5 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #6 0x0000562ec5c56bfb llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x3333bfb)
 #7 0x0000562ec5c56e49 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x3333e49)
 #8 0x0000562ec5c576f5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x33346f5)
 #9 0x0000562ec33fd319 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x0000562ec32fe30e main (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0x9db30e)
#11 0x00007f86a266a083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3
#12 0x0000562ec33f3a2e _start (/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/llc+0xad0a2e)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


atrosinenko added a commit that referenced this pull request Jul 6, 2024
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder ml-opt-dev-x86-64 running on ml-opt-dev-x86-64-b1 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/137/builds/1297

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /b/ml-opt-dev-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /b/ml-opt-dev-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /b/ml-opt-dev-x86-64-b1/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x00005654bb740fd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0x3d9bfd8)
 #1 0x00005654bb73e3bc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fcb6f01d140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
 #3 0x00005654ba6e28c1 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0x2d3d8c1)
 #4 0x00005654b8968ed4 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x00005654ba6cf677 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #6 0x00005654bacd8339 llvm::FPPassManager::runOnFunction(llvm::Function&) (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0x3333339)
 #7 0x00005654bacd8571 llvm::FPPassManager::runOnModule(llvm::Module&) (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0x3333571)
 #8 0x00005654bacd915b llvm::legacy::PassManagerImpl::run(llvm::Module&) (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0x333415b)
 #9 0x00005654b84c39a1 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x00005654b83bbfee main (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0xa16fee)
#11 0x00007fcb6eaf5d0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d0a)
#12 0x00005654b84b9fca _start (/b/ml-opt-dev-x86-64-b1/build/bin/llc+0xb14fca)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /b/ml-opt-dev-x86-64-b1/build/bin/FileCheck /b/ml-opt-dev-x86-64-b1/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@atrosinenko
Copy link
Contributor Author

Reverted the PR for now, will investigate and reopen it on Monday.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder clang-ppc64be-linux-test-suite running on ppc64be-clang-test-suite while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/176/builds/791

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x000000001442d298 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc+0x1442d298)
 #1 0x000000001442a16c SignalHandler(int) Signals.cpp:0:0
 #2 0x00003fff91ef0478 (+0x478)
 #3 0x00003fffcaa87be0 
 #4 0x0000000010a0ce54 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x0000000012f5875c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #6 0x000000001371e528 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc+0x1371e528)
 #7 0x000000001371e858 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc+0x1371e858)
 #8 0x000000001371f4d4 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc+0x1371f4d4)
 #9 0x00000000103f541c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x00000000102f0e58 main (/home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/llc+0x102f0e58)
#11 0x00003fff91917cec generic_start_main.isra.0 libc-start.c:0:0
#12 0x00003fff91917ef4 __libc_start_main (/lib64/libc.so.6+0x47ef4)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64be-clang-test-suite/clang-ppc64be-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-test-suite running on ppc64le-clang-test-suite while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/928

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x0000000013eea130 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x13eea130)
 #1 0x0000000013ee6ea4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fffb0ef04d8 (linux-vdso64.so.1+0x4d8)
 #3 0x0000000012c56194 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x12c56194)
 #4 0x00000000109bcff4 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x0000000012c41f9c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.70) MachineFunctionPass.cpp:0:0
 #6 0x0000000013330cd0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x13330cd0)
 #7 0x0000000013331018 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x13331018)
 #8 0x0000000013331f48 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x13331f48)
 #9 0x000000001042afdc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x000000001032dc78 main (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/llc+0x1032dc78)
#11 0x00007fffb076a96c generic_start_main.isra.0 (/lib64/libc.so.6+0x2a96c)
#12 0x00007fffb076ab04 __libc_start_main (/lib64/libc.so.6+0x2ab04)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 7 "test-build-stage1-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/765

Here is the relevant piece of the build log for the reference:

Step 7 (test-build-stage1-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x0000000013eea130 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x13eea130)
 #1 0x0000000013ee6ea4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fff90b804d8 (linux-vdso64.so.1+0x4d8)
 #3 0x0000000012c56194 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x12c56194)
 #4 0x00000000109bcff4 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x0000000012c41f9c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.70) MachineFunctionPass.cpp:0:0
 #6 0x0000000013330cd0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x13330cd0)
 #7 0x0000000013331018 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x13331018)
 #8 0x0000000013331f48 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x13331f48)
 #9 0x000000001042afdc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x000000001032dc78 main (/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc+0x1032dc78)
#11 0x00007fff903fa96c generic_start_main.isra.0 (/lib64/libc.so.6+0x2a96c)
#12 0x00007fff903fab04 __libc_start_main (/lib64/libc.so.6+0x2ab04)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 6, 2024

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-multistage running on ppc64le-clang-multistage-test while building llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/735

Here is the relevant piece of the build log for the reference:

Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x00007fff920829b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/../lib/libLLVMSupport.so.19.0git+0x2329b0)
 #1 0x00007fff9207f714 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fff9c6804d8 (linux-vdso64.so.1+0x4d8)
 #3 0x00007fff943b1794 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/../lib/libLLVMCodeGen.so.19.0git+0x471794)
 #4 0x00007fff9b6f0894 llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #5 0x00007fff943985dc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.70) MachineFunctionPass.cpp:0:0
 #6 0x00007fff925db8f0 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/../lib/libLLVMCore.so.19.0git+0x33b8f0)
 #7 0x00007fff925dbc38 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/../lib/libLLVMCore.so.19.0git+0x33bc38)
 #8 0x00007fff925dcb68 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/../lib/libLLVMCore.so.19.0git+0x33cb68)
 #9 0x000000001001d5bc compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#10 0x0000000010011398 main (/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/llc+0x10011398)
#11 0x00007fff918aa96c generic_start_main.isra.0 (/lib64/libc.so.6+0x2a96c)
#12 0x00007fff918aab04 __libc_start_main (/lib64/libc.so.6+0x2ab04)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/llvm/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


atrosinenko added a commit that referenced this pull request Jul 8, 2024
Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.

This patch reapplies #97605.
atrosinenko added a commit that referenced this pull request Jul 9, 2024
Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.

This patch reapplies #97605.
atrosinenko added a commit that referenced this pull request Jul 9, 2024
Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.

This patch reapplies #97605.
atrosinenko added a commit that referenced this pull request Jul 9, 2024
Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.

This patch reapplies #97605.
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jul 11, 2024

LLVM Buildbot has detected a new failure on builder lld-x86_64-ubuntu-fast running on as-builder-4 while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/33/builds/394

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: CodeGen/AArch64/speculation-hardening-sls-blra.mir' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu      -start-before aarch64-sls-hardening -o - /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      -asm-verbose=0  | /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir      --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8      --implicit-check-not=__llvm_slsblr_thunk_aaz_x5      --implicit-check-not=__llvm_slsblr_thunk_abz_x5
+ /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
+ /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu -start-before aarch64-sls-hardening -o - /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir -asm-verbose=0
1.	Running pass 'Function Pass Manager' on module '/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir'.
2.	Running pass 'AArch64 sls hardening pass' on function '@__llvm_slsblr_thunk_aa_x0_x1'
 #0 0x00005612b723d2c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x3e0e2c0)
 #1 0x00005612b723a6df llvm::sys::RunSignalHandlers() (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x3e0b6df)
 #2 0x00005612b723a835 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f4792b89520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00005612b619abf5 llvm::MachineInstr::addOperand(llvm::MachineFunction&, llvm::MachineOperand const&) (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x2d6bbf5)
 #5 0x00005612b437dc6b llvm::ThunkInserter<(anonymous namespace)::SLSHardeningInserter, (anonymous namespace)::ThunksSet>::run(llvm::MachineModuleInfo&, llvm::MachineFunction&) AArch64SLSHardening.cpp:0:0
 #6 0x00005612b6187857 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
 #7 0x00005612b679f666 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x3370666)
 #8 0x00005612b679f8b9 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x33708b9)
 #9 0x00005612b67a0215 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x3371215)
#10 0x00005612b3ebfd16 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#11 0x00005612b3dc4d36 main (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0x995d36)
#12 0x00007f4792b70d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#13 0x00007f4792b70e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#14 0x00005612b3eb6525 _start (/home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/llc+0xa87525)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/lld-x86_64/llvm-project/llvm/test/CodeGen/AArch64/speculation-hardening-sls-blra.mir --implicit-check-not=__llvm_slsblr_thunk_aa_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_ab_x5_x8 --implicit-check-not=__llvm_slsblr_thunk_aaz_x5 --implicit-check-not=__llvm_slsblr_thunk_abz_x5

--

********************


aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
…#98062)

Make SLS Hardening pass handle BLRA* instructions the same way it
handles BLR. The thunk names have the form

    __llvm_slsblr_thunk_xN            for BLR thunks
    __llvm_slsblr_thunk_(aaz|abz)_xN  for BLRAAZ and BLRABZ thunks
    __llvm_slsblr_thunk_(aa|ab)_xN_xM for BLRAA and BLRAB thunks

Now there are about 1800 possible thunk names, so do not rely on linear
thunk function's name lookup and parse the name instead.

This patch reapplies llvm#97605.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants