From 233b217b012938f640021047073d240ec0213616 Mon Sep 17 00:00:00 2001 From: York Jasper Niebuhr Date: Wed, 15 Oct 2025 23:03:02 +0200 Subject: [PATCH] Docs updated --- docs/plan.txt | 12 +++++++++++- docs/writeup.txt | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/plan.txt b/docs/plan.txt index 11cf659..c9792ef 100644 --- a/docs/plan.txt +++ b/docs/plan.txt @@ -1,10 +1,20 @@ General: - Use custom __builtin_offsetof definition to preserve the call until lower gimple -Approach: +OLD Approach: - At the very last point of gimple (after gimple optimizations), recognize accesses - Build a mapping of statement location (multiple statements share) to a semantic graph (or tree) - Right after expansion to RTL, pattern match set of RTL instructions with same location to graph - Add notes (persistent over RTL transformations) to any RTL instruction that is relevant - After all RTL optimizations, add assembly labels before relevant RTL instructions (identified by notes) - Might need an additional early pass to prevent COMPONENT_REFs to constant/static stuff from being folded early + +Approach: +- At the very first point of gimple (before optimizations), replace COMPONENT_REFs of relevant structs + - Turn them into calls of __spslr_component_ref(base (new ssa stmt), type uid, member uid) + - Make sure the return type is matching that of the COMPONENT_REF (member type) +- Let those calls get lowered all the way into UNOPTIMIZED RTL +- Replace calls by inserting original constants and attaching notes +- Let RTL optimizations do their job with those many separate constants +- At the very end of RTL, recognize member offsets by notes and add assembly labels +- MIGHT require some logic to trace notes through RTL optimizations (which operand?, combined how?) diff --git a/docs/writeup.txt b/docs/writeup.txt index 8901464..4f1b8bf 100644 --- a/docs/writeup.txt +++ b/docs/writeup.txt @@ -18,3 +18,4 @@ Constant foldable expressions, e.g. "size_t myOffset = ((size_t)&((struct task_s -> gcc folds those expressions before PLUGIN_FINISH_PARSE_FUNCTION -> any recoverability of COMPONENT_REF is impossible -> requires gcc patch (fairly small one though) + -> fold_offsetof in the C frontend is responsible