llvm.org GIT mirror llvm / 689836b
Merging r352465: ------------------------------------------------------------------------ r352465 | mstorsjo | 2019-01-29 10:36:48 +0100 (Tue, 29 Jan 2019) | 17 lines [COFF, ARM64] Don't put jump table into a separate COFF section for EK_LabelDifference32 Windows ARM64 has PIC relocation model and uses jump table kind EK_LabelDifference32. This produces jump table entry as ".word LBB123 - LJTI1_2" which represents the distance between the block and jump table. A new relocation type (IMAGE_REL_ARM64_REL32) is needed to do the fixup correctly if they are in different COFF section. This change saves the jump table to the same COFF section as the associated code. An ideal fix could be utilizing IMAGE_REL_ARM64_REL32 relocation type. Patch by Tom Tan! Differential Revision: https://reviews.llvm.org/D57277 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_80@355311 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 months ago
3 changed file(s) with 61 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
470470 const std::vector &JT = MJTI->getJumpTables();
471471 if (JT.empty()) return;
472472
473 const Function &F = MF->getFunction();
473474 const TargetLoweringObjectFile &TLOF = getObjFileLowering();
474 MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(MF->getFunction(), TM);
475 OutStreamer->SwitchSection(ReadOnlySec);
475 bool JTInDiffSection =
476 !STI->isTargetCOFF() ||
477 !TLOF.shouldPutJumpTableInFunctionSection(
478 MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
479 F);
480 if (JTInDiffSection) {
481 // Drop it in the readonly section.
482 MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(F, TM);
483 OutStreamer->SwitchSection(ReadOnlySec);
484 }
476485
477486 auto AFI = MF->getInfo();
478487 for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
208208
209209 static Reloc::Model getEffectiveRelocModel(const Triple &TT,
210210 Optional RM) {
211 // AArch64 Darwin is always PIC.
212 if (TT.isOSDarwin())
211 // AArch64 Darwin and Windows are always PIC.
212 if (TT.isOSDarwin() || TT.isOSWindows())
213213 return Reloc::PIC_;
214214 // On ELF platforms the default static relocation model has a smart enough
215215 // linker to cope with referencing external symbols defined in a shared
0 ; RUN: llc -o - %s -mtriple=aarch64-windows -aarch64-enable-compress-jump-tables=0 | FileCheck %s
1
2 define void @f(i32 %x) {
3 entry:
4 switch i32 %x, label %sw.epilog [
5 i32 0, label %sw.bb
6 i32 1, label %sw.bb1
7 i32 2, label %sw.bb2
8 i32 3, label %sw.bb3
9 ]
10
11 sw.bb: ; preds = %entry
12 tail call void @g(i32 0) #2
13 br label %sw.epilog
14
15 sw.bb1: ; preds = %entry
16 tail call void @g(i32 1) #2
17 br label %sw.epilog
18
19 sw.bb2: ; preds = %entry
20 tail call void @g(i32 2) #2
21 br label %sw.epilog
22
23 sw.bb3: ; preds = %entry
24 tail call void @g(i32 3) #2
25 br label %sw.epilog
26
27 sw.epilog: ; preds = %entry, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb
28 tail call void @g(i32 10) #2
29 ret void
30 }
31
32 declare void @g(i32)
33
34 ; CHECK: .text
35 ; CHECK: f:
36 ; CHECK: .seh_proc f
37 ; CHECK: b g
38 ; CHECK-NEXT: .p2align 2
39 ; CHECK-NEXT: .LJTI0_0:
40 ; CHECK: .word .LBB0_2-.LJTI0_0
41 ; CHECK: .word .LBB0_3-.LJTI0_0
42 ; CHECK: .word .LBB0_4-.LJTI0_0
43 ; CHECK: .word .LBB0_5-.LJTI0_0
44 ; CHECK: .section .xdata,"dr"
45 ; CHECK: .seh_handlerdata
46 ; CHECK: .text
47 ; CHECK: .seh_endproc