1 From fe2afdf3f3701489c05d2a7509752d6f0c7616f7 Mon Sep 17 00:00:00 2001 2 From: Doug Kwan <dougkwan (a] google.com> 3 Date: Fri, 10 Jun 2011 16:02:39 -0700 4 Subject: [PATCH 3/4] Sync internal and external version: 5 6 Changes: 7 -x86 security patch (for ChromeOS) 8 -Fix bug in inlining. 9 -Fix freestanding C++ library build: 10 http://gcc.gnu.org/viewcvs?view=revision&revision=173220 11 -Fix out-of-range branches in Thumb-2 mode. 12 -Fix gcda file corruption problem. 13 -Hanlde LDFLAGS_FOR_TARGETS in configure. This is a backport of upstrem 14 patch r173558. 15 -Backport upstream fix for Atom performance at r164379. 16 17 Change-Id: Id5a6cfb8949cbd390a0bb3546d55d83383ee4f8c 18 --- 19 gcc-4.4.3/README.google | 62 ++++++++++ 20 gcc-4.4.3/configure | 5 +- 21 gcc-4.4.3/configure.ac | 2 + 22 gcc-4.4.3/gcc/config/arm/thumb2.md | 10 +- 23 gcc-4.4.3/gcc/config/i386/i386.c | 137 +++++++++++++++++++++- 24 gcc-4.4.3/gcc/config/i386/i386.h | 3 + 25 gcc-4.4.3/gcc/config/i386/i386.md | 34 ++++++ 26 gcc-4.4.3/gcc/esp.h | 16 +++- 27 gcc-4.4.3/gcc/gcc.c | 7 +- 28 gcc-4.4.3/gcc/ipa-inline.c | 3 +- 29 gcc-4.4.3/gcc/libgcov.c | 2 + 30 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-1.c | 9 ++ 31 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-10.c | 18 +++ 32 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-2.c | 9 ++ 33 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-3.c | 15 +++ 34 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-4.c | 13 ++ 35 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5a.c | 12 ++ 36 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5b.c | 12 ++ 37 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6a.c | 12 ++ 38 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6b.c | 12 ++ 39 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-7.c | 11 ++ 40 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-8.c | 11 ++ 41 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-9.c | 15 +++ 42 gcc-4.4.3/libstdc++-v3/include/Makefile.am | 1 + 43 gcc-4.4.3/libstdc++-v3/include/Makefile.in | 1 + 44 25 files changed, 415 insertions(+), 17 deletions(-) 45 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-1.c 46 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-10.c 47 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-2.c 48 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-3.c 49 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-4.c 50 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5a.c 51 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5b.c 52 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6a.c 53 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6b.c 54 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-7.c 55 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-8.c 56 create mode 100644 gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-9.c 57 58 diff --git a/gcc-4.4.3/README.google b/gcc-4.4.3/README.google 59 index f36db91..f626550 100644 60 --- a/gcc-4.4.3/README.google 61 +++ b/gcc-4.4.3/README.google 62 @@ -3386,3 +3386,65 @@ libstdc++/include/Makefile.in 63 Installed cpu_defines.h in freestanding standing mode (libstdc++/48123) 64 Owner: dougkwan 65 Status: In gcc trunk rev 171019 66 + 67 +gcc/gcc.c 68 +gcc/esp.h 69 + Added the ability to have the driver always pass in -D_FORTIFY_SOURCE=2 70 + when doing compiles. 71 + Also guarded -z,now and -z,relro with other defines. 72 + Owner: asharif 73 + Status: local, derived from Gentoo patchset: 74 + http://distfiles.gentoo.org/distfiles/gcc-4.4.3-patches-1.4.tar.bz2 75 + 76 +gcc/ipa-inline.c 77 + Fix updating of inlining priority for corner-case in which callsites of 78 + always_inline functions are promoted from indirect calls during inlining. 79 + Owner: meheff 80 + Status: local 81 + 82 +libstdc++-v3/include/Makefile.am 83 +libstdc++-v3/include/Makefile.in 84 + Backport r173220 from trunk to fix freestanding C++ library. 85 + http://gcc.gnu.org/viewcvs?view=revision&revision=173220 86 + Owner: dougkwan 87 + Status: upstream 88 + 89 +gcc/config/arm/thumb2.md 90 + Fix out-of-range branches in Thumb-2 mode. b/2961998 91 + Owner: dougkwan 92 + Status: In upstream r149501. 93 + 94 +gcc/libgcov.c 95 + Fix gcda corruption problem in b/4462929 reported by an external user. 96 + Fix contributed by <nkondrashov (a] nvidia.com> 97 + Owner: dougkwan 98 + Status: local 99 + 100 +Makefile.in 101 +Makefile.tpl 102 +configure 103 +configure.ac 104 + Propagate LDFLAGS_FOR_TARGETS in top level configure. 105 + This is required to build x86 Android toolchain properly. 106 + Owner: dougkwan 107 + Status: backport of upstream r173558 108 + 109 +gcc/config/i386/i386.c 110 +gcc/config/i386/i386.h 111 +gcc/config/i386/i386.md 112 +gcc/testsuite/gcc.target/i386/pad-1.c 113 +gcc/testsuite/gcc.target/i386/pad-10.c 114 +gcc/testsuite/gcc.target/i386/pad-2.c 115 +gcc/testsuite/gcc.target/i386/pad-3.c 116 +gcc/testsuite/gcc.target/i386/pad-4.c 117 +gcc/testsuite/gcc.target/i386/pad-5a.c 118 +gcc/testsuite/gcc.target/i386/pad-5b.c 119 +gcc/testsuite/gcc.target/i386/pad-6a.c 120 +gcc/testsuite/gcc.target/i386/pad-6b.c 121 +gcc/testsuite/gcc.target/i386/pad-7.c 122 +gcc/testsuite/gcc.target/i386/pad-8.c 123 +gcc/testsuite/gcc.target/i386/pad-9.c 124 + Backport r164379 from trunk to help Atom performance on small functions. 125 + http://gcc.gnu.org/viewcvs?view=revision&revision=164379 126 + Owner: asharif 127 + Status: upstream in r164379 128 diff --git a/gcc-4.4.3/configure b/gcc-4.4.3/configure 129 index 2804923..e713c32 100755 130 --- a/gcc-4.4.3/configure 131 +++ b/gcc-4.4.3/configure 132 @@ -272,7 +272,7 @@ PACKAGE_STRING= 133 PACKAGE_BUGREPORT= 134 135 ac_unique_file="move-if-change" 136 -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TOPLEVEL_CONFIGURE_ARGUMENTS build build_cpu build_vendor build_os build_noncanonical host_noncanonical target_noncanonical host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN LN_S build_libsubdir build_subdir host_subdir target_subdir enable_esp CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE do_compare gmplibs gmpinc extra_mpfr_configure_flags ppllibs pplinc clooglibs clooginc stage1_languages DEBUG_PREFIX_CFLAGS_FOR_TARGET CFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET RPATH_ENVVAR GCC_SHLIB_SUBDIR tooldir build_tooldir CONFIGURE_GDB_TK GDB_TK INSTALL_GDB_TK build_configargs build_configdirs host_configargs configdirs target_configargs AR_FOR_BUILD AS_FOR_BUILD CC_FOR_BUILD CFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CXX_FOR_BUILD DLLTOOL_FOR_BUILD GCJ_FOR_BUILD GFORTRAN_FOR_BUILD LDFLAGS_FOR_BUILD LD_FOR_BUILD NM_FOR_BUILD RANLIB_FOR_BUILD WINDMC_FOR_BUILD WINDRES_FOR_BUILD config_shell YACC BISON M4 LEX FLEX MAKEINFO EXPECT RUNTEST AR AS DLLTOOL LD LIPO NM RANLIB STRIP WINDRES WINDMC OBJCOPY OBJDUMP CC_FOR_TARGET CXX_FOR_TARGET GCC_FOR_TARGET GCJ_FOR_TARGET GFORTRAN_FOR_TARGET AR_FOR_TARGET AS_FOR_TARGET DLLTOOL_FOR_TARGET LD_FOR_TARGET LIPO_FOR_TARGET NM_FOR_TARGET OBJDUMP_FOR_TARGET RANLIB_FOR_TARGET STRIP_FOR_TARGET WINDRES_FOR_TARGET WINDMC_FOR_TARGET RAW_CXX_FOR_TARGET FLAGS_FOR_TARGET COMPILER_AS_FOR_TARGET COMPILER_LD_FOR_TARGET COMPILER_NM_FOR_TARGET MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT stage1_cflags stage1_checking stage2_werror_flag datarootdir docdir pdfdir htmldir LIBOBJS LTLIBOBJS' 137 +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS TOPLEVEL_CONFIGURE_ARGUMENTS build build_cpu build_vendor build_os build_noncanonical host_noncanonical target_noncanonical host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN LN_S build_libsubdir build_subdir host_subdir target_subdir enable_esp CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX GNATBIND ac_ct_GNATBIND GNATMAKE ac_ct_GNATMAKE do_compare gmplibs gmpinc extra_mpfr_configure_flags ppllibs pplinc clooglibs clooginc stage1_languages DEBUG_PREFIX_CFLAGS_FOR_TARGET CFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET RPATH_ENVVAR GCC_SHLIB_SUBDIR tooldir build_tooldir CONFIGURE_GDB_TK GDB_TK INSTALL_GDB_TK build_configargs build_configdirs host_configargs configdirs target_configargs AR_FOR_BUILD AS_FOR_BUILD CC_FOR_BUILD CFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CXX_FOR_BUILD DLLTOOL_FOR_BUILD GCJ_FOR_BUILD GFORTRAN_FOR_BUILD LDFLAGS_FOR_BUILD LD_FOR_BUILD NM_FOR_BUILD RANLIB_FOR_BUILD WINDMC_FOR_BUILD WINDRES_FOR_BUILD config_shell YACC BISON M4 LEX FLEX MAKEINFO EXPECT RUNTEST AR AS DLLTOOL LD LIPO NM RANLIB STRIP WINDRES WINDMC OBJCOPY OBJDUMP CC_FOR_TARGET CXX_FOR_TARGET GCC_FOR_TARGET GCJ_FOR_TARGET GFORTRAN_FOR_TARGET AR_FOR_TARGET AS_FOR_TARGET DLLTOOL_FOR_TARGET LD_FOR_TARGET LIPO_FOR_TARGET NM_FOR_TARGET OBJDUMP_FOR_TARGET RANLIB_FOR_TARGET STRIP_FOR_TARGET WINDRES_FOR_TARGET WINDMC_FOR_TARGET RAW_CXX_FOR_TARGET FLAGS_FOR_TARGET COMPILER_AS_FOR_TARGET COMPILER_LD_FOR_TARGET COMPILER_NM_FOR_TARGET MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT stage1_cflags stage1_checking stage2_werror_flag datarootdir docdir pdfdir htmldir LIBOBJS LTLIBOBJS' 138 ac_subst_files='serialization_dependencies host_makefile_frag target_makefile_frag alphaieee_frag ospace_frag' 139 ac_pwd=`pwd` 140 141 @@ -5586,6 +5586,8 @@ if test "x$CXXFLAGS_FOR_TARGET" = x; then 142 fi 143 144 145 + 146 + 147 # Handle --with-headers=XXX. If the value is not "yes", the contents of 148 # the named directory are copied to $(tooldir)/sys-include. 149 if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then 150 @@ -13289,6 +13291,7 @@ s,@stage1_languages@,$stage1_languages,;t t 151 s,@DEBUG_PREFIX_CFLAGS_FOR_TARGET@,$DEBUG_PREFIX_CFLAGS_FOR_TARGET,;t t 152 s,@CFLAGS_FOR_TARGET@,$CFLAGS_FOR_TARGET,;t t 153 s,@CXXFLAGS_FOR_TARGET@,$CXXFLAGS_FOR_TARGET,;t t 154 +s,@LDFLAGS_FOR_TARGET@,$LDFLAGS_FOR_TARGET,;t t 155 s,@RPATH_ENVVAR@,$RPATH_ENVVAR,;t t 156 s,@GCC_SHLIB_SUBDIR@,$GCC_SHLIB_SUBDIR,;t t 157 s,@tooldir@,$tooldir,;t t 158 diff --git a/gcc-4.4.3/configure.ac b/gcc-4.4.3/configure.ac 159 index 40aea37..5ae58cc 100644 160 --- a/gcc-4.4.3/configure.ac 161 +++ b/gcc-4.4.3/configure.ac 162 @@ -1891,6 +1891,8 @@ if test "x$CXXFLAGS_FOR_TARGET" = x; then 163 fi 164 AC_SUBST(CXXFLAGS_FOR_TARGET) 165 166 +AC_SUBST(LDFLAGS_FOR_TARGET) 167 + 168 # Handle --with-headers=XXX. If the value is not "yes", the contents of 169 # the named directory are copied to $(tooldir)/sys-include. 170 if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then 171 diff --git a/gcc-4.4.3/gcc/config/arm/thumb2.md b/gcc-4.4.3/gcc/config/arm/thumb2.md 172 index 6e03e8b..c982ea7 100644 173 --- a/gcc-4.4.3/gcc/config/arm/thumb2.md 174 +++ b/gcc-4.4.3/gcc/config/arm/thumb2.md 175 @@ -1190,7 +1190,7 @@ 176 (clobber (reg:CC CC_REGNUM))] 177 "TARGET_THUMB2" 178 "* 179 - if (get_attr_length (insn) == 2 && which_alternative == 0) 180 + if (get_attr_length (insn) == 2) 181 return \"cbz\\t%0, %l1\"; 182 else 183 return \"cmp\\t%0, #0\;beq\\t%l1\"; 184 @@ -1198,7 +1198,8 @@ 185 [(set (attr "length") 186 (if_then_else 187 (and (ge (minus (match_dup 1) (pc)) (const_int 2)) 188 - (le (minus (match_dup 1) (pc)) (const_int 128))) 189 + (le (minus (match_dup 1) (pc)) (const_int 128)) 190 + (eq (symbol_ref ("which_alternative")) (const_int 0))) 191 (const_int 2) 192 (const_int 8)))] 193 ) 194 @@ -1212,7 +1213,7 @@ 195 (clobber (reg:CC CC_REGNUM))] 196 "TARGET_THUMB2" 197 "* 198 - if (get_attr_length (insn) == 2 && which_alternative == 0) 199 + if (get_attr_length (insn) == 2) 200 return \"cbnz\\t%0, %l1\"; 201 else 202 return \"cmp\\t%0, #0\;bne\\t%l1\"; 203 @@ -1220,7 +1221,8 @@ 204 [(set (attr "length") 205 (if_then_else 206 (and (ge (minus (match_dup 1) (pc)) (const_int 2)) 207 - (le (minus (match_dup 1) (pc)) (const_int 128))) 208 + (le (minus (match_dup 1) (pc)) (const_int 128)) 209 + (eq (symbol_ref ("which_alternative")) (const_int 0))) 210 (const_int 2) 211 (const_int 8)))] 212 ) 213 diff --git a/gcc-4.4.3/gcc/config/i386/i386.c b/gcc-4.4.3/gcc/config/i386/i386.c 214 index fa148be..b237ed8 100644 215 --- a/gcc-4.4.3/gcc/config/i386/i386.c 216 +++ b/gcc-4.4.3/gcc/config/i386/i386.c 217 @@ -1481,6 +1481,9 @@ static unsigned int initial_ix86_tune_features[X86_TUNE_LAST] = { 218 /* X86_TUNE_PAD_RETURNS */ 219 m_AMD_MULTIPLE | m_CORE2 | m_GENERIC, 220 221 + /* X86_TUNE_PAD_SHORT_FUNCTION: Pad short funtion. */ 222 + m_ATOM, 223 + 224 /* X86_TUNE_EXT_80387_CONSTANTS */ 225 m_K6_GEODE | m_ATHLON_K8 | m_ATOM | m_PENT4 | m_NOCONA | m_PPRO 226 | m_CORE2 | m_GENERIC, 227 @@ -7640,6 +7643,11 @@ ix86_file_end (void) 228 229 xops[0] = gen_rtx_REG (Pmode, regno); 230 xops[1] = gen_rtx_MEM (Pmode, stack_pointer_rtx); 231 + /* Pad stack IP move with 4 instructions. 2 NOPs count as 1 232 + instruction. */ 233 + if (TARGET_PAD_SHORT_FUNCTION) 234 + output_asm_insn ("nop; nop; nop; nop; nop; nop; nop; nop", 235 + xops); 236 output_asm_insn ("mov%z0\t{%1, %0|%0, %1}", xops); 237 output_asm_insn ("ret", xops); 238 } 239 @@ -27911,17 +27919,134 @@ ix86_pad_returns (void) 240 } 241 } 242 243 +/* Count the minimum number of instructions in BB. Return 4 if the 244 + number of instructions >= 4. */ 245 + 246 +static int 247 +ix86_count_insn_bb (basic_block bb) 248 +{ 249 + rtx insn; 250 + int insn_count = 0; 251 + 252 + /* Count number of instructions in this block. Return 4 if the number 253 + of instructions >= 4. */ 254 + FOR_BB_INSNS (bb, insn) 255 + { 256 + /* Only happen in exit blocks. */ 257 + if (JUMP_P (insn) 258 + && GET_CODE (PATTERN (insn)) == RETURN) 259 + break; 260 + 261 + if (NONDEBUG_INSN_P (insn) 262 + && GET_CODE (PATTERN (insn)) != USE 263 + && GET_CODE (PATTERN (insn)) != CLOBBER) 264 + { 265 + insn_count++; 266 + if (insn_count >= 4) 267 + return insn_count; 268 + } 269 + } 270 + 271 + return insn_count; 272 +} 273 + 274 + 275 +/* Count the minimum number of instructions in code path in BB. 276 + Return 4 if the number of instructions >= 4. */ 277 + 278 +static int 279 +ix86_count_insn (basic_block bb) 280 +{ 281 + edge e; 282 + edge_iterator ei; 283 + int min_prev_count; 284 + 285 + /* Only bother counting instructions along paths with no 286 + more than 2 basic blocks between entry and exit. Given 287 + that BB has an edge to exit, determine if a predecessor 288 + of BB has an edge from entry. If so, compute the number 289 + of instructions in the predecessor block. If there 290 + happen to be multiple such blocks, compute the minimum. */ 291 + min_prev_count = 4; 292 + FOR_EACH_EDGE (e, ei, bb->preds) 293 + { 294 + edge prev_e; 295 + edge_iterator prev_ei; 296 + 297 + if (e->src == ENTRY_BLOCK_PTR) 298 + { 299 + min_prev_count = 0; 300 + break; 301 + } 302 + FOR_EACH_EDGE (prev_e, prev_ei, e->src->preds) 303 + { 304 + if (prev_e->src == ENTRY_BLOCK_PTR) 305 + { 306 + int count = ix86_count_insn_bb (e->src); 307 + if (count < min_prev_count) 308 + min_prev_count = count; 309 + break; 310 + } 311 + } 312 + } 313 + 314 + if (min_prev_count < 4) 315 + min_prev_count += ix86_count_insn_bb (bb); 316 + 317 + return min_prev_count; 318 +} 319 + 320 +/* Pad short funtion to 4 instructions. */ 321 + 322 +static void 323 +ix86_pad_short_function (void) 324 +{ 325 + edge e; 326 + edge_iterator ei; 327 + 328 + FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) 329 + { 330 + rtx ret = BB_END (e->src); 331 + if (JUMP_P (ret) && GET_CODE (PATTERN (ret)) == RETURN) 332 + { 333 + int insn_count = ix86_count_insn (e->src); 334 + 335 + /* Pad short function. */ 336 + if (insn_count < 4) 337 + { 338 + rtx insn = ret; 339 + 340 + /* Find epilogue. */ 341 + while (insn 342 + && (!NOTE_P (insn) 343 + || NOTE_KIND (insn) != NOTE_INSN_EPILOGUE_BEG)) 344 + insn = PREV_INSN (insn); 345 + 346 + if (!insn) 347 + insn = ret; 348 + 349 + /* Two NOPs are counted as one instruction. */ 350 + insn_count = 2 * (4 - insn_count); 351 + emit_insn_before (gen_nops (GEN_INT (insn_count)), insn); 352 + } 353 + } 354 + } 355 +} 356 + 357 /* Implement machine specific optimizations. We implement padding of returns 358 for K8 CPUs and pass to avoid 4 jumps in the single 16 byte window. */ 359 static void 360 ix86_reorg (void) 361 { 362 - if (TARGET_PAD_RETURNS && optimize 363 - && optimize_function_for_speed_p (cfun)) 364 - ix86_pad_returns (); 365 - if (TARGET_FOUR_JUMP_LIMIT && optimize 366 - && optimize_function_for_speed_p (cfun)) 367 - ix86_avoid_jump_misspredicts (); 368 + if (optimize && optimize_function_for_speed_p (cfun)) 369 + { 370 + if (TARGET_PAD_SHORT_FUNCTION) 371 + ix86_pad_short_function (); 372 + else if (TARGET_PAD_RETURNS) 373 + ix86_pad_returns (); 374 + if (TARGET_FOUR_JUMP_LIMIT) 375 + ix86_avoid_jump_misspredicts (); 376 + } 377 } 378 379 /* Return nonzero when QImode register that must be represented via REX prefix 380 diff --git a/gcc-4.4.3/gcc/config/i386/i386.h b/gcc-4.4.3/gcc/config/i386/i386.h 381 index e9014b7..d7cb8ac 100644 382 --- a/gcc-4.4.3/gcc/config/i386/i386.h 383 +++ b/gcc-4.4.3/gcc/config/i386/i386.h 384 @@ -291,6 +291,7 @@ enum ix86_tune_indices { 385 X86_TUNE_USE_BT, 386 X86_TUNE_USE_INCDEC, 387 X86_TUNE_PAD_RETURNS, 388 + X86_TUNE_PAD_SHORT_FUNCTION, 389 X86_TUNE_EXT_80387_CONSTANTS, 390 X86_TUNE_SHORTEN_X87_SSE, 391 X86_TUNE_AVOID_VECTOR_DECODE, 392 @@ -372,6 +373,8 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST]; 393 #define TARGET_USE_BT ix86_tune_features[X86_TUNE_USE_BT] 394 #define TARGET_USE_INCDEC ix86_tune_features[X86_TUNE_USE_INCDEC] 395 #define TARGET_PAD_RETURNS ix86_tune_features[X86_TUNE_PAD_RETURNS] 396 +#define TARGET_PAD_SHORT_FUNCTION \ 397 + ix86_tune_features[X86_TUNE_PAD_SHORT_FUNCTION] 398 #define TARGET_EXT_80387_CONSTANTS \ 399 ix86_tune_features[X86_TUNE_EXT_80387_CONSTANTS] 400 #define TARGET_SHORTEN_X87_SSE ix86_tune_features[X86_TUNE_SHORTEN_X87_SSE] 401 diff --git a/gcc-4.4.3/gcc/config/i386/i386.md b/gcc-4.4.3/gcc/config/i386/i386.md 402 index bbe9151..7989c31 100644 403 --- a/gcc-4.4.3/gcc/config/i386/i386.md 404 +++ b/gcc-4.4.3/gcc/config/i386/i386.md 405 @@ -77,6 +77,7 @@ 406 (UNSPEC_TLSDESC 23) 407 408 ; Other random patterns 409 + (UNSPEC_NOPS 29) 410 (UNSPEC_SCAS 30) 411 (UNSPEC_FNSTSW 31) 412 (UNSPEC_SAHF 32) 413 @@ -15323,6 +15324,39 @@ 414 (set_attr "length_immediate" "0") 415 (set_attr "modrm" "0")]) 416 417 +;; Generate nops. Operand 0 is the number of nops, up to 8. 418 +(define_insn "nops" 419 + [(unspec [(match_operand 0 "const_int_operand" "")] 420 + UNSPEC_NOPS)] 421 + "reload_completed" 422 +{ 423 + switch (INTVAL (operands[0])) 424 + { 425 + case 1: 426 + return "nop"; 427 + case 2: 428 + return "nop; nop"; 429 + case 3: 430 + return "nop; nop; nop"; 431 + case 4: 432 + return "nop; nop; nop; nop"; 433 + case 5: 434 + return "nop; nop; nop; nop; nop"; 435 + case 6: 436 + return "nop; nop; nop; nop; nop; nop"; 437 + case 7: 438 + return "nop; nop; nop; nop; nop; nop; nop"; 439 + case 8: 440 + return "nop; nop; nop; nop; nop; nop; nop; nop"; 441 + default: 442 + gcc_unreachable (); 443 + break; 444 + } 445 +} 446 + [(set (attr "length") (symbol_ref "INTVAL (operands[0])")) 447 + (set_attr "length_immediate" "0") 448 + (set_attr "modrm" "0")]) 449 + 450 ;; Align to 16-byte boundary, max skip in op0. Used to avoid 451 ;; branch prediction penalty for the third jump in a 16-byte 452 ;; block on K8. 453 diff --git a/gcc-4.4.3/gcc/esp.h b/gcc-4.4.3/gcc/esp.h 454 index db2135b..cbcf9d1 100644 455 --- a/gcc-4.4.3/gcc/esp.h 456 +++ b/gcc-4.4.3/gcc/esp.h 457 @@ -34,8 +34,19 @@ 458 /* ESP_LINK_SPEC is added to LINK_PIE_SPEC if esp is enable 459 -z now will be added if we don't have -vanilla spec. We do a -pie incompatible check 460 Don't remove the specs in the end */ 461 - #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_pie_check) " 462 - #define ESP_LINK_NOW_SPEC "%{!nonow:-z now}" 463 + #define ESP_LINK_SPEC "%(esp_link_now) %(esp_link_pie_check) %(esp_link_relro)" 464 + 465 + #if defined EFAULT_BIND_NOW 466 + #define ESP_LINK_NOW_SPEC "%{!nonow:-z now}" 467 + #else 468 + #define ESP_LINK_NOW_SPEC "" 469 + #endif 470 + 471 + #if defined EFAULT_RELRO 472 + #define ESP_LINK_RELRO_SPEC "%{!norelro:-z relro}" 473 + #else 474 + #define ESP_LINK_RELRO_SPEC "" 475 + #endif 476 477 /* We use ESP_COMMAND_OPTIONS_SPEC to add pie command-line options. */ 478 #define ESP_COMMAND_OPTIONS_SPEC "%{!D__KERNEL__:%{!nopie:%(esp_options_pie) %(esp_link_pie)}}" 479 @@ -120,6 +131,7 @@ 480 { "esp_cc1_strict_overflow", ESP_CC1_STRICT_OVERFLOW_SPEC }, \ 481 { "esp_link", ESP_LINK_SPEC }, \ 482 { "esp_link_now", ESP_LINK_NOW_SPEC }, \ 483 + { "esp_link_relro", ESP_LINK_RELRO_SPEC }, \ 484 { "esp_link_pie", ESP_LINK_PIE_SPEC }, \ 485 { "esp_link_pie_check", ESP_LINK_PIE_CHECK_SPEC }, \ 486 { "esp_command_options", ESP_COMMAND_OPTIONS_SPEC }, \ 487 diff --git a/gcc-4.4.3/gcc/gcc.c b/gcc-4.4.3/gcc/gcc.c 488 index 3ce244c..afa6a01 100644 489 --- a/gcc-4.4.3/gcc/gcc.c 490 +++ b/gcc-4.4.3/gcc/gcc.c 491 @@ -829,8 +829,11 @@ static const char *cpp_unique_options = 492 %{remap} %{g3|ggdb3|gstabs3|gcoff3|gxcoff3|gvms3:-dD}\ 493 %{H} %C %{D*&U*&A*} %{i*} %Z %i\ 494 %{fmudflap:-D_MUDFLAP -include mf-runtime.h}\ 495 - %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}\ 496 - %{E|M|MM:%W{o*}}"; 497 + %{fmudflapth:-D_MUDFLAP -D_MUDFLAPTH -include mf-runtime.h}" 498 +#ifdef EFAULT_FORTIFY_SOURCE 499 +" %{!D_FORTIFY_SOURCE:%{!D_FORTIFY_SOURCE=*:%{!U_FORTIFY_SOURCE:-D_FORTIFY_SOURCE=2}}}" 500 +#endif 501 +" %{E|M|MM:%W{o*}}"; 502 503 /* This contains cpp options which are common with cc1_options and are passed 504 only when preprocessing only to avoid duplication. We pass the cc1 spec 505 diff --git a/gcc-4.4.3/gcc/ipa-inline.c b/gcc-4.4.3/gcc/ipa-inline.c 506 index 48754d4..e2745dd 100644 507 --- a/gcc-4.4.3/gcc/ipa-inline.c 508 +++ b/gcc-4.4.3/gcc/ipa-inline.c 509 @@ -1495,8 +1495,7 @@ update_caller_keys (fibheap_t heap, struct cgraph_node *node, 510 struct cgraph_edge *edge; 511 const char *failed_reason; 512 513 - if (!node->local.inlinable || node->local.disregard_inline_limits 514 - || node->global.inlined_to) 515 + if (!node->local.inlinable || node->global.inlined_to) 516 return; 517 if (bitmap_bit_p (updated_nodes, node->uid)) 518 return; 519 diff --git a/gcc-4.4.3/gcc/libgcov.c b/gcc-4.4.3/gcc/libgcov.c 520 index 9b1c7bb..a39cee7 100644 521 --- a/gcc-4.4.3/gcc/libgcov.c 522 +++ b/gcc-4.4.3/gcc/libgcov.c 523 @@ -802,6 +802,8 @@ gcov_merge_gcda_file (struct gcov_info *info, 524 int error = 0; 525 gcov_unsigned_t tag, length; 526 527 + eof_pos = 0; 528 + 529 tag = gcov_read_unsigned (); 530 if (tag) 531 { 532 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-1.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-1.c 533 new file mode 100644 534 index 0000000..87a9d6c 535 --- /dev/null 536 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-1.c 537 @@ -0,0 +1,9 @@ 538 +/* { dg-do compile } */ 539 +/* { dg-options "-O2 -fomit-frame-pointer -mtune=generic -S" } */ 540 +/* { dg-final { scan-assembler "rep" } } */ 541 +/* { dg-final { scan-assembler-not "nop" } } */ 542 + 543 +void 544 +foo () 545 +{ 546 +} 547 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-10.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-10.c 548 new file mode 100644 549 index 0000000..6ba3b78 550 --- /dev/null 551 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-10.c 552 @@ -0,0 +1,18 @@ 553 +/* { dg-do compile } */ 554 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 555 +/* { dg-final { scan-assembler-not "nop" } } */ 556 +/* { dg-final { scan-assembler-not "rep" } } */ 557 + 558 +extern void bar (); 559 + 560 +int 561 +foo2 (int z, int x) 562 +{ 563 + if (x == 1) 564 + { 565 + bar (); 566 + return z; 567 + } 568 + else 569 + return x + z; 570 +} 571 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-2.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-2.c 572 new file mode 100644 573 index 0000000..964547c 574 --- /dev/null 575 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-2.c 576 @@ -0,0 +1,9 @@ 577 +/* { dg-do compile } */ 578 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 579 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop; nop; nop; nop; nop" 1 } } */ 580 +/* { dg-final { scan-assembler-not "rep" } } */ 581 + 582 +void 583 +foo () 584 +{ 585 +} 586 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-3.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-3.c 587 new file mode 100644 588 index 0000000..52442b4 589 --- /dev/null 590 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-3.c 591 @@ -0,0 +1,15 @@ 592 +/* { dg-do compile } */ 593 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 594 +/* { dg-final { scan-assembler-not "nop" } } */ 595 +/* { dg-final { scan-assembler-not "rep" } } */ 596 + 597 +int s[8] = {1, 2, 3, 4, 5, 6, 7, 8}; 598 +int d[8] = {11, 22, 33, 44, 55, 66, 77, 88}; 599 + 600 +void 601 +foo () 602 +{ 603 + int i; 604 + for (i = 0; i < 8; i++) 605 + d[i] = s[i] + 0x1000; 606 +} 607 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-4.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-4.c 608 new file mode 100644 609 index 0000000..a7033fa 610 --- /dev/null 611 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-4.c 612 @@ -0,0 +1,13 @@ 613 +/* { dg-do compile } */ 614 +/* { dg-require-effective-target ilp32 } */ 615 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S -fPIC" } */ 616 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop; nop; nop; nop; nop" 1 } } */ 617 +/* { dg-final { scan-assembler-not "rep" } } */ 618 + 619 +extern int bar; 620 + 621 +int 622 +foo () 623 +{ 624 + return bar; 625 +} 626 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5a.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5a.c 627 new file mode 100644 628 index 0000000..9d0aa2a 629 --- /dev/null 630 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5a.c 631 @@ -0,0 +1,12 @@ 632 +/* { dg-do compile } */ 633 +/* { dg-require-effective-target ilp32 } */ 634 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 635 +/* { dg-final { scan-assembler-times "nop; nop" 1 } } */ 636 +/* { dg-final { scan-assembler-not "nop; nop; nop" } } */ 637 +/* { dg-final { scan-assembler-not "rep" } } */ 638 + 639 +int 640 +foo (int x, int y, int z) 641 +{ 642 + return x + y + z; 643 +} 644 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5b.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5b.c 645 new file mode 100644 646 index 0000000..2e1cf12 647 --- /dev/null 648 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-5b.c 649 @@ -0,0 +1,12 @@ 650 +/* { dg-do compile } */ 651 +/* { dg-require-effective-target lp64 } */ 652 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 653 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop" 1 } } */ 654 +/* { dg-final { scan-assembler-not "nop; nop; nop; nop; nop" } } */ 655 +/* { dg-final { scan-assembler-not "rep" } } */ 656 + 657 +int 658 +foo (int x, int y, int z) 659 +{ 660 + return x + y + z; 661 +} 662 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6a.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6a.c 663 new file mode 100644 664 index 0000000..e865967 665 --- /dev/null 666 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6a.c 667 @@ -0,0 +1,12 @@ 668 +/* { dg-do compile } */ 669 +/* { dg-require-effective-target ilp32 } */ 670 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 671 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop" 1 } } */ 672 +/* { dg-final { scan-assembler-not "nop; nop; nop; nop; nop" } } */ 673 +/* { dg-final { scan-assembler-not "rep" } } */ 674 + 675 +int 676 +foo (int x, int y) 677 +{ 678 + return x + y; 679 +} 680 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6b.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6b.c 681 new file mode 100644 682 index 0000000..41aeaee 683 --- /dev/null 684 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-6b.c 685 @@ -0,0 +1,12 @@ 686 +/* { dg-do compile } */ 687 +/* { dg-require-effective-target lp64 } */ 688 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 689 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop; nop; nop" 1 } } */ 690 +/* { dg-final { scan-assembler-not "nop; nop; nop; nop; nop; nop; nop" } } */ 691 +/* { dg-final { scan-assembler-not "rep" } } */ 692 + 693 +int 694 +foo (int x, int y) 695 +{ 696 + return x + y; 697 +} 698 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-7.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-7.c 699 new file mode 100644 700 index 0000000..7a7493d 701 --- /dev/null 702 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-7.c 703 @@ -0,0 +1,11 @@ 704 +/* { dg-do compile } */ 705 +/* { dg-require-effective-target ilp32 } */ 706 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 707 +/* { dg-final { scan-assembler-not "nop" } } */ 708 +/* { dg-final { scan-assembler-not "rep" } } */ 709 + 710 +int 711 +foo (int x, int y, int z) 712 +{ 713 + return x + y + z + y; 714 +} 715 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-8.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-8.c 716 new file mode 100644 717 index 0000000..873a0a4 718 --- /dev/null 719 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-8.c 720 @@ -0,0 +1,11 @@ 721 +/* { dg-do compile } */ 722 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 723 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop; nop; nop" 1 } } */ 724 +/* { dg-final { scan-assembler-not "nop; nop; nop; nop; nop; nop; nop" } } */ 725 +/* { dg-final { scan-assembler-not "rep" } } */ 726 + 727 +int 728 +foo (int x, int y) 729 +{ 730 + return y; 731 +} 732 diff --git a/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-9.c b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-9.c 733 new file mode 100644 734 index 0000000..3d68805 735 --- /dev/null 736 +++ b/gcc-4.4.3/gcc/testsuite/gcc.target/i386/pad-9.c 737 @@ -0,0 +1,15 @@ 738 +/* { dg-do compile } */ 739 +/* { dg-require-effective-target lp64 } */ 740 +/* { dg-options "-O2 -fomit-frame-pointer -march=atom -S" } */ 741 +/* { dg-final { scan-assembler-times "nop; nop; nop; nop" 1 } } */ 742 +/* { dg-final { scan-assembler-not "nop; nop; nop; nop; nop" } } */ 743 +/* { dg-final { scan-assembler-not "rep" } } */ 744 + 745 +extern void bar (void); 746 + 747 +void 748 +foo (int x) 749 +{ 750 + if (x) 751 + bar (); 752 +} 753 diff --git a/gcc-4.4.3/libstdc++-v3/include/Makefile.am b/gcc-4.4.3/libstdc++-v3/include/Makefile.am 754 index 162983a..9779550 100644 755 --- a/gcc-4.4.3/libstdc++-v3/include/Makefile.am 756 +++ b/gcc-4.4.3/libstdc++-v3/include/Makefile.am 757 @@ -1137,6 +1137,7 @@ install-freestanding-headers: 758 $(mkinstalldirs) $(DESTDIR)${gxx_include_dir} 759 $(mkinstalldirs) $(DESTDIR)${host_installdir} 760 for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h \ 761 + ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \ 762 ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \ 763 $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done 764 $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} 765 diff --git a/gcc-4.4.3/libstdc++-v3/include/Makefile.in b/gcc-4.4.3/libstdc++-v3/include/Makefile.in 766 index c4614f4..a790676 100644 767 --- a/gcc-4.4.3/libstdc++-v3/include/Makefile.in 768 +++ b/gcc-4.4.3/libstdc++-v3/include/Makefile.in 769 @@ -1538,6 +1538,7 @@ install-freestanding-headers: 770 $(mkinstalldirs) $(DESTDIR)${gxx_include_dir} 771 $(mkinstalldirs) $(DESTDIR)${host_installdir} 772 for file in ${host_srcdir}/os_defines.h ${host_builddir}/c++config.h \ 773 + ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h \ 774 ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \ 775 $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done 776 $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} 777 -- 778 1.7.1 779 780