public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/114938] New: Basic blocks in generated CFG referencing the incorrect source token column
@ 2024-05-03 14:27 0xd at tutamail dot com
  2024-05-03 20:48 ` [Bug middle-end/114938] " pinskia at gcc dot gnu.org
  2024-05-03 20:53 ` [Bug c/114938] Function argument column info seems to have been lost pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: 0xd at tutamail dot com @ 2024-05-03 14:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114938

            Bug ID: 114938
           Summary: Basic blocks in generated CFG referencing the
                    incorrect source token column
           Product: gcc
           Version: 11.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 0xd at tutamail dot com
  Target Milestone: ---

Created attachment 58101
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58101&action=edit
reprocessed intermediate, original source, and CFG output with line number,
basic blocks

I'm currently working with gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04),
the official package for the repo using the following options to dump the
intermediate and cfg files:

-save-temps=obj -Wa,-adhn -g -fdump-tree-cfg-blocks-lineno

I've noticed though the line numbers are correct in the CFG, the column numbers
don't seem to correspond to the referenced location in the original C file. As
an example:

CFG:
;;   basic block 2, loop depth 0
...
  [kernel/sysctl.c:372:5] if (write != 0)
...
;;   basic block 3, loop depth 0
...
  [kernel/sysctl.c:373:3] proc_first_pos_non_zero_ignore (ppos, table);
...
;;   basic block 4, loop depth 0
  [kernel/sysctl.c:375:9] _1 = [kernel/sysctl.c:375:9] table->maxlen;
  [kernel/sysctl.c:375:30] _2 = [kernel/sysctl.c:375:30] table->data;
  [kernel/sysctl.c:375:9] D.100751 = _proc_do_string (_2, _1, write, buffer,
lenp, ppos);
  [kernel/sysctl.c:375:9] return D.100751;

C source:        
int proc_dostring(struct ctl_table *table, int write,
                  void *buffer, size_t *lenp, loff_t *ppos)
{
372:    if (write)
--->    ^ "if" token starts at column 5, this is CORRECT in the CFG
373:            proc_first_pos_non_zero_ignore(ppos, table);
--->            ^ starts at column 9, this is INCORRECT in CFG (3)
375:    return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
                        ppos);
--->                                        ^ this starts at column 41 (CFG, 9) 
                               ^this starts at column 28 (CFG, 30)
}
// column 9 is referenced 3 times for line 375, but this is just corresponds to
// the second "r" in "return" in the original source.
// the dereference assignment, function call, and return.

I'm confused where these column numbers in the output CFG are coming from. For
the moment I'm only referencing the line number but it would much more
beneficial to get the exact column of the original token, especially when
dealing with compound/conditional statements which will branch off to multiple
basic blocks.

Also of note, I haven't tested any of the newer gcc versions since the source
I'm working with won't compile with newer features added in 12+.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug middle-end/114938] Basic blocks in generated CFG referencing the incorrect source token column
  2024-05-03 14:27 [Bug rtl-optimization/114938] New: Basic blocks in generated CFG referencing the incorrect source token column 0xd at tutamail dot com
@ 2024-05-03 20:48 ` pinskia at gcc dot gnu.org
  2024-05-03 20:53 ` [Bug c/114938] Function argument column info seems to have been lost pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-03 20:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114938

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 58102
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58102&action=edit
reduced

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/114938] Function argument column info seems to have been lost
  2024-05-03 14:27 [Bug rtl-optimization/114938] New: Basic blocks in generated CFG referencing the incorrect source token column 0xd at tutamail dot com
  2024-05-03 20:48 ` [Bug middle-end/114938] " pinskia at gcc dot gnu.org
@ 2024-05-03 20:53 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-03 20:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114938

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |c
            Summary|Basic blocks in generated   |Function argument column
                   |CFG referencing the         |info seems to have been
                   |incorrect source token      |lost
                   |column                      |

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take the reduced testcase we get using the C front-end:
```
int proc_dostring (struct ctl_table * table, int write, void * buffer, int *
lenp, int * ppos)
[/app/example.cpp:13:1] {
  int D.2793;

  [/app/example.cpp:14:5] if (write != 0) goto <D.2791>; else goto <D.2792>;
  <D.2791>:
  [/app/example.cpp:15:3] proc_first_pos_non_zero_ignore (ppos, table);
  <D.2792>:
  [/app/example.cpp:17:9] _1 = [/app/example.cpp:17:9] table->maxlen;
  [/app/example.cpp:17:9] _2 = [/app/example.cpp:17:9] table->data;
  [/app/example.cpp:17:9] D.2793 = _proc_do_string (_2, _1, write, buffer,
lenp, ppos);
  [/app/example.cpp:17:9] return D.2793;
}

```

The column 9 is the start of the call. But really the first statement should
have a column of 24.

Note with the C++ FE we get:

  [/app/example.cpp:17:24] _1 = [/app/example.cpp:17:24] table->maxlen;
  [/app/example.cpp:17:24] _2 = [/app/example.cpp:17:24] table->data;
  [/app/example.cpp:17:24] D.2822 = _proc_do_string (_2, _1, write, buffer,
lenp, ppos);
  [/app/example.cpp:17:24 discrim 1] D.2820 = D.2822;

the :24 is the column after `(`.

But _2 statement really should be the column after the first `,`.

I remember seeing this before ...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-03 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03 14:27 [Bug rtl-optimization/114938] New: Basic blocks in generated CFG referencing the incorrect source token column 0xd at tutamail dot com
2024-05-03 20:48 ` [Bug middle-end/114938] " pinskia at gcc dot gnu.org
2024-05-03 20:53 ` [Bug c/114938] Function argument column info seems to have been lost pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).