X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FDwarfWriter.cpp;h=8cc7f30979b8e9d5d81667b82d35a04bac883216;hb=420cdebbcb95f3881ab3518fd3bb670837669e43;hp=c1091e9e7deb578c3fed73fe06ac391658a7c6f0;hpb=749c6f6b5ed301c84aac562e414486549d7b98eb;p=oota-llvm.git diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index c1091e9e7de..8cc7f30979b 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -30,7 +30,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/System/Path.h" #include "llvm/Target/TargetAsmInfo.h" -#include "llvm/Target/MRegisterInfo.h" +#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" @@ -782,7 +782,7 @@ protected: const TargetData *TD; /// RI - Register Information. - const MRegisterInfo *RI; + const TargetRegisterInfo *RI; /// M - Current module. /// @@ -1875,7 +1875,8 @@ private: // Add variable address. MachineLocation Location; - RI->getLocation(*MF, DV->getFrameIndex(), Location); + Location.set(RI->getFrameRegister(*MF), + RI->getFrameIndexOffset(*MF, DV->getFrameIndex())); AddAddress(VariableDie, DW_AT_location, Location); return VariableDie; @@ -2720,6 +2721,11 @@ public: // Assumes in correct section after the entry point. EmitLabel("func_begin", ++SubprogramCount); + + // Emit label for the implicitly defined dbg.stoppoint at the start of + // the function. + const SourceLineInfo &LineInfo = MMI->getSourceLines()[0]; + Asm->printLabel(LineInfo.getLabelID()); } /// EndFunction - Gather and emit post-function debug information. @@ -2764,15 +2770,14 @@ private: bool hasCalls; bool hasLandingPads; std::vector Moves; - Function::LinkageTypes linkage; + const Function * function; FunctionEHFrameInfo(const std::string &FN, unsigned Num, unsigned P, bool hC, bool hL, const std::vector &M, - Function::LinkageTypes l): + const Function *f): FnName(FN), Number(Num), PersonalityIndex(P), - hasCalls(hC), hasLandingPads(hL), Moves(M), - linkage(l) { } + hasCalls(hC), hasLandingPads(hL), Moves(M), function (f) { } }; std::vector EHFrames; @@ -2835,11 +2840,13 @@ private: Asm->EOL("Personality (pcrel sdata4 indirect)"); - PrintRelDirective(); + PrintRelDirective(TAI->getShortenEHDataOn64Bit()); O << TAI->getPersonalityPrefix(); Asm->EmitExternalGlobal((const GlobalVariable *)(Personality)); O << TAI->getPersonalitySuffix(); - O << "-" << TAI->getPCSymbol(); + if (!TAI->getShortenEHDataOn64Bit()) { + O << "-" << TAI->getPCSymbol(); + } Asm->EOL("Personality"); Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); @@ -2867,28 +2874,42 @@ private: /// EmitEHFrame - Emit function exception frame information. /// void EmitEHFrame(const FunctionEHFrameInfo &EHFrameInfo) { + Function::LinkageTypes linkage = EHFrameInfo.function->getLinkage(); + Asm->SwitchToTextSection(TAI->getDwarfEHFrameSection()); // Externally visible entry into the functions eh frame info. // If the corresponding function is static, this should not be // externally visible. - if (EHFrameInfo.linkage != Function::InternalLinkage) { + if (linkage != Function::InternalLinkage) { if (const char *GlobalEHDirective = TAI->getGlobalEHDirective()) O << GlobalEHDirective << EHFrameInfo.FnName << "\n"; } - // If there are no calls then you can't unwind. - if (!EHFrameInfo.hasCalls) { + // If corresponding function is weak definition, this should be too. + if ((linkage == Function::WeakLinkage || + linkage == Function::LinkOnceLinkage) && + TAI->getWeakDefDirective()) + O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n"; + + // If there are no calls then you can't unwind. This may mean we can + // omit the EH Frame, but some environments do not handle weak absolute + // symbols. + if (!EHFrameInfo.hasCalls && + ((linkage != Function::WeakLinkage && + linkage != Function::LinkOnceLinkage) || + !TAI->getWeakDefDirective() || + TAI->getSupportsWeakOmittedEHFrame())) + { O << EHFrameInfo.FnName << " = 0\n"; + // This name has no connection to the function, so it might get + // dead-stripped when the function is not, erroneously. Prohibit + // dead-stripping unconditionally. + if (const char *UsedDirective = TAI->getUsedDirective()) + O << UsedDirective << EHFrameInfo.FnName << "\n\n"; } else { O << EHFrameInfo.FnName << ":\n"; - // If corresponding function is weak definition, this should be too. - if ((EHFrameInfo.linkage == Function::WeakLinkage || - EHFrameInfo.linkage == Function::LinkOnceLinkage) && - TAI->getWeakDefDirective()) - O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n"; - // EH frame header. EmitDifference("eh_frame_end", EHFrameInfo.Number, "eh_frame_begin", EHFrameInfo.Number, true); @@ -2910,7 +2931,7 @@ private: // If there is a personality and landing pads then point to the language // specific data area in the exception table. if (EHFrameInfo.PersonalityIndex) { - Asm->EmitULEB128Bytes(4); + Asm->EmitULEB128Bytes(TAI->getShortenEHDataOn64Bit() ? 8 : 4); Asm->EOL("Augmentation size"); if (EHFrameInfo.hasLandingPads) { @@ -2932,10 +2953,16 @@ private: Asm->EmitAlignment(2); EmitLabel("eh_frame_end", EHFrameInfo.Number); - } - if (const char *UsedDirective = TAI->getUsedDirective()) - O << UsedDirective << EHFrameInfo.FnName << "\n\n"; + // If the function is marked used, this table should be also. We cannot + // make the mark unconditional in this case, since retaining the table + // also retains the function in this case, and there is code around + // that depends on unused functions (calling undefined externals) being + // dead-stripped to link correctly. Yes, there really is. + if (MMI->getUsedFunctions().count(EHFrameInfo.function)) + if (const char *UsedDirective = TAI->getUsedDirective()) + O << UsedDirective << EHFrameInfo.FnName << "\n\n"; + } } /// EmitExceptionTable - Emit landing pads and actions. @@ -3277,24 +3304,26 @@ private: } EmitSectionOffset(BeginTag, "eh_func_begin", BeginNumber, SubprogramCount, - false, true); + TAI->getShortenEHDataOn64Bit(), true); Asm->EOL("Region start"); if (!S.EndLabel) { - EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber); + EmitDifference("eh_func_end", SubprogramCount, BeginTag, BeginNumber, + TAI->getShortenEHDataOn64Bit()); } else { - EmitDifference("label", S.EndLabel, BeginTag, BeginNumber); + EmitDifference("label", S.EndLabel, BeginTag, BeginNumber, + TAI->getShortenEHDataOn64Bit()); } Asm->EOL("Region length"); if (!S.PadLabel) { - if (TD->getPointerSize() == sizeof(int32_t)) + if (TD->getPointerSize() == sizeof(int32_t) || TAI->getShortenEHDataOn64Bit()) Asm->EmitInt32(0); else Asm->EmitInt64(0); } else { EmitSectionOffset("label", "eh_func_begin", S.PadLabel, SubprogramCount, - false, true); + TAI->getShortenEHDataOn64Bit(), true); } Asm->EOL("Landing pad"); @@ -3403,7 +3432,7 @@ public: MF->getFrameInfo()->hasCalls(), !MMI->getLandingPads().empty(), MMI->getFrameMoves(), - MF->getFunction()->getLinkage())); + MF->getFunction())); } };