PR 66215: S390: Fix placement of post-label NOPs with -mhotpatch
authorDominik Vogt <vogt@linux.vnet.ibm.com>
Fri, 29 May 2015 14:26:56 +0000 (14:26 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Fri, 29 May 2015 14:26:56 +0000 (14:26 +0000)
gcc/ChangeLog:
    PR target/66215
    * config/s390/s390.c (s390_reorg): Fix placement of post-label NOPs
    with -mhotpatch=.

gcc/testsuite/ChangeLog:
    PR target/66215
    * gcc.target/s390/hotpatch-1.c: Remove optimization options from
    dg-options.
    * gcc.target/s390/hotpatch-10.c: Likewise.
    * gcc.target/s390/hotpatch-11.c: Likewise.
    * gcc.target/s390/hotpatch-12.c: Likewise.
    * gcc.target/s390/hotpatch-17.c: Likewise.
    * gcc.target/s390/hotpatch-18.c: Likewise.
    * gcc.target/s390/hotpatch-20.c: Likewise.
    * gcc.target/s390/hotpatch-21.c: Likewise.
    * gcc.target/s390/hotpatch-22.c: Likewise.
    * gcc.target/s390/hotpatch-23.c: Likewise.
    * gcc.target/s390/hotpatch-24.c: Likewise.
    * gcc.target/s390/hotpatch-2.c: Likewise.  Adjust scan-assembler
    to check for the exact nops too.
    * gcc.target/s390/hotpatch-3.c: Likewise.
    * gcc.target/s390/hotpatch-4.c: Likewise.
    * gcc.target/s390/hotpatch-5.c: Likewise.
    * gcc.target/s390/hotpatch-6.c: Likewise.
    * gcc.target/s390/hotpatch-7.c: Likewise.
    * gcc.target/s390/hotpatch-8.c: Likewise.
    * gcc.target/s390/hotpatch-9.c: Likewise.
    * gcc.target/s390/hotpatch-14.c: Likewise.
    * gcc.target/s390/hotpatch-15.c: Likewise.
    * gcc.target/s390/hotpatch-16.c: Likewise.
    * gcc.target/s390/hotpatch-19.c: Likewise.
    * gcc.target/s390/hotpatch-25.c: Likewise.  Remove
    scan-assembler-times counting number of .align directives.
    * gcc.target/s390/hotpatch-13.c: Remove optimization options from
    dg-options.  Remove scan-assembler-times counting number of .align
    directives.
    * gcc.target/s390/hotpatch-26.c: New file.
    * gcc.target/s390/hotpatch-27.c: New file.
    * gcc.target/s390/hotpatch-28.c: New file.
    * gcc.target/s390/s390.exp: Run hotpatch-*.c tests as torture tests
    using -Os -O0 -O1 -O2 -O3 options.

From-SVN: r223867

32 files changed:
gcc/ChangeLog
gcc/config/s390/s390.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/hotpatch-1.c
gcc/testsuite/gcc.target/s390/hotpatch-10.c
gcc/testsuite/gcc.target/s390/hotpatch-11.c
gcc/testsuite/gcc.target/s390/hotpatch-12.c
gcc/testsuite/gcc.target/s390/hotpatch-13.c
gcc/testsuite/gcc.target/s390/hotpatch-14.c
gcc/testsuite/gcc.target/s390/hotpatch-15.c
gcc/testsuite/gcc.target/s390/hotpatch-16.c
gcc/testsuite/gcc.target/s390/hotpatch-17.c
gcc/testsuite/gcc.target/s390/hotpatch-18.c
gcc/testsuite/gcc.target/s390/hotpatch-19.c
gcc/testsuite/gcc.target/s390/hotpatch-2.c
gcc/testsuite/gcc.target/s390/hotpatch-20.c
gcc/testsuite/gcc.target/s390/hotpatch-21.c
gcc/testsuite/gcc.target/s390/hotpatch-22.c
gcc/testsuite/gcc.target/s390/hotpatch-23.c
gcc/testsuite/gcc.target/s390/hotpatch-24.c
gcc/testsuite/gcc.target/s390/hotpatch-25.c
gcc/testsuite/gcc.target/s390/hotpatch-26.c [new file with mode: 0644]
gcc/testsuite/gcc.target/s390/hotpatch-27.c [new file with mode: 0644]
gcc/testsuite/gcc.target/s390/hotpatch-28.c [new file with mode: 0644]
gcc/testsuite/gcc.target/s390/hotpatch-3.c
gcc/testsuite/gcc.target/s390/hotpatch-4.c
gcc/testsuite/gcc.target/s390/hotpatch-5.c
gcc/testsuite/gcc.target/s390/hotpatch-6.c
gcc/testsuite/gcc.target/s390/hotpatch-7.c
gcc/testsuite/gcc.target/s390/hotpatch-8.c
gcc/testsuite/gcc.target/s390/hotpatch-9.c
gcc/testsuite/gcc.target/s390/s390.exp

index c8b1c44f07149535e656321fcc899e750d380991..1d5989831a3e9e49ebd3ae4503ee96e84708c1b5 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-29  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       PR target/66215
+       * config/s390/s390.c (s390_reorg): Fix placement of post-label NOPs
+       with -mhotpatch=.
+
 2015-05-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/66142
index 6648597fe442e55b63f1c4ca703e61084dd30afe..90d43b1498cccbc4de337775a5d1a2e0d44d7fea 100644 (file)
@@ -12843,31 +12843,37 @@ s390_reorg (void)
 
       /* Insert NOPs for hotpatching. */
       for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
-       {
-         if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_FUNCTION_BEG)
-           break;
-       }
-      gcc_assert (insn);
-      /* Output a series of NOPs after the NOTE_INSN_FUNCTION_BEG.  */
-      while (hw_after > 0)
+       /* Emit NOPs
+           1. inside the area covered by debug information to allow setting
+              breakpoints at the NOPs,
+           2. before any insn which results in an asm instruction,
+           3. before in-function labels to avoid jumping to the NOPs, for
+              example as part of a loop,
+           4. before any barrier in case the function is completely empty
+              (__builtin_unreachable ()) and has neither internal labels nor
+              active insns.
+       */
+       if (active_insn_p (insn) || BARRIER_P (insn) || LABEL_P (insn))
+         break;
+      /* Output a series of NOPs before the first active insn.  */
+      while (insn && hw_after > 0)
        {
          if (hw_after >= 3 && TARGET_CPU_ZARCH)
            {
-             insn = emit_insn_after (gen_nop_6_byte (), insn);
+             emit_insn_before (gen_nop_6_byte (), insn);
              hw_after -= 3;
            }
          else if (hw_after >= 2)
            {
-             insn = emit_insn_after (gen_nop_4_byte (), insn);
+             emit_insn_before (gen_nop_4_byte (), insn);
              hw_after -= 2;
            }
          else
            {
-             insn = emit_insn_after (gen_nop_2_byte (), insn);
+             emit_insn_before (gen_nop_2_byte (), insn);
              hw_after -= 1;
            }
        }
