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:
Jonas Jensen
2018-08-09 15:19:04 +02:00
parent badb167962
commit 8c06a68835
3 changed files with 21 additions and 3 deletions

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}