[llvm] [LAA] Fix recordAnalysis receiving null Instruction pointer (PR #183512)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 26 04:42:41 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Igor Kirillov (igogo-x86)
<details>
<summary>Changes</summary>
When a memory-reading or memory-writing instruction is not a LoadInst/StoreInst, the dyn_cast to Ld/St returns nullptr, which is then passed to recordAnalysis. This causes the optimization remark to fall back to the loop header location instead of pointing at the actual problematic instruction.
Pass &I (the actual Instruction) instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/183512.diff
1 Files Affected:
- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index ca6b8461970b5..524caab0367cc 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -2581,7 +2581,7 @@ bool LoopAccessInfo::analyzeLoop(AAResults *AA, const LoopInfo *LI,
auto *Ld = dyn_cast<LoadInst>(&I);
if (!Ld) {
- recordAnalysis("CantVectorizeInstruction", Ld)
+ recordAnalysis("CantVectorizeInstruction", &I)
<< "instruction cannot be vectorized";
HasComplexMemInst = true;
continue;
@@ -2605,7 +2605,7 @@ bool LoopAccessInfo::analyzeLoop(AAResults *AA, const LoopInfo *LI,
if (I.mayWriteToMemory()) {
auto *St = dyn_cast<StoreInst>(&I);
if (!St) {
- recordAnalysis("CantVectorizeInstruction", St)
+ recordAnalysis("CantVectorizeInstruction", &I)
<< "instruction cannot be vectorized";
HasComplexMemInst = true;
continue;
``````````
</details>
https://github.com/llvm/llvm-project/pull/183512
More information about the llvm-commits
mailing list