[PATCH] D42358: [X86][x32] Save callee-save register used as base pointer for x32 ABI
Pratik Bhatu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 21 20:46:12 PST 2018
pbhatu created this revision.
pbhatu added reviewers: craig.topper, pavel.v.chupin, dschuff.
Herald added a subscriber: llvm-commits.
For the x32 ABI, since the base pointer register (EBX) is a callee save register
it should be saved before use.
This fixes https://bugs.llvm.org/show_bug.cgi?id=36011
Repository:
rL LLVM
https://reviews.llvm.org/D42358
Files:
lib/Target/X86/X86FrameLowering.cpp
test/CodeGen/X86/x86-64-baseptr.ll
Index: test/CodeGen/X86/x86-64-baseptr.ll
===================================================================
--- test/CodeGen/X86/x86-64-baseptr.ll
+++ test/CodeGen/X86/x86-64-baseptr.ll
@@ -39,6 +39,7 @@
; X32ABI: # %bb.0: # %entry
; X32ABI-NEXT: pushq %rbp
; X32ABI-NEXT: movl %esp, %ebp
+; X32ABI-NEXT: pushq %rbx
; X32ABI-NEXT: andl $-32, %esp
; X32ABI-NEXT: subl $32, %esp
; X32ABI-NEXT: movl %esp, %ebx
Index: lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- lib/Target/X86/X86FrameLowering.cpp
+++ lib/Target/X86/X86FrameLowering.cpp
@@ -2087,8 +2087,12 @@
TargetFrameLowering::determineCalleeSaves(MF, SavedRegs, RS);
// Spill the BasePtr if it's used.
- if (TRI->hasBasePointer(MF))
- SavedRegs.set(TRI->getBaseRegister());
+ if (TRI->hasBasePointer(MF)){
+ unsigned BasePtr = TRI->getBaseRegister();
+ if (STI.isTarget64BitILP32())
+ BasePtr = getX86SubSuperRegister(BasePtr, 64);
+ SavedRegs.set(BasePtr);
+ }
}
static bool
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42358.130827.patch
Type: text/x-patch
Size: 1058 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180122/3fdb5bc9/attachment.bin>
More information about the llvm-commits
mailing list