[llvm] [polly] [delinearize] Extract array dimensions from alloca and global declarations (PR #156342)
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 10 15:27:57 PDT 2025
================
@@ -408,6 +425,145 @@ void llvm::computeAccessFunctions(ScalarEvolution &SE, const SCEV *Expr,
});
}
+/// Backward compatibility wrapper for the old 4-parameter version.
+void llvm::computeAccessFunctions(ScalarEvolution &SE, const SCEV *Expr,
+ SmallVectorImpl<const SCEV *> &Subscripts,
+ SmallVectorImpl<const SCEV *> &Sizes) {
+ // Use the element size from the last element in Sizes array (legacy behavior)
+ if (Sizes.empty()) {
+ Subscripts.clear();
+ return;
+ }
+ const SCEV *ElementSize = Sizes.back();
+ computeAccessFunctions(SE, Expr, Subscripts, Sizes, ElementSize);
+}
+
+/// Extract array dimensions from alloca or global variable declarations.
+/// Returns true if array dimensions were successfully extracted.
+static bool
+extractArrayInfoFromAllocaOrGlobal(ScalarEvolution &SE, Value *BasePtr,
+ SmallVectorImpl<const SCEV *> &Sizes,
+ const SCEV *ElementSize) {
+ // Clear output vector.
+ Sizes.clear();
+
+ LLVM_DEBUG(
+ dbgs() << "extractArrayInfoFromAllocaOrGlobal called with BasePtr: "
+ << *BasePtr << "\n");
+
+ // Distinguish between simple array accesses and complex pointer arithmetic.
+ // Only apply array_info extraction to direct array accesses to avoid
----------------
sebpop wrote:
This is a remnant of the previous attempt that was to attach an array_info bundle to assumes. We may want to revive that patch and instead of attaching the array_info bundle to an assume, we will attach the array_info bundles to allocas and to globals. Right now array_info is the same as 'type' of alloca and globals.
https://github.com/llvm/llvm-project/pull/156342
More information about the llvm-commits
mailing list