[llvm] 97bd838 - [llvm][DebugInfo] Allow anonymous basic types (#180016)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 07:07:46 PST 2026
Author: Tom Tromey
Date: 2026-02-12T08:07:42-07:00
New Revision: 97bd838eead62836cd07dcf0c68dba636cbe7bea
URL: https://github.com/llvm/llvm-project/commit/97bd838eead62836cd07dcf0c68dba636cbe7bea
DIFF: https://github.com/llvm/llvm-project/commit/97bd838eead62836cd07dcf0c68dba636cbe7bea.diff
LOG: [llvm][DebugInfo] Allow anonymous basic types (#180016)
For the Ada compiler, it is sometimes useful to emit an anonymous basic
type. Currently, this is prohibited by DIBuilder, but there doesn't seem
to be a deep reason for this prohibition -- DWARF allows anonymous base
types, and the LLVM DWARF writer also accounts for this possibility.
Added:
llvm/test/DebugInfo/Generic/anonymous-base-type.ll
Modified:
llvm/lib/IR/DIBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 38cf3f552b83d..54e80806245e0 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -276,7 +276,6 @@ DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
DINode::DIFlags Flags,
uint32_t NumExtraInhabitants,
uint32_t DataSizeInBits) {
- assert(!Name.empty() && "Unable to create type without name");
return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
0, Encoding, NumExtraInhabitants, DataSizeInBits,
Flags);
diff --git a/llvm/test/DebugInfo/Generic/anonymous-base-type.ll b/llvm/test/DebugInfo/Generic/anonymous-base-type.ll
new file mode 100644
index 0000000000000..a9ae51fb81fda
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/anonymous-base-type.ll
@@ -0,0 +1,23 @@
+;; Check that a base type can be anonymous.
+
+; Use llvm-dis here to check round-tripping.
+; RUN: llvm-as < %s | llvm-dis | llc -O0 -filetype=obj -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
+
+; CHECK: DW_TAG_base_type
+; CHECK-NOT: DW_AT_name
+; CHECK: DW_AT_encoding
+; CHECK-NEXT: DW_AT_byte_size
+
+; ModuleID = 'subrange_type.ll'
+source_filename = "/dir/anonymous-base-type.adb"
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !{i32 2, !"Dwarf Version", i32 4}
+!2 = distinct !DICompileUnit(language: DW_LANG_Ada95, file: !3, producer: "GNAT/LLVM", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !4, imports: !4)
+!3 = !DIFile(filename: "subrange_type.adb", directory: "/dir")
+!4 = !{}
+!5 = !{!6}
+!6 = !DIBasicType(size: 32, encoding: DW_ATE_signed)
More information about the llvm-commits
mailing list