-      gcc_assert (hw_after == 0);
     }
 }
 
index b6724472de98b923ba4ef4d073cd724c0706e617..2fe348afd8338b8f14394abf434a7f31520bdfbc 100644 (file)
@@ -1,3 +1,42 @@
+2015-05-29  Dominik Vogt  <vogt@linux.vnet.ibm.com>
+
+       PR target/66215
+       * gcc.target/s390/hotpatch-1.c: Remove optimization options from
+       dg-options.
+       * gcc.target/s390/hotpatch-10.c: Likewise.
+       * gcc.target/s390/hotpatch-11.c: Likewise.
+       * gcc.target/s390/hotpatch-12.c: Likewise.
+       * gcc.target/s390/hotpatch-17.c: Likewise.
+       * gcc.target/s390/hotpatch-18.c: Likewise.
+       * gcc.target/s390/hotpatch-20.c: Likewise.
+       * gcc.target/s390/hotpatch-21.c: Likewise.
+       * gcc.target/s390/hotpatch-22.c: Likewise.
+       * gcc.target/s390/hotpatch-23.c: Likewise.
+       * gcc.target/s390/hotpatch-24.c: Likewise.
+       * gcc.target/s390/hotpatch-2.c: Likewise.  Adjust scan-assembler
+       to check for the exact nops too.
+       * gcc.target/s390/hotpatch-3.c: Likewise.
+       * gcc.target/s390/hotpatch-4.c: Likewise.
+       * gcc.target/s390/hotpatch-5.c: Likewise.
+       * gcc.target/s390/hotpatch-6.c: Likewise.
+       * gcc.target/s390/hotpatch-7.c: Likewise.
+       * gcc.target/s390/hotpatch-8.c: Likewise.
+       * gcc.target/s390/hotpatch-9.c: Likewise.
+       * gcc.target/s390/hotpatch-14.c: Likewise.
+       * gcc.target/s390/hotpatch-15.c: Likewise.
+       * gcc.target/s390/hotpatch-16.c: Likewise.
+       * gcc.target/s390/hotpatch-19.c: Likewise.
+       * gcc.target/s390/hotpatch-25.c: Likewise.  Remove
+       scan-assembler-times counting number of .align directives.
+       * gcc.target/s390/hotpatch-13.c: Remove optimization options from
+       dg-options.  Remove scan-assembler-times counting number of .align
+       directives.
+       * gcc.target/s390/hotpatch-26.c: New file.
+       * gcc.target/s390/hotpatch-27.c: New file.
+       * gcc.target/s390/hotpatch-28.c: New file.
+       * gcc.target/s390/s390.exp: Run hotpatch-*.c tests as torture tests
+       using -Os -O0 -O1 -O2 -O3 options.
+
 2015-05-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/aarch64/vdup_lane_2.c: Close comment on final line.
