mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C++ IR: Remove redundant check for same function
The check that an instruction is in the same function as its operands is hopefully redundant and can be removed. Just to be sure, I've added the check to a sanity query. This check turned out to cause bad performance in the alias analysis because it got inlined into `AliasAnalysis::resultEscapes` and then pulled out to a loop-invariant predicate that got a bad join order. With this check removed, the `ssa/AliasAnalysis.qll` file is orders of magnitude faster.
This commit is contained in:
@@ -66,6 +66,13 @@ module InstructionSanity {
|
||||
count(instr.getOperand(tag)) > 1 and
|
||||
not tag instanceof UnmodeledUseOperand
|
||||
}
|
||||
|
||||
query predicate operandAcrossFunctions(
|
||||
Instruction op, Instruction operand, OperandTag tag
|
||||
) {
|
||||
operand = op.getOperand(tag) and
|
||||
operand.getFunctionIR() != op.getFunctionIR()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction {
|
||||
* an operand with tag `useTag`.
|
||||
*/
|
||||
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
|
||||
useInstruction.getFunctionIR() = funcIR and
|
||||
this = useInstruction.getOperand(useTag)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,13 @@ module InstructionSanity {
|
||||
count(instr.getOperand(tag)) > 1 and
|
||||
not tag instanceof UnmodeledUseOperand
|
||||
}
|
||||
|
||||
query predicate operandAcrossFunctions(
|
||||
Instruction op, Instruction operand, OperandTag tag
|
||||
) {
|
||||
operand = op.getOperand(tag) and
|
||||
operand.getFunctionIR() != op.getFunctionIR()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction {
|
||||
* an operand with tag `useTag`.
|
||||
*/
|
||||
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
|
||||
useInstruction.getFunctionIR() = funcIR and
|
||||
this = useInstruction.getOperand(useTag)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,13 @@ module InstructionSanity {
|
||||
count(instr.getOperand(tag)) > 1 and
|
||||
not tag instanceof UnmodeledUseOperand
|
||||
}
|
||||
|
||||
query predicate operandAcrossFunctions(
|
||||
Instruction op, Instruction operand, OperandTag tag
|
||||
) {
|
||||
operand = op.getOperand(tag) and
|
||||
operand.getFunctionIR() != op.getFunctionIR()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +309,6 @@ class Instruction extends Construction::TInstruction {
|
||||
* an operand with tag `useTag`.
|
||||
*/
|
||||
final predicate hasUse(Instruction useInstruction, OperandTag useTag) {
|
||||
useInstruction.getFunctionIR() = funcIR and
|
||||
this = useInstruction.getOperand(useTag)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user