diff --git a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp --- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp +++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp @@ -1,4 +1,3 @@ -// UNSUPPORTED: powerpc64 // Tests that __asan_handle_no_return properly unpoisons the signal alternate // stack. diff --git a/compiler-rt/test/asan/TestCases/longjmp.cpp b/compiler-rt/test/asan/TestCases/longjmp.cpp --- a/compiler-rt/test/asan/TestCases/longjmp.cpp +++ b/compiler-rt/test/asan/TestCases/longjmp.cpp @@ -1,4 +1,3 @@ -// UNSUPPORTED: powerpc64 // RUN: %clangxx_asan -O %s -o %t && %run %t #include diff --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp --- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp @@ -1644,11 +1644,18 @@ // offset by the STDU/STDUX/STWU/STWUX instruction. For targets with red // zone add this offset back now. + // If the function has a base pointer, the stack pointer has been copied + // to it so we can restore it by copying in the other direction. + if (HasRedZone && HasBP) { + BuildMI(MBB, MBBI, dl, OrInst, RBReg). + addReg(BPReg). + addReg(BPReg); + } // If this function contained a fastcc call and GuaranteedTailCallOpt is // enabled (=> hasFastCall()==true) the fastcc call might contain a tail // call which invalidates the stack pointer value in SP(0). So we use the // value of R31 in this case. Similar situation exists with setjmp. - if (FI->hasFastCall() || MF.exposesReturnsTwice()) { + else if (FI->hasFastCall() || MF.exposesReturnsTwice()) { assert(HasFP && "Expecting a valid frame pointer."); if (!HasRedZone) RBReg = FPReg; diff --git a/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll b/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll --- a/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll +++ b/llvm/test/CodeGen/PowerPC/aix-base-pointer.ll @@ -27,7 +27,7 @@ ; 32BIT: stwux 1, 1, 0 ; 32BIT: addi 3, 1, 64 ; 32BIT: bl .callee -; 32BIT: lwz 1, 0(1) +; 32BIT: mr 1, 30 ; 32BIT: lwz 30, -16(1) ; 64BIT-LABEL: .caller: @@ -38,5 +38,5 @@ ; 64BIT: stdux 1, 1, 0 ; 64BIT: addi 3, 1, 128 ; 64BIT: bl .callee -; 64BIT: ld 1, 0(1) +; 64BIT: mr 1, 30 ; 64BIT: ld 30, -24(1) diff --git a/llvm/test/CodeGen/PowerPC/pr46759.ll b/llvm/test/CodeGen/PowerPC/pr46759.ll --- a/llvm/test/CodeGen/PowerPC/pr46759.ll +++ b/llvm/test/CodeGen/PowerPC/pr46759.ll @@ -61,7 +61,7 @@ ; CHECK-LE-NEXT: .LBB0_6: # %entry ; CHECK-LE-NEXT: addi r3, r1, 2048 ; CHECK-LE-NEXT: lbz r3, 0(r3) -; CHECK-LE-NEXT: ld r1, 0(r1) +; CHECK-LE-NEXT: mr r1, r30 ; CHECK-LE-NEXT: ld r31, -8(r1) ; CHECK-LE-NEXT: ld r30, -16(r1) ; CHECK-LE-NEXT: blr diff --git a/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll b/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll --- a/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll +++ b/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll @@ -544,7 +544,7 @@ ; CHECK-LE-NEXT: li r5, 1 ; CHECK-LE-NEXT: stwx r5, r4, r3 ; CHECK-LE-NEXT: lwz r3, 64(r1) -; CHECK-LE-NEXT: ld r1, 0(r1) +; CHECK-LE-NEXT: mr r1, r30 ; CHECK-LE-NEXT: ld r30, -16(r1) ; CHECK-LE-NEXT: blr ; @@ -562,7 +562,7 @@ ; CHECK-BE-NEXT: sldi r3, r3, 2 ; CHECK-BE-NEXT: stwx r5, r4, r3 ; CHECK-BE-NEXT: lwz r3, 64(r1) -; CHECK-BE-NEXT: ld r1, 0(r1) +; CHECK-BE-NEXT: mr r1, r30 ; CHECK-BE-NEXT: ld r30, -16(r1) ; CHECK-BE-NEXT: blr ; @@ -631,7 +631,7 @@ ; CHECK-LE-NEXT: li r5, 1 ; CHECK-LE-NEXT: stwx r5, r4, r3 ; CHECK-LE-NEXT: lwz r3, 2048(r1) -; CHECK-LE-NEXT: ld r1, 0(r1) +; CHECK-LE-NEXT: mr r1, r30 ; CHECK-LE-NEXT: ld r30, -16(r1) ; CHECK-LE-NEXT: blr ; @@ -669,7 +669,7 @@ ; CHECK-BE-NEXT: sldi r3, r3, 2 ; CHECK-BE-NEXT: stwx r5, r4, r3 ; CHECK-BE-NEXT: lwz r3, 2048(r1) -; CHECK-BE-NEXT: ld r1, 0(r1) +; CHECK-BE-NEXT: mr r1, r30 ; CHECK-BE-NEXT: ld r30, -16(r1) ; CHECK-BE-NEXT: blr ; @@ -743,7 +743,7 @@ ; CHECK-LE-NEXT: li r5, 1 ; CHECK-LE-NEXT: stwx r5, r4, r3 ; CHECK-LE-NEXT: lwz r3, 1024(r1) -; CHECK-LE-NEXT: ld r1, 0(r1) +; CHECK-LE-NEXT: mr r1, r30 ; CHECK-LE-NEXT: ld r30, -16(r1) ; CHECK-LE-NEXT: blr ; @@ -780,7 +780,7 @@ ; CHECK-BE-NEXT: sldi r3, r3, 2 ; CHECK-BE-NEXT: stwx r5, r4, r3 ; CHECK-BE-NEXT: lwz r3, 1024(r1) -; CHECK-BE-NEXT: ld r1, 0(r1) +; CHECK-BE-NEXT: mr r1, r30 ; CHECK-BE-NEXT: ld r30, -16(r1) ; CHECK-BE-NEXT: blr ; @@ -884,7 +884,7 @@ ; CHECK-LE-NEXT: .LBB11_8: ; CHECK-LE-NEXT: addi r3, r1, -32768 ; CHECK-LE-NEXT: lbz r3, 0(r3) -; CHECK-LE-NEXT: ld r1, 0(r1) +; CHECK-LE-NEXT: mr r1, r30 ; CHECK-LE-NEXT: ld r31, -8(r1) ; CHECK-LE-NEXT: ld r30, -16(r1) ; CHECK-LE-NEXT: blr @@ -954,7 +954,7 @@ ; CHECK-BE-NEXT: .LBB11_8: ; CHECK-BE-NEXT: addi r3, r1, -32768 ; CHECK-BE-NEXT: lbz r3, 0(r3) -; CHECK-BE-NEXT: ld r1, 0(r1) +; CHECK-BE-NEXT: mr r1, r30 ; CHECK-BE-NEXT: ld r31, -8(r1) ; CHECK-BE-NEXT: ld r30, -16(r1) ; CHECK-BE-NEXT: blr diff --git a/llvm/test/CodeGen/PowerPC/stack-realign.ll b/llvm/test/CodeGen/PowerPC/stack-realign.ll --- a/llvm/test/CodeGen/PowerPC/stack-realign.ll +++ b/llvm/test/CodeGen/PowerPC/stack-realign.ll @@ -43,7 +43,7 @@ ; CHECK: std 3, 48(30) -; CHECK: ld 1, 0(1) +; CHECK: mr 1, 30 ; CHECK-DAG: ld [[SR:[0-9]+]], 16(1) ; CHECK-DAG: ld 30, -16(1) ; CHECK-DAG: mtlr [[SR]] @@ -69,7 +69,7 @@ ; CHECK-FP: std 3, 48(30) -; CHECK-FP: ld 1, 0(1) +; CHECK-FP: mr 1, 30 ; CHECK-FP-DAG: ld [[SR:[0-9]+]], 16(1) ; CHECK-FP-DAG: ld 31, -8(1) ; CHECK-FP-DAG: ld 30, -16(1)