[llvm-commits] llvm-test patch for review

Reid Spencer rspencer at reidspencer.com
Sun Dec 10 14:26:11 PST 2006


Hi Anton,

On Sat, 2006-12-09 at 14:35 +0300, Anton Korobeynikov wrote:
> Hello, Everyone.
> 
> Please find patch for llvm-test for review.
> 
> Features:
> 
> 1. Much more mingw32-friendly. Almost all tests were fixed.
> 2. Added features for cross-platform tests
> 

Overall it looks okay. There appear to be a couple Makefile bugs using
$(CC)
instead of $(CXX) and similarly $(CROSS_CC) instead of $(CROSS_CXX).
Also,
I would prefer better implementations of the "millisec" functions you
added in some tests. Counting the number of calls isn't accurate given
that you could at least call time(0) and multiply by 1000 (after
subtracting
the baseline value). There's also a potential bug in the configure.ac 
script that would wipe out the value of EXTRA_INTERP.

Please correct those few mistakes and then this is fine to commit.

Reid.

> Index: Makefile.config.in
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/Makefile.config.in,v
> retrieving revision 1.24
> diff -u -r1.24 Makefile.config.in
> --- Makefile.config.in  20 Sep 2006 23:40:57 -0000      1.24
> +++ Makefile.config.in  9 Dec 2006 11:12:21 -0000
> @@ -11,6 +11,9 @@
>  #
>  LLVM_OBJ_ROOT = @LLVM_OBJ@
>  
> +# Extra binary interpreter for cross-platform tests (e.g. wine)
> +EXTRA_INTERP := @EXTRA_INTERP@
> +
>  # Set the directory root of this project's source files
>  PROJ_SRC_ROOT := $(subst //,/, at abs_top_srcdir@)
>  
> @@ -20,6 +23,17 @@
>  # Set the root directory of this project's install prefix
>  PROJ_INSTALL_ROOT := @prefix@
>  
> +# Indicates, whether we're cross-compiling LLVM or not
> +LLVM_TEST_CROSS_COMPILING := @LLVM_TEST_CROSS_COMPILING@
> +
> +# Path to the cross C++ compiler to use. 
> +CROSS_CXX := @CXX@
> +
> +# Path to the cross CC binary, which use used by testcases for native
> builds.
> +CROSS_CC := @CC@
> +
> +CROSS_LDFLAGS := @LDFLAGS@
> +
>  # Include LLVM's configuration Makefile.
>  include $(LLVM_OBJ_ROOT)/Makefile.config
>  
> Index: Makefile.programs
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/Makefile.programs,v
> retrieving revision 1.246
> diff -u -r1.246 Makefile.programs
> --- Makefile.programs   30 Nov 2006 23:00:41 -0000      1.246
> +++ Makefile.programs   9 Dec 2006 11:12:22 -0000
> @@ -101,10 +101,17 @@
>  # the LINK_WITH_LLVMGCC_LIBS variable is set, then the link is done
> that
>  # way. Unfortunately, this can't help JIT because it is always linked
> with
>  # the libraries of lli.
> +ifeq ($(LLVM_TEST_CROSS_COMPILING),1)
> +LLVMGCCLD := $(CROSS_CC)
> +ifdef LINK_WITH_LLVMGCC_LIBS
> +LLVMGCCLD := $(CROSS_CC) -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L
> $(LLVMGCCDIR)/lib
> +endif
> +else
>  LLVMGCCLD := $(CC)
>  ifdef LINK_WITH_LLVMGCC_LIBS
>  LLVMGCCLD := $(CC) -L$(LLVMGCCDIR)/lib/gcc/$(LLVMGCCARCH) -L
> $(LLVMGCCDIR)/lib
>  endif
> +endif
>  
>  ifndef STDIN_FILENAME
>  STDIN_FILENAME := /dev/null
> @@ -369,7 +376,7 @@
>  ifndef USE_PRECOMPILED_BYTECODE
>  $(PROGRAMS_TO_TEST:%=Output/%.out-nat): \
>  Output/%.out-nat: Output/%.native
> -       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS)
> +       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(EXTRA_INTERP) $<
> $(RUN_OPTIONS)

This isn't strictly right because it depends on EXTRA_INTERP expanding
to 
empty in the non-cross-compiling case, but I see why it works. The
program 
to run just becomes an argument to the EXTRA_INTERP.  Did you check
RunSafely.sh to make sure it handles this correctly in all cases?

>  endif
>  
>  $(PROGRAMS_TO_TEST:%=Output/%.out-lli): \
> @@ -386,15 +393,15 @@
>  
>  $(PROGRAMS_TO_TEST:%=Output/%.out-llc): \
>  Output/%.out-llc: Output/%.llc
> -       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS)
> +       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(EXTRA_INTERP) $<
> $(RUN_OPTIONS)

Same comment.

