Skip to content

Commit

Permalink
Using IdentityHashSet in EOG pass to remove superfluous EOG nodes (#…
Browse files Browse the repository at this point in the history
…1275)

* EOG pass speedup

There was an issue that massivly slowed down the EOG pass for programs that a LOT (>500.000) EOG nodes. Now we are using an identity hash set instead of a regular hash set to store the set of unique EOG nodes.

* Add some comments

* revert js change

---------

Co-authored-by: Alexander Kuechler <[email protected]>
  • Loading branch information
oxisto and KuechA committed Aug 10, 2023
1 parent 8746d62 commit c2982d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ import de.fraunhofer.aisec.cpg.TranslationContext
import de.fraunhofer.aisec.cpg.graph.Name
import de.fraunhofer.aisec.cpg.graph.Node
import de.fraunhofer.aisec.cpg.graph.statements.expressions.BinaryOperator
import de.fraunhofer.aisec.cpg.graph.statements.expressions.CastExpression
import de.fraunhofer.aisec.cpg.graph.types.*
import de.fraunhofer.aisec.cpg.graph.types.Type
import de.fraunhofer.aisec.cpg.graph.unknownType
import de.fraunhofer.aisec.cpg.helpers.Util
import java.io.File
import kotlin.reflect.KClass
import kotlin.reflect.full.primaryConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,19 @@ internal class CXXLanguageFrontendTest : BaseTest() {
// a = b * 2
var assign = statements[2] as? AssignExpression
assertNotNull(assign)
<<<<<<< HEAD

var ref = assign.lhs<DeclaredReferenceExpression>()
assertNotNull(ref)
assertLocalName("a", ref)

=======

var ref = assign.lhs<DeclaredReferenceExpression>()
assertNotNull(ref)
assertLocalName("a", ref)

>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268))
var binOp = assign.rhs<BinaryOperator>()
assertNotNull(binOp)

Expand All @@ -658,10 +666,23 @@ internal class CXXLanguageFrontendTest : BaseTest() {
ref = assign.lhs<DeclaredReferenceExpression>()
assertNotNull(ref)
assertLocalName("a", ref)
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268))

binOp = assign.rhs<BinaryOperator>()
assertNotNull(binOp)

<<<<<<< HEAD
=======
=======

binOp = assign.rhs<BinaryOperator>()
assertNotNull(binOp)

>>>>>>> 490562dce (Overhaul of type propagation (#1268))
>>>>>>> f8cf854d8 (Overhaul of type propagation (#1268))
assertTrue(binOp.lhs is Literal<*>)
assertEquals(1, (binOp.lhs as Literal<*>).value)
assertTrue(binOp.rhs is Literal<*>)
Expand Down

0 comments on commit c2982d0

Please sign in to comment.