[llvm] DXIL: Use correct type ID when writing ValueAsMetadata. (PR #94337)
Tim Besard via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 02:47:56 PDT 2024
https://github.com/maleadt updated https://github.com/llvm/llvm-project/pull/94337
>From 2276f7ecb67e26ec37d99946e6b4f3dda682b30e Mon Sep 17 00:00:00 2001
From: Tim Besard <tim.besard at gmail.com>
Date: Tue, 4 Jun 2024 13:05:50 +0200
Subject: [PATCH] DXIL: Use correct type ID when writing ValueAsMetadata.
---
.../Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp | 2 +-
llvm/test/tools/dxil-dis/metadata.ll | 10 +++++++++-
llvm/tools/dxil-dis/CMakeLists.txt | 4 +++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
index cd0d6d34e9a67b..45aadac861946b 100644
--- a/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
+++ b/llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp
@@ -1345,7 +1345,7 @@ void DXILBitcodeWriter::writeValueAsMetadata(
Ty = TypedPointerType::get(F->getFunctionType(), F->getAddressSpace());
else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
Ty = TypedPointerType::get(GV->getValueType(), GV->getAddressSpace());
- Record.push_back(getTypeID(Ty));
+ Record.push_back(getTypeID(Ty, V));
Record.push_back(VE.getValueID(V));
Stream.EmitRecord(bitc::METADATA_VALUE, Record, 0);
Record.clear();
diff --git a/llvm/test/tools/dxil-dis/metadata.ll b/llvm/test/tools/dxil-dis/metadata.ll
index 758860a2deb8f9..18f2530ab8fc27 100644
--- a/llvm/test/tools/dxil-dis/metadata.ll
+++ b/llvm/test/tools/dxil-dis/metadata.ll
@@ -1,13 +1,21 @@
-; RUN: llc --filetype=obj %s -o - | dxil-dis
+; RUN: llc --filetype=obj %s -o - | dxil-dis
target triple = "dxil-unknown-shadermodel6.7-library"
+define void @kernel(ptr addrspace(1)) {
+ ret void
+}
+
!llvm.foo = !{!0}
!llvm.bar = !{!1}
+!llvm.baz = !{!2}
!0 = !{i32 42}
!1 = !{!"Some MDString"}
+!2 = !{ptr @kernel}
; CHECK: !llvm.foo = !{!0}
; CHECK: !llvm.bar = !{!1}
+; CHECK: !llvm.baz = !{!2}
; CHECK: !0 = !{i32 42}
; CHECK: !1 = !{!"Some MDString"}
+; CHECK: !2 = !{void (i8 addrspace(1)*)* @kernel}
diff --git a/llvm/tools/dxil-dis/CMakeLists.txt b/llvm/tools/dxil-dis/CMakeLists.txt
index 9addf108a8614e..d0541fcf802e98 100644
--- a/llvm/tools/dxil-dis/CMakeLists.txt
+++ b/llvm/tools/dxil-dis/CMakeLists.txt
@@ -25,7 +25,9 @@ include(ExternalProject)
set(SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/DXC-src)
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/DXC-bins)
-set(GIT_SETTINGS GIT_REPOSITORY https://github.com/microsoft/DirectXShaderCompiler.git)
+set(GIT_SETTINGS
+ GIT_REPOSITORY https://github.com/microsoft/DirectXShaderCompiler.git
+ GIT_TAG main)
if (DXC_SOURCE_DIR)
set(SOURCE_DIR ${DXC_SOURCE_DIR})
More information about the llvm-commits
mailing list