[llvm] r261010 - [codeview] Fix assertion on non-memory, non-register DBG_VALUE instructions

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 13:14:51 PST 2016


Author: rnk
Date: Tue Feb 16 15:14:51 2016
New Revision: 261010

URL: http://llvm.org/viewvc/llvm-project?rev=261010&view=rev
Log:
[codeview] Fix assertion on non-memory, non-register DBG_VALUE instructions

Eventually we should find a way to describe constant variables, but it
is not obvious how to do this at the moment.

Added:
    llvm/trunk/test/DebugInfo/COFF/local-constant.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=261010&r1=261009&r2=261010&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Tue Feb 16 15:14:51 2016
@@ -594,6 +594,13 @@ void CodeViewDebug::collectVariableInfo(
       if (DIExpr && DIExpr->getNumElements() > 0)
         continue;
 
+      // Bail if the value is not indirect in memory or in a register. In these
+      // cases, operand 0 will not be a register.
+      // FIXME: CodeView does not have an obvious representation for a variable
+      // that has been optimized to be a constant.
+      if (!DVInst->getOperand(0).isReg())
+        continue;
+
       // Handle the two cases we can handle: indirect in memory and in register.
       bool IsIndirect = DVInst->getOperand(1).isImm();
       unsigned CVReg = TRI->getCodeViewRegNum(DVInst->getOperand(0).getReg());

Added: llvm/trunk/test/DebugInfo/COFF/local-constant.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/local-constant.ll?rev=261010&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/local-constant.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/local-constant.ll Tue Feb 16 15:14:51 2016
@@ -0,0 +1,72 @@
+; RUN: llc -mtriple=x86_64-windows-msvc < %s -filetype=obj | llvm-readobj -codeview - | FileCheck %s --check-prefix=OBJ
+
+; This LL file was generated by running 'clang -g -gcodeview' on the
+; following code:
+; void useint(int);
+; void constant_var() {
+;   int x = 42;
+;   useint(x);
+;   useint(x);
+; }
+
+; FIXME: Find a way to describe variables optimized to constants.
+
+; OBJ:        ProcStart {
+; OBJ:           DisplayName: constant_var
+; OBJ:         }
+; OBJ:         Local {
+; OBJ-NEXT:      Type: int (0x74)
+; OBJ-NEXT:      Flags [ (0x100)
+; OBJ-NEXT:        IsOptimizedOut (0x100)
+; OBJ-NEXT:      ]
+; OBJ-NEXT:      VarName: x
+; OBJ-NEXT:    }
+; OBJ-NOT:     DefRange
+; OBJ:         ProcEnd
+
+; ModuleID = 't.cpp'
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc18.0.0"
+
+; Function Attrs: nounwind uwtable
+define void @"\01?constant_var@@YAXXZ"() #0 !dbg !4 {
+entry:
+  tail call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !8, metadata !14), !dbg !15
+  tail call void @"\01?useint@@YAXH at Z"(i32 42) #3, !dbg !16
+  tail call void @"\01?useint@@YAXH at Z"(i32 42) #3, !dbg !17
+  ret void, !dbg !18
+}
+
+declare void @"\01?useint@@YAXH at Z"(i32) #1
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
+
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { nounwind readnone }
+attributes #3 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!10, !11, !12}
+!llvm.ident = !{!13}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 260957)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
+!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
+!2 = !{}
+!3 = !{!4}
+!4 = distinct !DISubprogram(name: "constant_var", linkageName: "\01?constant_var@@YAXXZ", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, variables: !7)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
+!7 = !{!8}
+!8 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 3, type: !9)
+!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!10 = !{i32 2, !"CodeView", i32 1}
+!11 = !{i32 2, !"Debug Info Version", i32 3}
+!12 = !{i32 1, !"PIC Level", i32 2}
+!13 = !{!"clang version 3.9.0 (trunk 260957)"}
+!14 = !DIExpression()
+!15 = !DILocation(line: 3, column: 7, scope: !4)
+!16 = !DILocation(line: 4, column: 3, scope: !4)
+!17 = !DILocation(line: 5, column: 3, scope: !4)
+!18 = !DILocation(line: 6, column: 1, scope: !4)




More information about the llvm-commits mailing list