Method forgetLoop only forgets expression of phi or its users. SCEV
expressions except the above mentioned may still has loop dispositions
that point to the destroyed loop, which might cause a crash.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Are you sure we need to forget the incoming value rather than the phi? I haven't looked at the code in detail, but I'd generally expect that removing an incoming value doesn't change dispositions of that value, but may change dispositions of the using phi.
llvm/test/Transforms/LoopFlatten/pr58865.ll | ||
---|---|---|
2 | I'd suggest adding check lines as well. |
If I understand correctly, the phi will be forgotten when calling forgetLoop method in the below. But I found that just forgetting the incoming value is still not sufficient or is wrong.
This is (slightly) offtopic, but I am wondering what the lesson learned here is for me. I.e., I forgot forgetBlockAndLoopDispositions, but was wondering how I could/should have known.... I will check some SCEV documentation, that's one thing, but I am also wondering if SCEV could be made more robust. It was running in an assert because it thought it was in an invalid state, so could it call forgetBlockAndLoopDispositions instead of asserting?
Unfortunately that's unlikely. We only catch this with verification, which basically computes most SCEV information again from scratch and compares it to the cached values, so it is super expensive.
Is this the same issue I previously reported in D109958? Did we lose that fix when that was reverted?
Forgot to reply, but yeah, sorry, I think that was my bad. I think we accidentally lost that with a revert.
I'd suggest adding check lines as well.