[PATCH] D57753: [AArch64][Outliner] Don't outline BTI instructions

Oliver Stannard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 5 09:21:58 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL353190: [AArch64][Outliner] Don't outline BTI instructions (authored by olista01, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57753?vs=185308&id=185329#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57753/new/

https://reviews.llvm.org/D57753

Files:
  llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/trunk/test/CodeGen/AArch64/machine-outliner-outline-bti.ll


Index: llvm/trunk/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
+++ llvm/trunk/test/CodeGen/AArch64/machine-outliner-outline-bti.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple aarch64--none-eabi < %s | FileCheck %s
+
+; The BTI instruction cannot be outlined, because it needs to be the very first
+; instruction executed after an indirect call.
+
+ at g = hidden global i32 0, align 4
+
+define hidden void @foo() minsize "branch-target-enforcement" {
+entry:
+; CHECK: hint #34
+; CHECK: b       OUTLINED_FUNCTION_0
+  store volatile i32 1, i32* @g, align 4
+  ret void
+}
+
+define hidden void @bar() minsize "branch-target-enforcement" {
+entry:
+; CHECK: hint #34
+; CHECK: b       OUTLINED_FUNCTION_0
+  store volatile i32 1, i32* @g, align 4
+  ret void
+}
Index: llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5330,6 +5330,14 @@
       MI.modifiesRegister(AArch64::W30, &getRegisterInfo()))
     return outliner::InstrType::Illegal;
 
+  // Don't outline BTI instructions, because that will prevent the outlining
+  // site from being indirectly callable.
+  if (MI.getOpcode() == AArch64::HINT) {
+    int64_t Imm = MI.getOperand(0).getImm();
+    if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
+      return outliner::InstrType::Illegal;
+  }
+
   return outliner::InstrType::Legal;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57753.185329.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190205/59ac3c89/attachment.bin>


More information about the llvm-commits mailing list