Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Improve LIR dumping #10140

Merged
merged 3 commits into from
Mar 14, 2017
Merged

Improve LIR dumping #10140

merged 3 commits into from
Mar 14, 2017

Conversation

BruceForstall
Copy link
Member

@BruceForstall BruceForstall commented Mar 13, 2017

  1. Use the LIR node dumper to display nodes to be generated by
    codegen, since we're in LIR form at that point. Add a new
    "prefix message" argument to allow "Generating: " to prefix all
    such lines.
  2. Fix off-by-one error in LIR dump due to #ifdef versus #if.
  3. Remove extra trailing line for each LIR node. This interfered
    with (1). But I always thought it was unnecessarily verbose; I don't
    believe there is any ambiguity without that extra space.
  4. Add dTreeLIR()/cTreeLIR() functions for use in the debugger.

1. Use the LIR node dumper to display nodes to be generated by
codegen, since we're in LIR form at that point. Add a new
"prefix message" argument to allow "Generating: " to prefix all
such lines.
2. Fix off-by-one error in LIR dump due to `#ifdef` versus `#if`.
3. Remove extra trailing line for each LIR node. This interfered
with #1. But I always thought it was unnecessarily verbose; I don't
believe there is any ambiguity without that extra space.
4. Add dTreeLIR()/cTreeLIR() functions for use in the debugger.
@BruceForstall
Copy link
Member Author

@dotnet/jit-contrib PTAL

@@ -501,11 +501,13 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode)

#ifdef DEBUG
lastConsumedNode = nullptr;
if (compiler->verbose)
{
unsigned seqNum = treeNode->gtSeqNum; // Useful for setting a conditional break in Visual Studio
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not set a breakpoint on treeNode->gtSeqNum itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it. I just copy-and-pasted that from the other codegen files. Since it doesn't hurt, it made sense to keep it the same.

assert(operand != nullptr);
assert(message != nullptr);

if (prefixMsg != nullptr)
{
printf("%s", prefixMsg);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: you could capture the length of prefixMsg and use it to adjust the alignment below. I'd be interested to see how the codegen dumps looked in both cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the prefixMsg is output for both the operand (here), and the operator (below), and the operator doesn't have any leading space. And, I want the operator and operands to be indented by the same amount, when a prefixMsg is given.

Here's an example from codegen:

Generating: N037 (  1,  4) [000034] ------------       t34 =    const(h)  int    0x8B6604 ftn REG NA
Generating:                                                  /--*  t34    int
Generating: N039 (  3,  6) [000035] ------------       t35 = *  indir     int    REG NA
Generating:                                                  /--*  t35    int    control expr
Generating: N041 ( 69, 33) [000008] --C-G-------             *  call      void   System.Console.WriteLine $VN.Void

A "full dump" looks like:

                                                 /--*  t32    int    control expr
N029 ( 45, 22) [000005] --C-G-------        t5 = *  call      float  Program.f2 $c3
                                                 /--*  t5     float
N031 ( 49, 25) [000021] DAC-G-----L-             *  st.lclVar float  V02 tmp1         d:2 REG NA
N033 (  3,  2) [000022] ------------       t22 =    lclVar    float  V02 tmp1         u:2 (last use) REG NA $c3
                                                 /--*  t22    float
N035 (???,???) [000033] ------------             *  putarg_stk [+0x00] float  REG NA
N037 (  1,  4) [000034] ------------       t34 =    const(h)  int    0x8B6604 ftn REG NA
                                                 /--*  t34    int
N039 (  3,  6) [000035] ------------       t35 = *  indir     int    REG NA
                                                 /--*  t35    int    control expr
N041 ( 69, 33) [000008] --C-G-------             *  call      void   System.Console.WriteLine $VN.Void
N043 (  2,  2) [000013] ------------                il_offset void   IL offset: 25 REG NA
N045 (  1,  1) [000011] ------------       t11 =    const     int    100 REG NA $42
                                                 /--*  t11    int
N047 (  2,  2) [000012] ------------             *  return    int    REG NA $1c0

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hugely picky of me, but is there any chance we could avoid printing the message before the operands? No big deal if there isn't.

@BruceForstall
Copy link
Member Author

@pgavlin @dotnet/jit-contrib any additional comments?

Copy link

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from one super-picky nit :)

@BruceForstall
Copy link
Member Author

@pgavlin Done. Sample codegen output now:

Generating: N245 (  1,  1) [000115] ------------      t115 =    const     int    0 REG NA $40
                                                             /--*  t115   int
Generating: N247 (???,???) [000210] ------------             *  putarg_stk [+0x00] int    REG NA
IN0031:        push     0
Generating: N249 (  1,  1) [000113] ------------      t113 =    lclVar    ref    V00 this         u:2 esi (last use) REG esi RV $80
                                                             /--*  t113   ref
Generating: N251 (???,???) [000211] ------------      t211 = *  putarg_reg ref    REG ecx

@pgavlin
Copy link

pgavlin commented Mar 13, 2017

LGTM. Thanks for making the change!

@BruceForstall BruceForstall merged commit 8d749d3 into dotnet:master Mar 14, 2017
@BruceForstall BruceForstall deleted the LIRdumps branch March 14, 2017 01:33
jorive pushed a commit to guhuro/coreclr that referenced this pull request May 4, 2017
1. Use the LIR node dumper to display nodes to be generated by
codegen, since we're in LIR form at that point. Add a new
"prefix message" argument to allow "Generating: " to prefix all
such lines.
2. Fix off-by-one error in LIR dump due to `#ifdef` versus `#if`.
3. Remove extra trailing line for each LIR node. This interfered
with dotnet#1. But I always thought it was unnecessarily verbose; I don't
believe there is any ambiguity without that extra space.
4. Add dTreeLIR()/cTreeLIR() functions for use in the debugger.
@karelz karelz modified the milestone: 2.0.0 Aug 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants