[llvm] improve debug messages in delinearization and dependence analysis (PR #156339)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 03:11:02 PDT 2025
================
@@ -787,22 +805,38 @@ void printDelinearization(raw_ostream &O, Function *F, LoopInfo *LI,
SE->getElementSize(&Inst));
}
- if (IsDelinearizationFailed()) {
- O << "failed to delinearize\n";
- continue;
- }
+ if (IsDelinearizationFailed()) {
+ O << "failed to delinearize\n";
+ continue;
+ }
- O << "Base offset: " << *BasePointer << "\n";
- O << "ArrayDecl[UnknownSize]";
- int Size = Subscripts.size();
- for (int i = 0; i < Size - 1; i++)
+ O << "Base offset: " << *BasePointer << "\n";
+ O << "ArrayDecl";
+
+ // Print [Unknown] when the outermost dimension of the array is not known.
+ // Sizes[NumSizes - 1] is the array element size.
+ int NumSubscripts = Subscripts.size();
+ int NumSizes = Sizes.size();
+ if (NumSizes == NumSubscripts)
+ O << "[UnknownSize]";
+
+ // Handle different size relationships between Subscripts and Sizes.
+ if (NumSizes > 0) {
+ // Print array dimensions (all but the last size, which is element
+ // size).
+ for (int i = 0; i < NumSizes - 1; i++)
O << "[" << *Sizes[i] << "]";
- O << " with elements of " << *Sizes[Size - 1] << " bytes.\n";
- O << "ArrayRef";
- for (int i = 0; i < Size; i++)
- O << "[" << *Subscripts[i] << "]";
- O << "\n";
+ // Print element size (last element in Sizes array).
+ O << " with elements of " << *Sizes[NumSizes - 1] << " bytes.\n";
+ } else {
+ O << " unknown sizes.\n";
+ }
+
+ O << "ArrayRef";
+ for (int i = 0; i < NumSubscripts; i++)
+ O << "[" << *Subscripts[i] << "]";
+ O << "\n";
----------------
kasuga-fj wrote:
These changes don't seem relevant to "improve debug messages". Especially, if I understand correctly, the condition `NumSizes == NumSubscripts` is always true in the current implementation. If these changes are necessary for later PRs, it would be better to move them to those PRs.
https://github.com/llvm/llvm-project/pull/156339
More information about the llvm-commits
mailing list