mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C++/C#: Do filtering of instructions in cached predicates
The four cached predicates used to access common properties of instructions took a `TStageInstruction` as a parameter. This requires the calling code, in `Instruction.qll`, to then join the results with `hasInstruction()` to filter out results for `TRawInstruction`s that were discarded as unreachable. By simply switching the parameter types to `Instruction`, we can force that join to happen in the cached predicate itself. This makes the various accessor predicates on `Instruction` trivially inlinable to the cached predicate, instead of being joins of two huge relations that might have to be recomputed in later stages.
This commit is contained in:
@@ -263,7 +263,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::AST getInstructionAST(TStageInstruction instr) {
|
||||
Language::AST getInstructionAST(Instruction instr) {
|
||||
instr = rawInstruction(_, _, result)
|
||||
or
|
||||
exists(RawIR::Instruction blockStartInstr |
|
||||
@@ -282,7 +282,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::LanguageType getInstructionResultType(TStageInstruction instr) {
|
||||
Language::LanguageType getInstructionResultType(Instruction instr) {
|
||||
result = instr.(RawIR::Instruction).getResultLanguageType()
|
||||
or
|
||||
exists(Alias::MemoryLocation defLocation |
|
||||
@@ -300,7 +300,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Opcode getInstructionOpcode(TStageInstruction instr) {
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
instr = rawInstruction(_, result, _)
|
||||
or
|
||||
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
|
||||
@@ -311,7 +311,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
|
||||
instr = rawInstruction(result, _, _)
|
||||
or
|
||||
instr = phiInstruction(result, _, _)
|
||||
|
||||
@@ -263,7 +263,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::AST getInstructionAST(TStageInstruction instr) {
|
||||
Language::AST getInstructionAST(Instruction instr) {
|
||||
instr = rawInstruction(_, _, result)
|
||||
or
|
||||
exists(RawIR::Instruction blockStartInstr |
|
||||
@@ -282,7 +282,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::LanguageType getInstructionResultType(TStageInstruction instr) {
|
||||
Language::LanguageType getInstructionResultType(Instruction instr) {
|
||||
result = instr.(RawIR::Instruction).getResultLanguageType()
|
||||
or
|
||||
exists(Alias::MemoryLocation defLocation |
|
||||
@@ -300,7 +300,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Opcode getInstructionOpcode(TStageInstruction instr) {
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
instr = rawInstruction(_, result, _)
|
||||
or
|
||||
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
|
||||
@@ -311,7 +311,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
|
||||
instr = rawInstruction(result, _, _)
|
||||
or
|
||||
instr = phiInstruction(result, _, _)
|
||||
|
||||
@@ -263,7 +263,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::AST getInstructionAST(TStageInstruction instr) {
|
||||
Language::AST getInstructionAST(Instruction instr) {
|
||||
instr = rawInstruction(_, _, result)
|
||||
or
|
||||
exists(RawIR::Instruction blockStartInstr |
|
||||
@@ -282,7 +282,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Language::LanguageType getInstructionResultType(TStageInstruction instr) {
|
||||
Language::LanguageType getInstructionResultType(Instruction instr) {
|
||||
result = instr.(RawIR::Instruction).getResultLanguageType()
|
||||
or
|
||||
exists(Alias::MemoryLocation defLocation |
|
||||
@@ -300,7 +300,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
Opcode getInstructionOpcode(TStageInstruction instr) {
|
||||
Opcode getInstructionOpcode(Instruction instr) {
|
||||
instr = rawInstruction(_, result, _)
|
||||
or
|
||||
instr = phiInstruction(_, _, _) and result instanceof Opcode::Phi
|
||||
@@ -311,7 +311,7 @@ private module Cached {
|
||||
}
|
||||
|
||||
cached
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(TStageInstruction instr) {
|
||||
IRFunctionBase getInstructionEnclosingIRFunction(Instruction instr) {
|
||||
instr = rawInstruction(result, _, _)
|
||||
or
|
||||
instr = phiInstruction(result, _, _)
|
||||
|
||||
Reference in New Issue
Block a user