Index: include/llvm/Target/TargetAsmInfo.h =================================================================== --- include/llvm/Target/TargetAsmInfo.h (revision 41797) +++ include/llvm/Target/TargetAsmInfo.h (working copy) @@ -110,6 +110,12 @@ const char *FunctionAddrPrefix; // Defaults to "" const char *FunctionAddrSuffix; // Defaults to "" + /// PersonalityPrefix/Suffix - If these are nonempty, these strings will + /// enclose any personality function in the common frame section. + /// + const char *PersonalityPrefix; // Defaults to "" + const char *PersonalitySuffix; // Defaults to "" + /// InlineAsmStart/End - If these are nonempty, they contain a directive to /// emit before and after an inline assembly statement. const char *InlineAsmStart; // Defaults to "#APP\n" @@ -428,6 +434,12 @@ const char *getFunctionAddrSuffix() const { return FunctionAddrSuffix; } + const char *getPersonalityPrefix() const { + return PersonalityPrefix; + } + const char *getPersonalitySuffix() const { + return PersonalitySuffix; + } const char *getInlineAsmStart() const { return InlineAsmStart; } Index: lib/CodeGen/DwarfWriter.cpp =================================================================== --- lib/CodeGen/DwarfWriter.cpp (revision 41797) +++ lib/CodeGen/DwarfWriter.cpp (working copy) @@ -2789,26 +2789,15 @@ if (Personality) { Asm->EmitULEB128Bytes(7); Asm->EOL("Augmentation Size"); - Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4); - Asm->EOL("Personality (pcrel sdata4)"); + Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect); + Asm->EOL("Personality (pcrel sdata4 indirect)"); - if (TAI->needsSet()) { - O << "\t.set\t"; - PrintLabelName("set", SetCounter); - O << ","; - Asm->EmitExternalGlobal((const GlobalVariable *)(Personality)); - O << "-" << TAI->getPCSymbol(); - Asm->EOL("Set Personality"); - PrintRelDirective(); - PrintLabelName("set", SetCounter); - Asm->EOL("Personality"); - ++SetCounter; - } else { - PrintRelDirective(); - Asm->EmitExternalGlobal((const GlobalVariable *)(Personality)); - O << "-" << TAI->getPCSymbol(); - Asm->EOL("Personality"); - } + PrintRelDirective(); + O << TAI->getPersonalityPrefix(); + Asm->EmitExternalGlobal((const GlobalVariable *)(Personality)); + O << TAI->getPersonalitySuffix(); + O << "-" << TAI->getPCSymbol(); + Asm->EOL("Personality"); Asm->EmitULEB128Bytes(DW_EH_PE_pcrel); Asm->EOL("LSDA Encoding (pcrel)"); @@ -3297,7 +3286,7 @@ const std::vector Personalities = MMI->getPersonalities(); for (unsigned i =0; i < Personalities.size(); ++i) EmitCommonEHFrame(Personalities[i], i); - + for (std::vector::iterator I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I) EmitEHFrame(*I); Index: lib/Target/TargetAsmInfo.cpp =================================================================== --- lib/Target/TargetAsmInfo.cpp (revision 41797) +++ lib/Target/TargetAsmInfo.cpp (working copy) @@ -38,6 +38,8 @@ GlobalVarAddrSuffix(""), FunctionAddrPrefix(""), FunctionAddrSuffix(""), + PersonalityPrefix(""), + PersonalitySuffix(""), InlineAsmStart("#APP"), InlineAsmEnd("#NO_APP"), AssemblerDialect(0), Index: lib/Target/X86/X86AsmPrinter.h =================================================================== --- lib/Target/X86/X86AsmPrinter.h (revision 41797) +++ lib/Target/X86/X86AsmPrinter.h (working copy) @@ -30,10 +30,11 @@ struct VISIBILITY_HIDDEN X86SharedAsmPrinter : public AsmPrinter { DwarfWriter DW; + MachineModuleInfo *MMI; X86SharedAsmPrinter(std::ostream &O, X86TargetMachine &TM, const TargetAsmInfo *T) - : AsmPrinter(O, TM, T), DW(O, this, T) { + : AsmPrinter(O, TM, T), DW(O, this, T), MMI(0) { Subtarget = &TM.getSubtarget(); } Index: lib/Target/X86/X86ATTAsmPrinter.cpp =================================================================== --- lib/Target/X86/X86ATTAsmPrinter.cpp (revision 41797) +++ lib/Target/X86/X86ATTAsmPrinter.cpp (working copy) @@ -74,7 +74,8 @@ if (TAI->doesSupportDebugInformation()) { // Let PassManager know we need debug information and relay // the MachineModuleInfo address on to DwarfWriter. - DW.SetModuleInfo(&getAnalysis()); + MMI = &getAnalysis(); + DW.SetModuleInfo(MMI); } SetupMachineFunction(MF); Index: lib/Target/X86/X86TargetAsmInfo.cpp =================================================================== --- lib/Target/X86/X86TargetAsmInfo.cpp (revision 41797) +++ lib/Target/X86/X86TargetAsmInfo.cpp (working copy) @@ -68,6 +68,8 @@ StaticCtorsSection = ".mod_init_func"; StaticDtorsSection = ".mod_term_func"; } + PersonalityPrefix = "L"; + PersonalitySuffix = "$non_lazy_ptr"; InlineAsmStart = "# InlineAsm Start"; InlineAsmEnd = "# InlineAsm End"; SetDirective = "\t.set"; Index: lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- lib/Target/X86/X86AsmPrinter.cpp (revision 41797) +++ lib/Target/X86/X86AsmPrinter.cpp (working copy) @@ -352,6 +352,15 @@ O << "\n"; + if (MMI) { + // Add the (possibly multiple) personalities to the set of global values. + const std::vector& Personalities = MMI->getPersonalities(); + + for (std::vector::const_iterator I = Personalities.begin(), + E = Personalities.end(); I != E; ++I) + if (*I) GVStubs.insert("_" + (*I)->getName()); + } + // Output stubs for external and common global variables. if (GVStubs.begin() != GVStubs.end()) SwitchToDataSection(