[llvm] 101216d - Revert "Emit DW_OP_lit0/1 for constant boolean values" (#156172)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 30 04:44:25 PDT 2025


Author: Michael Buch
Date: 2025-08-30T11:44:21Z
New Revision: 101216dfdd88a716bfe2bf734e7c94c8fe227f1d

URL: https://github.com/llvm/llvm-project/commit/101216dfdd88a716bfe2bf734e7c94c8fe227f1d
DIFF: https://github.com/llvm/llvm-project/commit/101216dfdd88a716bfe2bf734e7c94c8fe227f1d.diff

LOG: Revert "Emit DW_OP_lit0/1 for constant boolean values" (#156172)

Reverts llvm/llvm-project#155539

Failing on buildbots with:
```
Step 7 (test-build-stage1-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: DebugInfo/debug-bool-const-location.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll -O3 -filetype=obj -o - | /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llvm-dwarfdump - | /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll # RUN: at line 2
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llc /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll -O3 -filetype=obj -o -
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/llvm-dwarfdump -
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage1/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll:7:10: error: CHECK: expected string not found in input
; CHECK: {{.*}} DW_OP_lit0
         ^
<stdin>:27:54: note: scanning from here
 [0x0000000000000018, 0x0000000000000020): DW_OP_lit1, DW_OP_stack_value
                                                     ^
<stdin>:28:41: note: possible intended match here
 [0x0000000000000020, 0x0000000000000034): DW_OP_reg3 X3)
                                        ^

Input file: <stdin>
Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/test/DebugInfo/debug-bool-const-location.ll

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           .
           .
           .
          22:  DW_AT_decl_line (5) 
          23:  DW_AT_external (true) 
          24:  
          25: 0x0000003f: DW_TAG_variable 
          26:  DW_AT_location (0x00000000:  
          27:  [0x0000000000000018, 0x0000000000000020): DW_OP_lit1, DW_OP_stack_value 
check:7'0                                                          X~~~~~~~~~~~~~~~~~~~ error: no match found
          28:  [0x0000000000000020, 0x0000000000000034): DW_OP_reg3 X3) 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:7'1                                             ?                  possible intended match
          29:  DW_AT_name ("arg") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~
          30:  DW_AT_decl_file ("test") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
          31:  DW_AT_decl_line (5) 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~
          32:  DW_AT_type (0x0000004f "bool") 
check:7'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          33:  
check:7'0     ~
           .
```

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
    llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h

Removed: 
    llvm/test/DebugInfo/debug-bool-const-location.ll


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2090157a1a91c..c27f100775625 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3111,10 +3111,8 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
                             &AP](const DbgValueLocEntry &Entry,
                                  DIExpressionCursor &Cursor) -> bool {
     if (Entry.isInt()) {
-      if (BT && (BT->getEncoding() == dwarf::DW_ATE_boolean))
-        DwarfExpr.addBooleanConstant(Entry.getInt());
-      else if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
-                      BT->getEncoding() == dwarf::DW_ATE_signed_char))
+      if (BT && (BT->getEncoding() == dwarf::DW_ATE_signed ||
+                 BT->getEncoding() == dwarf::DW_ATE_signed_char))
         DwarfExpr.addSignedConstant(Entry.getInt());
       else
         DwarfExpr.addUnsignedConstant(Entry.getInt());

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index 8a30714db2fdf..e684054ffa3e4 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -194,15 +194,6 @@ void DwarfExpression::addStackValue() {
     emitOp(dwarf::DW_OP_stack_value);
 }
 
-void DwarfExpression::addBooleanConstant(int64_t Value) {
-  assert(isImplicitLocation() || isUnknownLocation());
-  LocationKind = Implicit;
-  if (Value == 0)
-    emitOp(dwarf::DW_OP_lit0);
-  else
-    emitOp(dwarf::DW_OP_lit1);
-}
-
 void DwarfExpression::addSignedConstant(int64_t Value) {
   assert(isImplicitLocation() || isUnknownLocation());
   LocationKind = Implicit;

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 700e0ec5813ee..06809ab263875 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -229,9 +229,6 @@ class DwarfExpression {
   /// This needs to be called last to commit any pending changes.
   void finalize();
 
-  /// Emit a boolean constant.
-  void addBooleanConstant(int64_t Value);
-
   /// Emit a signed constant.
   void addSignedConstant(int64_t Value);
 

diff  --git a/llvm/test/DebugInfo/debug-bool-const-location.ll b/llvm/test/DebugInfo/debug-bool-const-location.ll
deleted file mode 100644
index a3e3529d9b5e5..0000000000000
--- a/llvm/test/DebugInfo/debug-bool-const-location.ll
+++ /dev/null
@@ -1,48 +0,0 @@
-; REQUIRES: object-emission
-; RUN: %llc_dwarf %s -O3 -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
-
-; CHECK: {{.*}}DW_TAG_variable
-; CHECK: {{.*}} DW_OP_lit1
-; CHECK-NOT: {{.*}} DW_OP_lit0, DW_OP_not
-; CHECK: {{.*}} DW_OP_lit0
-; CHECK: {{.*}} DW_AT_name    ("arg")
-
-define void @foo(i8 %"arg.arg") !dbg !5
-{
-entry:
-  %".4" = alloca i1
-  %".5" = icmp eq i8 %"arg.arg", 0
-  %arg = alloca i1
-  br i1 %".5", label %"entry.if", label %"entry.else"
-entry.if:
-  store i1 false, i1* %arg
-  call void @"llvm.dbg.value"(metadata i1 false , metadata !9, metadata !10), !dbg !6
-  br label %"entry.endif"
-entry.else:
-  store i1 true, i1* %arg
-  call void @"llvm.dbg.value"(metadata i1 true , metadata !9, metadata !10), !dbg !7
-  br label %"entry.endif"
-entry.endif:
-  %".11" = load i1, i1* %arg
-  store i1 %".11", i1* %".4", !dbg !8
-  call void @"llvm.dbg.value"(metadata i1 %".11" , metadata !9, metadata !10), !dbg !8
-  ret void, !dbg !8
-}
-
-declare void @"llvm.dbg.value"(metadata %".1", metadata %".2", metadata %".3")
-
-!llvm.dbg.cu = !{ !2 }
-!llvm.module.flags = !{ !11, !12 }
-
-!1 = !DIFile(directory: "", filename: "test")
-!2 = distinct !DICompileUnit(emissionKind: FullDebug, file: !1, isOptimized: false, language: DW_LANG_C_plus_plus, runtimeVersion: 0)
-!3 = !DIBasicType(encoding: DW_ATE_boolean, name: "bool", size: 8)
-!4 = !DISubroutineType(types: !{null})
-!5 = distinct !DISubprogram(file: !1, isDefinition: true, isLocal: false, isOptimized: false, line: 5, linkageName: "foo", name: "foo", scope: !1, scopeLine: 5, type: !4, unit: !2)
-!6 = !DILocation(column: 1, line: 5, scope: !5)
-!7 = !DILocation(column: 1, line: 7, scope: !5)
-!8 = !DILocation(column: 1, line: 8, scope: !5)
-!9 = !DILocalVariable(arg: 0, file: !1, line: 5, name: "arg", scope: !5, type: !3)
-!10 = !DIExpression()
-!11 = !{ i32 2, !"Dwarf Version", i32 4 }
-!12 = !{ i32 2, !"Debug Info Version", i32 3 }


        


More information about the llvm-commits mailing list