[llvm-commits] [llvm-gcc-4.2] r54305 - in /llvm-gcc-4.2/trunk/libgomp/testsuite: lib/libgomp.exp libgomp.c/pr32362-1.c libgomp.c/pr32362-2.c libgomp.c/pr32362-3.c libgomp.c/pr32468.c

Bill Wendling isanbard at gmail.com
Sat Aug 2 21:30:20 PDT 2008


Author: void
Date: Sat Aug  2 23:30:20 2008
New Revision: 54305

URL: http://llvm.org/viewvc/llvm-project?rev=54305&view=rev
Log:
Add libgomp tests from Apple's GCC 4.2 mainline.

Added:
    llvm-gcc-4.2/trunk/libgomp/testsuite/lib/libgomp.exp
    llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-1.c
    llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-2.c
    llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-3.c
    llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32468.c

Added: llvm-gcc-4.2/trunk/libgomp/testsuite/lib/libgomp.exp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libgomp/testsuite/lib/libgomp.exp?rev=54305&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libgomp/testsuite/lib/libgomp.exp (added)
+++ llvm-gcc-4.2/trunk/libgomp/testsuite/lib/libgomp.exp Sat Aug  2 23:30:20 2008
@@ -0,0 +1,209 @@
+# APPLE LOCAL file mainline
+# Damn dejagnu for not having proper library search paths for load_lib.
+# We have to explicitly load everything that gcc-dg.exp wants to load.
+
+proc load_gcc_lib { filename } {
+    global srcdir loaded_libs
+
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+    set loaded_libs($filename) ""
+}
+
+load_lib dg.exp
+load_gcc_lib file-format.exp
+load_gcc_lib target-supports.exp
+load_gcc_lib target-supports-dg.exp
+load_gcc_lib scanasm.exp
+load_gcc_lib scandump.exp
+load_gcc_lib scanrtl.exp
+load_gcc_lib scantree.exp
+load_gcc_lib scanipa.exp
+load_gcc_lib prune.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+load_gcc_lib gcc-defs.exp
+load_gcc_lib gcc-dg.exp
+load_gcc_lib gfortran-dg.exp
+
+set dg-do-what-default run
+
+#
+# GCC_UNDER_TEST is the compiler under test.
+#
+
+set libgomp_compile_options ""
+
+#
+# libgomp_init
+#
+
+if [info exists TOOL_OPTIONS] {
+    set multilibs [get_multilibs $TOOL_OPTIONS]
+} else {
+    set multilibs [get_multilibs]
+}
+
+proc libgomp_init { args } {
+    global srcdir blddir objdir tool_root_dir
+    global libgomp_initialized
+    global tmpdir
+    global blddir
+    global gluefile wrap_flags
+    global ALWAYS_CFLAGS
+    global CFLAGS
+    global TOOL_EXECUTABLE TOOL_OPTIONS
+    global GCC_UNDER_TEST
+    global TESTING_IN_BUILD_TREE
+    global target_triplet
+    global always_ld_library_path
+
+    set blddir [lookfor_file [get_multilibs] libgomp]
+
+    # We set LC_ALL and LANG to C so that we get the same error
+    # messages as expected.
+    setenv LC_ALL C
+    setenv LANG C
+
+    if ![info exists GCC_UNDER_TEST] then {
+	if [info exists TOOL_EXECUTABLE] {
+	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
+	} else {
+	    set GCC_UNDER_TEST "[find_gcc]"
+	}
+    }
+
+    if ![info exists tmpdir] {
+	set tmpdir "/tmp"
+    }
+
+    if [info exists gluefile] {
+	unset gluefile
+    }
+
+    if {![info exists CFLAGS]} {
+	set CFLAGS ""
+    }
+
+    # Locate libgcc.a so we don't need to account for different values of
+    # SHLIB_EXT on different platforms
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+        set gccdir [file dirname $gccdir]
+    }
+
+    # Compute what needs to be put into LD_LIBRARY_PATH
+    set always_ld_library_path ".:${blddir}/.libs"
+
+    # Compute what needs to be added to the existing LD_LIBRARY_PATH.
+    if {$gccdir != ""} {
+	append always_ld_library_path ":${gccdir}"
+	set compiler [lindex $GCC_UNDER_TEST 0]
+
+	if { [is_remote host] == 0 && [which $compiler] != 0 } {
+	  foreach i "[exec $compiler --print-multi-lib]" {
+	    set mldir ""
+	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+	    set mldir [string trimright $mldir "\;@"]
+	    if { "$mldir" == "." } {
+	      continue
+	    }
+	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+	      append always_ld_library_path ":${gccdir}/${mldir}"
+	    }
+	  }
+	}
+    }
+
+    set ALWAYS_CFLAGS ""
+    # APPLE LOCAL begin mainline candidate
+    # Make sure that blddir exists...
+    if {$blddir != ""} {
+	lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
+	lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
+	lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
+    }
+    lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../"
+    lappend ALWAYS_CFLAGS "-lgomp"
+
+    # APPLE LOCAL end mainline candidate
+    # We use atomic operations in the testcases to validate results.
+    if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
+	 && [check_effective_target_ilp32] } {
+	lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
+    }
+
+    if [istarget *-*-darwin*] {
+	lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
+    }
+
+    if [istarget sparc*-*-*] {
+	lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
+    }
+
+    if [info exists TOOL_OPTIONS] {
+	lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
+    }
+
+    # Make sure that lines are not wrapped.  That can confuse the
+    # error-message parsing machinery.
+    lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
+
+    # And, gee, turn on OpenMP.
+    lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+}
+
+#
+# libgomp_target_compile -- compile a source file
+#
+
+proc libgomp_target_compile { source dest type options } {
+    global blddir
+    global libgomp_compile_options
+    global gluefile wrap_flags
+    global ALWAYS_CFLAGS
+    global GCC_UNDER_TEST
+    global lang_test_file
+    global lang_library_path
+    global lang_link_flags
+
+    if { [info exists lang_test_file] && [file exists "${blddir}/"] } {
+	lappend options "ldflags=-L${blddir}/${lang_library_path} ${lang_link_flags}"
+    }
+
+    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
+	lappend options "libs=${gluefile}"
+	lappend options "ldflags=${wrap_flags}"
+    }
+
+    lappend options "additional_flags=[libio_include_flags]"
+    lappend options "compiler=$GCC_UNDER_TEST"
+
+    set options [concat $libgomp_compile_options $options]
+
+    if [info exists ALWAYS_CFLAGS] {
+	set options [concat "$ALWAYS_CFLAGS" $options]
+    }
+
+    set options [dg-additional-files-options $options $source]
+
+    set result [target_compile $source $dest $type $options]
+
+    return $result
+}
+
+proc libgomp_option_help { } {
+    send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
+}
+
+proc libgomp_option_proc { option } {
+    if [regexp "^--additional_options," $option] {
+	global libgomp_compile_options
+	regsub "--additional_options," $option "" option
+	foreach x [split $option ","] {
+	    lappend libgomp_compile_options "additional_flags=$x"
+	}
+	return 1
+    } else {
+	return 0
+    }
+}

