[llvm] r263118 - ARM: correct __builtin_longjmp on WoA
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 07:11:10 PST 2016
Author: compnerd
Date: Thu Mar 10 09:11:09 2016
New Revision: 263118
URL: http://llvm.org/viewvc/llvm-project?rev=263118&view=rev
Log:
ARM: correct __builtin_longjmp on WoA
WoA uses r11 as the FP even though it is a pure thumb-2 environment in contrast
to AAPCS which states r7. This adjusts __builtin_longjmp to not clobber r7 and
to properly restore the frame pointer on execution.
Added:
llvm/trunk/test/CodeGen/ARM/Windows/builtin_longjmp.ll
Modified:
llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=263118&r1=263117&r2=263118&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Thu Mar 10 09:11:09 2016
@@ -1858,8 +1858,10 @@ void ARMAsmPrinter::EmitInstruction(cons
// ldr $scratch, [$src, #4]
// ldr r7, [$src]
// bx $scratch
+ const Triple &TT = TM.getTargetTriple();
unsigned SrcReg = MI->getOperand(0).getReg();
unsigned ScratchReg = MI->getOperand(1).getReg();
+
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
.addReg(ScratchReg)
.addReg(SrcReg)
@@ -1886,7 +1888,7 @@ void ARMAsmPrinter::EmitInstruction(cons
.addReg(0));
EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
- .addReg(ARM::R7)
+ .addReg(TT.isOSWindows() ? ARM::R11 : ARM::R7)
.addReg(SrcReg)
.addImm(0)
// Predicate.
Added: llvm/trunk/test/CodeGen/ARM/Windows/builtin_longjmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/builtin_longjmp.ll?rev=263118&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/builtin_longjmp.ll (added)
+++ llvm/trunk/test/CodeGen/ARM/Windows/builtin_longjmp.ll Thu Mar 10 09:11:09 2016
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple thumbv7--windows-itanium -filetype asm -o - %s | FileCheck %s
+
+declare void @llvm.eh.sjlj.longjmp(i8*)
+
+define arm_aapcs_vfpcc void @test___builtin_longjump(i8* %b) {
+entry:
+ tail call void @llvm.eh.sjlj.longjmp(i8* %b)
+ unreachable
+}
+
+; CHECK: ldr r[[SP:[0-9]+]], [r0, #8]
+; CHECK: mov sp, r[[SP]]
+; CHECK: ldr r[[PC:[0-9]+]], [r0, #4]
+; CHECK: ldr r11, [r0]
+; CHECK: bx r[[PC]]
+
More information about the llvm-commits
mailing list