[llvm] 34435fd - [llvm] Add support for DW_TAG_immutable_type
Luís Ferreira via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 5 11:19:03 PST 2022
Author: Luís Ferreira
Date: 2022-01-05T19:17:08Z
New Revision: 34435fd1053783c325ca2f57258d715045531168
URL: https://github.com/llvm/llvm-project/commit/34435fd1053783c325ca2f57258d715045531168
DIFF: https://github.com/llvm/llvm-project/commit/34435fd1053783c325ca2f57258d715045531168.diff
LOG: [llvm] Add support for DW_TAG_immutable_type
Added documentation about DW_TAG_immutable_type too.
Reviewed By: probinson
Differential Revision: https://reviews.llvm.org/D113633
Added:
llvm/test/DebugInfo/dwarfdump-immutable.ll
Modified:
llvm/docs/LangRef.rst
llvm/docs/SourceLevelDebugging.rst
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 389c90937bb00..d8fd7da7ce77a 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5328,6 +5328,7 @@ The following ``tag:`` values are valid:
DW_TAG_volatile_type = 53
DW_TAG_restrict_type = 55
DW_TAG_atomic_type = 71
+ DW_TAG_immutable_type = 75
.. _DIDerivedTypeMember:
@@ -5344,8 +5345,8 @@ friends.
``DW_TAG_typedef`` is used to provide a name for the ``baseType:``.
``DW_TAG_pointer_type``, ``DW_TAG_reference_type``, ``DW_TAG_const_type``,
-``DW_TAG_volatile_type``, ``DW_TAG_restrict_type`` and ``DW_TAG_atomic_type``
-are used to qualify the ``baseType:``.
+``DW_TAG_volatile_type``, ``DW_TAG_restrict_type``, ``DW_TAG_atomic_type`` and
+``DW_TAG_immutable_type`` are used to qualify the ``baseType:``.
Note that the ``void *`` type is expressed as a type derived from NULL.
diff --git a/llvm/docs/SourceLevelDebugging.rst b/llvm/docs/SourceLevelDebugging.rst
index b3647efe2f146..e4a529d0e2424 100644
--- a/llvm/docs/SourceLevelDebugging.rst
+++ b/llvm/docs/SourceLevelDebugging.rst
@@ -1881,6 +1881,7 @@ tag is one of:
* DW_TAG_subrange_type
* DW_TAG_base_type
* DW_TAG_const_type
+* DW_TAG_immutable_type
* DW_TAG_file_type
* DW_TAG_namelist
* DW_TAG_packed_type
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 4df34d2c94020..18fc46c74eb47 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -155,7 +155,8 @@ uint64_t DebugHandlerBase::getBaseTypeSize(const DIType *Ty) {
if (Tag != dwarf::DW_TAG_member && Tag != dwarf::DW_TAG_typedef &&
Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type &&
- Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_atomic_type)
+ Tag != dwarf::DW_TAG_restrict_type && Tag != dwarf::DW_TAG_atomic_type &&
+ Tag != dwarf::DW_TAG_immutable_type)
return DDTy->getSizeInBits();
DIType *BaseType = DDTy->getBaseType();
@@ -210,7 +211,8 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
return true;
assert(T == dwarf::DW_TAG_typedef || T == dwarf::DW_TAG_const_type ||
T == dwarf::DW_TAG_volatile_type ||
- T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type);
+ T == dwarf::DW_TAG_restrict_type || T == dwarf::DW_TAG_atomic_type ||
+ T == dwarf::DW_TAG_immutable_type);
assert(DTy->getBaseType() && "Expected valid base type");
return isUnsignedDIType(DTy->getBaseType());
}
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 4cc146e086f9c..30ff1e7fdaf3c 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -124,6 +124,7 @@ static bool isTypeTag(uint16_t Tag) {
case dwarf::DW_TAG_interface_type:
case dwarf::DW_TAG_unspecified_type:
case dwarf::DW_TAG_shared_type:
+ case dwarf::DW_TAG_immutable_type:
return true;
default:
break;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 95135c95e8d2e..34c42025109de 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -1098,6 +1098,7 @@ static Optional<uint64_t> getTypeSize(DWARFDie Type, uint64_t PointerSize) {
return PointerSize;
}
case DW_TAG_const_type:
+ case DW_TAG_immutable_type:
case DW_TAG_volatile_type:
case DW_TAG_restrict_type:
case DW_TAG_typedef: {
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 46da9cfbc6b5e..254d7b2fdff49 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1059,6 +1059,7 @@ void Verifier::visitDIDerivedType(const DIDerivedType &N) {
N.getTag() == dwarf::DW_TAG_reference_type ||
N.getTag() == dwarf::DW_TAG_rvalue_reference_type ||
N.getTag() == dwarf::DW_TAG_const_type ||
+ N.getTag() == dwarf::DW_TAG_immutable_type ||
N.getTag() == dwarf::DW_TAG_volatile_type ||
N.getTag() == dwarf::DW_TAG_restrict_type ||
N.getTag() == dwarf::DW_TAG_atomic_type ||
diff --git a/llvm/test/DebugInfo/dwarfdump-immutable.ll b/llvm/test/DebugInfo/dwarfdump-immutable.ll
new file mode 100644
index 0000000000000..e9cd8015e1e09
--- /dev/null
+++ b/llvm/test/DebugInfo/dwarfdump-immutable.ll
@@ -0,0 +1,34 @@
+;; This test checks whether DWARF tag DW_TAG_immutable_type
+;; is accepted and processed.
+
+; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
+
+;; Test whether DW_TAG_immutable_type is accepted.
+
+; CHECK: DW_TAG_immutable_type
+
+; ModuleID = 'immutable.d'
+source_filename = "immutable.d"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+
+ at _D9immutable1aya = constant i8 97, align 1, !dbg !0 ; [#uses = 0]
+
+!llvm.module.flags = !{!5}
+!llvm.dbg.cu = !{!6}
+!llvm.ident = !{!13}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "a", linkageName: "_D9immutable1aya", scope: !2, file: !3, line: 1, type: !4, isLocal: false, isDefinition: true)
+!2 = !DIModule(scope: !3, name: "immutable")
+!3 = !DIFile(filename: "immutable.d", directory: "/home/luis/Temp")
+!4 = !DIDerivedType(tag: DW_TAG_immutable_type, baseType: !14)
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DICompileUnit(language: DW_LANG_D, file: !3, producer: "LDC 1.28.0 (LLVM 13.0.0)", isOptimized: false, runtimeVersion: 1, emissionKind: FullDebug, enums: !7, globals: !8, imports: !9)
+!7 = !{}
+!8 = !{!0}
+!9 = !{!10}
+!10 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !2, entity: !11, file: !3)
+!11 = !DIModule(scope: !12, name: "object")
+!12 = !DIFile(filename: "usr/include/dlang/ldc/object.d", directory: "/")
+!13 = !{!"ldc version 1.28.0"}
+!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_UTF)
More information about the llvm-commits
mailing list