On 1/4/19 9:03 AM, Matthew Malcomson wrote: > Hi there, > > I'm trying to figure out precisely what NOTE_INSN_FUNCTION_BEG means and > hoping someone here knows. It doesn't mean very much anymore. I believe it was used to distinguish between stuff like copying incoming arguments into pseudos and real user code.
However, in a world with instruction scheduling and other code motion it just doesn't have much use because it's so imprecise, particularly as we get deeper into the RTL pipeline. > > The gcc internal documentation says it "Appears at the start of the > function body, after the function prologue." but this isn't very > precise, and it seems to not distinguish between the undocumented > NOTE_INSN_PROLOGUE_END and the NOTE_INSN_FUNCTION_BEG. > > A comment in dwarf2out.c shows it's used as a marker between boilerplate > and code corresponding to things "the user wrote". > This assumption is broken by things like -fstack-protector-strong (as > bugzilla 88432 shows). That was the intent, but I think it's a concept that's fundamentally flawed through much of the RTL pipeline these days. > > alias.c seems to use it to assume that argument registers have their > original values before it (see the use of the "copying_arguments" > variable and find_base_value function). > I'm not yet certain of this, but if that is the assumption I think this > is also not observed. > > The test file below compiles to something breaking that assumption when > compiled with `gcc -fsanitize=address -S test.c -o test.s -g3 > -fdump-rtl-final -O0` on aarch64. > > #include <string.h> > #include <stdio.h> > int main (int argc, char *argv[]) { > char buf[64]; > return !strcpy (buf, strrchr (argv[0], '/')); > } > > > Is there any tight meaning to NOTE_INSN_FUNCTION_BEG? > > I'm wondering whether it should be split into one note to determine for > the debugging use and another for the use in alias.c. Well, the question I'd ask is precisely what are you trying to mark? Jeff