Semantic Code Abstraction for Compiler Variation Matching

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for analyzing computer code are inefficient and prone to errors, particularly in identifying similar code fragments due to variations introduced by compilers, such as register renaming and code reordering, leading to high false positive and false negative rates, making them impractical for large collections of programs.

Innovation Solution

The system abstracts computer code into denotational semantics and further into generalized semantics by consistently replacing register names and constants with logical variables, allowing for efficient and accurate comparison of code segments, minimizing computational expense and inaccuracy.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If existing methods are used to analyze and compare computer code, then code comparison can be performed, but the methods are inefficient and produce high false positive and false negative rates

Engineering Contradiction:
Improveaccuracy of code matchingVSAvoidefficiency of code analysis
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent transforms code representation from concrete syntax (source code, assembly, machine code) to abstract semantic parameters (denotational semantics, generalized semantics). This parameter transformation allows code fragments with different syntactic representations to be compared based on their semantic equivalence, resolving the contradiction by improving matching accuracy without sacrificing efficiency.

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The patent introduces denotational semantics and generalized semantics as intermediary representations between the original code and the comparison process. These intermediaries serve as a common language that captures the essential meaning of code fragments while ignoring superficial differences, enabling accurate and efficient comparison.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Measurement precision

If code is compared using traditional methods, then comparison is possible, but variations introduced by compilers (register renaming, code reordering) lead to high false positive and false negative rates

Engineering Contradiction:
Improveprecision of code similarity detectionVSAvoidcomplexity of handling compiler variations
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent extracts the essential semantic meaning from code fragments by computing denotational semantics, separating the core functional behavior from compiler-introduced variations. This extraction process removes the harmful effects of register renaming and code reordering by focusing only on the semantic content that matters for equivalence detection.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent changes the representation parameters from concrete code details (register names, instruction order) to abstract semantic parameters (denotational semantics, generalized semantics). This parameter transformation makes the comparison invariant to compiler variations while maintaining precision in detecting true semantic equivalence.

Inventive Principle:
Principle #35Parameter changes

3Reliability

If large collections of programs are searched using existing methods, then code matching can be performed, but the process is computationally expensive and impractical

Engineering Contradiction:
Improveaccuracy of code matchingVSAvoidtime for code analysis
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs preliminary computation of denotational semantics and generalized semantics for code fragments, creating a semantic representation that can be efficiently compared. This preliminary action transforms the code into a form that enables fast subsequent comparisons, reducing the time loss when searching large code collections while maintaining high accuracy.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent transforms code into abstract semantic parameters that enable efficient comparison operations. This parameter change allows for fast matching algorithms that can handle large collections of programs without sacrificing matching accuracy, resolving the time-reliability contradiction.

Inventive Principle:
Principle #35Parameter changes

Data Source

PatentUS11481494B2System and method for identifying and comparing code by semantic abstractions
Publication Date: 2022.10.25 UNIVERSITY OF LOUISIANA AT LAFAYETTE
  • US11481494B2 patent drawing
  • US11481494B2 patent drawing
  • US11481494B2 patent drawing

AI summary

Certain embodiments of the present invention are configured to facilitate analyzing computer code more efficiently. For example, by conducting a first level abstraction (e.g., symbolic interpretation and algebraic simplification) and a second level abstraction (e.g., generalization) of the computer code, the analysis may more accurately account for variations in the code that may occur as a result of register renaming, instruction reordering, choice of instructions, etc. while minimizing the cost of computations required to perform the analysis.