index b14fa9010a8cce02218e3f41093c725948da1e73..55088b8b65582ee91aa39c3f0bfd0251a8939933 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 #include <stdio.h>
 
index a990c4cad6e3421b17dbf04dc9db66ea3ded61bf..d2cb9a2ee86c5f91505af175cb30490bba81f4d5 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,0" } */
+/* { dg-options "-mzarch -mhotpatch=0,0" } */
 
 #include <stdio.h>
 
index 6f8a52b26d341b1d817f4d8cb95ec7f0d5a24350..cabb9d263abdd0faa8fd0533b8a42ee41f51062c 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=1,0" } */
+/* { dg-options "-mzarch -mhotpatch=1,0" } */
 
 #include <stdio.h>
 
index b73ca90fd3dd20de9e4d699eed7f0571a542820c..fc9adc3336941b2e2a80126c2a512af592a48f78 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=999,0" } */
+/* { dg-options "-mzarch -mhotpatch=999,0" } */
 
 #include <stdio.h>
 
index 150667a1c66bf79a702dc70c57b56f80614116a0..b25fbd3f2aee4db7831d46309f0778df2dc13487 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 #include <stdio.h>
 
@@ -18,4 +18,3 @@ void hp1(void)
 /* { dg-final { scan-assembler-not "nop\t0" } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
 /* { dg-final { scan-assembler "alignment for hotpatch" } } */
-/* { dg-final { scan-assembler-times "\.align\t8" 2 } } */
index c5f118c1cc6d79b1e8a457dbe2cb9d491519034f..c387d6bf0638a75cdb619af792c8bf65ab00a088 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 #include <stdio.h>
 
@@ -13,7 +13,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index ef0fb746227e6ed4d684942815c80a925197f22b..410106bb7ca294a24372d6f8316e675a46002691 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 #include <stdio.h>
 
@@ -13,7 +13,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler "pre-label.*(1 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index a34bf95c3cb539558e28d191c8c6c4daff388306..fa06fff491fa8def33116537e9fb49e863b497b0 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,0" } */
+/* { dg-options "-mzarch -mhotpatch=0,0" } */
 
 #include <stdio.h>
 
@@ -13,7 +13,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler "pre-label.*(1 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index 66ac725d16a042f423a1fa3dac840455ba97542b..3ef7d69b57253e37b1cba8503c2ad25443a32da5 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=1,2" } */
+/* { dg-options "-mzarch -mhotpatch=1,2" } */
 
 #include <stdio.h>
 
index 8b076a4e175fadc33876320aa29028d87a976750..c93af7fa99b0c4c37a93459042a3e671fe209b66 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=1,2 -mhotpatch=0,0" } */
+/* { dg-options "-mzarch -mhotpatch=1,2 -mhotpatch=0,0" } */
 
 #include <stdio.h>
 
index 6993c7e855ced3d0b9a1b7fd247db0bf85692950..c69b35e562a50fb9d6ab2f9a59e1b957fd6d1dff 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=1,2" } */
+/* { dg-options "-mzarch -mhotpatch=1,2" } */
 
 #include <stdio.h>
 
@@ -19,7 +19,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler "pre-label.*(1 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index 67189f8a28b1123f1c10fc5ac168721ea701759d..2a2665e258510fb2268a324935694255e2da018d 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,1" } */
+/* { dg-options "-mzarch -mhotpatch=0,1" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(1 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(1 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nopr\t" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-not "nop\t0" } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index 09ef5caaea37e6c9e79c11a6ffd49861a0492106..0a32a68993f434f9519567cdf76e0f5c350cddf1 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 #include <stdio.h>
 
index e90999008550ff2020be68580b0204e5802b6ba3..f6e90996ba9f297e98c429f4621c551d5c7c3bf4 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,1" } */
+/* { dg-options "-mzarch -mhotpatch=0,1" } */
 
 #include <stdio.h>
 
