mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
f191e5a702
This behavior was added in r130928 for both FastISel and SD, and then disabled in r131156 for FastISel. This re-enables it for FastISel with the corresponding fix. This is triggered only when FastISel can't lower the arguments and falls back to SelectionDAG for it. FastISel contains a map of "register fixups" where at the end of the selection phase it replaces all uses of a register with another register that FastISel sometimes pre-assigned. Code at the end of SelectionDAGISel::runOnMachineFunction is doing the replacement at the very end of the function, while other pieces that come in before that look through the MachineFunction and assume everything is done. In this case, the real issue is that the code emitting COPY instructions for the liveins (physreg to vreg) (EmitLiveInCopies) is checking if the vreg assigned to the physreg is used, and if it's not, it will skip the COPY. If a register wasn't replaced with its assigned fixup yet, the copy will be skipped and we'll end up with uses of undefined registers. This fix moves the replacement of registers before the emission of copies for the live-ins. The initial motivation for this fix is to enable tail calls for swiftself functions, which were blocked because we couldn't prove that the swiftself argument (which is callee-save) comes from a function argument (live-in), because there was an extra copy (vreg to vreg). A few tests are affected by this: * llvm/test/CodeGen/AArch64/swifterror.ll: we used to spill x21 (callee-save) but never reload it because it's attached to the return. We now don't even spill it anymore. * llvm/test/CodeGen/*/swiftself.ll: we tail-call now. * llvm/test/CodeGen/AMDGPU/mubuf-legalize-operands.ll: I believe this test was not really testing the right thing, but it worked because the same registers were re-used. * llvm/test/CodeGen/ARM/cmpxchg-O0.ll: regalloc changes * llvm/test/CodeGen/ARM/swifterror.ll: get rid of a copy * llvm/test/CodeGen/Mips/*: get rid of spills and copies * llvm/test/CodeGen/SystemZ/swift-return.ll: smaller stack * llvm/test/CodeGen/X86/atomic-unordered.ll: smaller stack * llvm/test/CodeGen/X86/swifterror.ll: same as AArch64 * llvm/test/DebugInfo/X86/dbg-declare-arg.ll: stack size changed Differential Revision: https://reviews.llvm.org/D62361 llvm-svn: 362963
122 lines
4.4 KiB
LLVM
122 lines
4.4 KiB
LLVM
; RUN: llc -verify-machineinstrs -mtriple=armv7-linux-gnu -O0 %s -o - | FileCheck %s
|
|
; RUN: llc -verify-machineinstrs -mtriple=thumbv8-linux-gnu -O0 %s -o - | FileCheck %s
|
|
; RUN: llc -verify-machineinstrs -mtriple=thumbv6m-none-eabi -O0 %s -o - | FileCheck %s --check-prefix=CHECK-T1
|
|
|
|
; CHECK-T1-NOT: ldrex
|
|
; CHECK-T1-NOT: strex
|
|
|
|
define { i8, i1 } @test_cmpxchg_8(i8* %addr, i8 %desired, i8 %new) nounwind {
|
|
; CHECK-LABEL: test_cmpxchg_8:
|
|
; CHECK: dmb ish
|
|
; CHECK: uxtb [[DESIRED:r[0-9]+]], [[DESIRED]]
|
|
; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
|
|
; CHECK: ldrexb [[OLD:[lr0-9]+]], [r0]
|
|
; CHECK: cmp [[OLD]], [[DESIRED]]
|
|
; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
|
|
; CHECK: strexb [[STATUS:r[0-9]+]], r2, [r0]
|
|
; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
|
|
; CHECK: bne [[RETRY]]
|
|
; CHECK: [[DONE]]:
|
|
; Materialisation of a boolean is done with sub/clz/lsr
|
|
; CHECK: uxtb [[CMP1:r[0-9]+]], [[DESIRED]]
|
|
; CHECK: sub{{(\.w)?}} [[CMP1]], [[OLD]], [[CMP1]]
|
|
; CHECK: clz [[CMP2:r[0-9]+]], [[CMP1]]
|
|
; CHECK: lsr{{(s)?}} {{r[0-9]+}}, [[CMP2]], #5
|
|
; CHECK: dmb ish
|
|
%res = cmpxchg i8* %addr, i8 %desired, i8 %new seq_cst monotonic
|
|
ret { i8, i1 } %res
|
|
}
|
|
|
|
define { i16, i1 } @test_cmpxchg_16(i16* %addr, i16 %desired, i16 %new) nounwind {
|
|
; CHECK-LABEL: test_cmpxchg_16:
|
|
; CHECK: dmb ish
|
|
; CHECK: uxth [[DESIRED:r[0-9]+]], [[DESIRED]]
|
|
; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
|
|
; CHECK: ldrexh [[OLD:[lr0-9]+]], [r0]
|
|
; CHECK: cmp [[OLD]], [[DESIRED]]
|
|
; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
|
|
; CHECK: strexh [[STATUS:r[0-9]+]], r2, [r0]
|
|
; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
|
|
; CHECK: bne [[RETRY]]
|
|
; CHECK: [[DONE]]:
|
|
; Materialisation of a boolean is done with sub/clz/lsr
|
|
; CHECK: uxth [[CMP1:r[0-9]+]], [[DESIRED]]
|
|
; CHECK: sub{{(\.w)?}} [[CMP1]], [[OLD]], [[CMP1]]
|
|
; CHECK: clz [[CMP2:r[0-9]+]], [[CMP1]]
|
|
; CHECK: lsr{{(s)?}} {{r[0-9]+}}, [[CMP2]], #5
|
|
; CHECK: dmb ish
|
|
%res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst monotonic
|
|
ret { i16, i1 } %res
|
|
}
|
|
|
|
define { i32, i1 } @test_cmpxchg_32(i32* %addr, i32 %desired, i32 %new) nounwind {
|
|
; CHECK-LABEL: test_cmpxchg_32:
|
|
; CHECK: dmb ish
|
|
; CHECK-NOT: uxt
|
|
; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
|
|
; CHECK: ldrex [[OLD:r[0-9]+]], [r0]
|
|
; CHECK: cmp [[OLD]], [[DESIRED]]
|
|
; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
|
|
; CHECK: strex [[STATUS:r[0-9]+]], r2, [r0]
|
|
; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
|
|
; CHECK: bne [[RETRY]]
|
|
; CHECK: [[DONE]]:
|
|
; Materialisation of a boolean is done with sub/clz/lsr
|
|
; CHECK: sub{{(s)?}} [[CMP1:r[0-9]+]], [[OLD]], [[DESIRED]]
|
|
; CHECK: clz [[CMP2:r[0-9]+]], [[CMP1]]
|
|
; CHECK: lsr{{(s)?}} {{r[0-9]+}}, [[CMP2]], #5
|
|
; CHECK: dmb ish
|
|
%res = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst monotonic
|
|
ret { i32, i1 } %res
|
|
}
|
|
|
|
define { i64, i1 } @test_cmpxchg_64(i64* %addr, i64 %desired, i64 %new) nounwind {
|
|
; CHECK-LABEL: test_cmpxchg_64:
|
|
; CHECK: dmb ish
|
|
; CHECK-NOT: uxt
|
|
; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
|
|
; CHECK: ldrexd [[OLDLO:r[0-9]+]], [[OLDHI:r[0-9]+]], [r0]
|
|
; CHECK: cmp [[OLDLO]], r6
|
|
; CHECK: cmpeq [[OLDHI]], r7
|
|
; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
|
|
; CHECK: strexd [[STATUS:[lr0-9]+]], r4, r5, [r0]
|
|
; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
|
|
; CHECK: bne [[RETRY]]
|
|
; CHECK: [[DONE]]:
|
|
; CHECK: dmb ish
|
|
%res = cmpxchg i64* %addr, i64 %desired, i64 %new seq_cst monotonic
|
|
ret { i64, i1 } %res
|
|
}
|
|
|
|
define { i64, i1 } @test_nontrivial_args(i64* %addr, i64 %desired, i64 %new) {
|
|
; CHECK-LABEL: test_nontrivial_args:
|
|
; CHECK: dmb ish
|
|
; CHECK-NOT: uxt
|
|
; CHECK: [[RETRY:.LBB[0-9]+_[0-9]+]]:
|
|
; CHECK: ldrexd [[OLDLO:r[0-9]+]], [[OLDHI:r[0-9]+]], [r0]
|
|
; CHECK: cmp [[OLDLO]], {{r[0-9]+}}
|
|
; CHECK: cmpeq [[OLDHI]], {{r[0-9]+}}
|
|
; CHECK: bne [[DONE:.LBB[0-9]+_[0-9]+]]
|
|
; CHECK: strexd [[STATUS:r[0-9]+]], {{r[0-9]+}}, {{r[0-9]+}}, [r0]
|
|
; CHECK: cmp{{(\.w)?}} [[STATUS]], #0
|
|
; CHECK: bne [[RETRY]]
|
|
; CHECK: [[DONE]]:
|
|
; CHECK: dmb ish
|
|
|
|
%desired1 = add i64 %desired, 1
|
|
%new1 = add i64 %new, 1
|
|
%res = cmpxchg i64* %addr, i64 %desired1, i64 %new1 seq_cst seq_cst
|
|
ret { i64, i1 } %res
|
|
}
|
|
|
|
; The following used to trigger an assertion when creating a spill on thumb2
|
|
; for a physreg with RC==GPRPairRegClass.
|
|
; CHECK-LABEL: test_cmpxchg_spillbug:
|
|
; CHECK: ldrexd
|
|
; CHECK: strexd
|
|
; CHECK: bne
|
|
define void @test_cmpxchg_spillbug() {
|
|
%v = cmpxchg i64* undef, i64 undef, i64 undef seq_cst seq_cst
|
|
ret void
|
|
}
|