It is easy to not set the debug location which will result in problems
in debug builds. Hence, we should always use the helper
updateToLocation for all user facing entry points of the OMPIRBuilder.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
LG. I have one question. Is there a contract in place where the InsertionPointGuard is used to reset the IP back to the one at entry and would this change break it?
I don't think the Builder should reset to entry. It's an implicit contract that is hard to maintain and arguably useless as there is no reason to believe one would insert two "OpenMP things" at exactly the same point. IPs during codegen generally move and we should make all IPs explicit. These guards were introduced in a single patch (IIRC) and should not serve a purpose.
Why the pattern to just return without doing anything without an insert location? IMHO this should be an error instead of silently ignoring things.
I completely agree and already encountered problems with the reset location having become invalid between that guard and its dtor.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
1846–1848 | The insert- and debug location is already set inside createLoopSkeleton, setting it here has no effect. On line 1849 updateToLocation is then called and it handles the "no insert location" case by not connecting the loop skeleton to anything (as the caller wishes). return null makes this impossible. |
Because that is the clang pattern and we want/need to be compatible.
I completely agree and already encountered problems with the reset location having become invalid between that guard and its dtor.
Clang does not use such a pattern. When IRBuilder creates an instruction without an insert position, it still creates the instruction, but does not insert it into a function. createCanonicalLoop was supposed to do something similar (create the loop, but do not connect it to the CFG).
Commenting them all out still passes all tests. It essentially dead/untested code. Also seen in the code coverage: https://lab.llvm.org/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp.html
The insert- and debug location is already set inside createLoopSkeleton, setting it here has no effect.
On line 1849 updateToLocation is then called and it handles the "no insert location" case by not connecting the loop skeleton to anything (as the caller wishes). return null makes this impossible.