index d89d7790426f680061a6955103790beeca7c9e84..21f7d7e957a46b4a0f2faeeac41546d3e847557d 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,1 -falign-functions=1024" } */
+/* { dg-options "-mzarch -mhotpatch=0,1 -falign-functions=1024" } */
 
 #include <stdio.h>
 
index 1e05d123c22a64770099f6d295338cfbf8c9e16d..6e149cc0b5aed82ce55faad8cf2c70e3caf08caf 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,1 -falign-functions=4096" } */
+/* { dg-options "-mzarch -mhotpatch=0,1 -falign-functions=4096" } */
 
 #include <stdio.h>
 
index fc6427479d8edbcb6177156f42a337115a42f8a0..1e475917100a3c3b732e61d299c1ac9487de7d49 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,1 -falign-functions=2048" } */
+/* { dg-options "-mzarch -mhotpatch=0,1 -falign-functions=2048" } */
 
 #include <stdio.h>
 
index e9257e3744ee981fd51e23a902005b8e15c81263..e6cdbb6cb15605189a3f8da491b3834c3ce4064c 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch" } */
+/* { dg-options "-mzarch" } */
 
 typedef long (*fn_t)(void);
 
@@ -25,9 +25,8 @@ fn_t outer(void)
 /* { dg-final { scan-assembler "pre-label.*(1 halfwords)" } } */
 /* { dg-final { scan-assembler "pre-label.*(4 halfwords)" } } */
 /* { dg-final { scan-assembler "pre-label.*(16 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(8 halfwords)" } } */
-/* { dg-final { scan-assembler "post-label.*(32 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nopr\t" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(8 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(32 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
 /* { dg-final { scan-assembler-times "alignment for hotpatch" 3 } } */
-/* { dg-final { scan-assembler-times "\.align\t8" 6 } } */
 /* { dg-final { scan-assembler "nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr.*\n.*nopr" } } */
diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-26.c b/gcc/testsuite/gcc.target/s390/hotpatch-26.c
new file mode 100644 (file)
index 0000000..eb95c26
--- /dev/null
@@ -0,0 +1,17 @@
+/* Functional tests for the function hotpatching feature.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -mzarch -mhotpatch=1,2" } */
+
+__attribute__ ((noreturn)) void hp1(void)
+{
+  __builtin_unreachable ();
+}
+
+/* Check number of occurences of certain instructions.  */
+/* { dg-final { scan-assembler "pre-label NOPs" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
+/* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
+/* { dg-final { scan-assembler-times "nop\t0" 1 } } */
+/* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
+/* { dg-final { scan-assembler "alignment for hotpatch" } } */
diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-27.c b/gcc/testsuite/gcc.target/s390/hotpatch-27.c
new file mode 100644 (file)
index 0000000..cdbd4ca
--- /dev/null
@@ -0,0 +1,17 @@
+/* Functional tests for the function hotpatching feature.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -mzarch -mhotpatch=1,2" } */
+
+__attribute__ ((noreturn)) void hp3(void)
+{
+  __builtin_unreachable ();
+}
+
+/* Check number of occurences of certain instructions.  */
+/* { dg-final { scan-assembler "pre-label NOPs" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
+/* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
+/* { dg-final { scan-assembler-times "nop\t0" 1 } } */
+/* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
+/* { dg-final { scan-assembler "alignment for hotpatch" } } */
diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-28.c b/gcc/testsuite/gcc.target/s390/hotpatch-28.c
new file mode 100644 (file)
index 0000000..9922daa
--- /dev/null
@@ -0,0 +1,18 @@
+/* Functional tests for the function hotpatching feature.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -mzarch -mhotpatch=1,2" } */
+
+void hp1 (volatile unsigned int *i)
+{
+  for (;;)
+    (*i)++;
+}
+
+/* Check number of occurences of certain instructions.  */
+/* { dg-final { scan-assembler "pre-label NOPs" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
+/* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
+/* { dg-final { scan-assembler-times "nop\t0" 1 } } */
+/* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
+/* { dg-final { scan-assembler "alignment for hotpatch" } } */
index ec4a978f72eaffe285eb2af2a1178cc69dad0d9c..671859116d480fdd87270ab6b7bc5216e202dfd5 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,2" } */
+/* { dg-options "-mzarch -mhotpatch=0,2" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(2 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(2 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index d55e71d3d69c53faf7a6f872fd3dea01baf1dcc4..b770d4bd671d7ac91f0bca1772ce182554e41f90 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,3" } */
+/* { dg-options "-mzarch -mhotpatch=0,3" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(3 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(3 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-not "nop\t0" } } */
 /* { dg-final { scan-assembler-times "brcl\t0, 0" 1 } } */
