@@ -15,6 +15,9 @@ private import Imports::OperandTag
1515 * `File` and line number. Used for assigning register names when printing IR.
1616 */
1717private Instruction getAnInstructionAtLine ( IRFunction irFunc , Language:: File file , int line ) {
18+ exists ( IRConfiguration:: IRConfiguration config |
19+ config .shouldEvaluateDebugStringsForFunction ( irFunc .getFunction ( ) )
20+ ) and
1821 exists ( Language:: Location location |
1922 irFunc = result .getEnclosingIRFunction ( ) and
2023 location = result .getLocation ( ) and
@@ -39,13 +42,20 @@ class Instruction extends Construction::TInstruction {
3942 result = getResultString ( ) + " = " + getOperationString ( ) + " " + getOperandsString ( )
4043 }
4144
45+ private predicate shouldGenerateDumpStrings ( ) {
46+ exists ( IRConfiguration:: IRConfiguration config |
47+ config .shouldEvaluateDebugStringsForFunction ( this .getEnclosingFunction ( ) )
48+ )
49+ }
50+
4251 /**
4352 * Gets a string describing the operation of this instruction. This includes
4453 * the opcode and the immediate value, if any. For example:
4554 *
4655 * VariableAddress[x]
4756 */
4857 final string getOperationString ( ) {
58+ shouldGenerateDumpStrings ( ) and
4959 if exists ( getImmediateString ( ) )
5060 then result = getOperationPrefix ( ) + getOpcode ( ) .toString ( ) + "[" + getImmediateString ( ) + "]"
5161 else result = getOperationPrefix ( ) + getOpcode ( ) .toString ( )
@@ -57,10 +67,12 @@ class Instruction extends Construction::TInstruction {
5767 string getImmediateString ( ) { none ( ) }
5868
5969 private string getOperationPrefix ( ) {
70+ shouldGenerateDumpStrings ( ) and
6071 if this instanceof SideEffectInstruction then result = "^" else result = ""
6172 }
6273
6374 private string getResultPrefix ( ) {
75+ shouldGenerateDumpStrings ( ) and
6476 if getResultIRType ( ) instanceof IRVoidType
6577 then result = "v"
6678 else
@@ -74,6 +86,7 @@ class Instruction extends Construction::TInstruction {
7486 * used by debugging and printing code only.
7587 */
7688 int getDisplayIndexInBlock ( ) {
89+ shouldGenerateDumpStrings ( ) and
7790 exists ( IRBlock block |
7891 this = block .getInstruction ( result )
7992 or
@@ -87,6 +100,7 @@ class Instruction extends Construction::TInstruction {
87100 }
88101
89102 private int getLineRank ( ) {
103+ shouldGenerateDumpStrings ( ) and
90104 this =
91105 rank [ result ] ( Instruction instr |
92106 instr =
@@ -105,6 +119,7 @@ class Instruction extends Construction::TInstruction {
105119 * Example: `r1_1`
106120 */
107121 string getResultId ( ) {
122+ shouldGenerateDumpStrings ( ) and
108123 result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
109124 }
110125
@@ -116,6 +131,7 @@ class Instruction extends Construction::TInstruction {
116131 * Example: `r1_1(int*)`
117132 */
118133 final string getResultString ( ) {
134+ shouldGenerateDumpStrings ( ) and
119135 result = getResultId ( ) + "(" + getResultLanguageType ( ) .getDumpString ( ) + ")"
120136 }
121137
@@ -126,6 +142,7 @@ class Instruction extends Construction::TInstruction {
126142 * Example: `func:r3_4, this:r3_5`
127143 */
128144 string getOperandsString ( ) {
145+ shouldGenerateDumpStrings ( ) and
129146 result =
130147 concat ( Operand operand |
131148 operand = getAnOperand ( )
0 commit comments