[llvm] r321911 - Re-land "Fix faulty assertion in debug info"

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 9 01:37:28 PST 2018


Could this be merged to 6.0? I'm attempting to use CodeView + DWARF for some internal builds (DWARF because of legacy tooling and CodeView because VS and WinDbg are amazing), and I run into tons of assertion failures without this.

From: llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of Adrian McCarthy via llvm-commits <llvm-commits at lists.llvm.org>
Reply-To: Adrian McCarthy <amccarth at google.com>
Date: Friday, January 5, 2018 at 3:02 PM
To: "llvm-commits at lists.llvm.org" <llvm-commits at lists.llvm.org>
Subject: [llvm] r321911 - Re-land "Fix faulty assertion in debug info"

Author: amccarth
Date: Fri Jan  5 15:01:04 2018
New Revision: 321911

URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D321911-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=oYPzLUt12kbY0usUU-m1r_xEKlnRG30YjkOvUV6iaFs&e=
Log:
Re-land "Fix faulty assertion in debug info"

This had been reverted because the new test failed on non-X86 bots.  I moved
the new test to the appropriate subdirectory to correct this.

Differential Revision: https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D41264&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=7yNssmmoDpXKFL0vEHxIm9hofrOvjsG4t5USifus2_s&e=
Original submission:  r321122 (which was reverted by r321125)

This reverts commit 3c1639b5703c387a0d8cba2862803b4e68dff436.

Added:
    llvm/trunk/test/DebugInfo/X86/void-typedef.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DebugHandlerBase.cpp-3Frev-3D321911-26r1-3D321910-26r2-3D321911-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=S1E2Fg-WDQBUY0o6guHbViWFIu9ubKPKfT0m7uXWJBY&e=
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Fri Jan  5 15:01:04 2018
@@ -163,7 +163,8 @@ uint64_t DebugHandlerBase::getBaseTypeSi
   DIType *BaseType = DDTy->getBaseType().resolve();
