[llvm] r336452 - [Debugify] Allow unsigned values narrower than their variables

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 6 10:32:41 PDT 2018


Author: vedantk
Date: Fri Jul  6 10:32:40 2018
New Revision: 336452

URL: http://llvm.org/viewvc/llvm-project?rev=336452&view=rev
Log:
[Debugify] Allow unsigned values narrower than their variables

Suppress the diagnostic for mis-sized dbg.values when a value operand is
narrower than the unsigned variable it describes. Assume that a debugger
would implicitly zero-extend these values.

Modified:
    llvm/trunk/test/DebugInfo/debugify-bogus-dbg-value.ll
    llvm/trunk/tools/opt/Debugify.cpp

Modified: llvm/trunk/test/DebugInfo/debugify-bogus-dbg-value.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify-bogus-dbg-value.ll?rev=336452&r1=336451&r2=336452&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify-bogus-dbg-value.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify-bogus-dbg-value.ll Fri Jul  6 10:32:40 2018
@@ -16,6 +16,10 @@ define <2 x i64> @test-fun(<2 x i64> %A)
 ; CHECK-NOT: ERROR: dbg.value operand has size 512, but its variable has size 256
   call void @llvm.dbg.value(metadata i512 0, metadata !12, metadata !DIExpression()), !dbg !15
 
+; Assume the debugger implicitly zero-extends unsigned values.
+; CHECK-NOT: ERROR: dbg.value operand has size 4, but its variable has size 32
+  call void @llvm.dbg.value(metadata i8 0, metadata !17, metadata !DIExpression()), !dbg !15
+
   ret <2 x i64> %and, !dbg !16
 }
 ; CHECK: CheckModuleDebugify: FAIL
@@ -33,20 +37,23 @@ attributes #0 = { nounwind readnone spec
 !1 = !DIFile(filename: "/Users/vsk/src/llvm.org-master/llvm/test/DebugInfo/debugify-bogus-dbg-value.ll", directory: "/")
 !2 = !{}
 !3 = !{i32 4}
-!4 = !{i32 3}
+!4 = !{i32 4}
 !5 = !{i32 2, !"Debug Info Version", i32 3}
 !6 = distinct !DISubprogram(name: "test-fun", linkageName: "test-fun", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !8)
 !7 = !DISubroutineType(types: !2)
 !8 = !{!9, !11, !12}
 !9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 1, type: !10)
-!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
+!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_signed)
 !11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 2, type: !10)
 !12 = !DILocalVariable(name: "3", scope: !6, file: !1, line: 3, type: !13)
 
 ; Set the size here to an incorrect value to check that the size diagnostic
 ; triggers.
-!13 = !DIBasicType(name: "ty128", size: 256, encoding: DW_ATE_unsigned)
+!13 = !DIBasicType(name: "ty128", size: 256, encoding: DW_ATE_signed)
 
 !14 = !DILocation(line: 2, column: 1, scope: !6)
 !15 = !DILocation(line: 3, column: 1, scope: !6)
 !16 = !DILocation(line: 4, column: 1, scope: !6)
+
+!17 = !DILocalVariable(name: "4", scope: !6, file: !1, line: 3, type: !18)
+!18 = !DIBasicType(name: "ty32_unsigned", size: 32, encoding: DW_ATE_unsigned)

Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=336452&r1=336451&r2=336452&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Fri Jul  6 10:32:40 2018
@@ -188,8 +188,15 @@ bool diagnoseMisSizedDbgValue(Module &M,
   if (!ValueOperandSize || !DbgVarSize)
     return false;
 
-  bool HasBadSize = Ty->isIntegerTy() ? (ValueOperandSize < *DbgVarSize)
-                                      : (ValueOperandSize != *DbgVarSize);
+  bool HasBadSize = false;
+  if (Ty->isIntegerTy()) {
+    auto Signedness = DVI->getVariable()->getSignedness();
+    if (Signedness && *Signedness == DIBasicType::Signedness::Signed)
+      HasBadSize = ValueOperandSize < *DbgVarSize;
+  } else {
+    HasBadSize = ValueOperandSize != *DbgVarSize;
+  }
+
   if (HasBadSize) {
     dbg() << "ERROR: dbg.value operand has size " << ValueOperandSize
           << ", but its variable has size " << *DbgVarSize << ": ";




More information about the llvm-commits mailing list