Added: llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-1.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-1.c?rev=54305&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-1.c (added)
+++ llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-1.c Sat Aug  2 23:30:20 2008
@@ -0,0 +1,32 @@
+/* PR middle-end/32362 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  int n[4] = { -1, -1, -1, -1 };
+  static int a = 2, b = 4;
+  omp_set_num_threads (4);
+  omp_set_dynamic (0);
+  omp_set_nested (1);
+#pragma omp parallel private(b)
+  {
+    b = omp_get_thread_num ();
+#pragma omp parallel firstprivate(a)
+    {
+      a = (omp_get_thread_num () + a) + 1;
+      if (b == omp_get_thread_num ())
+	n[omp_get_thread_num ()] = a + (b << 4);
+    }
+  }
+  if (n[0] != 3)
+    abort ();
+  if (n[3] != -1
+      && (n[1] != 0x14 || n[2] != 0x25 || n[3] != 0x36))
+    abort ();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-2.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-2.c?rev=54305&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-2.c (added)
+++ llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-2.c Sat Aug  2 23:30:20 2008
@@ -0,0 +1,33 @@
+/* PR middle-end/32362 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int a = 2, b = 4;
+
+int
+main ()
+{
+  int n[4] = { -1, -1, -1, -1 };
+  omp_set_num_threads (4);
+  omp_set_dynamic (0);
+  omp_set_nested (1);
+#pragma omp parallel private(b)
+  {
+    b = omp_get_thread_num ();
+#pragma omp parallel firstprivate(a)
+    {
+      a = (omp_get_thread_num () + a) + 1;
+      if (b == omp_get_thread_num ())
+	n[omp_get_thread_num ()] = a + (b << 4);
+    }
+  }
+  if (n[0] != 3)
+    abort ();
+  if (n[3] != -1
+      && (n[1] != 0x14 || n[2] != 0x25 || n[3] != 0x36))
+    abort ();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-3.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-3.c?rev=54305&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-3.c (added)
+++ llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32362-3.c Sat Aug  2 23:30:20 2008
@@ -0,0 +1,34 @@
+/* PR middle-end/32362 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int a = 2;
+
+int
+main ()
+{
+  int n[4] = { -1, -1, -1, -1 };
+  int b = 4;
+  omp_set_num_threads (4);
+  omp_set_dynamic (0);
+  omp_set_nested (1);
+#pragma omp parallel private(b)
+  {
+    b = omp_get_thread_num ();
+#pragma omp parallel firstprivate(a)
+    {
+      a = (omp_get_thread_num () + a) + 1;
+      if (b == omp_get_thread_num ())
+	n[omp_get_thread_num ()] = a + (b << 4);
+    }
+  }
+  if (n[0] != 3)
+    abort ();
+  if (n[3] != -1
+      && (n[1] != 0x14 || n[2] != 0x25 || n[3] != 0x36))
+    abort ();
+  return 0;
+}

Added: llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32468.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32468.c?rev=54305&view=auto

==============================================================================
--- llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32468.c (added)
+++ llvm-gcc-4.2/trunk/libgomp/testsuite/libgomp.c/pr32468.c Sat Aug  2 23:30:20 2008
@@ -0,0 +1,26 @@
+/* PR libgomp/32468 */
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  int res[2] = { -1, -1 };
+  omp_set_dynamic (0);
+  omp_set_num_threads (4);
+#pragma omp parallel
+  {
+    #pragma omp sections
+      {
+	#pragma omp section
+	res[0] = omp_get_num_threads () != 4;
+	#pragma omp section
+	res[1] = omp_get_num_threads () != 4;
+      }
+  }
+  if (res[0] != 0 || res[1] != 0)
+    abort ();
+  return 0;
+}





More information about the llvm-commits mailing list