Skip to content

Commit

Permalink
fix unstable phi inst filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullinAM committed Oct 9, 2019
1 parent f31775b commit 2d93bab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.jetbrains.research</groupId>
<artifactId>kfg</artifactId>
<version>0.0.4.1</version>
<version>0.0.4.2</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ class CfgBuilder(val cm: ClassManager, val method: Method)
when (type) {
null -> removablePhis.add(phi)
else -> {
val newPhi = instFactory.getPhi(phi.name, type, incomings)
val newPhi = instFactory.getPhi(type, incomings)
phi.replaceAllUsesWith(newPhi)
phi.operands.forEach { it.removeUser(phi) }
bb.replace(phi, newPhi)
Expand Down Expand Up @@ -1011,6 +1011,8 @@ class CfgBuilder(val cm: ClassManager, val method: Method)
}

processPhis.addAll(removablePhis)
// this is generally fucked up
processPhis.sortBy { it.name.toString() }
while (processPhis.isNotEmpty()) {
val top = processPhis.first()
processPhis.removeAt(0)
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/jetbrains/research/kfg/ir/BasicBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import org.jetbrains.research.kfg.type.Type
import org.jetbrains.research.kfg.util.GraphNode

sealed class BasicBlock(val name: BlockName)
: UsableBlock(), Iterable<Instruction>, GraphNode<BasicBlock>, BlockUser {
: UsableBlock(), Iterable<Instruction>, GraphNode<BasicBlock>, BlockUser {
var parent: Method? = null
internal set(value) {
field = value
instructions.forEach { addValueToParent(it) }
}
override val predecessors = hashSetOf<BasicBlock>()
override val successors = hashSetOf<BasicBlock>()
override val predecessors = linkedSetOf<BasicBlock>()
override val successors = linkedSetOf<BasicBlock>()
val instructions = arrayListOf<Instruction>()
val handlers = arrayListOf<CatchBlock>()

Expand Down

0 comments on commit 2d93bab

Please sign in to comment.