>  
>  $(PROGRAMS_TO_TEST:%=Output/%.out-llc-beta): \
>  Output/%.out-llc-beta: Output/%.llc-beta
> -       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS)
> +       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(EXTRA_INTERP) $<
> $(RUN_OPTIONS)
>  
>  $(PROGRAMS_TO_TEST:%=Output/%.out-cbe): \
>  Output/%.out-cbe: Output/%.cbe
> -       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS)
> +       -$(RUNSAFELY) $(STDIN_FILENAME) $@ $(EXTRA_INTERP) $<
> $(RUN_OPTIONS)
>  
>  # The RunSafely.sh script puts an "exit <retval>" line at the end of
>  # the program's output. We have to make bugpoint do the same thing
> Index: Makefile.rules
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/Makefile.rules,v
> retrieving revision 1.19
> diff -u -r1.19 Makefile.rules
> --- Makefile.rules      3 Dec 2006 21:15:49 -0000       1.19
> +++ Makefile.rules      9 Dec 2006 11:12:22 -0000
> @@ -345,8 +345,13 @@
>  #
>  # Compile commands with libtool.
>  #
> +ifeq ($(LLVM_TEST_CROSS_COMPILING),1)
> +Compile  := $(LIBTOOL) --tag=CXX --mode=compile $(CROSS_CXX) -c
> $(CPPFLAGS) $(CXXFLAGS)
> +CompileC  := $(LIBTOOL) --mode=compile $(CROSS_CC) -c $(CPPFLAGS)
> $(CFLAGS)
> +else
>  Compile  := $(LIBTOOL) --tag=CXX --mode=compile $(CXX) -c $(CPPFLAGS)
> $(CXXFLAGS)
>  CompileC  := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS)
> +endif
>  
>  # Compile a cpp file, don't link...
>  CompileG := $(Compile) -g  -D_DEBUG
> @@ -366,7 +371,11 @@
>  # Link final executable
>  #      (Note that we always link with the C++ compiler).
>  #
> +ifeq ($(LLVM_TEST_CROSS_COMPILING),1)
> +Link     := $(LIBTOOL) --tag=CXX --mode=link $(CROSS_CXX)
> +else
>  Link     := $(LIBTOOL) --tag=CXX --mode=link $(CXX)
> +endif
>  
>  # link both projlib and llvmlib libraries
>  LinkG    := $(Link) -g -L$(PROJLIBDEBUGSOURCE)  -L
> $(LLVMLIBDEBUGSOURCE) $(STRIP)
> @@ -384,7 +393,11 @@
>  endif
>  
>  # Create one .o file from a bunch of .o files...
> +ifeq ($(LLVM_TEST_CROSS_COMPILING),1)
> +Relink := ${LIBTOOL} --tag=CXX --mode=link $(CROSS_CXX)
> +else
>  Relink := ${LIBTOOL} --tag=CXX --mode=link $(CXX)
> +endif
>  
>  #
>  # Configure where the item being compiled should go.
> @@ -398,8 +411,13 @@
>  endif
>  
>  # Create dependency file from CPP file, send to stdout.
> +ifeq ($(LLVM_TEST_CROSS_COMPILING),1)
> +Depend   := $(CROSS_CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) 
> +DependC  := $(CROSS_CC)  -MM -I$(LEVEL)/include $(CPPFLAGS) 
> +else
>  Depend   := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) 
>  DependC  := $(CC)  -MM -I$(LEVEL)/include $(CPPFLAGS) 
> +endif
>  
>  # Archive a bunch of .o files into a .a file...
>  AR       = $(AR_PATH) cr
> Index: configure
> ===================================================================
> 

I won't review the generated code so I snipped it out of your patch. In
the future, please don't include generated code in your patch
submissions.  I'll review the source, instead.

... snip ...

> Index: MultiSource/Makefile.multisrc
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Makefile.multisrc,v
> retrieving revision 1.53
> diff -u -r1.53 Makefile.multisrc
> --- MultiSource/Makefile.multisrc       7 Jun 2006 00:05:16
> -0000       1.53
> +++ MultiSource/Makefile.multisrc       9 Dec 2006 11:12:24 -0000
> @@ -29,16 +29,32 @@
>  .PRECIOUS: $(LObjects) $(NObjects) Output/%.linked.rll
>  
>  Output/%.o: %.c Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CC) $(CPPFLAGS) $(CFLAGS) -O2 $(TARGET_FLAGS) -c $<
> -o $@
> +else
>         -$(CC) $(CPPFLAGS) $(CFLAGS) -O2 $(TARGET_FLAGS) -c $< -o $@
> +endif

Instead of having these ifdef's sprinked through the rules, I'd prefer
that you just defined one variable as either $(CC) or $(CROSS_CC) and 
then use that variable in the rules. It keeps the makefiles cleaner.

>  
>  Output/%.o: %.C Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $<
> -o $@

This is a bug. It should be $(CROSS_CXX) as the source is C++ not C.

