When building code with -mregparm=x on i?86 which uses libgcc functions (eg. udivdi3), the calls to the libgcc functions use the calling convention as given by mregparm, even though libgcc is internal to the compiler (and the user has no ultimate control about when it is used).
Adding the compiler-native calling convention as regparm attribute to all calls that are synthesized by the compiler might fix the problem. The following shell script exhibits the problem. cat > test.c << EOF int main() { long long a= 4000000000; return a / 43937; } EOF gcc -S test.c mv test.s test.default.s gcc -mregparm=3 -S test.c mv test.s test.mregparm3.s diff -u test.default.s test.mregparm3.s exit 0 # there should be no difference in the calling convention # as __divdi3 is taken from libgcc, but I get the result: --- test.default.s Do. Aug 13 15:47:28 2009 +++ test.mregparm3.s Do. Aug 13 15:47:28 2009 -18,10 +18,9 @@ movl $0, -4(%ebp) movl -8(%ebp), %eax movl -4(%ebp), %edx + subl $8, %esp pushl $0 pushl $43937 - pushl %edx - pushl %eax call __divdi3 addl $16, %esp leave -- Summary: libgcc functions and -mregparm don't work well together Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: patrick dot georgi at coresystems dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41055