Hi, On Tue, Apr 06 2021, Erick Ochoa wrote: >> On Fri, Mar 26 2021, Erick Ochoa via Gcc wrote: >> > I already have some experience developing SIMPLE_IPA_PASSes, but I am >> > looking to understand IPA_PASSes better. I have made a hello world ipa >> > pass that stores "hello world $FUNCTION_NAME" in the function >> > summaries; however, I am having trouble reading this information back. >> > Can someone help me understand how to use these interfaces correctly? >> > >> > At the moment, it **seems** to be writing information correctly. >> > (I.e., it doesn't segfault when attempting to write data.) However, in >> > my read summary function (ipa_hello_world_read_summary (void)) the >> > function `lto_get_summary_section_data (file_data, >> > LTO_section_ipa_hello_world, &len);` always returns NULL and >> > `file_data_vec` is of size 1. This means that at run time, there is >> > only one call to `lto_get_summary_section_data` and it returns NULL. >> >> I looked at the code you posted and compared it with streaming in >> ipa-sra.c and did not spot any difference that could result in this >> behavior. >> >> You can try and send the whole patch (hopefully a hello world pass would >> not be too large) and I can have a look. > > thanks for taking some time to help me. I think I accidentally deleted > the original hello world pass, but I have re-made it and I still have > the same problem. I copy paste the patch at the bottom.
First, please either send patches as attachments or use an email client which does not corrupt the patch format. What you sent had some spaces removed and long lines clipped, which meant I had to manually fix it to try it. Doable for patch this small but if it was even a tiny bit bigger, I would have to ask you to resend it. Second, your problem seems to be that you are missing an entry in lto_section_name in lto-section-in.c that would correspond to the one you added to lto_section_type. You also forgot to copy calls to lto_free_section_data and lto_data_in_delete which means that subsequent attempts to stream stuff in them then ICE. The streaming API, especially the code setting it all up, is fairly horrible, which is a known issue. New IPA passes are however added only seldom, which means the incentive to clean it up is fairly low, unfortunately. Martin