[PATCH] D149041: [IVDescriptors] Add assert to isInductionPhi to check for invalid Phis
Vedant Paranjape via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 23 23:42:06 PDT 2023
vedant-amd updated this revision to Diff 516282.
vedant-amd edited the summary of this revision.
vedant-amd added a comment.
minor fix to commit message
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149041/new/
https://reviews.llvm.org/D149041
Files:
llvm/include/llvm/Analysis/IVDescriptors.h
llvm/lib/Analysis/IVDescriptors.cpp
Index: llvm/lib/Analysis/IVDescriptors.cpp
===================================================================
--- llvm/lib/Analysis/IVDescriptors.cpp
+++ llvm/lib/Analysis/IVDescriptors.cpp
@@ -1483,7 +1483,13 @@
dbgs() << "LV: PHI is a recurrence with respect to an outer loop.\n");
return false;
}
-
+
+ // This function assumes that InductionPhi is called only on Phi nodes
+ // present inside loop headers. Check for the same, and throw an assert if
+ // the current Phi is not present inside the loop header.
+ assert(Phi->getParent() == AR->getLoop()->getHeader()
+ && "Invalid Phi node, not present in loop header");
+
Value *StartValue =
Phi->getIncomingValueForBlock(AR->getLoop()->getLoopPreheader());
Index: llvm/include/llvm/Analysis/IVDescriptors.h
===================================================================
--- llvm/include/llvm/Analysis/IVDescriptors.h
+++ llvm/include/llvm/Analysis/IVDescriptors.h
@@ -322,7 +322,9 @@
/// Returns true if \p Phi is an induction in the loop \p L. If \p Phi is an
/// induction, the induction descriptor \p D will contain the data describing
- /// this induction. If by some other means the caller has a better SCEV
+ /// this induction. Since Induction Phis can only be present inside loop
+ /// headers, the function will assert if it is passed a Phi whose parent is
+ /// not the loop header. If by some other means the caller has a better SCEV
/// expression for \p Phi than the one returned by the ScalarEvolution
/// analysis, it can be passed through \p Expr. If the def-use chain
/// associated with the phi includes casts (that we know we can ignore
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149041.516282.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230424/45e7e121/attachment.bin>
More information about the llvm-commits
mailing list