> +else
>         -$(CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $< -o $@

Although not your fault, this is also a bug. It should be $(CXX).

> +endif
>  
>  Output/%.o: %.cpp Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $<
> -o $@
> +else
>         -$(CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $< -o $@
> +endif

Same comments as last one. These are C++ files (see the CXXFLAGS?).
Please fix both cases.

>  
>  Output/%.o: %.cc Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $<
> -o $@
> +else
>         -$(CC) $(CPPFLAGS) $(CXXFLAGS) -O2 $(TARGET_FLAGS) -c $< -o $@
> +endif

Same comment. This is C++.

>  
>  bugpoint-gccas: Output/$(PROG).bugpoint-gccas
>  bugpoint-gccld: Output/$(PROG).bugpoint-gccld
> Index: MultiSource/Applications/d/d.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Applications/d/d.h,v
> retrieving revision 1.2
> diff -u -r1.2 d.h
> --- MultiSource/Applications/d/d.h      12 Jul 2006 21:05:09
> -0000      1.2
> +++ MultiSource/Applications/d/d.h      9 Dec 2006 11:12:24 -0000
> @@ -76,7 +76,9 @@
>  typedef unsigned long long uint64;
>  typedef short int16;
>  typedef unsigned short uint16;
> -/* typedef uint32 uint; * already part of most systems */
> +#ifdef __MINGW32__
> +typedef uint32 uint;
> +#endif
> 

Did you verify that this change doesn't break Linux or Darwin? 
The uint type is only going to be defined on MINGW32. 

>  typedef unsigned long ulong;
>  
>  #include "dparse.h"
> Index: MultiSource/Applications/oggenc/oggenc.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Applications/oggenc/oggenc.c,v
> retrieving revision 1.3
> diff -u -r1.3 oggenc.c
> --- MultiSource/Applications/oggenc/oggenc.c    22 Jan 2006 18:41:05
> -0000      1.3
> +++ MultiSource/Applications/oggenc/oggenc.c    9 Dec 2006 11:12:28
> -0000
> @@ -17,6 +17,7 @@
>  #include <stdarg.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> +#include <stdint.h>
>  #include <string.h>
>  #include <sys/stat.h>
>  #include <sys/time.h>
> @@ -125,9 +126,9 @@
>  
>  /* these are filled in by configure */
>  typedef int16_t ogg_int16_t;
> -typedef u_int16_t ogg_uint16_t;
> +typedef uint16_t ogg_uint16_t;
>  typedef int32_t ogg_int32_t;
> -typedef u_int32_t ogg_uint32_t;
> +typedef uint32_t ogg_uint32_t;
>  typedef int64_t ogg_int64_t;
>  
>  typedef struct {
> Index: MultiSource/Applications/siod/siod.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Applications/siod/siod.c,v
> retrieving revision 1.1
> diff -u -r1.1 siod.c
> --- MultiSource/Applications/siod/siod.c        17 Oct 2003 18:48:45
> -0000      1.1
> +++ MultiSource/Applications/siod/siod.c        9 Dec 2006 11:12:28
> -0000
> @@ -20,6 +20,11 @@
>    "-s200000",
>    "-n2048"};
>  
> +#ifdef __MINGW32__
> +#undef unix
> +#undef vms
> +#endif
> +
>  int main(int argc,char **argv
>  #if defined(unix) || defined(vms) || defined(WIN32)
>       ,char **env
> Index: MultiSource/Applications/siod/slib.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Applications/siod/slib.c,v
> retrieving revision 1.1
> diff -u -r1.1 slib.c
> --- MultiSource/Applications/siod/slib.c        17 Oct 2003 18:48:45
> -0000      1.1
> +++ MultiSource/Applications/siod/slib.c        9 Dec 2006 11:12:28
> -0000
> @@ -80,6 +80,11 @@
>  #include "siod.h"
>  #include "siodp.h"
>  
> +#ifdef __MINGW32__
> +#undef unix
> +#undef vms
> +#endif
> +
>  static void init_slib_version(void)
>  {setvar(cintern("*slib-version*"),
>         cintern("$Id: slib.c,v 1.1 2003/10/17 18:48:45 gaeke Exp $"),
> Index: MultiSource/Applications/siod/sliba.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Applications/siod/sliba.c,v
> retrieving revision 1.1
> diff -u -r1.1 sliba.c
> --- MultiSource/Applications/siod/sliba.c       17 Oct 2003 18:48:45
> -0000      1.1
> +++ MultiSource/Applications/siod/sliba.c       9 Dec 2006 11:12:28
> -0000
> @@ -18,6 +18,11 @@
>  #include "siod.h"
>  #include "siodp.h"
>  
> +#ifdef __MINGW32__
> +#undef unix
> +#undef vms
> +#endif
> +
>  static void init_sliba_version(void)
>  {setvar(cintern("*sliba-version*"),
>         cintern("$Id: sliba.c,v 1.1 2003/10/17 18:48:45 gaeke Exp $"),
> Index: MultiSource/Applications/siod/slibu.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Applications/siod/slibu.c,v
> retrieving revision 1.5
> diff -u -r1.5 slibu.c
> --- MultiSource/Applications/siod/slibu.c       2 Jun 2004 23:06:37
> -0000       1.5
> +++ MultiSource/Applications/siod/slibu.c       9 Dec 2006 11:12:28
> -0000
> @@ -20,6 +20,11 @@
>  #include <errno.h>
>  #include <stdarg.h>
>  
> +#ifdef __MINGW32__
> +#undef unix
> +#undef vms
> +#endif

You have this change replicated in four .c files. Can this not go in
to siod.h or something?

>  #if defined(unix)
>  #include <unistd.h>
>  #include <dirent.h>
> Index: MultiSource/Benchmarks/ASCI_Purple/SMG2000/timer.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/ASCI_Purple/SMG2000/timer.c,v
> retrieving revision 1.1
> diff -u -r1.1 timer.c
> --- MultiSource/Benchmarks/ASCI_Purple/SMG2000/timer.c  11 Apr 2005
> 05:22:07 -0000      1.1
> +++ MultiSource/Benchmarks/ASCI_Purple/SMG2000/timer.c  9 Dec 2006
> 11:12:28 -0000
> @@ -19,7 +19,9 @@
>   */
>  
>  #include <time.h>
> +#ifndef __MINGW32__
>  #include <sys/times.h>
> +#endif
>  #ifdef TIMER_USE_MPI
>  #include "mpi.h"
>  #endif
> Index: MultiSource/Benchmarks/Fhourstones/time.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Fhourstones/time.c,v
> retrieving revision 1.2
> diff -u -r1.2 time.c
> --- MultiSource/Benchmarks/Fhourstones/time.c   2 May 2003 18:40:36
> -0000       1.2
> +++ MultiSource/Benchmarks/Fhourstones/time.c   9 Dec 2006 11:12:28
> -0000
> @@ -2,6 +2,15 @@
>  
>  /* add more platforms if necessary */
>  
> +#ifdef __MINGW32__
> +int64 millisecs()
> +{
> +  static int64 Time = 0;
> +  return ++Time;
> +}

Hmm. Is there no way to get the actual time? Counting the number
of calls isn't exactly the same thing.

> +#undef UNIX
> +#endif
> +
>  #ifdef UNIX
>  #include <sys/time.h>
>  #include <sys/resource.h>
> @@ -17,3 +26,5 @@
>  }
>  
>  #endif
> +
> +
> Index: MultiSource/Benchmarks/Fhourstones-3.1/Game.h
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Fhourstones-3.1/Game.h,v
> retrieving revision 1.1
> diff -u -r1.1 Game.h
> --- MultiSource/Benchmarks/Fhourstones-3.1/Game.h       14 Feb 2006
> 06:08:34 -0000      1.1
> +++ MultiSource/Benchmarks/Fhourstones-3.1/Game.h       9 Dec 2006
> 11:12:28 -0000
> @@ -42,7 +42,8 @@
>  #define TOP (BOTTOM << HEIGHT)
>  
>  #include <sys/types.h>
> -typedef u_int64_t uint64;
> +#include <stdint.h>
> +typedef uint64_t uint64;
>  typedef int64_t int64;
>  
>  uint64 color[2];  // black and white bitboard
> Index: MultiSource/Benchmarks/Fhourstones-3.1/SearchGame.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Fhourstones-3.1/SearchGame.c,v
> retrieving revision 1.1
> diff -u -r1.1 SearchGame.c
> --- MultiSource/Benchmarks/Fhourstones-3.1/SearchGame.c 14 Feb 2006
> 06:08:34 -0000      1.1
> +++ MultiSource/Benchmarks/Fhourstones-3.1/SearchGame.c 9 Dec 2006
> 11:12:28 -0000
> @@ -12,17 +12,27 @@
>  
>  #include "TransGame.h"
>  #include <sys/time.h>
> +#ifndef __MINGW32__
>  #include <sys/resource.h>
> +#endif
>   
>  #define BOOKPLY 0  // full-width search up to this depth
>  #define REPORTPLY -1
>  
> +#ifndef __MINGW32__
>  uint64 millisecs()
>  {
>    struct rusage rusage;
>    getrusage(RUSAGE_SELF,&rusage);
>    return rusage.ru_utime.tv_sec * 1000 + rusage.ru_utime.tv_usec /
> 1000;
>  }
> +#else
> +uint64 millisecs()
> +{
> +   static Time = 0;
> +   return ++Time;
> +}

Again, I'd prefer if you found a more suitable workaround
for this on Win32. Even if all you can do is get the time
in a 1 second resolution, multiplying that by 1000 is 
more accurate than counting the number of calls here.

> +#endif
>  
>  int history[2][SIZE1];
>  uint64 nodes, msecs;
> Index: MultiSource/Benchmarks/FreeBench/analyzer/analyzer.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/FreeBench/analyzer/analyzer.c,v
> retrieving revision 1.1
> diff -u -r1.1 analyzer.c
> --- MultiSource/Benchmarks/FreeBench/analyzer/analyzer.c        11 Oct
> 2003 21:18:46 -0000      1.1
> +++ MultiSource/Benchmarks/FreeBench/analyzer/analyzer.c        9 Dec
> 2006 11:12:28 -0000
> @@ -2,7 +2,9 @@
>  #include <stdlib.h>
>  #include <string.h>
>  #include <sys/time.h>
> +#ifndef __MINGW32__
>  #include <sys/resource.h> 
> +#endif
>  #include <unistd.h>
>  #include "version.h"
>  #include "types.h"
> Index: MultiSource/Benchmarks/FreeBench/distray/distray.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/FreeBench/distray/distray.c,v
> retrieving revision 1.2
> diff -u -r1.2 distray.c
> --- MultiSource/Benchmarks/FreeBench/distray/distray.c  14 Dec 2004
> 19:17:16 -0000      1.2
> +++ MultiSource/Benchmarks/FreeBench/distray/distray.c  9 Dec 2006
> 11:12:28 -0000
> @@ -2,7 +2,9 @@
>  #include <math.h>
>  #include <stdlib.h>
>  #include <sys/time.h>
> +#ifndef __MINGW32__
>  #include <sys/resource.h>
> +#endif
>  #include <unistd.h>
>  
>  /* Simple raytracer
> Index: MultiSource/Benchmarks/FreeBench/fourinarow/fourinarow.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/FreeBench/fourinarow/fourinarow.c,v
> retrieving revision 1.2
> diff -u -r1.2 fourinarow.c
> --- MultiSource/Benchmarks/FreeBench/fourinarow/fourinarow.c    16 Jan
> 2005 03:16:10 -0000      1.2
> +++ MultiSource/Benchmarks/FreeBench/fourinarow/fourinarow.c    9 Dec
> 2006 11:12:29 -0000
> @@ -31,7 +31,9 @@
>  #include <string.h>
>  #include <stdlib.h>
>  #include <sys/time.h>
> +#ifndef __MINGW32__
>  #include <sys/resource.h>
> +#endif
>  #include <unistd.h>
>  
>  /* 64 bit type needed */
> Index: MultiSource/Benchmarks/MallocBench/espresso/utility.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/MallocBench/espresso/utility.c,v
> retrieving revision 1.2
> diff -u -r1.2 utility.c
> --- MultiSource/Benchmarks/MallocBench/espresso/utility.c       5 Apr
> 2004 18:22:14 -0000       1.2
> +++ MultiSource/Benchmarks/MallocBench/espresso/utility.c       9 Dec
> 2006 11:12:29 -0000
> @@ -37,7 +37,7 @@
>  #endif
>  
>  /* default */
> -#if !defined(BSD) && !defined(UNIX10) && !defined(UNIX60) && !
> defined(UNIX100) && !defined(UNIX50)
> +#if !defined(BSD) && !defined(UNIX10) && !defined(UNIX60) && !
> defined(UNIX100) && !defined(UNIX50) && !defined(__MINGW32__)
>  #define BSD
>  #endif
>  
> @@ -78,7 +78,7 @@
>      t = (long) rusage.ru_utime.tv_sec*1000 +
> rusage.ru_utime.tv_usec/1000;
>  #endif
>  
> -#ifdef IBMPC
> +#if defined(IBMPC) || defined (__MINGW32__)
>      long ltime;
>      (void) time(&ltime);
>      t = ltime * 1000;

See? Here's an implementation of millisec that you could use in the
other test programs.

> Index: MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c,v
> retrieving revision 1.1
> diff -u -r1.1 seed.c
> --- MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c      5 Oct 2004
> 19:42:16 -0000       1.1
> +++ MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c      9 Dec 2006
> 11:12:29 -0000
> @@ -37,7 +37,9 @@
>  #define  IBM  8086
>  */
>  
> +#ifndef __MINGW32__
>  #define  SUN  68000
> +#endif
>  
>  #include <stdio.h>
>  
> @@ -77,3 +79,9 @@
>  
>  #endif
>  
> +#ifdef __MINGW32__
> +#include <windows.h>
> +void seed(int *i) {
> +   *i = GetTickCount();
> +}

That's probably even better for a millisec implementation.
Ticks in windows are either 10 or 20 msec, if I recall correctly.

> +#endif
> \ No newline at end of file
> Index: MultiSource/Benchmarks/Prolangs-C++/city/broken_light.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Prolangs-C
> ++/city/broken_light.h,v
> retrieving revision 1.3
> diff -u -r1.3 broken_light.h
> --- MultiSource/Benchmarks/Prolangs-C++/city/broken_light.h     25 Oct
> 2004 20:35:57 -0000      1.3
> +++ MultiSource/Benchmarks/Prolangs-C++/city/broken_light.h     9 Dec
> 2006 11:12:29 -0000
> @@ -8,6 +8,9 @@
>  #include <cstdlib>
>  
>  #define BROKEN_LIGHT_ID 1
> +#ifdef __MINGW32__
> +#define random(x) ((rand(x) << 16) ^ (rand(x)))
> +#endif
>  
>  class broken_light : public light
>  {
> Index: MultiSource/Benchmarks/Prolangs-C++/city/main.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Prolangs-C
> ++/city/main.cpp,v
> retrieving revision 1.6
> diff -u -r1.6 main.cpp
> --- MultiSource/Benchmarks/Prolangs-C++/city/main.cpp   25 Oct 2004
> 20:35:57 -0000      1.6
> +++ MultiSource/Benchmarks/Prolangs-C++/city/main.cpp   9 Dec 2006
> 11:12:29 -0000
> @@ -9,6 +9,9 @@
>  #include "intersection.h"
>  #include <cstdlib>
>  
> +#ifdef __MINGW32__
> +#define srandom(x) srand(x)
> +#endif
>  
>  // connect r1->d1 to r2->d2
>  void connect(roadlet *r1, direction d1, 
> Index: MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/Prolangs-C
> ++/ocean/ocean.cpp,v
> retrieving revision 1.2
> diff -u -r1.2 ocean.cpp
> --- MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp 5 Oct 2004
> 03:35:13 -0000       1.2
> +++ MultiSource/Benchmarks/Prolangs-C++/ocean/ocean.cpp 9 Dec 2006
> 11:12:29 -0000
> @@ -9,6 +9,10 @@
>  
>  #include <cstdlib>
>  
> +#ifdef __MINGW32__
> +#define random(x) ((rand(x) << 16) ^ rand(x))
> +#endif
> +
>  //cell.cc
>  Cell *Cell::getCellAt(Coordinate aCoord) {
>    return cells[aCoord.getY()][aCoord.getX()];
> Index: MultiSource/Benchmarks/sim/sim.c
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/MultiSource/Benchmarks/sim/sim.c,v
> retrieving revision 1.5
> diff -u -r1.5 sim.c
> --- MultiSource/Benchmarks/sim/sim.c    3 May 2003 05:48:35
> -0000       1.5
> +++ MultiSource/Benchmarks/sim/sim.c    9 Dec 2006 11:12:29 -0000
> @@ -83,6 +83,10 @@
>  /* #define WIN32       */
>  /***********************/
>  
> +#ifdef __MINGW32__
> +#undef UNIX
> +#endif
> +
>  #include   <stdio.h>
>  #include   <stdlib.h>
>  #include   <string.h>
> Index: SingleSource/Makefile.singlesrc
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/SingleSource/Makefile.singlesrc,v
> retrieving revision 1.32
> diff -u -r1.32 Makefile.singlesrc
> --- SingleSource/Makefile.singlesrc     23 Nov 2006 21:21:45
> -0000      1.32
> +++ SingleSource/Makefile.singlesrc     9 Dec 2006 11:12:29 -0000
> @@ -35,9 +35,17 @@
>  
>  # FIXME: LIBS should be specified, not hardcoded to -lm
>  Output/%.native: $(SourceDir)/%.c Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CC) $(CFLAGS) -O2 $(TARGET_FLAGS) $< -lm -o $@
> $(LDFLAGS)
> +else
>         -$(CC) $(CFLAGS) -O2 $(TARGET_FLAGS) $< -lm -o $@ $(LDFLAGS)
> +endif
>  Output/%.native: $(SourceDir)/%.cpp Output/.dir
> +ifeq ($(LLVM_TEST_CROSS_COMPILING), 1)
> +       -$(CROSS_CXX) $(CXXFLAGS) -O2 $(TARGET_FLAGS) $< -lm -o $@
> $(LDFLAGS)
> +else
>         -$(CXX) $(CXXFLAGS) -O2 $(TARGET_FLAGS) $< -lm -o $@
> $(LDFLAGS)
> +endif

Again, I would prefer a single variable for these rather than putting
conditionals in the rule.

>  
>  bugpoint-gccas bugpoint-gccld bugpoint-jit bugpoint-llc
> bugpoint-llc-beta:
> Index: SingleSource/Benchmarks/McGill/misr.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/SingleSource/Benchmarks/McGill/misr.c,v
> retrieving revision 1.3
> diff -u -r1.3 misr.c
> --- SingleSource/Benchmarks/McGill/misr.c       24 Nov 2006 21:19:41
> -0000      1.3
> +++ SingleSource/Benchmarks/McGill/misr.c       9 Dec 2006 11:12:29
> -0000
> @@ -40,6 +40,11 @@
>  #define TRUE 1
>  #define FALSE 0
>  
> +#ifdef __MINGW32__
> +# define seed48(x) srand(x)
> +# define lrand48(x) (rand(x) << 16) ^ (rand(x))
> +#endif
> +
>  int reg_len;
>  
>  typedef struct cells {
> @@ -116,7 +121,6 @@
>  /*initialize random f'n generator */
>          seed48(seed);
>  
> -
>  /* create MISRs of reg_len length */
>         create_link_list(&cell_array);
>  
> @@ -213,7 +217,7 @@
>         misr_type *temp;
>         int different, savef_free, savefaulty;
>         int rem, quot, h, i, j;
> -       long rand;
> +       long crand;
>         double randprob;
>  
>         different = FALSE;
> @@ -227,7 +231,7 @@
>                 savefaulty = 0;
>                 for (i=0; i<quot; i++)
>                 {
> -                       rand = lrand48();
> +                       crand = lrand48();
>                         for (j=0; j<31; j++)
>                         {
>                                 if (structure[i*31 + j] == '1')
> @@ -235,15 +239,15 @@
>                                         savef_free += temp->f_free;
>                                         savefaulty += temp->faulty;
>                                 }
> -                               temp->f_free = ((temp->next->f_free +
> rand) & BIN_MASK);
> +                               temp->f_free = ((temp->next->f_free +
> crand) & BIN_MASK);
>                                 randprob = ((double)(lrand48() %
> 1000) / 1000);
> -                               if (prob > randprob) rand ^= BIN_MASK;
> -                               temp->faulty = ((temp->next->faulty +
> rand) & BIN_MASK);
> +                               if (prob > randprob) crand ^=
> BIN_MASK;
> +                               temp->faulty = ((temp->next->faulty +
> crand) & BIN_MASK);
>                                 temp = temp->next;
> -                               rand >>= 1;
> +                               crand >>= 1;
>                         }
>                 }
> -               rand = lrand48();
> +               crand = lrand48();
>                 for (j=0; j<rem; j++)
>                 {
>                          if (structure[quot*31 + j] == '1')
> @@ -251,22 +255,23 @@
>                                  savef_free += temp->f_free;
>                                  savefaulty += temp->faulty;
>                          }
> -                        temp->f_free = ((temp->next->f_free + rand) &
> BIN_MASK);                                             
> -                        randprob = ((double)(lrand48() % 1000) /
> 1000);                                if (prob > randprob) rand ^=
> BIN_MASK;
> -                        temp->faulty = ((temp->next->faulty + rand) &
> BIN_MASK);
> +                        temp->f_free = ((temp->next->f_free + crand)
> & BIN_MASK);                                             
> +                        randprob = ((double)(lrand48() % 1000) /
> 1000);                                
> +                       if (prob > randprob) crand ^= BIN_MASK;
> +                        temp->faulty = ((temp->next->faulty + crand)
> & BIN_MASK);
>                          temp = temp->next;
> -                        rand >>= 1;
> +                        crand >>= 1;
>                  }
> -               rand = lrand48();
> +               crand = lrand48();
>                 if (structure[reg_len - 1] == '1')
>                 {
>                         savef_free += temp->f_free;
>                         savefaulty += temp->faulty;
>                 }
> -               temp->f_free = ((savef_free + rand) & BIN_MASK);
> +               temp->f_free = ((savef_free + crand) & BIN_MASK);
>                 randprob = ((double)(lrand48() % 10000) / 10000);
> -               if (prob > randprob) rand ^= BIN_MASK;
> -               temp->faulty = ((savefaulty + rand) & BIN_MASK);
> +               if (prob > randprob) crand ^= BIN_MASK;
> +               temp->faulty = ((savefaulty + crand) & BIN_MASK);
>  
>                 temp = present;
>         }
> Index: SingleSource/Benchmarks/Misc/ReedSolomon.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/SingleSource/Benchmarks/Misc/ReedSolomon.c,v
> retrieving revision 1.2
> diff -u -r1.2 ReedSolomon.c
> --- SingleSource/Benchmarks/Misc/ReedSolomon.c  25 Nov 2006 08:51:02
> -0000      1.2
> +++ SingleSource/Benchmarks/Misc/ReedSolomon.c  9 Dec 2006 11:12:29
> -0000
> @@ -413,6 +413,10 @@
>    
>  }
>  
> +#ifdef __MINGW32__
> +# define random(x) rand(x)
> +#endif
> +
>  int main(void) {
>    unsigned char rs_in[204], rs_out[204];
>    int i, j, k;
> Index: SingleSource/Benchmarks/Misc/mandel.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/SingleSource/Benchmarks/Misc/mandel.c,v
> retrieving revision 1.11
> diff -u -r1.11 mandel.c
> --- SingleSource/Benchmarks/Misc/mandel.c       17 Apr 2006 17:55:40
> -0000      1.11
> +++ SingleSource/Benchmarks/Misc/mandel.c       9 Dec 2006 11:12:29
> -0000
> @@ -16,7 +16,7 @@
>  
>  #if defined(__FreeBSD__) || defined(__OpenBSD__)
>  #include <complex.h>
> -#elif defined(__APPLE__)
> +#elif defined(__APPLE__) || defined(__MINGW32__)
>  #include <math.h>
>  #else
>  #include <tgmath.h>
> Index: SingleSource/Benchmarks/Shootout-C++/hash.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/SingleSource/Benchmarks/Shootout-C
> ++/hash.cpp,v
> retrieving revision 1.3
> diff -u -r1.3 hash.cpp
> --- SingleSource/Benchmarks/Shootout-C++/hash.cpp       24 Jul 2004
> 10:44:11 -0000      1.3
> +++ SingleSource/Benchmarks/Shootout-C++/hash.cpp       9 Dec 2006
> 11:12:29 -0000
> @@ -2,7 +2,7 @@
>  // $Id: hash.cpp,v 1.3 2004/07/24 10:44:11 alkis Exp $
>  // http://www.bagley.org/~doug/shootout/
>  
> -#include <stdio.h>
> +#include <cstdio>
>  #include <iostream>
>  #include <hash_map.h>
>  
> Index: SingleSource/Benchmarks/Shootout-C++/hash2.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/SingleSource/Benchmarks/Shootout-C
> ++/hash2.cpp,v
> retrieving revision 1.2
> diff -u -r1.2 hash2.cpp
> --- SingleSource/Benchmarks/Shootout-C++/hash2.cpp      15 Jun 2004
> 20:48:16 -0000      1.2
> +++ SingleSource/Benchmarks/Shootout-C++/hash2.cpp      9 Dec 2006
> 11:12:29 -0000
> @@ -2,7 +2,7 @@
>  // $Id: hash2.cpp,v 1.2 2004/06/15 20:48:16 lattner Exp $
>  // http://www.bagley.org/~doug/shootout/
>  
> -#include <stdio.h>
> +#include <cstdio>
>  #include <iostream>
>  #include <hash_map.h>
>  
> Index: SingleSource/CustomChecked/flops.c
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/SingleSource/CustomChecked/flops.c,v
> retrieving revision 1.5
> diff -u -r1.5 flops.c
> --- SingleSource/CustomChecked/flops.c  25 Jun 2005 02:50:00
> -0000      1.5
> +++ SingleSource/CustomChecked/flops.c  9 Dec 2006 11:12:29 -0000
> @@ -109,7 +109,11 @@
>  /* #define MAC         */
>  /* #define IPSC        */
>  /* #define FORTRAN_SEC */
> -#define GTODay
> +#ifndef __MINGW32__
> +# define GTODay
> +#else
> +# define WIN32
> +#endif
>  /* #define CTimer      */
>  /* #define UXPM        */
>  /* #define MAC_TMgr    */
> Index: SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c
> ===================================================================
> RCS
> file: /var/cvs/llvm/llvm-test/SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c,v
> retrieving revision 1.6
> diff -u -r1.6 2004-08-12-InlinerAndAllocas.c
> --- SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c    28 Nov
> 2006 18:41:03 -0000      1.6
> +++ SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c    9 Dec
> 2006 11:12:29 -0000
> @@ -1,7 +1,7 @@
>  // A compiler cannot inline Callee into main unless it is prepared to
> reclaim
>  // the stack memory allocated in it.
>  
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
> +#if defined(__FreeBSD__) || defined(__OpenBSD__) ||
> defined(__MINGW32__)
>  #include <stdlib.h>
>  #else
>  #include <alloca.h>
> Index: autoconf/configure.ac
> ===================================================================
> RCS file: /var/cvs/llvm/llvm-test/autoconf/configure.ac,v
> retrieving revision 1.40
> diff -u -r1.40 configure.ac
> --- autoconf/configure.ac       4 Dec 2006 20:37:53 -0000       1.40
> +++ autoconf/configure.ac       9 Dec 2006 11:12:29 -0000
> @@ -1,5 +1,5 @@
>  dnl Initialize autoconf
> -AC_INIT([[LLVM-TEST]],[[1.7cvs]],[llvmbugs at cs.uiuc.edu])
> +AC_INIT([[LLVM-TEST]],[[2.0cvs]],[llvmbugs at cs.uiuc.edu])

Thank you :)

>  
>  dnl Place all of the extra autoconf files into the config
> subdirectory
>  AC_CONFIG_AUX_DIR([autoconf])
> @@ -7,6 +7,19 @@
>  dnl Verify that the source directory is valid
>  AC_CONFIG_SRCDIR([SingleSource/Benchmarks/Makefile])
>  
> +dnl Check the target for which we're compiling and the host that will
> do the
> +dnl compilations. This will tell us which LLVM compiler will be used
> for 
> +dnl compiling SSA into object code. This needs to be done early
> because 
> +dnl following tests depend on it.
> +AC_CANONICAL_TARGET
> +
> +dnl Check for build platform executable suffix if we're
> crosscompiling
> +if test "$cross_compiling" = yes; then
> +  AC_SUBST(LLVM_TEST_CROSS_COMPILING, [1])
> +else
> +  AC_SUBST(LLVM_TEST_CROSS_COMPILING, [0])
> +fi

I'm assuming $cross_compiling is set by AC_CANONICAL_TARGET. 
If not, where does it come from?

> +
>  dnl Do special configuration of Makefiles
>  AC_CONFIG_COMMANDS([setup],,[llvm_src="${srcdir}"])
>  AC_CONFIG_FILES([Makefile.config])
> @@ -70,6 +83,12 @@
>    AC_SUBST(LLVM_EXTERNALS,[$withval]),
>    AC_SUBST(LLVM_EXTERNALS,[/home/vadve/shared/benchmarks]))
>  
> +dnl Extra binary interpreter for cross-platform tests
> +AC_ARG_WITH(interpreter,
> + AS_HELP_STRING([--with-interpreter=binary],Extra interpreter for
> cross-platform tests (e.g. wine)),
> + AC_SUBST(EXTRA_INTERP,[$withval]),
> + AC_SUBST(EXTRA_INTERP,[]))

Wouldn't this second AC_SUBST wipe out the value of the first?

> +
>  dnl Configure the default locations of the external benchmarks
>  EXTERNAL_BENCHMARK(spec95,${LLVM_EXTERNALS}/spec95/benchspec)
>  EXTERNAL_BENCHMARK(spec2000,${LLVM_EXTERNALS}/speccpu2000/benchspec)




More information about the llvm-commits mailing list