Patchwork Sanitize block partitioning under -freorder-blocks-and-partition

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 31, 2013, 4:04 p.m.
Message ID <20130831160420.GC7492@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/271540/
State New
Headers show

Comments

Jan Hubicka - Aug. 31, 2013, 4:04 p.m.
Hi,
With Martin we made script for testing the profiling failures.
First do

ld --verbose >~/script

then apply


then create t.c as:
__attribute__ ((noinline))
t()
{
  printf ("test\n");
}
main(int argc)
{
  if (argc>1)
        t();
return 0;
}

and dotests as:

for name in $*
do
rm a.out *.gcda 2>/dev/null
./xgcc -B ./ -Ofast -fprofile-generate $name --static  2>/dev/null
if [ -f a.out ]
then
./a.out >/dev/null 2>/dev/null || continue 
./xgcc -B ./ -Ofast -fprofile-use -freorder-blocks-and-partition -Wl,-T,/home/jh/script --static $name   2>/dev/null
./a.out t >/dev/null 2>/dev/null || echo FAIL $name
else
echo skip $name
fi
done

Then run:

jh@gcc10:~/trunk/build/gcc$ sh dotests t.c
FAIL t.c

You should get FAIL if things are fine, because t.c depends behaviour on number
of command line parameters.  If that fail you can run i.e.

jh@gcc10:~/trunk/build/gcc$ sh dotests ~/trunk/gcc/testsuite/gcc.c-torture/execute/*.c
skip /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20000402-1.c
FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20000422-1.c
FAIL /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20000910-2.c
skip /home/jh/trunk/gcc/testsuite/gcc.c-torture/execute/20010329-1.c

Those with fail get cold section executed.  When you run tehm again through dotests you can do gdb a.out
and see what function gets split incorrectly.

Honza

Patch

--- /home/jh/script2	2013-08-31 17:59:11.000000000 +0200
+++ /home/jh/script	2013-08-31 17:39:40.000000000 +0200
@@ -1,12 +1,3 @@ 
-GNU ld (GNU Binutils for Debian) 2.20.1-system.20100303
-  Supported emulations:
-   elf_x86_64
-   elf_i386
-   i386linux
-   elf_l1om
-using internal linker script:
-==================================================
-/* Script for -z combreloc: combine and sort reloc sections */
 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
 	      "elf64-x86-64")
 OUTPUT_ARCH(i386:x86-64)
@@ -55,6 +46,7 @@ 
     KEEP (*(.init))
   } =0x90909090
   .plt            : { *(.plt) *(.iplt) }
+  .text.unlikely (NOLOAD) : { *(.text.unlikely .text.*_unlikely .text.unlikely.*) }
   .text           :
   {
     *(.text.unlikely .text.*_unlikely)
@@ -218,4 +210,3 @@ 
 }
 
 
-==================================================