From patchwork Mon May 23 11:01:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 96934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 10796B6FA7 for ; Mon, 23 May 2011 21:01:50 +1000 (EST) Received: (qmail 29206 invoked by alias); 23 May 2011 11:01:47 -0000 Received: (qmail 29198 invoked by uid 22791); 23 May 2011 11:01:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_ZJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 11:01:32 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 0B816521; Mon, 23 May 2011 13:01:31 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Qrh4+Ia2sUBK; Mon, 23 May 2011 13:01:27 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id A4793520; Mon, 23 May 2011 13:01:27 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p4NB1Qpl015456; Mon, 23 May 2011 13:01:26 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak Subject: [testsuite] Provide TLS access model testcases Date: Mon, 23 May 2011 13:01:26 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org While working to improve Solaris/x86 TLS support, Uros provided me with a testcase to excercise all 4 TLS access models. Since there were different issues affecting the different models, I've split the testcase into one per access model so one can easier see what's broken. Tested with the appropriate runtest invocations in the whole range of Solaris configurations, as well as Tru64 UNIX: as, ld gas, ld gas, gld alpha-dec-osf5.1b PASS i386-pc-solaris2.8 PASS gd, ld FAIL PASS i386-pc-solaris2.9 PASS gd, ld FAIL PASS i386-pc-solaris2.10 gd, ld FAIL gd, ld FAIL PASS i386-pc-solaris2.11 PASS PASS PASS sparc-pc-solaris2.8 PASS PASS PASS sparc-pc-solaris2.9 PASS PASS PASS sparc-pc-solaris2.10 PASS PASS PASS sparc-pc-solaris2.11 PASS PASS PASS The Solaris 8 and 9 as, ld configurations are actually emutls, as is Tru64 UNIX, so we won't see failures on such targets. I do have a patch for the gd and ld failures on Solaris/x86. Those models weren't excercised anywhere in the testsuite before. The failures occur since the Solaris ABI requires slightly different code sequences here, and the patch accomodates this. In the very latest version of Solaris 11, the linker maintainers have added support for the GNU code sequences, too, so all is fine there. While testing the patch, the Solaris 8 and 9 gas, ld and gas, gld configurations were UNSUPPORTED initially, since the tls_runtime test itself failed: ld.so.1: tls_runtime4775.exe: fatal: tls_runtime4775.exe: object requires TLS, but TLS failed to initialize Adding the necessary TLS options fixes this and provides the results above. I'll install the patch in a day unless someone sees any problems. Rainer 2010-12-30 Uros Bizjak Rainer Orth * gcc.dg/torture/tls/run-gd.c: New test. * gcc.dg/torture/tls/run-ie.c: New test. * gcc.dg/torture/tls/run-ld.c: New test. * gcc.dg/torture/tls/run-le.c: New test. * lib/target-supports.exp (check_effective_target_tls_runtime): Build testcase with TLS options. diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-gd.c b/gcc/testsuite/gcc.dg/torture/tls/run-gd.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-gd.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_gd __attribute__((tls_model("global-dynamic"))) = 0; + +int get_gd (void) +{ + return tls_gd; +} + +int *get_gdp (void) +{ + return &tls_gd; +} + +int main (void) +{ + int val; + + val = get_gd (); + if (val != 0) + abort (); + + val = *get_gdp (); + if (val != 0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ie.c b/gcc/testsuite/gcc.dg/torture/tls/run-ie.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-ie.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ie __attribute__((tls_model("initial-exec"))) = 4; + +int get_ie (void) +{ + return tls_ie; +} + +int *get_iep (void) +{ + return &tls_ie; +} + +int main (void) +{ + int val; + + val = get_ie (); + if (val != 4) + abort (); + + val = *get_iep (); + if (val != 4) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-ld.c b/gcc/testsuite/gcc.dg/torture/tls/run-ld.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-ld.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_ld __attribute__((tls_model("local-dynamic"))) = 1; +__thread int tls_ld2 __attribute__((tls_model("local-dynamic"))) = 2; + +int get_ld (void) +{ + return tls_ld + tls_ld2; +} + +int *get_ldp (void) +{ + return &tls_ld; +} + +int main (void) +{ + int val; + + val = get_ld (); + if (val != 1 + 2) + abort (); + + val = *get_ldp (); + if (val != 1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/tls/run-le.c b/gcc/testsuite/gcc.dg/torture/tls/run-le.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/tls/run-le.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-add-options tls } */ + +extern void abort (void); + +__thread int tls_le __attribute__((tls_model("local-exec"))) = 3; + +int get_le (void) +{ + return tls_le; +} + +int *get_lep (void) +{ + return &tls_le; +} + +int main (void) +{ + int val; + + val = get_le (); + if (val != 3) + abort (); + + val = *get_lep (); + if (val != 3) + abort (); + + return 0; +}