[PATCH] D79822: [AArch64] Emit CFI instruction for updating x18 when using ShadowCallStack with exception unwinding

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 14:21:40 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dc462b58909: [AArch64] Emit CFI instruction for updating x18 when using ShadowCallStack with… (authored by leonardchan).

Changed prior to commit:
  https://reviews.llvm.org/D79822?vs=263554&id=378360#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79822

Files:
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  llvm/test/CodeGen/AArch64/shadow-call-stack.ll


Index: llvm/test/CodeGen/AArch64/shadow-call-stack.ll
===================================================================
--- llvm/test/CodeGen/AArch64/shadow-call-stack.ll
+++ llvm/test/CodeGen/AArch64/shadow-call-stack.ll
@@ -58,3 +58,10 @@
   ret i32 %res
 }
 
+define i32 @f6() shadowcallstack nounwind uwtable {
+  ; CHECK: f6:
+  ; CHECK: .cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78
+  %res = call i32 @bar()
+  %res1 = add i32 %res, 1
+  ret i32 %res
+}
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -2494,22 +2494,20 @@
       BuildMI(MBB, MI, DL, TII.get(AArch64::SEH_Nop))
           .setMIFlag(MachineInstr::FrameSetup);
 
-    if (!MF.getFunction().hasFnAttribute(Attribute::NoUnwind)) {
-      // Emit a CFI instruction that causes 8 to be subtracted from the value of
-      // x18 when unwinding past this frame.
-      static const char CFIInst[] = {
-          dwarf::DW_CFA_val_expression,
-          18, // register
-          2,  // length
-          static_cast<char>(unsigned(dwarf::DW_OP_breg18)),
-          static_cast<char>(-8) & 0x7f, // addend (sleb128)
-      };
-      unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createEscape(
-          nullptr, StringRef(CFIInst, sizeof(CFIInst))));
-      BuildMI(MBB, MI, DL, TII.get(AArch64::CFI_INSTRUCTION))
-          .addCFIIndex(CFIIndex)
-          .setMIFlag(MachineInstr::FrameSetup);
-    }
+    // Emit a CFI instruction that causes 8 to be subtracted from the value of
+    // x18 when unwinding past this frame.
+    static const char CFIInst[] = {
+        dwarf::DW_CFA_val_expression,
+        18, // register
+        2,  // length
+        static_cast<char>(unsigned(dwarf::DW_OP_breg18)),
+        static_cast<char>(-8) & 0x7f, // addend (sleb128)
+    };
+    unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createEscape(
+        nullptr, StringRef(CFIInst, sizeof(CFIInst))));
+    BuildMI(MBB, MI, DL, TII.get(AArch64::CFI_INSTRUCTION))
+        .addCFIIndex(CFIIndex)
+        .setMIFlag(MachineInstr::FrameSetup);
 
     // This instruction also makes x18 live-in to the entry block.
     MBB.addLiveIn(AArch64::X18);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79822.378360.patch
Type: text/x-patch
Size: 2311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/1923634c/attachment.bin>


More information about the llvm-commits mailing list