[PATCH] D71383: [LoopGuard] Instructions in loop preheader and loop exit must be safe to execute speculatively.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 12:16:42 PST 2019


Meinersbur added a comment.

In D71383#1786225 <https://reviews.llvm.org/D71383#1786225>, @Whitney wrote:

> I did a test with a loop that has a call which may throw inside, and SCEV is able to calculate the trip count, add recurrence of the induction variable, etc. Maybe we can keep getLoopGuardBranch() as is, and not worry about instructions which not guaranteed to transfer execution to successors? What do you think @Meinersbur?


I was assuming you need this change for your use case. If `getLoopGuardBranch` already fits your use case, I indeed do not see a reason to change it?



================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:402-405
+  // If the loop preheader or loop exit block contain instructions which are not
+  // guaranteed to transfer execution to successors (e.g. instructions that
+  // throw), then loop guard doesn't guarantee the execution of the loop it is
+  // guarding.
----------------
Meinersbur wrote:
> This applies to the preheader, but if an instruction throws in `ExitFromLatch`, the loop has been executed.
> 
> I am not arguing that `ExitFromLatch` should allow side-effect instructions, but we should correctly justify why not.
Btw, nothing guarantees that the loop itself is exiting, hence `ExitFromLatchSucc` may still not be executed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71383/new/

https://reviews.llvm.org/D71383





More information about the llvm-commits mailing list