[PATCH] D54129: [AArch64] [Windows] Trap after noreturn calls.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 7 13:33:40 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL346358: [AArch64] [Windows] Trap after noreturn calls. (authored by efriedma, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D54129?vs=172688&id=173017#toc
Repository:
rL LLVM
https://reviews.llvm.org/D54129
Files:
llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
Index: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -263,6 +263,16 @@
this->Options.NoTrapAfterNoreturn = true;
}
+ if (TT.isOSWindows()) {
+ // Unwinding can get confused if the last instruction in an
+ // exception-handling region (function, funclet, try block, etc.)
+ // is a call.
+ //
+ // FIXME: We could elide the trap if the next instruction would be in
+ // the same region anyway.
+ this->Options.TrapUnreachable = true;
+ }
+
// Enable GlobalISel at or below EnableGlobalISelAt0.
if (getOptLevel() <= EnableGlobalISelAtO)
setGlobalISel(true);
Index: llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
+++ llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple=aarch64-win32 %s -o - | FileCheck %s
+
+declare void @callee() noreturn
+
+; Make sure the call isn't the last instruction in the function; if it is,
+; unwinding may break.
+;
+; (The instruction after the call doesn't have to be anything in particular,
+; but trapping has the nice side-effect of catching bugs.)
+
+define void @test_unreachable() {
+; CHECK-LABEL: test_unreachable:
+; CHECK: bl callee
+; CHECK-NEXT: brk #0x1
+ call void @callee() noreturn
+ unreachable
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54129.173017.patch
Type: text/x-patch
Size: 1548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181107/ebbf1520/attachment.bin>
More information about the llvm-commits
mailing list