[PATCH] D127628: [NewGVN][LoadCoercion][3/3] Replace load with a phi node

Konstantina Mitropoulou via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 22:16:41 PDT 2022


kmitropoulou added a comment.

In D127628#3738907 <https://reviews.llvm.org/D127628#3738907>, @foad wrote:

> In example 2 you insert a new instruction `%V1 = load i32, i32* %P` at the end of BB2. I'm not sure this is safe in general. For example, if BB2 has other successors:
>
>   BB1     BB2
>      \   /   \
>       BB3     BB4
>
> then the new load instruction will be executed even if BB2 is going to branch to BB4, and in that case the load might trap.

In this case, I bail out.

> As another example, what if BB3 looked like this:
>
>   BB3:
>     call @foo // this function never returns
>     %V = load i32, i32* %P // this load always traps
>
> If you insert a load at the end of BB2 then it will trap //before// calling `@foo`, which changes the behaviour of the program.

I added implicit control flow tracking to detect such cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127628



More information about the llvm-commits mailing list