[llvm] r346358 - [AArch64] [Windows] Trap after noreturn calls.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 7 13:31:15 PST 2018
Author: efriedma
Date: Wed Nov 7 13:31:14 2018
New Revision: 346358
URL: http://llvm.org/viewvc/llvm-project?rev=346358&view=rev
Log:
[AArch64] [Windows] Trap after noreturn calls.
Like the comment says, this isn't the most efficient fix in terms of
codesize, but it works.
Differential Revision: https://reviews.llvm.org/D54129
Added:
llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
Modified:
llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp?rev=346358&r1=346357&r2=346358&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp Wed Nov 7 13:31:14 2018
@@ -263,6 +263,16 @@ AArch64TargetMachine::AArch64TargetMachi
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);
Added: llvm/trunk/test/CodeGen/AArch64/windows-trap.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/windows-trap.ll?rev=346358&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/windows-trap.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/windows-trap.ll Wed Nov 7 13:31:14 2018
@@ -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
+}
More information about the llvm-commits
mailing list