[llvm] r263139 - [X86] Correctly select registers to pop into for x86_64

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 08:23:20 PDT 2016


Tom: we should merge this to 3.8.1.
Nadav: owner's approval?

On Thu, Mar 10, 2016 at 10:43 AM, Michael Kuperstein via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: mkuper
> Date: Thu Mar 10 12:43:21 2016
> New Revision: 263139
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263139&view=rev
> Log:
> [X86] Correctly select registers to pop into for x86_64
>
> When trying to replace an add to esp with pops, we need to choose dead
> registers to pop into. Registers clobbered by the call and not imp-def'd
> by it should be safe. Except that it's not enough to check the register
> itself isn't defined, we also need to make sure no overlapping registers
> are defined either.
>
> This fixes PR26711.
>
> Differential Revision: http://reviews.llvm.org/D18029
>
> Modified:
>     llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
>     llvm/trunk/test/CodeGen/X86/pop-stack-cleanup.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=263139&r1=263138&r2=263139&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Thu Mar 10 12:43:21 2016
> @@ -2447,7 +2447,8 @@ bool X86FrameLowering::adjustStackWithPo
>
>      bool IsDef = false;
>      for (const MachineOperand &MO : Prev->implicit_operands()) {
> -      if (MO.isReg() && MO.isDef() && MO.getReg() == Candidate) {
> +      if (MO.isReg() && MO.isDef() &&
> +          TRI->isSuperOrSubRegisterEq(MO.getReg(), Candidate)) {
>          IsDef = true;
>          break;
>        }
>
> Modified: llvm/trunk/test/CodeGen/X86/pop-stack-cleanup.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pop-stack-cleanup.ll?rev=263139&r1=263138&r2=263139&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/pop-stack-cleanup.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/pop-stack-cleanup.ll Thu Mar 10 12:43:21 2016
> @@ -7,6 +7,7 @@ declare i64 @param2_ret64(i32 %a, i32 %b
>  declare void @param2(i32 %a, i32 %b)
>  declare void @param3(i32 %a, i32 %b, i32 %c)
>  declare void @param8(i64, i64, i64, i64, i64, i64, i64, i64)
> +declare i32 @param8_ret(i64, i64, i64, i64, i64, i64, i64, i64)
>
>
>  define void @test() minsize nounwind {
> @@ -74,3 +75,13 @@ define void @test_linux64(i32 %size) min
>    call void @param8(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8)
>    ret void
>  }
> +
> +define i32 @test_linux64_i32(i32 %size) minsize nounwind {
> +; LINUX64-LABEL: test_linux64_i32:
> +; LINUX64: callq param8_ret
> +; LINUX64-NOT: popq %rax
> +; LINUX64: retq
> +  %a = alloca i64, i32 %size, align 8
> +  %r = call i32 @param8_ret(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8)
> +  ret i32 %r
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list