llvm.org GIT mirror llvm / 322a7bb
Merging r368164: ------------------------------------------------------------------------ r368164 | s.desmalen | 2019-08-07 14:41:38 +0200 (Wed, 07 Aug 2019) | 13 lines [AArch64][WinCFI] Do not pair callee-save instructions in LoadStoreOptimizer Prevent the LoadStoreOptimizer from pairing any load/store instructions with instructions from the prologue/epilogue if the CFI information has encoded the operations as separate instructions. This would otherwise lead to a mismatch of the actual prologue size from the size as recorded in the Windows CFI. Reviewers: efriedma, mstorsjo, ssijaric Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D65817 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@370438 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 2 months ago
4 changed file(s) with 26 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3131 #include "llvm/CodeGen/TargetSubtargetInfo.h"
3232 #include "llvm/IR/DebugLoc.h"
3333 #include "llvm/IR/GlobalValue.h"
34 #include "llvm/MC/MCAsmInfo.h"
3435 #include "llvm/MC/MCInst.h"
3536 #include "llvm/MC/MCInstrDesc.h"
3637 #include "llvm/Support/Casting.h"
19251926 // Check if this load/store has a hint to avoid pair formation.
19261927 // MachineMemOperands hints are set by the AArch64StorePairSuppress pass.
19271928 if (isLdStPairSuppressed(MI))
1929 return false;
1930
1931 // Do not pair any callee-save store/reload instructions in the
1932 // prologue/epilogue if the CFI information encoded the operations as separate
1933 // instructions, as that will cause the size of the actual prologue to mismatch
1934 // with the prologue size recorded in the Windows CFI.
1935 const MCAsmInfo *MAI = MI.getMF()->getTarget().getMCAsmInfo();
1936 bool NeedsWinCFI = MAI->usesWindowsCFI() &&
1937 MI.getMF()->getFunction().needsUnwindTableEntry();
1938 if (NeedsWinCFI && (MI.getFlag(MachineInstr::FrameSetup) ||
1939 MI.getFlag(MachineInstr::FrameDestroy)))
19281940 return false;
19291941
19301942 // On some CPUs quad load/store pairs are slower than two single load/stores.
0 # RUN: llc -o - %s -mtriple=aarch64-windows -start-after=prologepilog -filetype=obj \
11 # RUN: | llvm-readobj --unwind | FileCheck %s
2 # RUN: llc -o - %s -mtriple=aarch64-windows -run-pass=aarch64-ldst-opt \
3 # RUN: | FileCheck %s --check-prefix=CHECK-LDSTOPT
24 # This test case checks the basic validity of the .xdata section. It's
35 # documented at:
46 # https://docs.microsoft.com/en-us/cpp/build/arm64-exception-handling
68 # We expect to see the following in the .xdata section:
79
810 # CHECK: ExceptionData {
9 # CHECK-NEXT: FunctionLength: 92
11 # CHECK-NEXT: FunctionLength: 96
1012 # CHECK-NEXT: Version: 0
1113 # CHECK-NEXT: ExceptionData: No
1214 # CHECK-NEXT: EpiloguePacked: No
2325 # CHECK-NEXT: ]
2426 # CHECK-NEXT: EpilogueScopes [
2527 # CHECK-NEXT: EpilogueScope {
26 # CHECK-NEXT: StartOffset: 15
28 # CHECK-NEXT: StartOffset: 16
2729 # CHECK-NEXT: EpilogueStartIndex: 13
2830 # CHECK-NEXT: Opcodes [
2931 # CHECK-NEXT: 0xc808 ; ldp x19, x20, [sp, #64]
3840 # CHECK-NEXT: }
3941 # CHECK-NEXT: ]
4042 # CHECK-NEXT: }
43
44 # Check that the load-store optimizer does not merge the two
45 # callee-saved stores in the prologue.
46 # CHECK-LDSTOPT: name: test
47 # CHECK-LDSTOPT: frame-setup STRXui killed $x21, $sp, 6
48 # CHECK-LDSTOPT: frame-setup STRXui killed $x22, $sp, 7
4149 ...
4250 ---
4351 name: test
22 # Test that the pre/post increment save of a flating point register is correct.
33
44 # CHECK: ExceptionData {
5 # CHECK-NEXT: FunctionLength: 136
5 # CHECK-NEXT: FunctionLength: 144
66 # CHECK-NEXT: Version: 0
77 # CHECK-NEXT: ExceptionData: No
88 # CHECK-NEXT: EpiloguePacked: No
2222 # CHECK-NEXT: ]
2323 # CHECK-NEXT: EpilogueScopes [
2424 # CHECK-NEXT: EpilogueScope {
25 # CHECK-NEXT: StartOffset: 25
25 # CHECK-NEXT: StartOffset: 26
2626 # CHECK-NEXT: EpilogueStartIndex: 19
2727 # CHECK-NEXT: Opcodes [
2828 # CHECK-NEXT: 0xc80e ; ldp x19, x20, [sp, #112]
2727 ; OBJ: OffsetInParent: 0
2828 ; OBJ: BasePointerOffset: 12
2929 ; OBJ: LocalVariableAddrRange {
30 ; OBJ: OffsetStart: .text+0x10
30 ; OBJ: OffsetStart: .text+0x14
3131 ; OBJ: ISectStart: 0x0
32 ; OBJ: Range: 0x2C
32 ; OBJ: Range: 0x30
3333 ; OBJ: }
3434 ; OBJ: }
3535