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+.