[llvm] [DirectX] Emit unresolved ptr as i8* (PR #192086)
Harald van Dijk via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 09:53:22 PDT 2026
https://github.com/hvdijk created https://github.com/llvm/llvm-project/pull/192086
None
>From c1564d9b75b7e126c4c559794a1cd125fccd537e Mon Sep 17 00:00:00 2001
From: Harald van Dijk <hdijk at accesssoftek.com>
Date: Tue, 14 Apr 2026 17:40:04 +0100
Subject: [PATCH] [DirectX] Emit unresolved ptr as i8*
---
.../Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp | 4 ++++
llvm/test/CodeGen/DirectX/global-variable.ll | 6 ++++++
2 files changed, 10 insertions(+)
create mode 100644 llvm/test/CodeGen/DirectX/global-variable.ll
diff --git a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
index 4309e29e1440d..dd2037277e460 100644
--- a/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
+++ b/llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp
@@ -81,8 +81,12 @@ Type *classifyPointerType(const Value *V, PointerTypeMap &Map) {
}
}
// If we were unable to determine the pointee type, set to i8
+ // If we were able to determine the pointee type as ptr, set to i8*
if (!PointeeTy)
PointeeTy = Type::getInt8Ty(V->getContext());
+ if (PointeeTy->isPointerTy())
+ PointeeTy = TypedPointerType::get(Type::getInt8Ty(V->getContext()),
+ PointeeTy->getPointerAddressSpace());
auto *TypedPtrTy =
TypedPointerType::get(PointeeTy, V->getType()->getPointerAddressSpace());
diff --git a/llvm/test/CodeGen/DirectX/global-variable.ll b/llvm/test/CodeGen/DirectX/global-variable.ll
new file mode 100644
index 0000000000000..66f3117f86314
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/global-variable.ll
@@ -0,0 +1,6 @@
+; RUN: llc -mtriple=dxil-pc-shadermodel6.3-library --filetype=obj -o %t.dxbc %s
+; RUN: llvm-objcopy --dump-section=DXIL=%t.bc %t.dxbc
+; RUN: llvm-dis -o - %t.bc | FileCheck %s
+
+; CHECK: @foo = common global ptr null
+ at foo = common global ptr null
More information about the llvm-commits
mailing list