You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[IRCE] Check loop clone legality before attempting to do so
Not all loop bodies are safe to clone. For example, they may have
`noduplicate` call in them. Additionally, if the transformation may
cause any of the cloned loop bodies to execute conditionally, we
must also disallow `convergent` calls, as well as any call that
returns a token that is used outside of the loop. The loop unswitching
pass had an appropriate legality check for this, but IRCE did not,
causing issues downstream (JuliaLang/julia#48918).
As a particular example, consider the test case in this commit, where
`opt -passes=irce`, creates invalid IR:
```
opt --passes=irce llvm/test/Transforms/IRCE/pre_post_loops_clone.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
Instruction does not dominate all uses!
%token = call token @llvm.source_token()
call void @llvm.sink_token(token %token)
Instruction does not dominate all uses!
%token = call token @llvm.source_token()
call void @llvm.sink_token(token %token)
LLVM ERROR: Broken module found, compilation aborted!
```
Fix this by factoring out the legality check from the loop unswitch
pass and using it in IRCE as well. I personally don't have any code
that is `noduplicate` or `convergent`, but I don't see any reason
why IRCE would be different here.
I will also mention llvm#56243 as related, which contains some related
discussion of LCSSA in the presence of tokens.
Fixesllvm#63984
(cherry picked from commit 5b9f963)
0 commit comments