[PATCH] D158441: [DXILBitcodeWriter] Fix handling of an unspecified lower bound in DISubrange
Justin Bogner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 14:31:23 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7f3b238fdc3: [DXILBitcodeWriter] Fix handling of an unspecified lower bound in DISubrange (authored by bogner).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158441/new/
https://reviews.llvm.org/D158441
Files:
llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
llvm/test/tools/dxil-dis/di-subrange.ll
Index: llvm/test/tools/dxil-dis/di-subrange.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/dxil-dis/di-subrange.ll
@@ -0,0 +1,28 @@
+; RUN: llc --filetype=obj %s -o - | dxil-dis -o - | FileCheck %s
+target triple = "dxil-unknown-shadermodel6.7-library"
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+
+!0 = !{i32 7, !"Dwarf Version", i32 2}
+!1 = !{i32 2, !"Debug Info Version", i32 3}
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "xyz", isOptimized: true, runtimeVersion: 0, emissionKind: 1, retainedTypes: !4)
+!3 = !DIFile(filename: "input.hlsl", directory: "/some/path")
+!4 = !{!5}
+!5 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 128, flags: DIFlagVector, elements: !7)
+!6 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
+!7 = !{!8}
+!8 = !DISubrange(count: 3)
+
+; CHECK: !llvm.module.flags = !{!0, !1}
+; CHECK: !llvm.dbg.cu = !{!2}
+
+; CHECK: !0 = !{i32 7, !"Dwarf Version", i32 2}
+; CHECK: !1 = !{i32 2, !"Debug Info Version", i32 3}
+; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "xyz", isOptimized: true, runtimeVersion: 0, emissionKind: 1, retainedTypes: !4)
+; CHECK: !3 = !DIFile(filename: "input.hlsl", directory: "/some/path")
+; CHECK: !4 = !{!5}
+; CHECK: !5 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 128, flags: DIFlagVector, elements: !7)
+; CHECK: !6 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
+; CHECK: !7 = !{!8}
+; CHECK: !8 = !DISubrange(count: 3)
Index: llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
===================================================================
--- llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+++ llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
@@ -1392,17 +1392,23 @@
return I < 0 ? ~(U << 1) : U << 1;
}
-static uint64_t rotateSign(DISubrange::BoundType Val) {
- return rotateSign(Val.get<ConstantInt *>()->getValue());
-}
-
void DXILBitcodeWriter::writeDISubrange(const DISubrange *N,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
Record.push_back(N->isDistinct());
+
+ // TODO: Do we need to handle DIExpression here? What about cases where Count
+ // isn't specified but UpperBound and such are?
+ ConstantInt *Count = N->getCount().dyn_cast<ConstantInt *>();
+ assert(Count && "Count is missing or not ConstantInt");
+ Record.push_back(Count->getValue().getSExtValue());
+
+ // TODO: Similarly, DIExpression is allowed here now
+ DISubrange::BoundType LowerBound = N->getLowerBound();
+ assert((LowerBound.isNull() || LowerBound.is<ConstantInt *>()) &&
+ "Lower bound provided but not ConstantInt");
Record.push_back(
- N->getCount().get<ConstantInt *>()->getValue().getSExtValue());
- Record.push_back(rotateSign(N->getLowerBound()));
+ LowerBound ? rotateSign(LowerBound.get<ConstantInt *>()->getValue()) : 0);
Stream.EmitRecord(bitc::METADATA_SUBRANGE, Record, Abbrev);
Record.clear();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158441.552137.patch
Type: text/x-patch
Size: 3143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230821/4d518937/attachment.bin>
More information about the llvm-commits
mailing list