index f77d83aea07132c3b0710dd504f37d417669ed10..f1dcd89def6ad0ee25e45a41f9851d7c8c7cd1a6 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,4" } */
+/* { dg-options "-mzarch -mhotpatch=0,4" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(4 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(4 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-not "nop\t0" } } */
 /* { dg-final { scan-assembler-times "brcl\t0, 0" 1 } } */
index 330cf5d011ff129661ddd0798aa927bebebb6bbf..6203a72ba2edae73a7a53dff20213ddafd8c2bc4 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,5" } */
+/* { dg-options "-mzarch -mhotpatch=0,5" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(5 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(5 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-times "brcl\t0, 0" 1 } } */
index 2f24e3cc15228b826f29044dd2ab0e68fff448b9..e201ae940e6874ece6afab1f779413458841e875 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -mhotpatch=0,6" } */
+/* { dg-options "-mzarch -mhotpatch=0,6" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(6 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(6 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*brcl\t0, 0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-not "nop\t0" } } */
 /* { dg-final { scan-assembler-times "brcl\t0, 0" 2 } } */
index 7b266bd463e18cac1bfc39014d9be8fa86e189d2..1ea3160c0f2ee2f910c7fbb66e22c879bd4adf6f 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile { target { ! lp64 } } } */
-/* { dg-options "-O3 -mesa -march=g5 -mhotpatch=0,3" } */
+/* { dg-options "-mesa -march=g5 -mhotpatch=0,3" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(3 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(3 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-times "nopr\t%r7" 1 } } */
 /* { dg-final { scan-assembler-times "nop\t0" 1 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index c0ad319c0bb758210c4d78d14826872f68247bf9..e30f2762d33575ec9165c03465c926c3cdf8e14a 100644 (file)
@@ -1,7 +1,7 @@
 /* Functional tests for the function hotpatching feature.  */
 
 /* { dg-do compile { target { ! lp64 } } } */
-/* { dg-options "-O3 -mesa -march=g5 -mhotpatch=0,4" } */
+/* { dg-options "-mesa -march=g5 -mhotpatch=0,4" } */
 
 #include <stdio.h>
 
@@ -12,7 +12,7 @@ void hp1(void)
 
 /* Check number of occurences of certain instructions.  */
 /* { dg-final { scan-assembler-not "pre-label NOPs" } } */
-/* { dg-final { scan-assembler "post-label.*(4 halfwords)" } } */
+/* { dg-final { scan-assembler "^\[^.\].*:\n.*post-label.*(4 halfwords).*\n\(\(.L.*:\n\)\|\(\[\[:space:\]\]*.cfi_.*\n\)\)*\[\[:space:\]\]*nop\t0" } } */
 /* { dg-final { scan-assembler-not "nopr\t%r7" } } */
 /* { dg-final { scan-assembler-times "nop\t0" 2 } } */
 /* { dg-final { scan-assembler-not "brcl\t0, 0" } } */
index eb1d73b5fbf337f4c3dccc054c653e6585a1c409..0b8f80ed6692e32ced08298196a5e80810f59dc8 100644 (file)
@@ -61,12 +61,21 @@ if ![info exists DEFAULT_CFLAGS] then {
 # Initialize `dg'.
 dg-init
 
+set hotpatch_tests $srcdir/$subdir/hotpatch-\[0-9\]*.c
+
 # Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
-       "" $DEFAULT_CFLAGS
+dg-runtest [lsort [prune [glob -nocomplain $srcdir/$subdir/*.\[cS\]] \
+                        $hotpatch_tests]] "" $DEFAULT_CFLAGS
 
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*vector*/*.\[cS\]]] \
        "" $DEFAULT_CFLAGS
 
+# Additional hotpatch torture tests.
+torture-init
+set HOTPATCH_TEST_OPTS [list -Os -O0 -O1 -O2 -O3]
+set-torture-options $HOTPATCH_TEST_OPTS
+gcc-dg-runtest [lsort [glob -nocomplain $hotpatch_tests]] "" $DEFAULT_CFLAGS
+torture-finish
+
 # All done.
 dg-finish