------- Comment #13 from phcoder at gmail dot com 2009-09-05 20:34 ------- (In reply to comment #2) > Created an attachment (id=18480) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18480&action=view) [edit] > gcc45-pr41246.patch > > I'm afraid there is nothing that can make that unmodified testcase work for > -mregparm=3. > It is true that gcc is buggy and doesn't force regparm(2) for nested functions > with -mregparm=3 (regparm(3) is impossible, due to the static chain in %ecx), Could this chain perhaps be moved to %edx? > we only error if explicit __attribute__((regparm (3))) is used on nested > functions. > But if we silently change the call to regparm(2), there is no way for the > compiler to know whether the hook is using regparm(3) or regparm(2) calling > convention If you pass a pointer to nested function you actually pass a pointer to a trampoline. Could trampoline just push %ecx as its first operation? this way trampoline would "convert" regparm(2) to regparm(3) function (if you pass it a non-nested function, it will be regparm(3), if you > pass a nested function, it will be regparm(2). So, perhaps we should just > error out whenever we see in -m32 mode on i?86/x86_64 a nested function in > -mregparm=3 mode. >
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41246