llvm.org GIT mirror llvm / 89bdc4d
Merging r198744: ------------------------------------------------------------------------ r198744 | iain | 2014-01-08 05:22:54 -0500 (Wed, 08 Jan 2014) | 8 lines [patch] Adjust behavior of FDE cross-section relocs for targets that don't support abs-differences. Modern versions of OSX/Darwin's ld (ld64 > 97.17) have an optimisation present that allows the back end to omit relocations (and replace them with an absolute difference) for FDE some text section refs. This patch allows a backend to opt-in to this behaviour by setting "DwarfFDESymbolsUseAbsDiff". At present, this is only enabled for modern x86 OSX ports. test changes by David Fang. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@205768 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 6 years ago
5 changed file(s) with 70 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
301301 /// uses relocations for references to other .debug_* sections.
302302 bool DwarfUsesRelocationsAcrossSections;
303303
304 /// DwarfFDESymbolsUseAbsDiff - true if DWARF FDE symbol reference
305 /// relocations should be replaced by an absolute difference.
306 bool DwarfFDESymbolsUseAbsDiff;
307
304308 /// DwarfRegNumForCFI - True if dwarf register numbers are printed
305309 /// instead of symbolic register names in .cfi_* directives.
306310 bool DwarfRegNumForCFI; // Defaults to false;
526530 bool doesDwarfUseRelocationsAcrossSections() const {
527531 return DwarfUsesRelocationsAcrossSections;
528532 }
533 bool doDwarfFDESymbolsUseAbsDiff() const {
534 return DwarfFDESymbolsUseAbsDiff;
535 }
529536 bool useDwarfRegNumForCFI() const {
530537 return DwarfRegNumForCFI;
531538 }
8484 SupportsDebugInformation = false;
8585 ExceptionsType = ExceptionHandling::None;
8686 DwarfUsesRelocationsAcrossSections = true;
87 DwarfFDESymbolsUseAbsDiff = false;
8788 DwarfRegNumForCFI = false;
8889 HasMicrosoftFastStdCallMangling = false;
8990 NeedsDwarfSectionOffsetDirective = false;
835835 }
836836 }
837837
838 static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
839 unsigned symbolEncoding, const char *comment = 0) {
838 static void EmitFDESymbol(MCStreamer &streamer, const MCSymbol &symbol,
839 unsigned symbolEncoding, bool isEH,
840 const char *comment = 0) {
840841 MCContext &context = streamer.getContext();
841842 const MCAsmInfo *asmInfo = context.getAsmInfo();
842843 const MCExpr *v = asmInfo->getExprForFDESymbol(&symbol,
844845 streamer);
845846 unsigned size = getSizeForEncoding(streamer, symbolEncoding);
846847 if (streamer.isVerboseAsm() && comment) streamer.AddComment(comment);
847 streamer.EmitAbsValue(v, size);
848 if (asmInfo->doDwarfFDESymbolsUseAbsDiff() && isEH)
849 streamer.EmitAbsValue(v, size);
850 else
851 streamer.EmitValue(v, size);
848852 }
849853
850854 static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol,
13431347 unsigned PCEncoding = IsEH ? MOFI->getFDEEncoding(UsingCFI)
13441348 : (unsigned)dwarf::DW_EH_PE_absptr;
13451349 unsigned PCSize = getSizeForEncoding(streamer, PCEncoding);
1346 EmitSymbol(streamer, *frame.Begin, PCEncoding, "FDE initial location");
1350 EmitFDESymbol(streamer, *frame.Begin, PCEncoding, IsEH, "FDE initial location");
13471351
13481352 // PC Range
13491353 const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
13631367
13641368 // Augmentation Data
13651369 if (frame.Lsda)
1366 EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding,
1367 "Language Specific Data Area");
1370 EmitFDESymbol(streamer, *frame.Lsda, frame.LsdaEncoding, true,
1371 "Language Specific Data Area");
13681372 }
13691373
13701374 // Call Frame Instructions
6464
6565 // Exceptions handling
6666 ExceptionsType = ExceptionHandling::DwarfCFI;
67
68 // FIXME: this should not depend on the target OS version, but on the ld64
69 // version in use. From at least >= ld64-97.17 (Xcode 3.2.6) the abs-ified
70 // FDE relocs may be used.
71 DwarfFDESymbolsUseAbsDiff = T.isMacOSX() && !T.isMacOSXVersionLT(10, 6);
6772 }
6873
6974 X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
None ; RUN: llc < %s -mtriple=x86_64-apple-macosx -disable-cfi | FileCheck %s
0 ; RUN: llc < %s -mtriple=x86_64-apple-macosx10.7 -disable-cfi | FileCheck --check-prefix=CHECK-64-D11 %s
1 ; RUN: llc < %s -mtriple=x86_64-apple-macosx10.6 -disable-cfi | FileCheck %s
2 ; RUN: llc < %s -mtriple=x86_64-apple-macosx10.5 -disable-cfi | FileCheck --check-prefix=CHECK-64-D89 %s
3 ; RUN: llc < %s -mtriple=i686-apple-macosx10.6 -disable-cfi | FileCheck --check-prefix=CHECK-I686-D10 %s
4 ; RUN: llc < %s -mtriple=i686-apple-macosx10.5 -disable-cfi | FileCheck --check-prefix=CHECK-I686-D89 %s
5 ; RUN: llc < %s -mtriple=i686-apple-macosx10.4 -disable-cfi | FileCheck --check-prefix=CHECK-I686-D89 %s
16
27 define private void @foo() {
38 ret void
1823 ; CHECK: Ltmp19:
1924 ; CHECK-NEXT: Ltmp20 = Ltmp2-Ltmp19 ## FDE initial location
2025 ; CHECK-NEXT: .quad Ltmp20
26
27
28 ; CHECK-64-D11: Ltmp13:
29 ; CHECK-64-D11-NEXT: Ltmp14 = L_foo-Ltmp13 ## FDE initial location
30 ; CHECK-64-D11-NEXT: .quad Ltmp14
31
32 ; CHECK-64-D11: Ltmp20:
33 ; CHECK-64-D11-NEXT: Ltmp21 = Ltmp2-Ltmp20 ## FDE initial location
34 ; CHECK-64-D11-NEXT: .quad Ltmp21
35
36
37 ; CHECK-64-D89: Ltmp12:
38 ; CHECK-64-D89-NEXT: .quad L_foo-Ltmp12 ## FDE initial location
39 ; CHECK-64-D89-NEXT: Ltmp13 = (Ltmp0-L_foo)-0 ## FDE address range
40 ; CHECK-64-D89-NEXT: .quad Ltmp13
41
42 ; CHECK-64-D89: Ltmp18:
43 ; CHECK-64-D89-NEXT: .quad Ltmp2-Ltmp18 ## FDE initial location
44 ; CHECK-64-D89-NEXT: Ltmp19 = (Ltmp4-Ltmp2)-0 ## FDE address range
45 ; CHECK-64-D89-NEXT: .quad Ltmp19
46
47
48 ; CHECK-I686-D10: Ltmp12:
49 ; CHECK-I686-D10-NEXT: Ltmp13 = L_foo-Ltmp12 ## FDE initial location
50 ; CHECK-I686-D10-NEXT: .long Ltmp13
51
52 ; CHECK-I686-D10: Ltmp19:
53 ; CHECK-I686-D10-NEXT: Ltmp20 = Ltmp2-Ltmp19 ## FDE initial location
54 ; CHECK-I686-D10-NEXT: .long Ltmp20
55
56
57 ; CHECK-I686-D89: Ltmp12:
58 ; CHECK-I686-D89-NEXT: .long L_foo-Ltmp12 ## FDE initial location
59 ; CHECK-I686-D89-NEXT: Ltmp13 = (Ltmp0-L_foo)-0 ## FDE address range
60 ; CHECK-I686-D89-NEXT: .long Ltmp13
61
62 ; CHECK-I686-D89: Ltmp18:
63 ; CHECK-I686-D89-NEXT: .long Ltmp2-Ltmp18 ## FDE initial location
64 ; CHECK-I686-D89-NEXT: Ltmp19 = (Ltmp4-Ltmp2)-0 ## FDE address range
65 ; CHECK-I686-D89-NEXT: .long Ltmp19
66