Previously the CodeExtractor created exit stubs, and the subsequent return value of the outlined function based on the order of out-of-region blocks after splitting any phi nodes, and collecting the blocks to be outlined. This could cause differences in order if there was a difference of exit block phi nodes between the two regions. This patch moves the collection of the output target blocks to be before this occurs, so that the assignment of target block to output value will be the same, regardless of the contents of the output block.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Utils/CodeExtractor.cpp | ||
---|---|---|
1269 | Should there be an assert: assert(NumExitBlocks < 0xffff && "too many exit blocks for switch"); or do you think that's too unlikely to matter? | |
1284 | Doesn't the switch need the same type as the cases, or am I misunderstanding what's going on here? | |
1291–1292 | Code following this doesn't assign into the variable, so we may as well drop the & on this one for clarity. |
llvm/lib/Transforms/Utils/CodeExtractor.cpp | ||
---|---|---|
1269 | I think it's pretty unlikely that there will ever by that many exits out of a function. | |
1284 | They do, but if there are only two exit blocks, there are only two options, a 0 and 1, returned out of the outlined function. If that's the case, the CodeExtractor simplifies this to a branch instruction anyway. |
llvm/lib/Transforms/Utils/CodeExtractor.cpp | ||
---|---|---|
1269 | 👍 |
llvm/lib/Transforms/Utils/CodeExtractor.cpp | ||
---|---|---|
1269 | I think it would be good to assert anyway if it's possible that it will happen. In the event that it does, I'd prefer to debug an assert than a later crash. |
Should there be an assert:
or do you think that's too unlikely to matter?