|
| 1 | +# The change being tested here is that X86InstrInfo's getSPAdjust correctly handles POP/ADD instructions within |
| 2 | +# call sequences, as previously it assumed only PUSHes would be present for parameter passing. |
| 3 | +# What this test actually does is recreate a situation where: |
| 4 | +# - something other than a PUSH appears in a call sequence, and |
| 5 | +# - failing to recognize the SP adjustment by such an instruction actually changes something |
| 6 | +# observable. |
| 7 | +# |
| 8 | +# To this end, we create a situation where: |
| 9 | +# - the FP must be spilled around calls |
| 10 | +# - a frame object is stored before a call frame and loaded in the call frame |
| 11 | +# (emulating an argument restored from spill), following a call which POPs something |
| 12 | +# - call-frame pseudos can *not* be simplified early in prologepilog |
| 13 | +# |
| 14 | +# The issue being corrected is the case where prologepilog sees the SP adjustment of PUSHes only, and not |
| 15 | +# POP/ADD. This adjustment value can be carried over and incorrectly applied to frame offsets. So, |
| 16 | +# in the following we ensure that references to a frame object carry the same offset. |
| 17 | +# |
| 18 | +# NB: |
| 19 | +# FPClobberedByCall and hasPushSequence have to be supplied in the MFI section. The former |
| 20 | +# is required to force spill of the FP, and the latter ensures call-frame pseudos are not simplified. |
| 21 | +# |
| 22 | +# The csr_64_intel_ocl_bi_avx512 regmask is used to ensure that the FP is spilled. Other csr's may |
| 23 | +# acheive the same. |
| 24 | +# |
| 25 | +# RUN: llc -mtriple x86_64-unknown-linux-gnu -run-pass=prologepilog %s -o - | FileCheck %s |
| 26 | +--- |
| 27 | +name: f |
| 28 | +alignment: 16 |
| 29 | +exposesReturnsTwice: false |
| 30 | +legalized: false |
| 31 | +regBankSelected: false |
| 32 | +selected: false |
| 33 | +failedISel: false |
| 34 | +tracksRegLiveness: true |
| 35 | +hasWinCFI: false |
| 36 | +callsEHReturn: false |
| 37 | +callsUnwindInit: false |
| 38 | +hasEHCatchret: false |
| 39 | +hasEHScopes: false |
| 40 | +hasEHFunclets: false |
| 41 | +isOutlined: false |
| 42 | +debugInstrRef: true |
| 43 | +failsVerification: false |
| 44 | +tracksDebugUserValues: true |
| 45 | +registers: [] |
| 46 | +liveins: |
| 47 | + - { reg: '$rdi', virtual-reg: '' } |
| 48 | + - { reg: '$rsi', virtual-reg: '' } |
| 49 | +frameInfo: |
| 50 | + isFrameAddressTaken: false |
| 51 | + isReturnAddressTaken: false |
| 52 | + hasStackMap: false |
| 53 | + hasPatchPoint: false |
| 54 | + stackSize: 0 |
| 55 | + offsetAdjustment: 0 |
| 56 | + maxAlignment: 64 |
| 57 | + adjustsStack: true |
| 58 | + hasCalls: true |
| 59 | + stackProtector: '' |
| 60 | + functionContext: '' |
| 61 | + maxCallFrameSize: 4294967295 |
| 62 | + cvBytesOfCalleeSavedRegisters: 0 |
| 63 | + hasOpaqueSPAdjustment: false |
| 64 | + hasVAStart: false |
| 65 | + hasMustTailInVarArgFunc: false |
| 66 | + hasTailCall: false |
| 67 | + isCalleeSavedInfoValid: false |
| 68 | + localFrameSize: 0 |
| 69 | + savePoint: '' |
| 70 | + restorePoint: '' |
| 71 | +fixedStack: [] |
| 72 | +stack: |
| 73 | + - { id: 0, name: '', type: spill-slot, offset: 0, size: 64, |
| 74 | + alignment: 32, stack-id: default, callee-saved-register: '', callee-saved-restored: true, |
| 75 | + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| 76 | +machineFunctionInfo: |
| 77 | + FPClobberedByCall: true |
| 78 | + hasPushSequences: true |
| 79 | +body: | |
| 80 | + bb.0: |
| 81 | + liveins: $rdi, $rsi |
| 82 | + MOV64mr %stack.0, 1, $noreg, 0, $noreg, renamable $rdi :: (store (s64) into %stack.0) |
| 83 | + ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp |
| 84 | + CALL64r renamable undef $rsi, csr_64_intel_ocl_bi_avx512, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp |
| 85 | + ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp |
| 86 | + ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp |
| 87 | + $rax = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load (s64) from %stack.0) |
| 88 | + $rdi = COPY renamable $rax |
| 89 | + CALL64r renamable undef $rsi, csr_64_intel_ocl_bi_avx512, implicit $rsp, implicit $ssp, implicit-def $rsp, implicit-def $ssp |
| 90 | + ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp |
| 91 | +... |
| 92 | +# ensure the store and load to the frame object have matching offsets after resolution. |
| 93 | +# CHECK: MOV64mr $rsp, 1, $noreg, [[DISP:[1-9][0-9]+]] |
| 94 | +# CHECK: MOV64rm $rsp, 1, $noreg, [[DISP]] |
0 commit comments