[llvm] r217020 - Fix PR20800: correctly calculate the offset of the subq instruction when generating compact unwind info.
Alexander Potapenko
glider at google.com
Wed Sep 3 00:11:34 PDT 2014
Author: glider
Date: Wed Sep 3 02:11:34 2014
New Revision: 217020
URL: http://llvm.org/viewvc/llvm-project?rev=217020&view=rev
Log:
Fix PR20800: correctly calculate the offset of the subq instruction when generating compact unwind info.
This CL replaces the constant DarwinX86AsmBackend.PushInstrSize with a method
that lets the backend account for different sizes of "push %reg" instruction
sizes.
Added:
llvm/trunk/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
Modified:
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
Added: llvm/trunk/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2014-08-29-CompactUnwind.ll?rev=217020&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2014-08-29-CompactUnwind.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2014-08-29-CompactUnwind.ll Wed Sep 3 02:11:34 2014
@@ -0,0 +1,46 @@
+; RUN: llc < %s -disable-fp-elim -mtriple x86_64-apple-darwin11 -mcpu corei7 -filetype=obj -o - | llvm-objdump -d -unwind-info -s - | FileCheck %s
+; Regression test for http://llvm.org/bugs/show_bug.cgi?id=20800.
+
+; ModuleID = 'asan_report.ii'
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.9.0"
+
+ at .str = private unnamed_addr constant [3 x i8] c"=>\00", align 1
+ at .str1 = private unnamed_addr constant [3 x i8] c" \00", align 1
+ at .str2 = private unnamed_addr constant [6 x i8] c"%s%p:\00", align 1
+
+; CHECK: ___asan_report_error:
+
+; subq instruction starts at 0x0a, so the second byte of the compact encoding
+; (UNWIND_X86_64_FRAMELESS_STACK_SIZE in mach-o/compact_unwind_encoding.h)
+; must be 0x0d.
+; CHECK: {{a:.*subq.*%rsp}}
+
+; CHECK: Contents of __compact_unwind section
+; CHECK: ___asan_report_error
+
+; Because of incorrect push instruction size in X86AsmBackend.cpp the stack
+; size was also calculated incorrectly.
+; CHECK-NOT: {{compact encoding:.*0x0309f800}}
+; CHECK: {{compact encoding:.*0x030df800}}
+
+define void @__asan_report_error() #0 {
+ %str.i = alloca i64, align 8
+ %stack = alloca [256 x i64], align 8
+ br label %print_shadow_bytes.exit.i
+
+print_shadow_bytes.exit.i: ; preds = %print_shadow_bytes.exit.i, %0
+ %iv.i = phi i64 [ -5, %0 ], [ %iv.next.i, %print_shadow_bytes.exit.i ]
+ %reg15 = icmp eq i64 %iv.i, 0
+ %.str..str1.i = select i1 %reg15, [3 x i8]* @.str, [3 x i8]* @.str1
+ %reg16 = getelementptr inbounds [3 x i8]* %.str..str1.i, i64 0, i64 0
+ %reg17 = shl i64 %iv.i, 1
+ %reg19 = inttoptr i64 %reg17 to i8*
+ call void (i64*, i8*, ...)* @append(i64* %str.i, i8* getelementptr inbounds ([6 x i8]* @.str2, i64 0, i64 0), i8* %reg16, i8* %reg19)
+ %iv.next.i = add nsw i64 %iv.i, 0
+ br label %print_shadow_bytes.exit.i
+}
+
+declare void @append(i64*, i8*, ...)
+
+attributes #0 = { "no-frame-pointer-elim"="false" }
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=217020&r1=217019&r2=217020&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Wed Sep 3 02:11:34 2014
@@ -306,19 +306,26 @@ LLVMSymbolizer::getOrCreateBinary(const
// 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<Binary> 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;
@@ -335,8 +342,11 @@ LLVMSymbolizer::getOrCreateBinary(const
}
}
}
- if (!DbgBin)
+ errs() << "HERE: " << __FILE__ << ":" << __LINE__ << ", DbgBin: " << DbgBin << "\n";
+ if (!DbgBin) {
+ errs() << "Failed to open DbgBin, falling back to Bin\n";
DbgBin = Bin;
+ }
BinaryPair Res = std::make_pair(Bin, DbgBin);
BinaryForPath[Path] = Res;
return Res;
More information about the llvm-commits
mailing list