[llvm] [DirectX] Emit unresolved ptr as i8* (PR #192086)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 09:53:58 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-directx
Author: Harald van Dijk (hvdijk)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/192086.diff
2 Files Affected:
- (modified) llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp (+4)
- (added) llvm/test/CodeGen/DirectX/global-variable.ll (+6)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/192086
More information about the llvm-commits
mailing list