[llvm] [DirectX] Simplify and correct the flattening of GEPs in DXILFlattenArrays (PR #146173)
Deric C. via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 8 10:47:51 PDT 2025
================
@@ -40,18 +41,19 @@ class DXILFlattenArraysLegacy : public ModulePass {
static char ID; // Pass identification.
};
-struct GEPData {
- ArrayType *ParentArrayType;
- Value *ParentOperand;
- SmallVector<Value *> Indices;
- SmallVector<uint64_t> Dims;
- bool AllIndicesAreConstInt;
+struct GEPInfo {
+ ArrayType *RootFlattenedArrayType;
+ Value *RootPointerOperand;
+ SmallMapVector<Value *, APInt, 4> VariableOffsets;
+ APInt ConstantOffset;
};
class DXILFlattenArraysVisitor
: public InstVisitor<DXILFlattenArraysVisitor, bool> {
public:
- DXILFlattenArraysVisitor() {}
+ DXILFlattenArraysVisitor(
+ DenseMap<GlobalVariable *, GlobalVariable *> &GlobalMap)
----------------
Icohedron wrote:
It's necessary because otherwise the `DXILFlattenArraysVisitor` won't have visibility of the `GlobalMap` which comes from a stack-allocated variable here
https://github.com/llvm/llvm-project/blob/db9162dd3c12e9f5e1d28abdfedf9758fd575814/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp#L462-L466
which is necessary to determine the type of the GEP
https://github.com/llvm/llvm-project/blob/db9162dd3c12e9f5e1d28abdfedf9758fd575814/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp#L273-L284
https://github.com/llvm/llvm-project/pull/146173
More information about the llvm-commits
mailing list