davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
197 stars 58 forks source link

no Function objects available in lto, show-lto-supergraph.py example doesn't work #118

Open fHachenberg opened 6 years ago

fHachenberg commented 6 years ago

At link time (and using the compiler flags described here http://gcc-python-plugin.readthedocs.io/en/latest/lto.html?highlight=supergraph) I always get None for the function object. The example script outputs an empty png.

for node in get_callgraph_nodes():
           fun = node.decl.function
           if fun:
               for edge in node.callees:
                   if edge.callee.decl.function:
                       ipcalls.add(edge.call_stmt)

I tested this using gcc-6 and gcc-7 and Python 2.7, Python 3.6 on a Ubuntu 17.10 workstation.

fHachenberg commented 6 years ago

For the case

./gcc-with-python \
  examples/show-lto-supergraph.py \
  -flto \
  -flto-partition=none \
    tests/examples/lto/input-* -c

I verified, that I end up with object files containing lto info (output of readelf):

readelf -a input-f.o | grep lto

[ 4] .gnu.lto_.inline. PROGBITS         0000000000000000  00000040
[ 5] .gnu.lto_f.f5283c PROGBITS         0000000000000000  00000064
[ 6] .gnu.lto_.symbol_ PROGBITS         0000000000000000  00000252
[ 7] .gnu.lto_.refs.f5 PROGBITS         0000000000000000  00000287
[ 8] .gnu.lto_.decls.f PROGBITS         0000000000000000  00000296
[ 9] .gnu.lto_.symtab. PROGBITS         0000000000000000  00000593
[10] .gnu.lto_.opts    PROGBITS         0000000000000000  000005a4
  14: 0000000000000001     1 OBJECT  GLOBAL DEFAULT  COM __gnu_lto_v1
  15: 0000000000000001     1 OBJECT  GLOBAL DEFAULT  COM __gnu_lto_slim
ampresent commented 3 years ago

hi, have you solved it? many thanks.

taptipalit commented 3 years ago

Any luck with this?