@@ -283,6 +283,9 @@ module InstructionSanity {
283
283
* `File` and line number. Used for assigning register names when printing IR.
284
284
*/
285
285
private Instruction getAnInstructionAtLine ( IRFunction irFunc , Language:: File file , int line ) {
286
+ exists ( IRConfiguration:: IRConfiguration config |
287
+ config .shouldEvaluateDebugStringsForFunction ( irFunc .getFunction ( ) )
288
+ ) and
286
289
exists ( Language:: Location location |
287
290
irFunc = result .getEnclosingIRFunction ( ) and
288
291
location = result .getLocation ( ) and
@@ -307,13 +310,19 @@ class Instruction extends Construction::TInstruction {
307
310
result = getResultString ( ) + " = " + getOperationString ( ) + " " + getOperandsString ( )
308
311
}
309
312
313
+ predicate shouldGenerateDumpStrings ( ) {
314
+ exists ( IRConfiguration:: IRConfiguration config |
315
+ config .shouldEvaluateDebugStringsForFunction ( this .getEnclosingFunction ( ) )
316
+ )
317
+ }
310
318
/**
311
319
* Gets a string describing the operation of this instruction. This includes
312
320
* the opcode and the immediate value, if any. For example:
313
321
*
314
322
* VariableAddress[x]
315
323
*/
316
324
final string getOperationString ( ) {
325
+ shouldGenerateDumpStrings ( ) and
317
326
if exists ( getImmediateString ( ) )
318
327
then result = getOperationPrefix ( ) + getOpcode ( ) .toString ( ) + "[" + getImmediateString ( ) + "]"
319
328
else result = getOperationPrefix ( ) + getOpcode ( ) .toString ( )
@@ -325,10 +334,12 @@ class Instruction extends Construction::TInstruction {
325
334
string getImmediateString ( ) { none ( ) }
326
335
327
336
private string getOperationPrefix ( ) {
337
+ shouldGenerateDumpStrings ( ) and
328
338
if this instanceof SideEffectInstruction then result = "^" else result = ""
329
339
}
330
340
331
341
private string getResultPrefix ( ) {
342
+ shouldGenerateDumpStrings ( ) and
332
343
if getResultIRType ( ) instanceof IRVoidType
333
344
then result = "v"
334
345
else
@@ -342,6 +353,7 @@ class Instruction extends Construction::TInstruction {
342
353
* used by debugging and printing code only.
343
354
*/
344
355
int getDisplayIndexInBlock ( ) {
356
+ shouldGenerateDumpStrings ( ) and
345
357
exists ( IRBlock block |
346
358
this = block .getInstruction ( result )
347
359
or
@@ -355,6 +367,7 @@ class Instruction extends Construction::TInstruction {
355
367
}
356
368
357
369
private int getLineRank ( ) {
370
+ shouldGenerateDumpStrings ( ) and
358
371
this =
359
372
rank [ result ] ( Instruction instr |
360
373
instr =
@@ -373,6 +386,7 @@ class Instruction extends Construction::TInstruction {
373
386
* Example: `r1_1`
374
387
*/
375
388
string getResultId ( ) {
389
+ shouldGenerateDumpStrings ( ) and
376
390
result = getResultPrefix ( ) + getAST ( ) .getLocation ( ) .getStartLine ( ) + "_" + getLineRank ( )
377
391
}
378
392
@@ -384,6 +398,7 @@ class Instruction extends Construction::TInstruction {
384
398
* Example: `r1_1(int*)`
385
399
*/
386
400
final string getResultString ( ) {
401
+ shouldGenerateDumpStrings ( ) and
387
402
result = getResultId ( ) + "(" + getResultLanguageType ( ) .getDumpString ( ) + ")"
388
403
}
389
404
@@ -394,6 +409,7 @@ class Instruction extends Construction::TInstruction {
394
409
* Example: `func:r3_4, this:r3_5`
395
410
*/
396
411
string getOperandsString ( ) {
412
+ shouldGenerateDumpStrings ( ) and
397
413
result =
398
414
concat ( Operand operand |
399
415
operand = getAnOperand ( )
0 commit comments