-  assert(BaseType && "Unexpected invalid base type");
+  if (!BaseType)
+    return 0;
   // If this is a derived type, go ahead and get the base type, unless it's a
   // reference then it's just the size of the field. Pointer types have no need

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfUnit.cpp-3Frev-3D321911-26r1-3D321910-26r2-3D321911-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=XQbyW8Q-dS6EZT2ndOU90hxLnptXCB0-ZKATE1JUEnY&e=
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Fri Jan  5 15:01:04 2018
@@ -1400,7 +1400,8 @@ void DwarfUnit::constructMemberDIE(DIE &
   if (!Name.empty())
     addString(MemberDie, dwarf::DW_AT_name, Name);
-  addType(MemberDie, resolve(DT->getBaseType()));
+  if (DIType *Resolved = resolve(DT->getBaseType()))
+    addType(MemberDie, Resolved);
   addSourceLine(MemberDie, DT);

Added: llvm/trunk/test/DebugInfo/X86/void-typedef.ll
URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_DebugInfo_X86_void-2Dtypedef.ll-3Frev-3D321911-26view-3Dauto&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=SVjciC7M3NJd00CLgZcYQ0CExtY9JGuZQKtv2jzby9I&e=
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/void-typedef.ll (added)
+++ llvm/trunk/test/DebugInfo/X86/void-typedef.ll Fri Jan  5 15:01:04 2018
@@ -0,0 +1,88 @@
+; Choosing CodeView generates debug metadata for class-scope typedefs that
+; Dwarf would normally omit.  Choosing both CodeView and Dwarf triggered
+; assertion failures and crashes because the Dwarf handler wasn't prepared for
+; those records (in particular, ones with the void type represented by a
+; null pointer).
+;
+; This test was generated with:
+;    clang++ -cc1 -emit-llvm -debug-info-kind=limited -dwarf-version=4 -gcodeview -x c++
+; on the following source code:
+;
+;   class A {
+;     typedef void _Nodeptr;
+;   };
+;   class B {
+;     A FailedTestsCache;
+;     bool m_fn1();
+;   };
+;   bool B::m_fn1() {}
+;
+; CodeView generates a DIDerivedType for the _Nodeptr typedef.
+;
+; RUN: llc %s -o - 2>&1 | FileCheck %s
+; CHECK-NOT: Assertion failed
+
+; ModuleID = 'bug.cpp'
+source_filename = "bug.cpp"
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
+target triple = "i686-pc-windows-msvc"
+
+%class.B = type { %class.A }
+%class.A = type { i8 }
+
+; Function Attrs: noinline nounwind optnone
+define x86_thiscallcc zeroext i1 @"\01?m_fn1 at B@@AAE_NXZ"(%class.B* %this) #0 align 2 !dbg !9 {
+entry:
+  %retval = alloca i1, align 1
+  %this.addr = alloca %class.B*, align 4
+  store %class.B* %this, %class.B** %this.addr, align 4
+  call void @llvm.dbg.declare(metadata %class.B** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24
+  %this1 = load %class.B*, %class.B** %this.addr, align 4
+  call void @llvm.trap(), !dbg !25
+  unreachable, !dbg !25
+
+return:                                           ; No predecessors!
+  %0 = load i1, i1* %retval, align 1, !dbg !25
+  ret i1 %0, !dbg !25
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: noreturn nounwind
+declare void @llvm.trap() #2
+
+attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone speculatable }
+attributes #2 = { noreturn nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "<stdin>", directory: "D:\5Csrc\5Cbug", checksumkind: CSK_MD5, checksum: "2216f11c5ddda8c48a6f92a6079ad4b6")
+!2 = !{}
+!3 = !{i32 1, !"NumRegisterParameters", i32 0}
+!4 = !{i32 2, !"Dwarf Version", i32 4}
+!5 = !{i32 2, !"CodeView", i32 1}
+!6 = !{i32 2, !"Debug Info Version", i32 3}
+!7 = !{i32 1, !"wchar_size", i32 2}
+!8 = !{!"clang version 6.0.0 "}
+!9 = distinct !DISubprogram(name: "m_fn1", linkageName: "\01?m_fn1 at B@@AAE_NXZ", scope: !11, file: !10, line: 8, type: !18, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !17, variables: !2)
+!10 = !DIFile(filename: "bug.cpp", directory: "D:\5Csrc\5Cbug", checksumkind: CSK_MD5, checksum: "2216f11c5ddda8c48a6f92a6079ad4b6")
+!11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !10, line: 4, size: 8, elements: !12, identifier: ".?AVB@@")
+!12 = !{!13, !17}
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "FailedTestsCache", scope: !11, file: !10, line: 5, baseType: !14, size: 8)
+!14 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !10, line: 1, size: 8, elements: !15, identifier: ".?AVA@@")
+!15 = !{!16}
+!16 = !DIDerivedType(tag: DW_TAG_typedef, name: "_Nodeptr", scope: !14, file: !10, line: 2, baseType: null)
+!17 = !DISubprogram(name: "m_fn1", linkageName: "\01?m_fn1 at B@@AAE_NXZ", scope: !11, file: !10, line: 6, type: !18, isLocal: false, isDefinition: false, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false)
+!18 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !19)
+!19 = !{!20, !21}
+!20 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
+!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
+!22 = !DILocalVariable(name: "this", arg: 1, scope: !9, type: !23, flags: DIFlagArtificial | DIFlagObjectPointer)
+!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32)
+!24 = !DILocation(line: 0, scope: !9)
+!25 = !DILocation(line: 8, scope: !9)


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=bb7Fnu5b5aPiw_2pitHpaqpp8rYq6F846YVLYF2PYfY&s=-9wjJkA4iICIgs2Uk8350oLiaBmMZiAeYGRGVBmQwoE&e=

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180209/8064cc5e/attachment.html>


More information about the llvm-commits mailing list