diff options
| author | Derek Schuff <dschuff@google.com> | 2018-03-02 17:46:39 +0000 |
|---|---|---|
| committer | Derek Schuff <dschuff@google.com> | 2018-03-02 17:46:39 +0000 |
| commit | 57feeed3076137da48c43010130eddbb8e81cb54 (patch) | |
| tree | 964b051cb0612658345e22886c5c5e03680bf9d4 | |
| parent | 4925653555942acbafbb936ccf81cc6e5b384868 (diff) | |
| download | bcm5719-llvm-57feeed3076137da48c43010130eddbb8e81cb54.tar.gz bcm5719-llvm-57feeed3076137da48c43010130eddbb8e81cb54.zip | |
[X86][x32] Save callee-save register used as base pointer for x32 ABI
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
Differential Revision: https://reviews.llvm.org/D42358
Patch by Pratik Bhatu
llvm-svn: 326593
| -rw-r--r-- | llvm/lib/Target/X86/X86FrameLowering.cpp | 8 | ||||
| -rw-r--r-- | llvm/test/CodeGen/X86/x86-64-baseptr.ll | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp index 545248ac100..34febe679db 100644 --- a/llvm/lib/Target/X86/X86FrameLowering.cpp +++ b/llvm/lib/Target/X86/X86FrameLowering.cpp @@ -2108,8 +2108,12 @@ void X86FrameLowering::determineCalleeSaves(MachineFunction &MF, 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 diff --git a/llvm/test/CodeGen/X86/x86-64-baseptr.ll b/llvm/test/CodeGen/X86/x86-64-baseptr.ll index 2c31a7a5cbc..30855e60e1d 100644 --- a/llvm/test/CodeGen/X86/x86-64-baseptr.ll +++ b/llvm/test/CodeGen/X86/x86-64-baseptr.ll @@ -39,6 +39,7 @@ define void @base() #0 { ; 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 @@ -52,7 +53,8 @@ define void @base() #0 { ; X32ABI-NEXT: movl %edx, %esp ; X32ABI-NEXT: negl %eax ; X32ABI-NEXT: movl $0, (%ecx,%eax) -; X32ABI-NEXT: movl %ebp, %esp +; X32ABI-NEXT: leal -8(%ebp), %esp +; X32ABI-NEXT: popq %rbx ; X32ABI-NEXT: popq %rbp ; X32ABI-NEXT: retq entry: |

