mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C++: Make Instruction.toString() less expensive
Previously, `Instruction.toString()` returned the same string that is used in IR dumps, which requires numbering all instructions and generating a unique string for each instruction. This is too expensive on large snapshots. I've moved the original code into the new `Instruction.getDumpString()`, and made `Instruction.toString()` just return the opcode plus `getAST().toString()`.
This commit is contained in:
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
final string toString() {
|
||||
result = getOpcode().toString() + ": " + getAST().toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
|
||||
* would be printed by PrintIR.ql. For example:
|
||||
*
|
||||
* `mu0_28(int) = Store r0_26, r0_27`
|
||||
*/
|
||||
final string getDumpString() {
|
||||
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
final string toString() {
|
||||
result = getOpcode().toString() + ": " + getAST().toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
|
||||
* would be printed by PrintIR.ql. For example:
|
||||
*
|
||||
* `mu0_28(int) = Store r0_26, r0_27`
|
||||
*/
|
||||
final string getDumpString() {
|
||||
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,16 @@ class Instruction extends Construction::TInstruction {
|
||||
}
|
||||
|
||||
final string toString() {
|
||||
result = getOpcode().toString() + ": " + getAST().toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string showing the result, opcode, and operands of the instruction, equivalent to what
|
||||
* would be printed by PrintIR.ql. For example:
|
||||
*
|
||||
* `mu0_28(int) = Store r0_26, r0_27`
|
||||
*/
|
||||
final string getDumpString() {
|
||||
result = getResultString() + " = " + getOperationString() + " " + getOperandsString()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user