Merge pull request #11153 from hvitved/ruby/basic-block-at-conditions

Ruby: Split basic blocks around constant conditionals
This commit is contained in:
Tom Hvitved
2022-11-08 13:35:52 +01:00
committed by GitHub
4 changed files with 98 additions and 1 deletions

View File

@@ -252,6 +252,30 @@ private module Cached {
cfn.isJoin()
or
cfn.getAPredecessor().isBranch()
or
/*
* In cases such as
*
* ```rb
* if x or y
* foo
* else
* bar
* ```
*
* we have a CFG that looks like
*
* x --false--> [false] x or y --false--> bar
* \ |
* --true--> y --false--
* \
* --true--> [true] x or y --true--> foo
*
* and we want to ensure that both `foo` and `bar` start a new basic block,
* in order to get a `ConditionalBlock` out of the disjunction.
*/
exists(cfn.getAPredecessor(any(SuccessorTypes::ConditionalSuccessor s)))
}
/**