mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
C++: Stop caching raw IR construction predicates
These predicates are only used within the new single IR stage, so there's no need to cache them beyond that. RA diffs are trivial. Where previously many of the predicate on `Instruction` were inline wrappers around cached predicates from `IRConstruction`, now the predicates from `IRConstruction` get inlined into the `Instruction` predicates, and the `Instruction` predicates get materialized. The net amount of work is the same, but now it's not getting cached unnecessarily.
This commit is contained in:
@@ -169,33 +169,24 @@ module Raw {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
import Cached
|
|
||||||
|
|
||||||
cached
|
|
||||||
private module Cached {
|
|
||||||
class TStageInstruction = TRawInstruction;
|
class TStageInstruction = TRawInstruction;
|
||||||
|
|
||||||
cached
|
|
||||||
predicate hasInstruction(TRawInstruction instr) { any() }
|
predicate hasInstruction(TRawInstruction instr) { any() }
|
||||||
|
|
||||||
cached
|
|
||||||
predicate hasModeledMemoryResult(Instruction instruction) { none() }
|
predicate hasModeledMemoryResult(Instruction instruction) { none() }
|
||||||
|
|
||||||
cached
|
|
||||||
predicate hasConflatedMemoryResult(Instruction instruction) {
|
predicate hasConflatedMemoryResult(Instruction instruction) {
|
||||||
instruction instanceof AliasedDefinitionInstruction
|
instruction instanceof AliasedDefinitionInstruction
|
||||||
or
|
or
|
||||||
instruction.getOpcode() instanceof Opcode::InitializeNonLocal
|
instruction.getOpcode() instanceof Opcode::InitializeNonLocal
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getRegisterOperandDefinition(Instruction instruction, RegisterOperandTag tag) {
|
Instruction getRegisterOperandDefinition(Instruction instruction, RegisterOperandTag tag) {
|
||||||
result =
|
result =
|
||||||
getInstructionTranslatedElement(instruction)
|
getInstructionTranslatedElement(instruction)
|
||||||
.getInstructionRegisterOperand(getInstructionTag(instruction), tag)
|
.getInstructionRegisterOperand(getInstructionTag(instruction), tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getMemoryOperandDefinition(
|
Instruction getMemoryOperandDefinition(
|
||||||
Instruction instruction, MemoryOperandTag tag, Overlap overlap
|
Instruction instruction, MemoryOperandTag tag, Overlap overlap
|
||||||
) {
|
) {
|
||||||
@@ -232,13 +223,11 @@ private module Cached {
|
|||||||
* better to remove these operands than to leave cycles in the operand graph.
|
* better to remove these operands than to leave cycles in the operand graph.
|
||||||
*/
|
*/
|
||||||
pragma[noopt]
|
pragma[noopt]
|
||||||
cached
|
|
||||||
predicate isInCycle(Instruction instr) {
|
predicate isInCycle(Instruction instr) {
|
||||||
instr instanceof Instruction and
|
instr instanceof Instruction and
|
||||||
getNonPhiOperandDefOfIntermediate+(instr) = instr
|
getNonPhiOperandDefOfIntermediate+(instr) = instr
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
CppType getInstructionOperandType(Instruction instruction, TypedOperandTag tag) {
|
CppType getInstructionOperandType(Instruction instruction, TypedOperandTag tag) {
|
||||||
// For all `LoadInstruction`s, the operand type of the `LoadOperand` is the same as
|
// For all `LoadInstruction`s, the operand type of the `LoadOperand` is the same as
|
||||||
// the result type of the load.
|
// the result type of the load.
|
||||||
@@ -251,17 +240,14 @@ private module Cached {
|
|||||||
.getInstructionMemoryOperandType(getInstructionTag(instruction), tag)
|
.getInstructionMemoryOperandType(getInstructionTag(instruction), tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getPhiOperandDefinition(
|
Instruction getPhiOperandDefinition(
|
||||||
PhiInstruction instruction, IRBlock predecessorBlock, Overlap overlap
|
PhiInstruction instruction, IRBlock predecessorBlock, Overlap overlap
|
||||||
) {
|
) {
|
||||||
none()
|
none()
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getPhiInstructionBlockStart(PhiInstruction instr) { none() }
|
Instruction getPhiInstructionBlockStart(PhiInstruction instr) { none() }
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) {
|
Instruction getInstructionSuccessor(Instruction instruction, EdgeKind kind) {
|
||||||
result =
|
result =
|
||||||
getInstructionTranslatedElement(instruction)
|
getInstructionTranslatedElement(instruction)
|
||||||
@@ -333,7 +319,6 @@ private module Cached {
|
|||||||
jumpSourceHasAncestor(jumpSource, ancestor.getAChild())
|
jumpSourceHasAncestor(jumpSource, ancestor.getAChild())
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getInstructionBackEdgeSuccessor(Instruction instruction, EdgeKind kind) {
|
Instruction getInstructionBackEdgeSuccessor(Instruction instruction, EdgeKind kind) {
|
||||||
exists(
|
exists(
|
||||||
TranslatedElement sourceElement, InstructionTag sourceTag, TranslatedElement requiredAncestor
|
TranslatedElement sourceElement, InstructionTag sourceTag, TranslatedElement requiredAncestor
|
||||||
@@ -364,12 +349,10 @@ private module Cached {
|
|||||||
goto.getLocation().isBefore(goto.getTarget().getLocation())
|
goto.getLocation().isBefore(goto.getTarget().getLocation())
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Locatable getInstructionAST(TStageInstruction instr) {
|
Locatable getInstructionAST(TStageInstruction instr) {
|
||||||
result = getInstructionTranslatedElement(instr).getAST()
|
result = getInstructionTranslatedElement(instr).getAST()
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
CppType getInstructionResultType(TStageInstruction instr) {
|
CppType getInstructionResultType(TStageInstruction instr) {
|
||||||
exists(TranslatedElement element, InstructionTag tag |
|
exists(TranslatedElement element, InstructionTag tag |
|
||||||
instructionOrigin(instr, element, tag) and
|
instructionOrigin(instr, element, tag) and
|
||||||
@@ -377,7 +360,6 @@ private module Cached {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Opcode getInstructionOpcode(TStageInstruction instr) {
|
Opcode getInstructionOpcode(TStageInstruction instr) {
|
||||||
exists(TranslatedElement element, InstructionTag tag |
|
exists(TranslatedElement element, InstructionTag tag |
|
||||||
instructionOrigin(instr, element, tag) and
|
instructionOrigin(instr, element, tag) and
|
||||||
@@ -385,19 +367,16 @@ private module Cached {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
||||||
result.getFunction() = getInstructionTranslatedElement(instr).getFunction()
|
result.getFunction() = getInstructionTranslatedElement(instr).getFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
cached
|
|
||||||
Instruction getPrimaryInstructionForSideEffect(SideEffectInstruction instruction) {
|
Instruction getPrimaryInstructionForSideEffect(SideEffectInstruction instruction) {
|
||||||
exists(TranslatedElement element, InstructionTag tag |
|
exists(TranslatedElement element, InstructionTag tag |
|
||||||
instructionOrigin(instruction, element, tag) and
|
instructionOrigin(instruction, element, tag) and
|
||||||
result = element.getPrimaryInstructionForSideEffect(tag)
|
result = element.getPrimaryInstructionForSideEffect(tag)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
import CachedForDebugging
|
import CachedForDebugging
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user