@@ -283,6 +283,9 @@ module InstructionSanity {
283283 * `File` and line number. Used for assigning register names when printing IR.
284284 */
285285private Instruction getAnInstructionAtLine ( IRFunction irFunc , Language:: File file , int line ) {
286+ exists ( IRConfiguration:: IRConfiguration config |
287+ config .shouldEvaluateDebugStringsForFunction ( irFunc .getFunction ( ) )
288+ ) and
286289 exists ( Language:: Location location |
287290 irFunc = result .getEnclosingIRFunction ( ) and
288291 location = result .getLocation ( ) and
@@ -307,13 +310,19 @@ class Instruction extends Construction::TInstruction {
307310 result = getResultString ( ) + " = " + getOperationString ( ) + " " + getOperandsString ( )
308311 }
309312
313+ predicate shouldGenerateDumpStrings ( ) {
314+ exists ( IRConfiguration:: IRConfiguration config |
315+ config .shouldEvaluateDebugStringsForFunction ( this .getEnclosingFunction ( ) )
316+ )
317+ }
310318 /**
311319 * Gets a string describing the operation of this instruction. This includes
312320 * the opcode and the immediate value, if any. For example:
313321 *
314322 * VariableAddress[x]
315323 */
316324 final string getOperationString ( ) {
325+ shouldGenerateDumpStrings ( ) and
317326 if exists ( getImmediateString ( ) )
318327 then result = getOperationPrefix ( ) + getOpcode ( ) .toString ( ) + "[" + getImmediateString ( ) + "]"
319328 else result = getOperationPrefix ( ) + getOpcode ( ) .toString ( )
@@ -325,10 +334,12 @@ class Instruction extends Construction::TInstruction {
325334 string getImmediateString ( ) { none ( ) }
326335
327336 private string getOperationPrefix ( ) {
337+ shouldGenerateDumpStrings ( ) and
328338 if this instanceof SideEffectInstruction then result = "^" else result = ""
329339 }
330340
331341 private string getResultPrefix ( ) {
342+ shouldGenerateDumpStrings ( ) and
332343 if getResultIRType ( ) instanceof IRVoidType
333344 then result = "v"
334345 else
@@ -342,6 +353,7 @@ class Instruction extends Construction::TInstruction {
342353 * used by debugging and printing code only.
343354 */
344355 int getDisplayIndexInBlock ( ) {
356+ shouldGenerateDumpStrings ( ) and
345357 exists ( IRBlock block |
346358 this = block .getInstruction ( result )
347359 or
@@ -355,6 +367,7 @@ class Instruction extends Construction::TInstruction {
355367 }
356368
357369 private int getLineRank ( ) {
370+ shouldGenerateDumpStrings ( ) and
358371 this =
359372 rank [ result ] ( Instruction instr |
360373 instr =
@@ -373,6 +386,7 @@ class Instruction extends Construction::TInstruction {
373386 * Example: `r1_1`
374387 */
375388 string getResultId ( ) {
389+ shouldGenerateDumpStrings ( ) and
376390 result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
377391 }
378392
@@ -384,6 +398,7 @@ class Instruction extends Construction::TInstruction {
384398 * Example: `r1_1(int*)`
385399 */
386400 final string getResultString ( ) {
401+ shouldGenerateDumpStrings ( ) and
387402 result = getResultId ( ) + "(" + getResultLanguageType ( ) .getDumpString ( ) + ")"
388403 }
389404
@@ -394,6 +409,7 @@ class Instruction extends Construction::TInstruction {
394409 * Example: `func:r3_4, this:r3_5`
395410 */
396411 string getOperandsString ( ) {
412+ shouldGenerateDumpStrings ( ) and
397413 result =
398414 concat ( Operand operand |
399415 operand = getAnOperand ( )
0 commit comments