[PATCH] D54667: [CodeView] Emit proper debug info for ref-qualified member functions

Andrew Kelley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 23 16:14:08 PST 2018


andrewrk added a comment.

I think this patch broke Zig's tests:

  zig: /store/dev/llvm-project/llvm/include/llvm/Support/Casting.h:255: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::DIDerivedType; Y = const llvm::DIType; typename llvm::cast_retty<X, Y*>::ret_type = const llvm::DIDerivedType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
  #0  0x00007ffff65d3264 in raise () from /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/libc.so.6
  #1  0x00007ffff65d4665 in abort () from /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/libc.so.6
  #2  0x00007ffff65cbce7 in __assert_fail_base () from /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/libc.so.6
  #3  0x00007ffff65cbd92 in __assert_fail () from /nix/store/2kcrj1ksd2a14bm5sky182fv2xwfhfap-glibc-2.26-131/lib/libc.so.6
  #4  0x0000000003ad313e in llvm::cast<llvm::DIDerivedType, llvm::DIType const> (Val=0xa9f98a8)
      at /store/dev/llvm-project/llvm/include/llvm/Support/Casting.h:255
  #5  0x00000000049c498a in llvm::CodeViewDebug::getTypeIndexForThisPtr (this=0x1c865190, TypeRef=..., SubroutineTy=0xb640010)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:2419
  #6  0x00000000049c1f58 in llvm::CodeViewDebug::lowerTypeMemberFunction (this=0x1c865190, Ty=0xb640010, ClassTy=0x176a1b38, ThisAdjustment=0, 
      IsStaticMethod=false, FO=llvm::codeview::FunctionOptions::None) at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1843
  #7  0x00000000049ba3a8 in llvm::CodeViewDebug::getMemberFunctionType (this=0x1c865190, SP=0x1cc572c0, Class=0x176a1b38)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:419
  #8  0x00000000049b9e70 in llvm::CodeViewDebug::getFuncIdForSubprogram (this=0x1c865190, SP=0x1cc572c0)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:355
  #9  0x00000000049bddc1 in llvm::CodeViewDebug::emitDebugInfoForFunction (this=0x1c865190, GV=0x1c95d228, FI=...)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1011
  #10 0x00000000049bac5f in llvm::CodeViewDebug::endModule (this=0x1c865190)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:542
  #11 0x0000000004922eb5 in llvm::AsmPrinter::doFinalization (this=0x16056300, M=...)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1450
  #12 0x0000000005edd4cb in llvm::FPPassManager::doFinalization (this=0x18ed1ac0, M=...)
      at /store/dev/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1697
  #13 0x0000000005edd9fd in (anonymous namespace)::MPPassManager::runOnModule (this=0x162b8150, M=...)
      at /store/dev/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1773
  #14 0x0000000005eddf34 in llvm::legacy::PassManagerImpl::run (this=0x1a07c230, M=...)
      at /store/dev/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1857
  #15 0x0000000005ede163 in llvm::legacy::PassManager::run (this=0x7fffffffaf60, M=...)
      at /store/dev/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1888
  #16 0x0000000001d9b889 in ZigLLVMTargetMachineEmitToFile (targ_machine_ref=0xa9f1fe0, module_ref=0xa9f0180, 



  #5  0x00000000049c498a in llvm::CodeViewDebug::getTypeIndexForThisPtr (this=0x1c865190, TypeRef=..., SubroutineTy=0xb640010)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:2419
  2419      TypeIndex TI = lowerTypePointer(cast<DIDerivedType>(Ty), Options);
  (gdb) p Ty->dump()
  <0xa9f98a8> = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
  $3 = void



  #8  0x00000000049b9e70 in llvm::CodeViewDebug::getFuncIdForSubprogram (this=0x1c865190, SP=0x1cc572c0)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:355
  355                                    DisplayName);
  (gdb) p DisplayName
  $4 = {static npos = 18446744073709551615, Data = 0x1c985700 "StructWithNoFields_add", Length = 22}



  #9  0x00000000049bddc1 in llvm::CodeViewDebug::emitDebugInfoForFunction (this=0x1c865190, GV=0x1c95d228, FI=...)
      at /store/dev/llvm-project/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:1011
  1011        OS.EmitIntValue(getFuncIdForSubprogram(GV->getSubprogram()).getIndex(), 4);
  (gdb) p GV->getSubprogram()
  $5 = (llvm::DISubprogram *) 0x1cc572c0
  (gdb) p GV->getSubprogram()->dump()
  <0x1cc572c0> = distinct !DISubprogram(name: "StructWithNoFields_add", scope: <0x176a1b38>, file: <0xb1bf220>, line: 7, type: <0xb640010>, scopeLine: 7, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: <0xa9b7098>, retainedNodes: <0x1c87f3b0>)
  $6 = void

Relevant excerpt from the module IR:

  ; Function Attrs: nobuiltin nounwind uwtable
  define internal fastcc i32 @StructWithNoFields_add(i32, i32) unnamed_addr #0 !dbg !12316 {
  Entry:
    %a = alloca i32, align 4
    %b = alloca i32, align 4
    store i32 %0, i32* %a, align 4
    call void @llvm.dbg.declare(metadata i32* %a, metadata !12319, metadata !DIExpression()), !dbg !12322
    store i32 %1, i32* %b, align 4
    call void @llvm.dbg.declare(metadata i32* %b, metadata !12320, metadata !DIExpression()), !dbg !12323
    %2 = load i32, i32* %a, align 4, !dbg !12324
    %3 = load i32, i32* %b, align 4, !dbg !12327
    %4 = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %2, i32 %3), !dbg !12328
    %5 = extractvalue { i32, i1 } %4, 0, !dbg !12328
    %6 = extractvalue { i32, i1 } %4, 1, !dbg !12328
    br i1 %6, label %OverflowFail, label %OverflowOk, !dbg !12328
  
  OverflowFail:                                     ; preds = %Entry
    tail call fastcc void @panic(%"[]u8"* @1141, %StackTrace* null), !dbg !12328
    unreachable, !dbg !12328
  
  OverflowOk:                                       ; preds = %Entry
    ret i32 %5, !dbg !12329
  }
  
  attributes #0 = { nobuiltin nounwind uwtable "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" }
  
  
  !1089 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)
  !12316 = distinct !DISubprogram(name: "StructWithNoFields_add", scope: !12317, file: !621, line: 7, type: !4560, scopeLine: 7, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !1, retainedNodes: !12318)
  !12317 = !DICompositeType(tag: DW_TAG_structure_type, name: "StructWithNoFields", scope: !621, file: !621, line: 6, elements: !1259)
  !12318 = !{!12319, !12320}
  !12319 = !DILocalVariable(name: "a", arg: 1, scope: !12316, file: !621, line: 7, type: !1089)
  !12320 = !DILocalVariable(name: "b", arg: 2, scope: !12321, file: !621, line: 7, type: !1089)

The same debug info, when using DWARF instead of CodeView, builds successfully.

Any clues as to something I'm doing wrong, or is this a regression in LLVM?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54667/new/

https://reviews.llvm.org/D54667





More information about the llvm-commits mailing list