llvm.org GIT mirror llvm / f0adba9
Add 129518 back with a fix for when we are producing eh just because of debug info. Change ELF systems to use CFI for producing the EH tables. This reduces the size of the clang binary in Debug builds from 690MB to 679MB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129571 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 9 years ago
9 changed file(s) with 92 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
182182 /// function.
183183 void EmitFunctionBody();
184184
185 void emitPrologLabel(const MachineInstr &MI);
186
185187 /// EmitConstantPool - Print to the current output stream assembly
186188 /// representations of the constants in the constant pool MCP. This is
187189 /// used to print out constants which have been "spilled to memory" by
3232 #include "llvm/MC/MCStreamer.h"
3333 #include "llvm/MC/MCSymbol.h"
3434 #include "llvm/Target/Mangler.h"
35 #include "llvm/Target/TargetAsmInfo.h"
3536 #include "llvm/Target/TargetData.h"
3637 #include "llvm/Target/TargetInstrInfo.h"
3738 #include "llvm/Target/TargetLowering.h"
623624 return true;
624625 }
625626
627 void AsmPrinter::emitPrologLabel(const MachineInstr &MI) {
628 MCSymbol *Label = MI.getOperand(0).getMCSymbol();
629 if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) {
630 OutStreamer.EmitLabel(Label);
631 return;
632 }
633
634 const MachineFunction &MF = *MI.getParent()->getParent();
635 MachineModuleInfo &MMI = MF.getMMI();
636 std::vector &Moves = MMI.getFrameMoves();
637 const MachineMove *Move = NULL;
638 for (std::vector::iterator I = Moves.begin(),
639 E = Moves.end(); I != E; ++I) {
640 if (I->getLabel() == Label) {
641 Move = &*I;
642 break;
643 }
644 }
645 assert(Move);
646
647 const MachineLocation &Dst = Move->getDestination();
648 const MachineLocation &Src = Move->getSource();
649 const TargetAsmInfo &AsmInfo = OutContext.getTargetAsmInfo();
650 if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) {
651 if (Src.getReg() == MachineLocation::VirtualFP)
652 OutStreamer.EmitCFIDefCfaOffset(-Src.getOffset());
653 else {
654 unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
655 OutStreamer.EmitCFIDefCfa(Reg, -Src.getOffset());
656 }
657 } else if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) {
658 unsigned Reg = AsmInfo.getDwarfRegNum(Dst.getReg(), true);
659 OutStreamer.EmitCFIDefCfaRegister(Reg);
660 } else {
661 unsigned Reg = AsmInfo.getDwarfRegNum(Src.getReg(), true);
662 OutStreamer.EmitCFIOffset(Reg, -Dst.getOffset());
663 }
664 }
665
626666 /// EmitFunctionBody - This method emits the body and trailer for a
627667 /// function.
628668 void AsmPrinter::EmitFunctionBody() {
659699
660700 switch (II->getOpcode()) {
661701 case TargetOpcode::PROLOG_LABEL:
702 emitPrologLabel(*II);
703 break;
704
662705 case TargetOpcode::EH_LABEL:
663706 case TargetOpcode::GC_LABEL:
664707 OutStreamer.EmitLabel(II->getOperand(0).getMCSymbol());
3131 #include "llvm/Target/TargetOptions.h"
3232 #include "llvm/Target/TargetRegisterInfo.h"
3333 #include "llvm/Support/Dwarf.h"
34 #include "llvm/Support/ErrorHandling.h"
3435 #include "llvm/Support/FormattedStream.h"
3536 #include "llvm/ADT/SmallString.h"
3637 #include "llvm/ADT/StringExtras.h"
5960 // Begin eh frame section.
6061 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
6162
63 if ((PerEncoding & 0x70) != dwarf::DW_EH_PE_pcrel)
64 return;
65
6266 // Emit references to all used personality functions
6367 const std::vector &Personalities = MMI->getPersonalities();
6468 for (size_t i = 0, e = Personalities.size(); i != e; ++i) {
6569 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("personality", i));
66 Asm->EmitReference(Personalities[i], PerEncoding);
70 const MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]);
71 unsigned Size = Asm->TM.getTargetData()->getPointerSize();
72 Asm->OutStreamer.EmitSymbolValue(Sym, Size);
6773 }
6874 }
6975
7682 shouldEmitTable = !MMI->getLandingPads().empty();
7783
7884 // See if we need frame move info.
79 shouldEmitMoves =
85 shouldEmitMoves = MMI->hasDebugInfo() ||
8086 !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
8187
8288 if (shouldEmitMoves || shouldEmitTable)
8692
8793 shouldEmitTableModule |= shouldEmitTable;
8894
89 if (shouldEmitMoves) {
90 const TargetFrameLowering *TFL = Asm->TM.getFrameLowering();
95 if (shouldEmitMoves || shouldEmitTable)
9196 Asm->OutStreamer.EmitCFIStartProc();
92
93 // Indicate locations of general callee saved registers in frame.
94 std::vector Moves;
95 TFL->getInitialFrameState(Moves);
96 Asm->EmitCFIFrameMoves(Moves);
97 Asm->EmitCFIFrameMoves(MMI->getFrameMoves());
98 }
9997
10098 if (!shouldEmitTable)
10199 return;
111109
112110 // Indicate personality routine, if any.
113111 unsigned PerEncoding = TLOF.getPersonalityEncoding();
114 if (PerEncoding != dwarf::DW_EH_PE_omit &&
115 MMI->getPersonalities()[MMI->getPersonalityIndex()])
116 Asm->OutStreamer.EmitCFIPersonality(Asm->GetTempSymbol("personality",
117 MMI->getPersonalityIndex()),
118 PerEncoding);
112 const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()];
113 if (PerEncoding == dwarf::DW_EH_PE_omit || !Per)
114 return;
115
116 const MCSymbol *Sym;
117 switch (PerEncoding & 0x70) {
118 default:
119 report_fatal_error("We do not support this DWARF encoding yet!");
120 case dwarf::DW_EH_PE_absptr: {
121 Sym = Asm->Mang->getSymbol(Per);
122 break;
123 }
124 case dwarf::DW_EH_PE_pcrel: {
125 Sym = Asm->GetTempSymbol("personality",
126 MMI->getPersonalityIndex());
127 break;
128 }
129 }
130 Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding);
119131 }
120132
121133 /// EndFunction - Gather and emit post-function exception information.
313313 MCStreamer &Streamer) const {
314314 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, getContext());
315315
316 switch (Encoding & 0xF0) {
316 switch (Encoding & 0x70) {
317317 default:
318318 report_fatal_error("We do not support this DWARF encoding yet!");
319319 case dwarf::DW_EH_PE_absptr:
2121 #include "llvm/CodeGen/MachineInstrBuilder.h"
2222 #include "llvm/CodeGen/MachineModuleInfo.h"
2323 #include "llvm/CodeGen/MachineRegisterInfo.h"
24 #include "llvm/MC/MCAsmInfo.h"
2425 #include "llvm/Target/TargetData.h"
2526 #include "llvm/Target/TargetOptions.h"
2627 #include "llvm/Support/CommandLine.h"
475476 .addReg(StackPtr);
476477
477478 if (needsFrameMoves) {
479 const MCAsmInfo &MAI = MMI.getContext().getAsmInfo();
480 if (MAI.getExceptionHandlingType() == ExceptionHandling::DwarfCFI) {
481 MCSymbol *FrameLabel0 = MMI.getContext().CreateTempSymbol();
482 BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(FrameLabel0);
483 MachineLocation FPSrc0(FramePtr);
484 MachineLocation FPDst0(FramePtr, -2 * stackGrowth);
485 Moves.push_back(MachineMove(FrameLabel0, FPDst0, FPSrc0));
486 }
487
478488 // Mark effective beginning of when frame pointer becomes valid.
479489 MCSymbol *FrameLabel = MMI.getContext().CreateTempSymbol();
480490 BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(FrameLabel);
614624 emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit,
615625 TII, *RegInfo);
616626
617 if ((NumBytes || PushedRegs) && needsFrameMoves) {
627 if (( (!HasFP && NumBytes) || PushedRegs) && needsFrameMoves) {
618628 // Mark end of stack pointer adjustment.
619629 MCSymbol *Label = MMI.getContext().CreateTempSymbol();
620630 BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(Label);
8888 SupportsDebugInformation = true;
8989
9090 // Exceptions handling
91 ExceptionsType = ExceptionHandling::DwarfTable;
91 ExceptionsType = ExceptionHandling::DwarfCFI;
92
93 DwarfRequiresFrameSection = false;
9294
9395 // OpenBSD has buggy support for .quad in 32-bit mode, just split into two
9496 // .words.
None ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -o - | grep zPL
0 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -o - | FileCheck %s
1
2 ; CHECK: .cfi_lsda 0, .Lexception0
3 ; CHECK: .cfi_personality 0, __gnat_eh_personality
14
25 @error = external global i8 ; [#uses=2]
36
+0
-12
test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll less more
None ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu | grep ^.L_Z1fv.eh
1 ; RUN: llc < %s -march=x86 -mtriple=i686-unknown-linux-gnu | grep ^.L_Z1fv.eh
2 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh
3 ; RUN: llc < %s -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh
4
5 define void @_Z1fv() {
6 entry:
7 br label %return
8
9 return:
10 ret void
11 }
0 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
1 ; RUN: grep { = } %t | count 16
2 ; RUN: grep set %t | count 18
31 ; RUN: grep globl %t | count 6
42 ; RUN: grep weak %t | count 1
53 ; RUN: grep hidden %t | count 1