From 42ebff8c99bc03abdb690e3e545beda1a6ea5cb7 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Wed, 3 Sep 2014 07:37:20 +0000 Subject: [PATCH] Follow-up for r217020: actually commit the fix for PR20800, revert the accidentally committed changes to LLVMSymbolize.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217021 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp | 25 ++++++++++++++++--- tools/llvm-symbolizer/LLVMSymbolize.cpp | 12 +-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp index 342c9b070e9..7277eda41c9 100644 --- a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp +++ b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp @@ -437,10 +437,30 @@ class DarwinX86AsmBackend : public X86AsmBackend { bool Is64Bit; unsigned OffsetSize; ///< Offset of a "push" instruction. - unsigned PushInstrSize; ///< Size of a "push" instruction. unsigned MoveInstrSize; ///< Size of a "move" instruction. unsigned StackDivide; ///< Amount to adjust stack size by. protected: + /// \brief Size of a "push" instruction for the given register. + unsigned PushInstrSize(unsigned Reg) const { + switch (Reg) { + case X86::EBX: + case X86::ECX: + case X86::EDX: + case X86::EDI: + case X86::ESI: + case X86::EBP: + case X86::RBX: + case X86::RBP: + return 1; + case X86::R12: + case X86::R13: + case X86::R14: + case X86::R15: + return 2; + } + return 1; + } + /// \brief Implementation of algorithm to generate the compact unwind encoding /// for the CFI instructions. uint32_t @@ -530,7 +550,7 @@ protected: unsigned Reg = MRI.getLLVMRegNum(Inst.getRegister(), true); SavedRegs[SavedRegIdx++] = Reg; StackAdjust += OffsetSize; - InstrOffset += PushInstrSize; + InstrOffset += PushInstrSize(Reg); break; } } @@ -724,7 +744,6 @@ public: OffsetSize = Is64Bit ? 8 : 4; MoveInstrSize = Is64Bit ? 3 : 2; StackDivide = Is64Bit ? 8 : 4; - PushInstrSize = 1; } }; diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp index e3218608642..2606beac17b 100644 --- a/tools/llvm-symbolizer/LLVMSymbolize.cpp +++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -306,26 +306,19 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { // Check if it's a universal binary. Bin = ParsedBinary.getBinary().get(); addOwningBinary(std::move(ParsedBinary)); - errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n"; if (Bin->isMachO() || Bin->isMachOUniversalBinary()) { // On Darwin we may find DWARF in separate object file in // resource directory. const std::string &ResourcePath = getDarwinDWARFResourceForPath(Path); - errs() << "Resource path: " << ResourcePath << "\n"; BinaryOrErr = createBinary(ResourcePath); std::error_code EC = BinaryOrErr.getError(); - errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n"; if (EC != errc::no_such_file_or_directory && !error(EC)) { - errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n"; OwningBinary B = std::move(BinaryOrErr.get()); DbgBin = B.getBinary().get(); addOwningBinary(std::move(B)); } - if (EC == errc::no_such_file_or_directory) - errs() << "no_such_file_or_directory: " << ResourcePath << "\n"; } - errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n"; // Try to locate the debug binary using .gnu_debuglink section. if (!DbgBin) { std::string DebuglinkName; @@ -342,11 +335,8 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) { } } } - errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n"; - if (!DbgBin) { - errs() << "Failed to open DbgBin, falling back to Bin\n"; + if (!DbgBin) DbgBin = Bin; - } BinaryPair Res = std::make_pair(Bin, DbgBin); BinaryForPath[Path] = Res; return Res;