Updated playground

This commit is contained in:
York Jasper Niebuhr 2025-10-17 22:09:17 +02:00
parent 7ef422b824
commit 08272b175a
2 changed files with 15 additions and 6 deletions

View File

@ -6,3 +6,7 @@ make all-target-libstdc++-v3 -j8
./gcc/xg++ -B./gcc/ -shared -fPIC -fno-rtti -I ../gcc/include -I ../gcc/gcc plugin.cpp -I ./gcc -I ./x86_64-pc-linux-gnu/libstdc++-v3/include -I ./x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I ../gcc/libstdc++-v3/include -I ../gcc/libstdc++-v3/libsupc++ -I ../gcc/libcpp/include -L ./x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -o myplugin.so
./gcc/xgcc -B./gcc -fplugin=./myplugin.so -fdump-tree-original test.c -o test
git log
git format-patch -1 <hash>
python3 contrib/check_GNU_style.py gcc_component_ref.patch

View File

@ -19,9 +19,6 @@
#include <builtins.h>
#include <unordered_map>
typedef tree (*c_component_ref_hook_fn) (tree ref);
extern "C" void c_register_component_ref_hook (c_component_ref_hook_fn hook);
int plugin_is_GPL_compatible;
struct MemberOffset {
@ -264,15 +261,23 @@ static tree my_component_ref_cb (tree ref)
return new_ref; // ALWAYS an INDIRECT_REF, directly to the member (same type as COMPONENT_REF!)
}
static void build_component_ref_cb(void* event_data, void* user_data) {
tree* component_ref_node = (tree*)event_data;
if (!component_ref_node)
return;
tree repl = my_component_ref_cb(*component_ref_node);
if (repl)
*component_ref_node = repl;
}
int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) {
if (!plugin_default_version_check(version, &gcc_version)) {
std::cerr << "GCC version mismatch!" << std::endl;
return 1;
}
c_register_component_ref_hook(my_component_ref_cb);
// register_callback(plugin_info->base_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
register_callback(plugin_info->base_name, PLUGIN_BUILD_COMPONENT_REF, build_component_ref_cb, NULL);
struct register_pass_info access_discover_pass_info;
access_discover_pass_info.pass = new access_discover_pass(nullptr);