Don't force relaxation of AdvanceLoc instructions on OS X. gdb is happy with

the smaller encoding and this cuts 270336 bytes from a release version of
clang and 1246272 bytes from a debug build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131067 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-05-08 14:35:21 +00:00
parent 6a61834d1c
commit 4eafe10945
3 changed files with 7 additions and 15 deletions

View File

@ -283,8 +283,7 @@ namespace llvm {
// //
static void Emit(MCStreamer &streamer, bool usingCFI); static void Emit(MCStreamer &streamer, bool usingCFI);
static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta);
static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS, static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS);
const TargetAsmInfo &AsmInfo);
}; };
} // end namespace llvm } // end namespace llvm

View File

@ -759,8 +759,7 @@ bool MCAssembler::RelaxDwarfCallFrameFragment(MCAsmLayout &Layout,
SmallString<8> &Data = DF.getContents(); SmallString<8> &Data = DF.getContents();
Data.clear(); Data.clear();
raw_svector_ostream OSE(Data); raw_svector_ostream OSE(Data);
const TargetAsmInfo &AsmInfo = getContext().getTargetAsmInfo(); MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OSE);
MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OSE, AsmInfo);
OSE.flush(); OSE.flush();
return OldSize != Data.size(); return OldSize != Data.size();
} }

View File

@ -868,27 +868,21 @@ void MCDwarfFrameEmitter::EmitAdvanceLoc(MCStreamer &Streamer,
SmallString<256> Tmp; SmallString<256> Tmp;
raw_svector_ostream OS(Tmp); raw_svector_ostream OS(Tmp);
const TargetAsmInfo &AsmInfo = Streamer.getContext().getTargetAsmInfo(); const TargetAsmInfo &AsmInfo = Streamer.getContext().getTargetAsmInfo();
MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OS, AsmInfo); MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OS);
Streamer.EmitBytes(OS.str(), /*AddrSpace=*/0); Streamer.EmitBytes(OS.str(), /*AddrSpace=*/0);
} }
void MCDwarfFrameEmitter::EncodeAdvanceLoc(uint64_t AddrDelta, void MCDwarfFrameEmitter::EncodeAdvanceLoc(uint64_t AddrDelta,
raw_ostream &OS, raw_ostream &OS) {
const TargetAsmInfo &AsmInfo) {
// This is a small hack to facilitate the transition to CFI on OS X. It
// relaxes all address advances which lets us produces identical output
// to the one produce by CodeGen.
const bool Relax = !AsmInfo.isFunctionEHFrameSymbolPrivate();
// FIXME: Assumes the code alignment factor is 1. // FIXME: Assumes the code alignment factor is 1.
if (AddrDelta == 0) { if (AddrDelta == 0) {
} else if (isUIntN(6, AddrDelta) && !Relax) { } else if (isUIntN(6, AddrDelta)) {
uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta; uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta;
OS << Opcode; OS << Opcode;
} else if (isUInt<8>(AddrDelta) && !Relax) { } else if (isUInt<8>(AddrDelta)) {
OS << uint8_t(dwarf::DW_CFA_advance_loc1); OS << uint8_t(dwarf::DW_CFA_advance_loc1);
OS << uint8_t(AddrDelta); OS << uint8_t(AddrDelta);
} else if (isUInt<16>(AddrDelta) && !Relax) { } else if (isUInt<16>(AddrDelta)) {
// FIXME: check what is the correct behavior on a big endian machine. // FIXME: check what is the correct behavior on a big endian machine.
OS << uint8_t(dwarf::DW_CFA_advance_loc2); OS << uint8_t(dwarf::DW_CFA_advance_loc2);
OS << uint8_t( AddrDelta & 0xff); OS << uint8_t( AddrDelta & 0xff);