[llvm] [AMDGPU][LowerBufferFatPointers] Fix lack of rewrite when loading/storing null (PR #154128)
Krzysztof Drewniak via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 07:45:05 PDT 2025
https://github.com/krzysz00 created https://github.com/llvm/llvm-project/pull/154128
Fixes #154056.
The fat buffer lowering pass was erroniously detecting that it did not need to run on functions that only load/store to the null constant (or other such constants). We thought this would be covered by specilaizing constants out to instructions, but that doesn't account foc trivial constants like null. Therefoe, we check the operands of instructions for buffer fat pointers in order to find such constants and ensure the pass runs.
>From e1db6b8efa609e38e8eb2bb5ce50f74a30f9fa0a Mon Sep 17 00:00:00 2001
From: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
Date: Mon, 18 Aug 2025 14:39:17 +0000
Subject: [PATCH] [AMDGPU][LowerBufferFatPointers] Fix lack of rewrite when
loading/storing null
Fixes #154056.
The fat buffer lowering pass was erroniously detecting that it did not
need to run on functions that only load/store to the null constant (or
other such constants). We thought this would be covered by
specilaizing constants out to instructions, but that doesn't account
foc trivial constants like null. Therefoe, we check the operands of
instructions for buffer fat pointers in order to find such constants
and ensure the pass runs.
---
llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
index ed73dc8903908..7090bc8124f9c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
@@ -2366,8 +2366,12 @@ static bool containsBufferFatPointers(const Function &F,
BufferFatPtrToStructTypeMap *TypeMap) {
bool HasFatPointers = false;
for (const BasicBlock &BB : F)
- for (const Instruction &I : BB)
+ for (const Instruction &I : BB) {
HasFatPointers |= (I.getType() != TypeMap->remapType(I.getType()));
+ // Catch null pointer constasts in loads, stores, etc.
+ for (const Value *V : I.operand_values())
+ HasFatPointers |= (V->getType() != TypeMap->remapType(V->getType()));
+ }
return HasFatPointers;
}
More information about the llvm-commits
mailing list