From: Julian Seward Date: Mon, 14 Mar 2011 12:35:18 +0000 (+0000) Subject: Wrap up "__attribute__((regparm(n)))" inside a macro so it is only X-Git-Tag: svn/VALGRIND_3_7_0^2~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4e22ed79287a39569a5d8b4c840f1d2bb9f10c4;p=thirdparty%2Fvalgrind.git Wrap up "__attribute__((regparm(n)))" inside a macro so it is only visible on x86, so as to avoid producing compiler warnings on targets for which it is ignored. Fixes #247223. (Modified version of patch from Bart Van Assche). git-svn-id: svn://svn.valgrind.org/vex/trunk@2108 --- diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c index 0f0a4f99bc..812fc3c6ee 100644 --- a/VEX/priv/guest_generic_bb_to_IR.c +++ b/VEX/priv/guest_generic_bb_to_IR.c @@ -42,58 +42,58 @@ /* Forwards .. */ -__attribute__((regparm(2))) +VEX_REGPARM(2) static UInt genericg_compute_checksum_4al ( HWord first_w32, HWord n_w32s ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_1 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_2 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_3 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_4 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_5 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_6 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_7 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_8 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_9 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_10 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_11 ( HWord first_w32 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_12 ( HWord first_w32 ); -__attribute__((regparm(2))) +VEX_REGPARM(2) static ULong genericg_compute_checksum_8al ( HWord first_w64, HWord n_w64s ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_1 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_2 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_3 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_4 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_5 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_6 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_7 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_8 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_9 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_10 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_11 ( HWord first_w64 ); -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_12 ( HWord first_w64 ); /* Small helpers */ @@ -425,8 +425,8 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, UInt len2check; HWord expectedhW; IRTemp tistart_tmp, tilen_tmp; - HWord __attribute__((regparm(2))) (*fn_generic)(HWord, HWord); - HWord __attribute__((regparm(1))) (*fn_spec)(HWord); + HWord VEX_REGPARM(2) (*fn_generic)(HWord, HWord); + HWord VEX_REGPARM(1) (*fn_spec)(HWord); HChar* nm_generic; HChar* nm_spec; HWord fn_generic_entry = 0; @@ -466,11 +466,11 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, /* vex_printf("%lx %lx %ld\n", first_w32, last_w32, w32s_to_check); */ if (host_word_szB == 8) { - fn_generic = (__attribute__((regparm(2))) HWord(*)(HWord, HWord)) + fn_generic = (VEX_REGPARM(2) HWord(*)(HWord, HWord)) genericg_compute_checksum_8al; nm_generic = "genericg_compute_checksum_8al"; } else { - fn_generic = (__attribute__((regparm(2))) HWord(*)(HWord, HWord)) + fn_generic = (VEX_REGPARM(2) HWord(*)(HWord, HWord)) genericg_compute_checksum_4al; nm_generic = "genericg_compute_checksum_4al"; } @@ -480,7 +480,7 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, if (host_word_szB == 8) { HChar* nm = NULL; - ULong __attribute__((regparm(1))) (*fn)(HWord) = NULL; + ULong VEX_REGPARM(1) (*fn)(HWord) = NULL; switch (hWs_to_check) { case 1: fn = genericg_compute_checksum_8al_1; nm = "genericg_compute_checksum_8al_1"; break; @@ -508,11 +508,11 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, nm = "genericg_compute_checksum_8al_12"; break; default: break; } - fn_spec = (__attribute__((regparm(1))) HWord(*)(HWord)) fn; + fn_spec = (VEX_REGPARM(1) HWord(*)(HWord)) fn; nm_spec = nm; } else { HChar* nm = NULL; - UInt __attribute__((regparm(1))) (*fn)(HWord) = NULL; + UInt VEX_REGPARM(1) (*fn)(HWord) = NULL; switch (hWs_to_check) { case 1: fn = genericg_compute_checksum_4al_1; nm = "genericg_compute_checksum_4al_1"; break; @@ -540,7 +540,7 @@ IRSB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, nm = "genericg_compute_checksum_4al_12"; break; default: break; } - fn_spec = (__attribute__((regparm(1))) HWord(*)(HWord))fn; + fn_spec = (VEX_REGPARM(1) HWord(*)(HWord))fn; nm_spec = nm; } @@ -661,7 +661,7 @@ static inline UInt ROL32 ( UInt w, Int n ) { return w; } -__attribute((regparm(2))) +VEX_REGPARM(2) static UInt genericg_compute_checksum_4al ( HWord first_w32, HWord n_w32s ) { UInt sum1 = 0, sum2 = 0; @@ -689,7 +689,7 @@ static UInt genericg_compute_checksum_4al ( HWord first_w32, HWord n_w32s ) /* Specialised versions of the above function */ -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_1 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -700,7 +700,7 @@ static UInt genericg_compute_checksum_4al_1 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_2 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -713,7 +713,7 @@ static UInt genericg_compute_checksum_4al_2 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_3 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -728,7 +728,7 @@ static UInt genericg_compute_checksum_4al_3 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_4 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -742,7 +742,7 @@ static UInt genericg_compute_checksum_4al_4 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_5 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -758,7 +758,7 @@ static UInt genericg_compute_checksum_4al_5 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_6 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -776,7 +776,7 @@ static UInt genericg_compute_checksum_4al_6 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_7 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -796,7 +796,7 @@ static UInt genericg_compute_checksum_4al_7 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_8 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -815,7 +815,7 @@ static UInt genericg_compute_checksum_4al_8 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_9 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -836,7 +836,7 @@ static UInt genericg_compute_checksum_4al_9 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_10 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -859,7 +859,7 @@ static UInt genericg_compute_checksum_4al_10 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_11 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -884,7 +884,7 @@ static UInt genericg_compute_checksum_4al_11 ( HWord first_w32 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static UInt genericg_compute_checksum_4al_12 ( HWord first_w32 ) { UInt sum1 = 0, sum2 = 0; @@ -916,7 +916,7 @@ static inline ULong ROL64 ( ULong w, Int n ) { return w; } -__attribute((regparm(2))) +VEX_REGPARM(2) static ULong genericg_compute_checksum_8al ( HWord first_w64, HWord n_w64s ) { ULong sum1 = 0, sum2 = 0; @@ -944,7 +944,7 @@ static ULong genericg_compute_checksum_8al ( HWord first_w64, HWord n_w64s ) /* Specialised versions of the above function */ -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_1 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -955,7 +955,7 @@ static ULong genericg_compute_checksum_8al_1 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_2 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -968,7 +968,7 @@ static ULong genericg_compute_checksum_8al_2 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_3 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -983,7 +983,7 @@ static ULong genericg_compute_checksum_8al_3 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_4 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -997,7 +997,7 @@ static ULong genericg_compute_checksum_8al_4 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_5 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1013,7 +1013,7 @@ static ULong genericg_compute_checksum_8al_5 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_6 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1031,7 +1031,7 @@ static ULong genericg_compute_checksum_8al_6 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_7 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1051,7 +1051,7 @@ static ULong genericg_compute_checksum_8al_7 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_8 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1070,7 +1070,7 @@ static ULong genericg_compute_checksum_8al_8 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_9 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1091,7 +1091,7 @@ static ULong genericg_compute_checksum_8al_9 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_10 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1114,7 +1114,7 @@ static ULong genericg_compute_checksum_8al_10 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_11 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; @@ -1139,7 +1139,7 @@ static ULong genericg_compute_checksum_8al_11 ( HWord first_w64 ) return sum1 + sum2; } -__attribute__((regparm(1))) +VEX_REGPARM(1) static ULong genericg_compute_checksum_8al_12 ( HWord first_w64 ) { ULong sum1 = 0, sum2 = 0; diff --git a/VEX/priv/guest_x86_defs.h b/VEX/priv/guest_x86_defs.h index 96335335f1..037bb6f9b1 100644 --- a/VEX/priv/guest_x86_defs.h +++ b/VEX/priv/guest_x86_defs.h @@ -86,7 +86,7 @@ extern UInt x86g_calculate_eflags_all ( UInt cc_op, UInt cc_dep1, UInt cc_dep2, UInt cc_ndep ); -__attribute((regparm(3))) +VEX_REGPARM(3) extern UInt x86g_calculate_eflags_c ( UInt cc_op, UInt cc_dep1, UInt cc_dep2, UInt cc_ndep ); diff --git a/VEX/priv/guest_x86_helpers.c b/VEX/priv/guest_x86_helpers.c index c538c07662..eebc7c26fe 100644 --- a/VEX/priv/guest_x86_helpers.c +++ b/VEX/priv/guest_x86_helpers.c @@ -588,7 +588,7 @@ UInt x86g_calculate_eflags_all ( UInt cc_op, /* CALLED FROM GENERATED CODE: CLEAN HELPER */ /* Calculate just the carry flag from the supplied thunk parameters. */ -__attribute((regparm(3))) +VEX_REGPARM(3) UInt x86g_calculate_eflags_c ( UInt cc_op, UInt cc_dep1, UInt cc_dep2, diff --git a/VEX/pub/libvex_basictypes.h b/VEX/pub/libvex_basictypes.h index 0d3e800060..56309962b9 100644 --- a/VEX/pub/libvex_basictypes.h +++ b/VEX/pub/libvex_basictypes.h @@ -130,29 +130,40 @@ typedef unsigned long HWord; and ULong_to_Ptr in a way that doesn't cause compilers to complain. These functions allow us to cast pointers to and from 64-bit integers without complaints from compilers, regardless of the host - word size. */ + word size. + + Also set up VEX_REGPARM. +*/ #undef VEX_HOST_WORDSIZE +#undef VEX_REGPARM /* The following 4 work OK for Linux. */ #if defined(__x86_64__) # define VEX_HOST_WORDSIZE 8 +# define VEX_REGPARM(_n) /* */ #elif defined(__i386__) # define VEX_HOST_WORDSIZE 4 +# define VEX_REGPARM(_n) __attribute__((regparm(_n))) #elif defined(__powerpc__) && defined(__powerpc64__) # define VEX_HOST_WORDSIZE 8 +# define VEX_REGPARM(_n) /* */ #elif defined(__powerpc__) && !defined(__powerpc64__) # define VEX_HOST_WORDSIZE 4 #elif defined(__arm__) # define VEX_HOST_WORDSIZE 4 +# define VEX_REGPARM(_n) /* */ #elif defined(_AIX) && !defined(__64BIT__) # define VEX_HOST_WORDSIZE 4 +# define VEX_REGPARM(_n) /* */ #elif defined(_AIX) && defined(__64BIT__) # define VEX_HOST_WORDSIZE 8 +# define VEX_REGPARM(_n) /* */ #elif defined(__s390x__) # define VEX_HOST_WORDSIZE 8 +# define VEX_REGPARM(_n) /* */ #else # error "Vex: Fatal: Can't establish the host architecture" diff --git a/VEX/pub/libvex_ir.h b/VEX/pub/libvex_ir.h index d005bf2292..3b5b272c16 100644 --- a/VEX/pub/libvex_ir.h +++ b/VEX/pub/libvex_ir.h @@ -322,9 +322,10 @@ extern Bool eqIRConst ( IRConst*, IRConst* ); /* Describes a helper function to call. The name part is purely for pretty printing and not actually used. regparms=n tells the back end that the callee has been declared - "__attribute__((regparm(n)))". On some targets (x86) the back end - will need to construct a non-standard sequence to call a function - declared like this. + "__attribute__((regparm(n)))", although indirectly using the + VEX_REGPARM(n) macro. On some targets (x86) the back end will need + to construct a non-standard sequence to call a function declared + like this. mcx_mask is a sop to Memcheck. It indicates which args should be considered 'always defined' when lazily computing definedness of