From lattner at cs.uiuc.edu Mon May 19 10:33:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon May 19 10:33:01 2003 Subject: [llvm-commits] CVS: llvm/www/pubs/2002-08-09-LLVMCompilationStrategy.html Message-ID: <200305191532.KAA18257@tank.cs.uiuc.edu> Changes in directory llvm/www/pubs: 2002-08-09-LLVMCompilationStrategy.html added (r1.1) --- Log message: New file --- Diffs of the changes: Index: llvm/www/pubs/2002-08-09-LLVMCompilationStrategy.html diff -c /dev/null llvm/www/pubs/2002-08-09-LLVMCompilationStrategy.html:1.1 *** /dev/null Mon May 19 10:32:58 2003 --- llvm/www/pubs/2002-08-09-LLVMCompilationStrategy.html Mon May 19 10:32:47 2003 *************** *** 0 **** --- 1,58 ---- + + + + The LLVM Instruction Set and Compilation Strategy + + + +


+ + + The LLVM Instruction Set and Compilation Strategy +
+ + + Chris Lattner and + Vikram Adve +

+ + +

Abstract:

+
+ This document introduces the LLVM compiler infrastructure and instruction set, a + simple approach that enables sophisticated code transformations at link time, + runtime, and in the field. It is a pragmatic approach to compilation, + interfering with programmers and tools as little as possible, while still + retaining extensive high-level information from source-level compilers for later + stages of an application's lifetime. We describe the LLVM instruction set, + the design of the LLVM system, and some of its key components. +
+ +

Published:

+ + +

Download:

+ + +

Bibtex Entry:

+
+   @TechReport{LattnerAdve:LLVM:ISCS,
+     Author      = {Chris Lattner and Vikram Adve},
+     Title       = {The {LLVM} Instruction Set and Compilation Strategy},
+     Institution = {Computer Science Dept.,
+                    Univ. of Illinois at Urbana-Champaign},
+     Number      = {UIUCDCS-R-2002-2292},
+     Type        = {Tech. Report},
+     Month       = {Aug},
+     Year        = {2002}
+   }
+ 
+ + From lattner at cs.uiuc.edu Mon May 19 10:44:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon May 19 10:44:01 2003 Subject: [llvm-commits] CVS: llvm/www/pubs/2002-06-AutomaticPoolAllocation.html Message-ID: <200305191543.KAA18320@tank.cs.uiuc.edu> Changes in directory llvm/www/pubs: 2002-06-AutomaticPoolAllocation.html added (r1.1) --- Log message: New file --- Diffs of the changes: Index: llvm/www/pubs/2002-06-AutomaticPoolAllocation.html diff -c /dev/null llvm/www/pubs/2002-06-AutomaticPoolAllocation.html:1.1 *** /dev/null Mon May 19 10:43:58 2003 --- llvm/www/pubs/2002-06-AutomaticPoolAllocation.html Mon May 19 10:43:47 2003 *************** *** 0 **** --- 1,63 ---- + + + + Automatic Pool Allocation for Disjoint Data Structures + + + + +


Automatic Pool Allocation for Disjoint Data + Structures
+ Chris Lattner and + Vikram Adve + +

+ + +

Abstract:

+
+ This paper presents an analysis technique and a novel program transformation + that can enable powerful optimizations for entire linked data structures. The + fully automatic transformation converts ordinary programs to use pool (aka + region) allocation for heap-based data structures. The transformation relies on + an efficient link-time interprocedural analysis to identify disjoint data + structures in the program, to check whether these data structures are accessed + in a type-safe manner, and to construct a Disjoint Data Structure Graph that + describes the connectivity pattern within such structures. We present + preliminary experimental results showing that the data structure analysis and + pool allocation are effective for a set of pointer intensive programs in the + Olden benchmark suite. To illustrate the optimizations that can be enabled by + these techniques, we describe a novel pointer compression transformation and + briefly discuss several other optimization possibilities for linked data + structures. +
+ +

Published:

+ + +

Download:

+ + +

Bibtex Entry:

+
+ @InProceedings{LattnerAdve:MSP02,
+     Author      = {Chris Lattner and Vikram Adve},
+     Title       = {{A}utomatic {P}ool {A}llocation for {D}isjoint {D}ata {S}tructures},
+     Booktitle   = {Proc. ACM SIGPLAN Workshop on Memory System Performance},
+     Address     = {Berlin, Germany},
+     Month       = {Jun},
+     Year        = {2002}
+ }
+ 
+ + From lattner at cs.uiuc.edu Mon May 19 10:48:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon May 19 10:48:01 2003 Subject: [llvm-commits] CVS: llvm/www/www-index.html Message-ID: <200305191547.KAA18420@apoc.cs.uiuc.edu> Changes in directory llvm/www: www-index.html updated: 1.32 -> 1.33 --- Log message: Add links to the HTML versions of pages --- Diffs of the changes: Index: llvm/www/www-index.html diff -u llvm/www/www-index.html:1.32 llvm/www/www-index.html:1.33 --- llvm/www/www-index.html:1.32 Sun May 11 16:36:21 2003 +++ llvm/www/www-index.html Mon May 19 10:47:07 2003 @@ -42,7 +42,7 @@ Low Level Virtual Machine (LLVM) is:
    -
  1. A +
  2. A compilation strategy - Fundamentally, LLVM is a compilation strategy designed to enable effective program optimization @@ -119,7 +119,7 @@ An Infrastructure for Multi-Stage Optimization"
    Chris Lattner. Masters Thesis, Dec. 2002
  3. -
  4. "Ensuring +
  5. "Ensuring Code Safety Without Runtime Checks for Real-Time Control Systems"
    Sumant Kowshik, Dinakar Dhurjati, and @@ -128,7 +128,7 @@ Embedded Systems (CASES02), Grenoble, France, Oct. 2002.
  6. "The + href="pubs/2002-08-09-LLVMCompilationStrategy.html">The LLVM Instruction Set and Compilation Strategy"
    Chris Lattner & Vikram Adve, Technical @@ -137,7 +137,7 @@ Aug. 2002.
  7. "Automatic + href="pubs/2002-06-AutomaticPoolAllocation.html">Automatic Pool Allocation for Disjoint Data Structures,"
    Chris Lattner & Vikram Adve, , Berlin, Germany, June 2002.
    - (Presentation).

@@ -312,7 +311,7 @@ Jun 28th, 2002 - Added The + href="pubs/2002-08-09-LLVMCompilationStrategy.html">The LLVM Instruction Set and Compilation Strategy document. @@ -334,7 +333,7 @@ Here are some technical and reference documents for the LLVM system:

Other useful information:

    From lattner at cs.uiuc.edu Wed May 21 17:39:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed May 21 17:39:00 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/Makefile Message-ID: <200305212238.RAA04808@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: Makefile updated: 1.2 -> 1.3 --- Log message: We test some c99 features, so add it to the make command --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/Makefile diff -u llvm/test/Regression/C++Frontend/Makefile:1.2 llvm/test/Regression/C++Frontend/Makefile:1.3 --- llvm/test/Regression/C++Frontend/Makefile:1.2 Tue May 13 15:07:08 2003 +++ llvm/test/Regression/C++Frontend/Makefile Wed May 21 17:38:44 2003 @@ -6,4 +6,5 @@ # LEVEL = ../../.. include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc +CFLAGS += -std=c99 From lattner at cs.uiuc.edu Wed May 21 18:02:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed May 21 18:02:00 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-21-UnionTest.c Message-ID: <200305212301.SAA07061@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-21-UnionTest.c added (r1.1) --- Log message: New testcase that was killing the CFE --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-21-UnionTest.c diff -c /dev/null llvm/test/Regression/C++Frontend/2003-05-21-UnionTest.c:1.1 *** /dev/null Wed May 21 18:01:45 2003 --- llvm/test/Regression/C++Frontend/2003-05-21-UnionTest.c Wed May 21 18:01:35 2003 *************** *** 0 **** --- 1,11 ---- + #include + + int __signbit (double __x) { + union { double __d; int __i[3]; } __u = { __d: __x }; + return __u.__i[1] < 0; + } + + int main() { + printf("%d %d\n", __signbit(-1), __signbit(2.0)); + return 0; + } From lattner at cs.uiuc.edu Wed May 21 18:03:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed May 21 18:03:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-21-UnionBitfields.c Message-ID: <200305212302.SAA07126@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-21-UnionBitfields.c added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-21-UnionBitfields.c diff -c /dev/null llvm/test/Regression/C++Frontend/2003-05-21-UnionBitfields.c:1.1 *** /dev/null Wed May 21 18:02:00 2003 --- llvm/test/Regression/C++Frontend/2003-05-21-UnionBitfields.c Wed May 21 18:01:50 2003 *************** *** 0 **** --- 1,22 ---- + #include + #include + + int target_isinf(double x) { + union { + double d; + struct { + unsigned mantissa2; + unsigned mantissa1 : 20; + unsigned exponent : 11; + unsigned sign : 1; + } big_endian; + } u; + + u.d = x; + return (u.big_endian.exponent == 2047 && u.big_endian.mantissa1 == 0 && u.big_endian.mantissa2 == 0); + } + + int main() { + printf("%d %d\n", target_isinf(1234.42), target_isinf(INFINITY)); + return 0; + } From jstanley at cs.uiuc.edu Thu May 22 00:34:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 00:34:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/rtl/ Message-ID: <200305220533.AAA28571@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/rtl: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/lib/Reoptimizer/Inst/rtl added to the repository --- Diffs of the changes: From jstanley at cs.uiuc.edu Thu May 22 08:10:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 08:10:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/Makefile Message-ID: <200305221309.IAA29577@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst: Makefile updated: 1.3 -> 1.4 --- Log message: Added rtl/ directory for the runtime lib and performance primitive "metric library". --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/Makefile diff -u llvm/lib/Reoptimizer/Inst/Makefile:1.3 llvm/lib/Reoptimizer/Inst/Makefile:1.4 --- llvm/lib/Reoptimizer/Inst/Makefile:1.3 Wed Apr 30 16:54:27 2003 +++ llvm/lib/Reoptimizer/Inst/Makefile Thu May 22 08:08:58 2003 @@ -1,4 +1,4 @@ LEVEL = ../../.. -DIRS := lib mkexcl +DIRS := lib rtl mkexcl include $(LEVEL)/Makefile.common From jstanley at cs.uiuc.edu Thu May 22 08:10:07 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 08:10:07 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/rtl/Makefile pprtl.cpp pprtl.h Message-ID: <200305221309.IAA29590@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/rtl: Makefile added (r1.1) pprtl.cpp added (r1.1) pprtl.h added (r1.1) --- Log message: Added rtl/ directory for the runtime lib and performance primitive "metric library". --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/rtl/Makefile diff -c /dev/null llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.1 *** /dev/null Thu May 22 08:09:10 2003 --- llvm/lib/Reoptimizer/Inst/rtl/Makefile Thu May 22 08:08:58 2003 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../.. + LIBRARYNAME = pprtl + BUILD_ARCHIVE = 1 + + include $(LEVEL)/Makefile.common Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp diff -c /dev/null llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.1 *** /dev/null Thu May 22 08:09:10 2003 --- llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp Thu May 22 08:08:59 2003 *************** *** 0 **** --- 1,31 ---- + // Implementation of the performance primtive runtime library / "library of metrics" + + #include "pprtl.h" + + void pp_elapsed_time_start(double* retVal) + { + struct timeval tv; + gettimeofday(&tv, 0); + printf("pp_elapsed_time_start invoked!\n"); + printf("address of return value is: 0x%lx\n", (unsigned long) retVal); + fflush(stdout); + + // return result in ms + *retVal = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; + printf("pp_elasped_time_start returning %f\n", *retVal); + } + + void pp_elapsed_time_end(double* retVal, double* start) + { + struct timeval tv; + double end; + + printf("pp_elapsed_time_end invoked!\n"); + printf("Address of start is 0x%lx, value is %f\n", (unsigned long) start, *start); + fflush(stdout); + + gettimeofday(&tv, 0); + end = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; // convert to ms + *retVal = end - *start; // compute diff + printf("pp_elapsed_time_end returning %f\n", *retVal); + } Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.h diff -c /dev/null llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.1 *** /dev/null Thu May 22 08:09:10 2003 --- llvm/lib/Reoptimizer/Inst/rtl/pprtl.h Thu May 22 08:08:59 2003 *************** *** 0 **** --- 1,25 ---- + // The standard header for the performance primitive "runtime/metric library" + + #ifndef _INCLUDED_PPLIB_H + #define _INCLUDED_PPLIB_H + + #include + #include + + extern "C" { + + // library functions + + long pp_timestamp(void); + void pp_elapsed_time_start(double* retVal); + void pp_elapsed_time_end(double* retVal, double* start); + unsigned pp_counterPrim(void); + + // significant functions + + void pp_regionPair(void*, void*); + void pp_metricSpec(void*); + + } + + #endif // _INCLUDED_PPLIB_H From jstanley at cs.uiuc.edu Thu May 22 08:17:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 08:17:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/rtl/Makefile pprtl.h Message-ID: <200305221316.IAA29732@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/rtl: Makefile updated: 1.1 -> 1.2 pprtl.h updated: 1.1 -> 1.2 --- Log message: --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/rtl/Makefile diff -u llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.1 llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.2 --- llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.1 Thu May 22 08:08:58 2003 +++ llvm/lib/Reoptimizer/Inst/rtl/Makefile Thu May 22 08:16:40 2003 @@ -1,5 +1,6 @@ LEVEL = ../../../.. LIBRARYNAME = pprtl BUILD_ARCHIVE = 1 +CXXFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ include $(LEVEL)/Makefile.common Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.h diff -u llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.1 llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.2 --- llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.1 Thu May 22 08:08:59 2003 +++ llvm/lib/Reoptimizer/Inst/rtl/pprtl.h Thu May 22 08:16:40 2003 @@ -6,7 +6,9 @@ #include #include +#ifdef _BUILDING_RUNTIME_LIBRARY_ extern "C" { +#endif // library functions @@ -20,6 +22,9 @@ void pp_regionPair(void*, void*); void pp_metricSpec(void*); + +#ifdef _BUILDING_RUNTIME_LIBRARY_ } +#endif #endif // _INCLUDED_PPLIB_H From jstanley at cs.uiuc.edu Thu May 22 08:18:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 08:18:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Reoptimizer/inst/Makefile Test1.c Message-ID: <200305221317.IAA29747@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Reoptimizer/inst: Makefile updated: 1.3 -> 1.4 Test1.c updated: 1.2 -> 1.3 --- Log message: --- Diffs of the changes: Index: llvm/test/Regression/Reoptimizer/inst/Makefile diff -u llvm/test/Regression/Reoptimizer/inst/Makefile:1.3 llvm/test/Regression/Reoptimizer/inst/Makefile:1.4 --- llvm/test/Regression/Reoptimizer/inst/Makefile:1.3 Sun May 4 16:16:53 2003 +++ llvm/test/Regression/Reoptimizer/inst/Makefile Thu May 22 08:16:53 2003 @@ -1,31 +1,40 @@ -LEVEL = ../../../.. +LEVEL = /localhome/$(USER)/Research/llvm -PERFOBJS = $(LEVEL)/lib/Debug/libperfinst.a \ +CC = /usr/dcs/software/evaluation/bin/gcc +CXX = /usr/dcs/software/evaluation/bin/g++ +LLVMGCC = /home/vadve/lattner/local/sparc/llvm-gcc/bin/gcc + +PERFOBJS = $(LEVEL)/lib/Debug/libpprtl.a \ + $(LEVEL)/lib/Debug/libperfinst.a \ $(LEVEL)/lib/Debug/libtracecache.a \ $(LEVEL)/lib/Debug/libbininterface.a +LIBINSTRBC = /home/vadve/lattner/cvs/gcc_install_sparc/llvm/lib/libinstr.bc + Test1: Test1.o $(PERFOBJS) - mkexcl $(PERFOBJS) > mkexcl.cpp - /usr/dcs/software/evaluation/bin/g++ -o Test1 -lelf mkexcl.cpp $^ + mkexcl $(PERFOBJS) libinstr.o > mkexcl.cpp + $(CXX) -o Test1 -lelf mkexcl.cpp $^ Test1.o: Test1.opt.c - /usr/dcs/software/evaluation/bin/gcc -c Test1.opt.c -o Test1.o + $(CC) -c Test1.opt.c -o Test1.o Test1.opt.c: Test1.opt.bc dis -c < Test1.opt.bc > Test1.opt.c -Test1.opt.bc: Test1.bc +Test1.opt.bc: Test1.bc libinstr.o $(LEVEL)/lib/Debug/libperf.so opt -load $(LEVEL)/lib/Debug/libperf.so -pp1 -emitfuncs -deadtypeelim < Test1.bc > Test1.opt.o - llvm-gcc -Wl,-disable-internalize Test1.opt.o -o Test1.opt +# $(LLVMGCC) -Wl,-disable-internalize Test1.opt.o -o Test1.opt + gccld -disable-internalize $(LIBINSTRBC) Test1.opt.o -o Test1.opt Test1.bc: Test1.c - llvm-gcc -c Test1.c -o Test1.bc + $(LLVMGCC) -I$(LOCAL_CVSROOT)/llvm/lib/Reoptimizer/Inst/rtl -c Test1.c -o Test1.bc + +libinstr.o: $(LIBINSTRBC) + dis -c < $^ > $(@:.o=.c) + $(CC) -c $(@:.o=.c) 2>/dev/null test1asm: /usr/ccs/bin/dis Test1 > Test1.s clean: - rm -f *.o *.bc *.opt *.opt.c Test1 - - - + rm -f *.o *.bc *.opt *.opt.c mkexcl.cpp libinstr.c Test1 Index: llvm/test/Regression/Reoptimizer/inst/Test1.c diff -u llvm/test/Regression/Reoptimizer/inst/Test1.c:1.2 llvm/test/Regression/Reoptimizer/inst/Test1.c:1.3 --- llvm/test/Regression/Reoptimizer/inst/Test1.c:1.2 Wed Apr 30 17:17:37 2003 +++ llvm/test/Regression/Reoptimizer/inst/Test1.c Thu May 22 08:16:54 2003 @@ -1,59 +1,18 @@ -// begin includes for rtl, etc... +#include "pprtl.h" -#include - -// RTL functions && sigfun protos -extern void doAbsolutelyNothing(); - -long pp_timestamp(void); -double pp_elapsed_time_start(void); -double pp_elapsed_time_end(double* start); -unsigned pp_counterPrim(void); -void pp_regionPair(void*, void*); -void pp_metricSpec(void*); - -// implementations of RTL stuff, etc - -double pp_elapsed_time_start(void) -{ - struct timeval tv; - gettimeofday(&tv, 0); - - // return result in ms - return (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; -} - -double pp_elapsed_time_end(double* start) -{ - struct timeval tv; - double end; - - gettimeofday(&tv, 0); - end = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; // convert to ms - return end - *start; // compute diff & return -} - -// Begin user source file! - -// The following is actually the semantic result of processing a metric declaration (need -// more sigfun support) +// The following is actually the semantic result of processing a metric +// declaration (need more sigfun support) double elapsedTime = 0; +double elapsedTime2 = 0; #include -//extern "C" void phase2(); void phase2(); int fib(int n); void fibs(); - -void floogle() -{ - printf("this is lame"); -} - int main(int argc, char** argv) { phase2(); @@ -61,6 +20,7 @@ printf("Just about to call fibs()...\n"); fibs(); + printf("Leaving main...\n"); return 0; } @@ -72,15 +32,25 @@ return fib(n-2) + fib(n-1); } +void functionToBeInlined() +{ + double y; + pp_elapsed_time_start(&y); + printf("This function should be inlined..."); + pp_elapsed_time_end(&elapsedTime2, &y); +} + void fibs() { int i; - printf("Inside fibs now, sleeping for 2 seconds...\n"); + printf("Inside fibs now, calling functionToBeInlined...\n"); + functionToBeInlined(); + //////////////// // The following is the "scope" that the sampling applies to, represented by - // sigfuns. We need better sigfun support so that the phase 1. + // sigfuns. We need better sigfun support. // // That is, the below should look like: // @@ -92,8 +62,10 @@ // although the post-phase1 transformed code should be "similar" (calls removed and // volatile loads put in their place, of course!) - double y = pp_elapsed_time_start(); - + long x; + double y; + pp_elapsed_time_start(&y); + for(i = 10; i > 0; i--) { printf("fib(%d) = %d\n", i, fib(i)); } @@ -101,10 +73,12 @@ printf("after for loop...\n"); fflush(stdout); - elapsedTime = pp_elapsed_time_end(&y); + pp_elapsed_time_end(&elapsedTime, &y); + + printf("ElapsedTime (metric variable) has address %lx, value %f\n", &elapsedTime, elapsedTime); // //////////////// - printf("Leaving fibs..."); + printf("Leaving fibs...\n"); } From lattner at cs.uiuc.edu Thu May 22 10:34:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 10:34:07 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c Message-ID: <200305221533.KAA28385@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-22-LocalTypeTest.c added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c diff -c /dev/null llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c:1.1 *** /dev/null Thu May 22 10:33:43 2003 --- llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c Thu May 22 10:33:33 2003 *************** *** 0 **** --- 1,10 ---- + struct sometimes { + short offset; short bit; + short live_length; short calls_crossed; + } Y; + + int main() { + struct sometimes { int X, Y; } S; + S.X = 1; + return Y.offset; + } From lattner at cs.uiuc.edu Thu May 22 10:59:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 10:59:07 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c Message-ID: <200305221550.KAA30320@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-22-LocalTypeTest.c updated: 1.1 -> 1.2 --- Log message: Make the testcase even more insane --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c diff -u llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c:1.1 llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c:1.2 --- llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c:1.1 Thu May 22 10:33:33 2003 +++ llvm/test/Regression/C++Frontend/2003-05-22-LocalTypeTest.c Thu May 22 10:49:58 2003 @@ -1,10 +1,24 @@ +#include + struct sometimes { short offset; short bit; short live_length; short calls_crossed; } Y; int main() { - struct sometimes { int X, Y; } S; - S.X = 1; - return Y.offset; + int X; + { + struct sometimes { int X, Y; } S; + S.X = 1; + X = S.X; + } + { + struct sometimes { char X; } S; + S.X = -1; + X += S.X; + } + X += Y.offset; + + printf("Result is %d\n", X); + return X; } From lattner at cs.uiuc.edu Thu May 22 11:27:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 11:27:02 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Makefile.multisrc Message-ID: <200305221626.LAA00544@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource: Makefile.multisrc updated: 1.28 -> 1.29 --- Log message: Remove Program modified messages from linker output --- Diffs of the changes: Index: llvm/test/Programs/MultiSource/Makefile.multisrc diff -u llvm/test/Programs/MultiSource/Makefile.multisrc:1.28 llvm/test/Programs/MultiSource/Makefile.multisrc:1.29 --- llvm/test/Programs/MultiSource/Makefile.multisrc:1.28 Sat May 17 17:33:04 2003 +++ llvm/test/Programs/MultiSource/Makefile.multisrc Thu May 22 11:26:31 2003 @@ -53,7 +53,7 @@ # without any libraries linked in... # Output/%.linked.rll: $(LObjects) $(LLINK) $(LOPT) $(LDIS) - $(LLINK) -f $(LObjects) | $(LOPT) -funcresolve -deadtypeelim | $(LDIS) > $@ + $(LLINK) -f $(LObjects) | $(LOPT) -funcresolve -deadtypeelim -q | $(LDIS) > $@ Output/%.LOC.txt: $(Source) cat $(Source) $(wildcard *.h) | wc -l > $@ From lattner at cs.uiuc.edu Thu May 22 11:29:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 11:29:02 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/186.crafty/ Message-ID: <200305221628.LAA00770@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/186.crafty: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/External/SPEC/CINT2000/186.crafty added to the repository --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 11:29:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 11:29:07 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/176.gcc/ Message-ID: <200305221628.LAA00756@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/176.gcc: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/External/SPEC/CINT2000/176.gcc added to the repository --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 11:29:12 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 11:29:12 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/255.vortex/ Message-ID: <200305221628.LAA00750@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/255.vortex: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/External/SPEC/CINT2000/255.vortex added to the repository --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 12:01:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:01:02 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk/ Message-ID: <200305221700.MAA02472@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk added to the repository --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 12:30:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:02 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/300.twolf/Makefile Message-ID: <200305221729.MAA03475@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/300.twolf: Makefile added (r1.1) --- Log message: New makefiles --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/CINT2000/300.twolf/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT2000/300.twolf/Makefile:1.1 *** /dev/null Thu May 22 12:29:35 2003 --- llvm/test/Programs/External/SPEC/CINT2000/300.twolf/Makefile Thu May 22 12:29:25 2003 *************** *** 0 **** --- 1,6 ---- + LEVEL = ../../../../../.. + LDFLAGS = -lm + RUN_OPTIONS = test.net + STDOUT_FILENAME := test.net.stdout + include ../../Makefile.spec + From lattner at cs.uiuc.edu Thu May 22 12:30:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:06 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile Message-ID: <200305221729.MAA03468@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/255.vortex: Makefile added (r1.1) --- Log message: New makefiles --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile:1.1 *** /dev/null Thu May 22 12:29:33 2003 --- llvm/test/Programs/External/SPEC/CINT2000/255.vortex/Makefile Thu May 22 12:29:23 2003 *************** *** 0 **** --- 1,4 ---- + LEVEL = ../../../../../.. + #RUN_OPTIONS = `cat $(REF_IN_DIR)control` + #STDOUT_FILENAME := input.random.out + include ../../Makefile.spec From lattner at cs.uiuc.edu Thu May 22 12:30:09 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:09 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk/Makefile Message-ID: <200305221729.MAA03461@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk: Makefile added (r1.1) --- Log message: New makefiles --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk/Makefile:1.1 *** /dev/null Thu May 22 12:29:31 2003 --- llvm/test/Programs/External/SPEC/CINT2000/253.perlbmk/Makefile Thu May 22 12:29:21 2003 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../../../.. + #RUN_OPTIONS = `cat $(REF_IN_DIR)control` + #STDOUT_FILENAME := input.compressed.out + CPPFLAGS = -DSPEC_CPU2000_LINUX -Dbool=char -DI_TIME -DI_SYS_TIME + include ../../Makefile.spec From lattner at cs.uiuc.edu Thu May 22 12:30:13 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:13 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/186.crafty/Makefile Message-ID: <200305221729.MAA03454@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/186.crafty: Makefile added (r1.1) --- Log message: New makefiles --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/CINT2000/186.crafty/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT2000/186.crafty/Makefile:1.1 *** /dev/null Thu May 22 12:29:30 2003 --- llvm/test/Programs/External/SPEC/CINT2000/186.crafty/Makefile Thu May 22 12:29:20 2003 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../../../.. + #RUN_OPTIONS = cccp.i -o cccp.s + #STDOUT_FILENAME = cccp.out + CPPFLAGS = + include ../../Makefile.spec From lattner at cs.uiuc.edu Thu May 22 12:30:16 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:16 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile Message-ID: <200305221729.MAA03447@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/176.gcc: Makefile added (r1.1) --- Log message: New makefiles --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile diff -c /dev/null llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile:1.1 *** /dev/null Thu May 22 12:29:28 2003 --- llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile Thu May 22 12:29:18 2003 *************** *** 0 **** --- 1,5 ---- + LEVEL = ../../../../../.. + #RUN_OPTIONS = cccp.i -o cccp.s + #STDOUT_FILENAME = cccp.out + CPPFLAGS = + include ../../Makefile.spec From lattner at cs.uiuc.edu Thu May 22 12:30:20 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 12:30:20 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/300.twolf/ Message-ID: <200305221729.MAA03424@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/300.twolf: --- Log message: Directory /home/vadve/vadve/Research/DynOpt/CVSRepository/llvm/test/Programs/External/SPEC/CINT2000/300.twolf added to the repository --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 13:09:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 13:09:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReadConst.cpp ReadInst.cpp Reader.cpp ReaderInternals.h Message-ID: <200305221808.NAA03964@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: ReadConst.cpp updated: 1.45 -> 1.46 ReadInst.cpp updated: 1.41 -> 1.42 Reader.cpp updated: 1.54 -> 1.55 ReaderInternals.h updated: 1.35 -> 1.36 --- Log message: Eliminate the uchar typedef, use unsigned char explicitly --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/ReadConst.cpp diff -u llvm/lib/Bytecode/Reader/ReadConst.cpp:1.45 llvm/lib/Bytecode/Reader/ReadConst.cpp:1.46 --- llvm/lib/Bytecode/Reader/ReadConst.cpp:1.45 Mon May 12 10:13:52 2003 +++ llvm/lib/Bytecode/Reader/ReadConst.cpp Thu May 22 13:08:30 2003 @@ -13,8 +13,8 @@ #include "llvm/Constants.h" #include -const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, - const uchar *EndBuf) { +const Type *BytecodeParser::parseTypeConstant(const unsigned char *&Buf, + const unsigned char *EndBuf) { unsigned PrimType; if (read_vbr(Buf, EndBuf, PrimType)) return 0; @@ -131,7 +131,8 @@ // with a new resolved concrete type. // void debug_type_tables(); -bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::parseTypeConstants(const unsigned char *&Buf, + const unsigned char *EndBuf, TypeValuesListTy &Tab, unsigned NumEntries) { assert(Tab.size() == 0 && "should not have read type constants in before!"); @@ -173,7 +174,8 @@ } -bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::parseConstantValue(const unsigned char *&Buf, + const unsigned char *EndBuf, const Type *Ty, Constant *&V) { // We must check for a ConstantExpr before switching by type because @@ -379,12 +381,14 @@ return false; } -bool BytecodeParser::ParseGlobalTypes(const uchar *&Buf, const uchar *EndBuf) { +bool BytecodeParser::ParseGlobalTypes(const unsigned char *&Buf, + const unsigned char *EndBuf) { ValueTable T; return ParseConstantPool(Buf, EndBuf, T, ModuleTypeValues); } -bool BytecodeParser::ParseConstantPool(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::ParseConstantPool(const unsigned char *&Buf, + const unsigned char *EndBuf, ValueTable &Tab, TypeValuesListTy &TypeTab) { while (Buf < EndBuf) { Index: llvm/lib/Bytecode/Reader/ReadInst.cpp diff -u llvm/lib/Bytecode/Reader/ReadInst.cpp:1.41 llvm/lib/Bytecode/Reader/ReadInst.cpp:1.42 --- llvm/lib/Bytecode/Reader/ReadInst.cpp:1.41 Wed May 7 21:44:04 2003 +++ llvm/lib/Bytecode/Reader/ReadInst.cpp Thu May 22 13:08:30 2003 @@ -17,7 +17,8 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" -bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::ParseRawInst(const unsigned char *&Buf, + const unsigned char *EndBuf, RawInst &Result) { unsigned Op, Typ; if (read(Buf, EndBuf, Op)) return true; @@ -113,7 +114,8 @@ } -bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::ParseInstruction(const unsigned char *&Buf, + const unsigned char *EndBuf, Instruction *&Res, BasicBlock *BB /*HACK*/) { RawInst Raw; Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.54 llvm/lib/Bytecode/Reader/Reader.cpp:1.55 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.54 Tue Apr 22 13:15:08 2003 +++ llvm/lib/Bytecode/Reader/Reader.cpp Thu May 22 13:08:30 2003 @@ -215,7 +215,8 @@ return Error; } -bool BytecodeParser::ParseBasicBlock(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::ParseBasicBlock(const unsigned char *&Buf, + const unsigned char *EndBuf, BasicBlock *&BB) { BB = new BasicBlock(); @@ -237,7 +238,8 @@ return false; } -bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf, +bool BytecodeParser::ParseSymbolTable(const unsigned char *&Buf, + const unsigned char *EndBuf, SymbolTable *ST) { while (Buf < EndBuf) { // Symtab block header: [num entries][type id number] @@ -294,7 +296,8 @@ } -bool BytecodeParser::ParseFunction(const uchar *&Buf, const uchar *EndBuf) { +bool BytecodeParser::ParseFunction(const unsigned char *&Buf, + const unsigned char *EndBuf) { // Clear out the local values table... if (FunctionSignatureList.empty()) { Error = "Function found, but FunctionSignatureList empty!"; @@ -390,7 +393,8 @@ return false; } -bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End){ +bool BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf, + const unsigned char *End){ if (!FunctionSignatureList.empty()) { Error = "Two ModuleGlobalInfo packets found!"; return true; // Two ModuleGlobal blocks? @@ -488,7 +492,8 @@ return false; } -bool BytecodeParser::ParseVersionInfo(const uchar *&Buf, const uchar *EndBuf) { +bool BytecodeParser::ParseVersionInfo(const unsigned char *&Buf, + const unsigned char *EndBuf) { unsigned Version; if (read_vbr(Buf, EndBuf, Version)) return true; @@ -538,7 +543,8 @@ return false; } -bool BytecodeParser::ParseModule(const uchar *Buf, const uchar *EndBuf) { +bool BytecodeParser::ParseModule(const unsigned char *Buf, + const unsigned char *EndBuf) { unsigned Type, Size; if (readBlock(Buf, EndBuf, Type, Size)) return true; if (Type != BytecodeFormat::Module || Buf+Size != EndBuf) { @@ -625,7 +631,8 @@ return 0; } -Module *BytecodeParser::ParseBytecode(const uchar *Buf, const uchar *EndBuf, +Module *BytecodeParser::ParseBytecode(const unsigned char *Buf, + const unsigned char *EndBuf, const std::string &ModuleID) { unsigned Sig; // Read and check signature... @@ -703,7 +710,7 @@ munmap((char*)Buffer, Length); } else { // Read from stdin int BlockSize; - uchar Buffer[4096*4]; + unsigned char Buffer[4096*4]; std::vector FileData; // Read in all of the data from stdin, we cannot mmap stdin... @@ -719,9 +726,10 @@ #define ALIGN_PTRS 0 #if ALIGN_PTRS - uchar *Buf = (uchar*)mmap(0, FileData.size(), PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - assert((Buf != (uchar*)-1) && "mmap returned error!"); + unsigned char *Buf = + (unsigned char*)mmap(0, FileData.size(), PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + assert((Buf != (unsigned char*)-1) && "mmap returned error!"); memcpy(Buf, &FileData[0], FileData.size()); #else unsigned char *Buf = &FileData[0]; Index: llvm/lib/Bytecode/Reader/ReaderInternals.h diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.35 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.36 --- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.35 Tue Apr 22 13:02:51 2003 +++ llvm/lib/Bytecode/Reader/ReaderInternals.h Thu May 22 13:08:30 2003 @@ -24,8 +24,6 @@ #define BCR_TRACE(n, X) #endif -typedef unsigned char uchar; - struct RawInst { // The raw fields out of the bytecode stream... unsigned NumOperands; unsigned Opcode; @@ -52,7 +50,7 @@ freeTable(ModuleValues); } - Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf, + Module *ParseBytecode(const unsigned char *Buf, const unsigned char *EndBuf, const std::string &ModuleID); std::string getError() const { return Error; } @@ -128,24 +126,29 @@ } } - bool ParseModule (const uchar * Buf, const uchar *End); - bool ParseVersionInfo (const uchar *&Buf, const uchar *End); - bool ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End); - bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *); - bool ParseFunction (const uchar *&Buf, const uchar *End); - bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&); - bool ParseInstruction (const uchar *&Buf, const uchar *End, Instruction *&, - BasicBlock *BB /*HACK*/); - bool ParseRawInst (const uchar *&Buf, const uchar *End, RawInst &); + bool ParseModule (const unsigned char * Buf, const unsigned char *End); + bool ParseVersionInfo (const unsigned char *&Buf, const unsigned char *End); + bool ParseModuleGlobalInfo(const unsigned char *&Buf, const unsigned char *E); + bool ParseSymbolTable (const unsigned char *&Buf, const unsigned char *End, + SymbolTable *); + bool ParseFunction (const unsigned char *&Buf, const unsigned char *End); + bool ParseBasicBlock (const unsigned char *&Buf, const unsigned char *End, + BasicBlock *&); + bool ParseInstruction (const unsigned char *&Buf, const unsigned char *End, + Instruction *&, BasicBlock *BB /*HACK*/); + bool ParseRawInst (const unsigned char *&Buf, const unsigned char *End, + RawInst &); - bool ParseGlobalTypes(const uchar *&Buf, const uchar *EndBuf); - bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf, + bool ParseGlobalTypes(const unsigned char *&Buf, const unsigned char *EndBuf); + bool ParseConstantPool(const unsigned char *&Buf, const unsigned char *EndBuf, ValueTable &Tab, TypeValuesListTy &TypeTab); - bool parseConstantValue(const uchar *&Buf, const uchar *End, + bool parseConstantValue(const unsigned char *&Buf, const unsigned char *End, const Type *Ty, Constant *&V); - bool parseTypeConstants(const uchar *&Buf, const uchar *EndBuf, + bool parseTypeConstants(const unsigned char *&Buf, + const unsigned char *EndBuf, TypeValuesListTy &Tab, unsigned NumEntries); - const Type *parseTypeConstant(const uchar *&Buf, const uchar *EndBuf); + const Type *parseTypeConstant(const unsigned char *&Buf, + const unsigned char *EndBuf); Value *getValue(const Type *Ty, unsigned num, bool Create = true); const Type *getType(unsigned ID); @@ -212,7 +215,8 @@ } } -static inline bool readBlock(const uchar *&Buf, const uchar *EndBuf, +static inline bool readBlock(const unsigned char *&Buf, + const unsigned char *EndBuf, unsigned &Type, unsigned &Size) { #if DEBUG_OUTPUT bool Result = read(Buf, EndBuf, Type) || read(Buf, EndBuf, Size); From lattner at cs.uiuc.edu Thu May 22 13:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 13:27:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp ReaderInternals.h Message-ID: <200305221826.NAA04301@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.55 -> 1.56 ReaderInternals.h updated: 1.36 -> 1.37 --- Log message: Do not assert fail or crash when a bytecode parse fails! --- Diffs of the changes: Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.55 llvm/lib/Bytecode/Reader/Reader.cpp:1.56 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.55 Thu May 22 13:08:30 2003 +++ llvm/lib/Bytecode/Reader/Reader.cpp Thu May 22 13:26:48 2003 @@ -642,6 +642,7 @@ TheModule = new Module(ModuleID); if (ParseModule(Buf, EndBuf)) { + freeState(); // Must destroy handles before deleting module! delete TheModule; TheModule = 0; } Index: llvm/lib/Bytecode/Reader/ReaderInternals.h diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.36 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.37 --- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.36 Thu May 22 13:08:30 2003 +++ llvm/lib/Bytecode/Reader/ReaderInternals.h Thu May 22 13:26:48 2003 @@ -45,6 +45,9 @@ FirstDerivedTyID = Type::FirstDerivedTyID; } ~BytecodeParser() { + freeState(); + } + void freeState() { freeTable(Values); freeTable(LateResolveValues); freeTable(ModuleValues); From lattner at cs.uiuc.edu Thu May 22 13:37:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 13:37:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200305221835.NAA04387@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.33 -> 1.34 --- Log message: Fix bug: Assembler/2003-05-03-BytecodeReaderProblem.llx by emitting the type planes before any constants (which could be constant expressions involving undefined types!) --- Diffs of the changes: Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.33 llvm/lib/Bytecode/Writer/Writer.cpp:1.34 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.33 Tue Apr 22 13:15:10 2003 +++ llvm/lib/Bytecode/Writer/Writer.cpp Thu May 22 13:35:38 2003 @@ -125,25 +125,34 @@ BytecodeBlock CPool(BytecodeFormat::ConstantPool, Out); unsigned NumPlanes = Table.getNumPlanes(); - - for (unsigned pno = 0; pno != NumPlanes; pno++) { - const std::vector &Plane = Table.getPlane(pno); - if (!Plane.empty()) { // Skip empty type planes... - unsigned ValNo = 0; - if (isFunction) // Don't reemit module constants - ValNo += Table.getModuleLevel(pno); - else if (pno == Type::TypeTyID) // If type plane wasn't written out above - continue; - - if (pno >= Type::FirstDerivedTyID) { - // Skip zero initializer - if (ValNo == 0) - ValNo = 1; - } - outputConstantsInPlane(Plane, ValNo); // Write out constants in the plane + // Output the type plane before any constants! + if (isFunction && NumPlanes > Type::TypeTyID) { + const std::vector &Plane = Table.getPlane(Type::TypeTyID); + if (!Plane.empty()) { // Skip empty type planes... + unsigned ValNo = Table.getModuleLevel(Type::TypeTyID); + outputConstantsInPlane(Plane, ValNo); } } + + for (unsigned pno = 0; pno != NumPlanes; pno++) + if (pno != Type::TypeTyID) { // Type plane handled above. + const std::vector &Plane = Table.getPlane(pno); + if (!Plane.empty()) { // Skip empty type planes... + unsigned ValNo = 0; + if (isFunction) // Don't reemit module constants + ValNo += Table.getModuleLevel(pno); + + if (pno >= Type::FirstDerivedTyID) { + // Skip zero initializer + if (ValNo == 0) + ValNo = 1; + } + + // Write out constants in the plane + outputConstantsInPlane(Plane, ValNo); + } + } } void BytecodeWriter::outputModuleInfoBlock(const Module *M) { From lattner at cs.uiuc.edu Thu May 22 14:08:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 14:08:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200305221907.OAA04927@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.82 -> 1.83 --- Log message: Minor cleanups. This hunk: - } else if (Src->getNumOperands() == 2 && Src->use_size() == 1) { + } else if (Src->getNumOperands() == 2) { Allows GEP folding to be more aggressive, which reduces the number of instructions and can dramatically speed up BasicAA in some cases. --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.82 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.83 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.82 Tue May 20 13:45:35 2003 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu May 22 14:07:21 2003 @@ -18,10 +18,7 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/ConstantHandling.h" -#include "llvm/iMemory.h" -#include "llvm/iOther.h" -#include "llvm/iPHINode.h" -#include "llvm/iOperators.h" +#include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/InstIterator.h" @@ -941,7 +938,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { - // Is it 'getelementptr %P, uint 0' or 'getelementptr %P' + // Is it 'getelementptr %P, long 0' or 'getelementptr %P' // If so, eliminate the noop. if ((GEP.getNumOperands() == 2 && GEP.getOperand(1) == Constant::getNullValue(Type::LongTy)) || @@ -956,8 +953,8 @@ std::vector Indices; // Can we combine the two pointer arithmetics offsets? - if (Src->getNumOperands() == 2 && isa(Src->getOperand(1)) && - isa(GEP.getOperand(1))) { + if (Src->getNumOperands() == 2 && isa(Src->getOperand(1)) && + isa(GEP.getOperand(1))) { // Replace: gep (gep %P, long C1), long C2, ... // With: gep %P, long (C1+C2), ... Value *Sum = *cast(Src->getOperand(1)) + @@ -967,7 +964,7 @@ GEP.setOperand(1, Sum); AddUsesToWorkList(*Src); // Reduce use count of Src return &GEP; - } else if (Src->getNumOperands() == 2 && Src->use_size() == 1) { + } else if (Src->getNumOperands() == 2) { // Replace: gep (gep %P, long B), long A, ... // With: T = long A+B; gep %P, T, ... // From lattner at cs.uiuc.edu Thu May 22 14:31:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 14:31:01 2003 Subject: [llvm-commits] CVS: llvm/test/Libraries/crtend/listend.ll Message-ID: <200305221930.OAA05135@apoc.cs.uiuc.edu> Changes in directory llvm/test/Libraries/crtend: listend.ll updated: 1.2 -> 1.3 --- Log message: Update to match typename produced by the C frontend --- Diffs of the changes: Index: llvm/test/Libraries/crtend/listend.ll diff -u llvm/test/Libraries/crtend/listend.ll:1.2 llvm/test/Libraries/crtend/listend.ll:1.3 --- llvm/test/Libraries/crtend/listend.ll:1.2 Wed May 14 08:09:41 2003 +++ llvm/test/Libraries/crtend/listend.ll Thu May 22 14:30:11 2003 @@ -4,23 +4,23 @@ target endian = little target pointersize = 32 -%struct.TorRec = type { int, void ()* } +%struct..TorRec = type { int, void ()* } -%llvm.global_ctors = appending global [1 x %struct.TorRec] [ - %struct.TorRec { int 2147483647, void ()* null } +%llvm.global_ctors = appending global [1 x %struct..TorRec] [ + %struct..TorRec { int 2147483647, void ()* null } ] -%llvm.global_dtors = appending global [1 x %struct.TorRec] [ - %struct.TorRec { int 2147483647, void ()* null } +%llvm.global_dtors = appending global [1 x %struct..TorRec] [ + %struct..TorRec { int 2147483647, void ()* null } ] implementation -%struct.TorRec* %__llvm_getGlobalCtors() { - ret %struct.TorRec* getelementptr ([1 x %struct.TorRec]* %llvm.global_ctors, +%struct..TorRec* %__llvm_getGlobalCtors() { + ret %struct..TorRec* getelementptr ([1 x %struct..TorRec]* %llvm.global_ctors, long 0, long 0) } -%struct.TorRec* %__llvm_getGlobalDtors() { - ret %struct.TorRec* getelementptr ([1 x %struct.TorRec]* %llvm.global_dtors, +%struct..TorRec* %__llvm_getGlobalDtors() { + ret %struct..TorRec* getelementptr ([1 x %struct..TorRec]* %llvm.global_dtors, long 0, long 0) } From lattner at cs.uiuc.edu Thu May 22 14:35:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 14:35:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Internalize.cpp Message-ID: <200305221934.OAA05201@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Internalize.cpp updated: 1.13 -> 1.14 --- Log message: Add option to internalize to allow it to read a file to determine which symbols should not be internalized --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Internalize.cpp diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.13 llvm/lib/Transforms/IPO/Internalize.cpp:1.14 --- llvm/lib/Transforms/IPO/Internalize.cpp:1.13 Wed Apr 16 15:28:39 2003 +++ llvm/lib/Transforms/IPO/Internalize.cpp Thu May 22 14:34:49 2003 @@ -10,25 +10,55 @@ #include "llvm/Pass.h" #include "llvm/Module.h" #include "Support/Statistic.h" +#include "Support/CommandLine.h" +#include +#include namespace { Statistic<> NumFunctions("internalize", "Number of functions internalized"); Statistic<> NumGlobals ("internalize", "Number of global vars internalized"); + // APIFile - A file which contains a list of symbols that should not be marked + // external. + cl::opt + APIFile("internalize-public-api-file", cl::value_desc("filename"), + cl::desc("A file containing list of globals to not internalize")); + class InternalizePass : public Pass { - virtual bool run(Module &M) { - Function *MainFunc = M.getMainFunction(); + std::set ExternalNames; + public: + InternalizePass() { + if (!APIFile.empty()) + LoadFile(APIFile.c_str()); + else + ExternalNames.insert("main"); + } - if (MainFunc == 0 || MainFunc->isExternal()) - return false; // No main found, must be a library... - + void LoadFile(const char *Filename) { + // Load the APIFile... + std::ifstream In(Filename); + if (!In.good()) { + std::cerr << "WARNING: Internalize couldn't load file '" << Filename + << "'!: Not internalizing.\n"; + return; // Do not internalize anything... + } + while (In) { + std::string Symbol; + In >> Symbol; + if (!Symbol.empty()) + ExternalNames.insert(Symbol); + } + } + + virtual bool run(Module &M) { + if (ExternalNames.empty()) return false; // Error loading file... bool Changed = false; // Found a main function, mark all functions not named main as internal. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (&*I != MainFunc && // Leave the main function external - !I->isExternal() && // Function must be defined here - !I->hasInternalLinkage()) { // Can't already have internal linkage + if (!I->isExternal() && // Function must be defined here + !I->hasInternalLinkage() && // Can't already have internal linkage + !ExternalNames.count(I->getName())) {// Not marked to keep external? I->setLinkage(GlobalValue::InternalLinkage); Changed = true; ++NumFunctions; @@ -37,7 +67,8 @@ // Mark all global variables with initializers as internal as well... for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) - if (!I->isExternal() && I->hasExternalLinkage()) { + if (!I->isExternal() && !I->hasInternalLinkage() && + !ExternalNames.count(I->getName())) { I->setLinkage(GlobalValue::InternalLinkage); Changed = true; ++NumGlobals; @@ -48,7 +79,7 @@ } }; - RegisterOpt X("internalize", "Internalize Functions"); + RegisterOpt X("internalize", "Internalize Global Symbols"); } // end anonymous namespace Pass *createInternalizePass() { From lattner at cs.uiuc.edu Thu May 22 14:49:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 14:49:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Internalize.cpp Message-ID: <200305221948.OAA05351@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Internalize.cpp updated: 1.14 -> 1.15 --- Log message: * Revert to old behavior of ignoring a module if it doesn't contain a main function and no symbols were explicitly marked to be externalized. * Add new -internalize-public-api-list option that can be used if the symbol list is small, and making a new file is annoying. --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Internalize.cpp diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.14 llvm/lib/Transforms/IPO/Internalize.cpp:1.15 --- llvm/lib/Transforms/IPO/Internalize.cpp:1.14 Thu May 22 14:34:49 2003 +++ llvm/lib/Transforms/IPO/Internalize.cpp Thu May 22 14:48:00 2003 @@ -22,16 +22,21 @@ // external. cl::opt APIFile("internalize-public-api-file", cl::value_desc("filename"), - cl::desc("A file containing list of globals to not internalize")); - + cl::desc("A file containing list of symbol names to preserve")); + + // APIList - A list of symbols that should not be marked internal. + cl::list + APIList("internalize-public-api-list", cl::value_desc("list"), + cl::desc("A list of symbol names to preserve")); + class InternalizePass : public Pass { std::set ExternalNames; public: InternalizePass() { - if (!APIFile.empty()) + if (!APIFile.empty()) // If a filename is specified, use it LoadFile(APIFile.c_str()); - else - ExternalNames.insert("main"); + else // Else, if a list is specified, use it. + ExternalNames.insert(APIList.begin(), APIList.end()); } void LoadFile(const char *Filename) { @@ -39,7 +44,7 @@ std::ifstream In(Filename); if (!In.good()) { std::cerr << "WARNING: Internalize couldn't load file '" << Filename - << "'!: Not internalizing.\n"; + << "'!\n"; return; // Do not internalize anything... } while (In) { @@ -51,7 +56,19 @@ } virtual bool run(Module &M) { - if (ExternalNames.empty()) return false; // Error loading file... + // If no list or file of symbols was specified, check to see if there is a + // "main" symbol defined in the module. If so, use it, otherwise do not + // internalize the module, it must be a library or something. + // + if (ExternalNames.empty()) { + Function *MainFunc = M.getMainFunction(); + if (MainFunc == 0 || MainFunc->isExternal()) + return false; // No main found, must be a library... + + // Preserve main, internalize all else. + ExternalNames.insert(MainFunc->getName()); + } + bool Changed = false; // Found a main function, mark all functions not named main as internal. From lattner at cs.uiuc.edu Thu May 22 14:51:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 14:51:01 2003 Subject: [llvm-commits] CVS: llvm/test/Libraries/crtend/Makefile Message-ID: <200305221950.OAA05406@apoc.cs.uiuc.edu> Changes in directory llvm/test/Libraries/crtend: Makefile updated: 1.1 -> 1.2 --- Log message: Specify a list of symbols that should be exported by the library --- Diffs of the changes: Index: llvm/test/Libraries/crtend/Makefile diff -u llvm/test/Libraries/crtend/Makefile:1.1 llvm/test/Libraries/crtend/Makefile:1.2 --- llvm/test/Libraries/crtend/Makefile:1.1 Wed May 14 08:09:41 2003 +++ llvm/test/Libraries/crtend/Makefile Thu May 22 14:50:30 2003 @@ -2,6 +2,8 @@ LIBNAME = crtend Source = crtend.c listend.ll +EXPORTED_SYMBOL_LIST = __main,llvm.global_ctors,llvm.global_dtors + include ../Makefile.libs install:: $(DESTLIBNAME) From lattner at cs.uiuc.edu Thu May 22 15:07:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:07:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp Message-ID: <200305222006.PAA06099@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: CommandLine.cpp updated: 1.27 -> 1.28 --- Log message: Destroy using declarations --- Diffs of the changes: Index: llvm/lib/Support/CommandLine.cpp diff -u llvm/lib/Support/CommandLine.cpp:1.27 llvm/lib/Support/CommandLine.cpp:1.28 --- llvm/lib/Support/CommandLine.cpp:1.27 Wed Aug 7 13:36:37 2002 +++ llvm/lib/Support/CommandLine.cpp Thu May 22 15:06:43 2003 @@ -16,11 +16,6 @@ #include using namespace cl; -using std::map; -using std::pair; -using std::vector; -using std::string; -using std::cerr; //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery... @@ -29,27 +24,28 @@ // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // -static map *CommandLineOptions = 0; -static map &getOpts() { - if (CommandLineOptions == 0) CommandLineOptions = new map(); +static std::map *CommandLineOptions = 0; +static std::map &getOpts() { + if (CommandLineOptions == 0) + CommandLineOptions = new std::map(); return *CommandLineOptions; } -static Option *getOption(const string &Str) { +static Option *getOption(const std::string &Str) { if (CommandLineOptions == 0) return 0; - map::iterator I = CommandLineOptions->find(Str); + std::map::iterator I = CommandLineOptions->find(Str); return I != CommandLineOptions->end() ? I->second : 0; } -static vector &getPositionalOpts() { - static vector Positional; +static std::vector &getPositionalOpts() { + static std::vector Positional; return Positional; } static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - cerr << "CommandLine Error: Argument '" << ArgName - << "' defined more than once!\n"; + std::cerr << "CommandLine Error: Argument '" << ArgName + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts()[ArgName] = Opt; @@ -89,18 +85,18 @@ case ValueDisallowed: if (*Value != 0) return Handler->error(" does not allow a value! '" + - string(Value) + "' specified."); + std::string(Value) + "' specified."); break; case ValueOptional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; abort(); + default: std::cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; abort(); } // Run the handler now! return Handler->addOccurance(ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, string &Arg) { +static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { int Dummy; return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); } @@ -165,8 +161,8 @@ ProgramOverview = Overview; bool ErrorParsing = false; - map &Opts = getOpts(); - vector &PositionalOpts = getPositionalOpts(); + std::map &Opts = getOpts(); + std::vector &PositionalOpts = getPositionalOpts(); // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; @@ -209,7 +205,7 @@ // PositionalVals - A vector of "positional" arguments we accumulate into to // processes at the end... // - vector PositionalVals; + std::vector PositionalVals; // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? @@ -258,9 +254,9 @@ ++Value; // Advance to value... if (*ArgName != 0) { - string RealName(ArgName, ArgNameEnd); + std::string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = Opts.find(RealName); + std::map::iterator I = Opts.find(RealName); if (I == Opts.end() && !*Value && RealName.size() > 1) { // Check to see if this "option" is really a prefixed or grouped @@ -276,7 +272,7 @@ if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { ArgNameEnd = ArgName+Length; Value = ArgNameEnd; - I = Opts.find(string(ArgName, ArgNameEnd)); + I = Opts.find(std::string(ArgName, ArgNameEnd)); assert(I->second == PGOpt); } else if (PGOpt) { // This must be a grouped option... handle all of them now... @@ -284,7 +280,7 @@ do { // Move current arg name out of RealName into RealArgName... - string RealArgName(RealName.begin(), RealName.begin()+Length); + std::string RealArgName(RealName.begin(),RealName.begin()+Length); RealName.erase(RealName.begin(), RealName.begin()+Length); // Because ValueRequired is an invalid flag for grouped arguments, @@ -316,8 +312,8 @@ } if (Handler == 0) { - cerr << "Unknown command line argument '" << argv[i] << "'. Try: " - << argv[0] << " --help'\n"; + std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -327,9 +323,9 @@ // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - cerr << "Not enough positional command line arguments specified!\n"; - cerr << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; + std::cerr << "Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; @@ -387,7 +383,7 @@ } // Loop over args and make sure all required args are specified! - for (map::iterator I = Opts.begin(), + for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurancesFlag()) { case Required: @@ -416,17 +412,17 @@ // Option Base class implementation // -bool Option::error(string Message, const char *ArgName) { +bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) - cerr << HelpStr; // Be nice for positional arguments + std::cerr << HelpStr; // Be nice for positional arguments else - cerr << "-" << ArgName; - cerr << " option" << Message << "\n"; + std::cerr << "-" << ArgName; + std::cerr << " option" << Message << "\n"; return true; } -bool Option::addOccurance(const char *ArgName, const string &Value) { +bool Option::addOccurance(const char *ArgName, const std::string &Value) { NumOccurances++; // Increment the number of times we have been seen switch (getNumOccurancesFlag()) { @@ -468,7 +464,7 @@ if (ArgStr[0]) { RemoveArgument(ArgStr, this); } else if (getFormattingFlag() == Positional) { - vector::iterator I = + std::vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); getPositionalOpts().erase(I); @@ -500,8 +496,8 @@ // Print out the option for the alias... void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << "\n"; + std::cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + << HelpStr << "\n"; } @@ -527,13 +523,13 @@ // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - cerr << " -" << O.ArgStr; + std::cerr << " -" << O.ArgStr; if (const char *ValName = getValueName()) - cerr << "=<" << getValueStr(O, ValName) << ">"; + std::cerr << "=<" << getValueStr(O, ValName) << ">"; - cerr << string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; + std::cerr << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } @@ -542,7 +538,7 @@ // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, bool &Value) { + const std::string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; @@ -558,7 +554,7 @@ // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, int &Value) { + const std::string &Arg, int &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = (int)strtol(ArgStart, &End, 0); @@ -569,7 +565,7 @@ // parser/parser implementation // -static bool parseDouble(Option &O, const string &Arg, double &Value) { +static bool parseDouble(Option &O, const std::string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); @@ -602,7 +598,7 @@ // unsigned generic_parser_base::findOption(const char *Name) { unsigned i = 0, e = getNumOptions(); - string N(Name); + std::string N(Name); while (i != e) if (getOption(i) == N) @@ -635,21 +631,21 @@ unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') - << " - " << O.HelpStr << "\n"; + std::cerr << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - cerr << " =" << getOption(i) << string(NumSpaces, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " =" << getOption(i) << std::string(NumSpaces, ' ') + << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - cerr << " " << O.HelpStr << "\n"; + std::cerr << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - cerr << " -" << getOption(i) << string(GlobalWidth-L-8, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + << " - " << getDescription(i) << "\n"; } } } @@ -666,10 +662,10 @@ const bool ShowHidden; // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. - inline static bool isHidden(pair &OptPair) { + inline static bool isHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() >= Hidden; } - inline static bool isReallyHidden(pair &OptPair) { + inline static bool isReallyHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() == ReallyHidden; } @@ -682,7 +678,7 @@ if (Value == false) return; // Copy Options into a vector so we can sort them as we like... - vector > Options; + std::vector > Options; copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden @@ -701,30 +697,30 @@ } if (ProgramOverview) - cerr << "OVERVIEW:" << ProgramOverview << "\n"; + std::cerr << "OVERVIEW:" << ProgramOverview << "\n"; - cerr << "USAGE: " << ProgramName << " [options]"; + std::cerr << "USAGE: " << ProgramName << " [options]"; // Print out the positional options... - vector &PosOpts = getPositionalOpts(); + std::vector &PosOpts = getPositionalOpts(); Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) - cerr << " " << PosOpts[i]->HelpStr; + std::cerr << " " << PosOpts[i]->HelpStr; // Print the consume after option info if it exists... - if (CAOpt) cerr << " " << CAOpt->HelpStr; + if (CAOpt) std::cerr << " " << CAOpt->HelpStr; - cerr << "\n\n"; + std::cerr << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Options.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); - cerr << "OPTIONS:\n"; + std::cerr << "OPTIONS:\n"; for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); From lattner at cs.uiuc.edu Thu May 22 15:14:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:14:01 2003 Subject: [llvm-commits] CVS: llvm/tools/opt/opt.cpp Message-ID: <200305222013.PAA06341@apoc.cs.uiuc.edu> Changes in directory llvm/tools/opt: opt.cpp updated: 1.81 -> 1.82 --- Log message: Kill using declarations --- Diffs of the changes: Index: llvm/tools/opt/opt.cpp diff -u llvm/tools/opt/opt.cpp:1.81 llvm/tools/opt/opt.cpp:1.82 --- llvm/tools/opt/opt.cpp:1.81 Thu Apr 24 14:10:09 2003 +++ llvm/tools/opt/opt.cpp Thu May 22 15:13:16 2003 @@ -20,9 +20,6 @@ #include #include -using std::cerr; -using std::string; - // The OptimizationList is automatically populated with registered Passes by the // PassNameParser. @@ -34,10 +31,10 @@ // Other command line options... // -static cl::opt +static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); -static cl::opt +static cl::opt OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("filename")); @@ -78,11 +75,11 @@ // Load the input module... std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { - cerr << argv[0] << ": "; + std::cerr << argv[0] << ": "; if (ErrorMessage.size()) - cerr << ErrorMessage << "\n"; + std::cerr << ErrorMessage << "\n"; else - cerr << "bytecode didn't read correctly.\n"; + std::cerr << "bytecode didn't read correctly.\n"; return 1; } @@ -91,15 +88,15 @@ if (OutputFilename != "") { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } @@ -130,10 +127,11 @@ assert(target.get() && "Could not allocate target machine!"); Passes.add(Opt->getTargetCtor()(*target.get())); } else - cerr << argv[0] << ": cannot create pass: " << Opt->getPassName() << "\n"; + std::cerr << argv[0] << ": cannot create pass: " << Opt->getPassName() + << "\n"; if (PrintEachXForm) - Passes.add(new PrintModulePass(&cerr)); + Passes.add(new PrintModulePass(&std::cerr)); } // Check that the module is well formed on completion of optimization @@ -146,7 +144,7 @@ // Now that we have all of the passes ready, run them. if (Passes.run(*M.get()) && !Quiet) - cerr << "Program modified.\n"; + std::cerr << "Program modified.\n"; return 0; } From lattner at cs.uiuc.edu Thu May 22 15:14:06 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:14:06 2003 Subject: [llvm-commits] CVS: llvm/tools/link/link.cpp Message-ID: <200305222013.PAA06334@apoc.cs.uiuc.edu> Changes in directory llvm/tools/link: link.cpp updated: 1.23 -> 1.24 --- Log message: Kill using declarations --- Diffs of the changes: Index: llvm/tools/link/link.cpp diff -u llvm/tools/link/link.cpp:1.23 llvm/tools/link/link.cpp:1.24 --- llvm/tools/link/link.cpp:1.23 Tue Jul 30 16:43:21 2002 +++ llvm/tools/link/link.cpp Thu May 22 15:13:15 2003 @@ -20,8 +20,6 @@ #include // For FileExists #include -using std::cerr; - static cl::list InputFilenames(cl::Positional, cl::OneOrMore, cl::desc("")); @@ -59,15 +57,15 @@ bool FoundAFile = false; while (1) { - if (Verbose) cerr << "Loading '" << Filename << "'\n"; + if (Verbose) std::cerr << "Loading '" << Filename << "'\n"; if (FileExists(Filename)) FoundAFile = true; Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); if (Result) return std::auto_ptr(Result); // Load successful! if (Verbose) { - cerr << "Error opening bytecode file: '" << Filename << "'"; - if (ErrorMessage.size()) cerr << ": " << ErrorMessage; - cerr << "\n"; + std::cerr << "Error opening bytecode file: '" << Filename << "'"; + if (ErrorMessage.size()) std::cerr << ": " << ErrorMessage; + std::cerr << "\n"; } if (NextLibPathIdx == LibPaths.size()) break; @@ -75,10 +73,10 @@ } if (FoundAFile) - cerr << "Bytecode file '" << FN << "' corrupt! " - << "Use 'link -v ...' for more info.\n"; + std::cerr << "Bytecode file '" << FN << "' corrupt! " + << "Use 'link -v ...' for more info.\n"; else - cerr << "Could not locate bytecode file: '" << FN << "'\n"; + std::cerr << "Could not locate bytecode file: '" << FN << "'\n"; return std::auto_ptr(); } @@ -106,29 +104,29 @@ std::auto_ptr M(LoadFile(InputFilenames[i])); if (M.get() == 0) return 1; - if (Verbose) cerr << "Linking in '" << InputFilenames[i] << "'\n"; + if (Verbose) std::cerr << "Linking in '" << InputFilenames[i] << "'\n"; if (LinkModules(Composite.get(), M.get(), &ErrorMessage)) { - cerr << argv[0] << ": error linking in '" << InputFilenames[i] << "': " - << ErrorMessage << "\n"; + std::cerr << argv[0] << ": error linking in '" << InputFilenames[i] + << "': " << ErrorMessage << "\n"; return 1; } } - if (DumpAsm) cerr << "Here's the assembly:\n" << Composite.get(); + if (DumpAsm) std::cerr << "Here's the assembly:\n" << Composite.get(); std::ostream *Out = &std::cout; // Default to printing to stdout... if (OutputFilename != "-") { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { - cerr << argv[0] << ": error opening '" << OutputFilename << "'!\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename << "'!\n"; return 1; } @@ -137,7 +135,7 @@ RemoveFileOnSignal(OutputFilename); } - if (Verbose) cerr << "Writing bytecode...\n"; + if (Verbose) std::cerr << "Writing bytecode...\n"; WriteBytecodeToFile(Composite.get(), *Out); if (Out != &std::cout) delete Out; From lattner at cs.uiuc.edu Thu May 22 15:14:10 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:14:10 2003 Subject: [llvm-commits] CVS: llvm/tools/dis/dis.cpp Message-ID: <200305222013.PAA06327@apoc.cs.uiuc.edu> Changes in directory llvm/tools/dis: dis.cpp updated: 1.29 -> 1.30 --- Log message: Kill using declarations --- Diffs of the changes: Index: llvm/tools/dis/dis.cpp diff -u llvm/tools/dis/dis.cpp:1.29 llvm/tools/dis/dis.cpp:1.30 --- llvm/tools/dis/dis.cpp:1.29 Wed Apr 16 15:51:35 2003 +++ llvm/tools/dis/dis.cpp Thu May 22 15:13:14 2003 @@ -20,7 +20,6 @@ #include "Support/Signals.h" #include #include -using std::cerr; // OutputMode - The different orderings to print basic blocks in... enum OutputMode { @@ -52,19 +51,19 @@ std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { - cerr << argv[0] << ": "; + std::cerr << argv[0] << ": "; if (ErrorMessage.size()) - cerr << ErrorMessage << "\n"; + std::cerr << ErrorMessage << "\n"; else - cerr << "bytecode didn't read correctly.\n"; + std::cerr << "bytecode didn't read correctly.\n"; return 1; } if (OutputFilename != "") { // Specified an output filename? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists! Sending to standard output.\n"; } else { Out = new std::ofstream(OutputFilename.c_str()); } @@ -87,8 +86,8 @@ if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists! Sending to standard output.\n"; } else { Out = new std::ofstream(OutputFilename.c_str()); @@ -100,8 +99,8 @@ } if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename - << ": sending to stdout instead!\n"; + std::cerr << argv[0] << ": error opening " << OutputFilename + << ": sending to stdout instead!\n"; Out = &std::cout; } From lattner at cs.uiuc.edu Thu May 22 15:14:14 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:14:14 2003 Subject: [llvm-commits] CVS: llvm/tools/as/as.cpp Message-ID: <200305222013.PAA06319@apoc.cs.uiuc.edu> Changes in directory llvm/tools/as: as.cpp updated: 1.17 -> 1.18 --- Log message: Kill using declarations --- Diffs of the changes: Index: llvm/tools/as/as.cpp diff -u llvm/tools/as/as.cpp:1.17 llvm/tools/as/as.cpp:1.18 --- llvm/tools/as/as.cpp:1.17 Fri Aug 30 17:54:41 2002 +++ llvm/tools/as/as.cpp Thu May 22 15:13:13 2003 @@ -17,13 +17,11 @@ #include "Support/Signals.h" #include #include -using std::cerr; -using std::string; -static cl::opt +static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); -static cl::opt +static cl::opt OutputFilename("o", cl::desc("Override output filename"), cl::value_desc("filename")); @@ -41,24 +39,25 @@ // Parse the file now... std::auto_ptr M(ParseAssemblyFile(InputFilename)); if (M.get() == 0) { - cerr << argv[0] << ": assembly didn't read correctly.\n"; + std::cerr << argv[0] << ": assembly didn't read correctly.\n"; return 1; } if (verifyModule(*M.get())) { - cerr << argv[0] << ": assembly parsed, but does not verify as correct!\n"; + std::cerr << argv[0] + << ": assembly parsed, but does not verify as correct!\n"; return 1; } - if (DumpAsm) cerr << "Here's the assembly:\n" << M.get(); + if (DumpAsm) std::cerr << "Here's the assembly:\n" << M.get(); if (OutputFilename != "") { // Specified an output filename? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str()); @@ -79,9 +78,9 @@ if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } @@ -93,13 +92,13 @@ } if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } WriteBytecodeToFile(M.get(), *Out); } catch (const ParseException &E) { - cerr << argv[0] << ": " << E.getMessage() << "\n"; + std::cerr << argv[0] << ": " << E.getMessage() << "\n"; return 1; } From lattner at cs.uiuc.edu Thu May 22 15:27:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:27:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp Message-ID: <200305222026.PAA06457@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: CommandLine.cpp updated: 1.28 -> 1.29 --- Log message: Add new CommaSeparated option modifier --- Diffs of the changes: Index: llvm/lib/Support/CommandLine.cpp diff -u llvm/lib/Support/CommandLine.cpp:1.28 llvm/lib/Support/CommandLine.cpp:1.29 --- llvm/lib/Support/CommandLine.cpp:1.28 Thu May 22 15:06:43 2003 +++ llvm/lib/Support/CommandLine.cpp Thu May 22 15:26:17 2003 @@ -318,6 +318,26 @@ continue; } + // Check to see if this option accepts a comma separated list of values. If + // it does, we have to split up the value into multiple values... + if (Handler->getMiscFlags() & CommaSeparated) { + std::string Val(Value); + std::string::size_type Pos = Val.find(','); + + while (Pos != std::string::npos) { + // Process the portion before the comma... + ErrorParsing |= ProvideOption(Handler, ArgName, + std::string(Val.begin(), + Val.begin()+Pos).c_str(), + argc, argv, i); + // Erase the portion before the comma, AND the comma... + Val.erase(Val.begin(), Val.begin()+Pos+1); + Value += Pos+1; // Increment the original value pointer as well... + + // Check for another comma... + Pos = Val.find(','); + } + } ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } From lattner at cs.uiuc.edu Thu May 22 15:27:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:27:05 2003 Subject: [llvm-commits] CVS: llvm/include/Support/CommandLine.h Message-ID: <200305222026.PAA06448@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: CommandLine.h updated: 1.9 -> 1.10 --- Log message: Add support for a new "CommaSeparated" modifier --- Diffs of the changes: Index: llvm/include/Support/CommandLine.h diff -u llvm/include/Support/CommandLine.h:1.9 llvm/include/Support/CommandLine.h:1.10 --- llvm/include/Support/CommandLine.h:1.9 Fri Sep 13 09:33:39 2002 +++ llvm/include/Support/CommandLine.h Thu May 22 15:25:57 2003 @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "boost/type_traits/object_traits.hpp" namespace cl { // Short namespace to make usage concise @@ -50,7 +50,7 @@ }; enum ValueExpected { // Is a value required for the option? - ValueOptional = 0x08, // The value can oppear... or not + ValueOptional = 0x08, // The value can appear... or not ValueRequired = 0x10, // The value is required to appear! ValueDisallowed = 0x18, // A value may not be specified (for flags) ValueMask = 0x18, @@ -86,6 +86,12 @@ FormattingMask = 0x180, }; +enum MiscFlags { // Miscellaneous flags to adjust argument + CommaSeparated = 0x200, // Should this cl::list split between commas? + MiscMask = 0x200, +}; + + //===----------------------------------------------------------------------===// // Option Base class @@ -137,6 +143,9 @@ int OH = Flags & FormattingMask; return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault(); } + inline unsigned getMiscFlags() const { + return Flags & MiscMask; + } // hasArgStr - Return true if the argstr != "" bool hasArgStr() const { return ArgStr[0] != 0; } @@ -163,7 +172,7 @@ void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } - + void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } protected: Option() : NumOccurances(0), Flags(0), ArgStr(""), HelpStr(""), ValueStr("") {} @@ -582,6 +591,9 @@ }; template<> struct applicator { static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } +}; +template<> struct applicator { + static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); } }; // apply method - Apply a modifier to an option in a type safe way. From lattner at cs.uiuc.edu Thu May 22 15:28:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:28:01 2003 Subject: [llvm-commits] CVS: llvm/test/Libraries/Makefile.libs Message-ID: <200305222027.PAA06481@apoc.cs.uiuc.edu> Changes in directory llvm/test/Libraries: Makefile.libs updated: 1.5 -> 1.6 --- Log message: add support for an explicit EXPORTED_SYMBOL_LIST --- Diffs of the changes: Index: llvm/test/Libraries/Makefile.libs diff -u llvm/test/Libraries/Makefile.libs:1.5 llvm/test/Libraries/Makefile.libs:1.6 --- llvm/test/Libraries/Makefile.libs:1.5 Wed May 14 08:09:57 2003 +++ llvm/test/Libraries/Makefile.libs Thu May 22 15:27:30 2003 @@ -7,6 +7,9 @@ # # 1. LEVEL - Must be set as per normal semantics: The depth from the top of tree # 2. LIBNAME - Name of library to link together. Forms lib.bc +# 3. EXPORTED_SYMBOL_LIST - If this symbol is defined, it contains a comma +# separated list of symbols that are exported by the library. All other +# symbols are marked internal, reducing namespace pollution. # DESTLIBDIR := $(LEVEL)/test/Libraries/Output @@ -22,10 +25,16 @@ .PRECIOUS: $(LObjects) +# If the library specified a list of symbols to export, add an internalize pass +# to the link options. +ifdef EXPORTED_SYMBOL_LIST +LLINK_OPTS += -internalize -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST) +endif + # Link the library, then perform postlink optimization... -$(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) +$(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) $(LLINK) $(LOPT) $(LLINK) -f $(LObjects) $(LDFLAGS) | \ - $(LOPT) -f -funcresolve -deadtypeelim -globaldce -o $@ + $(LOPT) -f -q -funcresolve -deadtypeelim $(LLINK_OPTS) -globaldce -o $@ # Install target for libraries: Copy into the gcc install directory. # From lattner at cs.uiuc.edu Thu May 22 15:28:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:28:05 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Internalize.cpp Message-ID: <200305222027.PAA06470@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Internalize.cpp updated: 1.15 -> 1.16 --- Log message: Make the list accept comma separated names --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/Internalize.cpp diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.15 llvm/lib/Transforms/IPO/Internalize.cpp:1.16 --- llvm/lib/Transforms/IPO/Internalize.cpp:1.15 Thu May 22 14:48:00 2003 +++ llvm/lib/Transforms/IPO/Internalize.cpp Thu May 22 15:27:13 2003 @@ -27,7 +27,8 @@ // APIList - A list of symbols that should not be marked internal. cl::list APIList("internalize-public-api-list", cl::value_desc("list"), - cl::desc("A list of symbol names to preserve")); + cl::desc("A list of symbol names to preserve"), + cl::CommaSeparated); class InternalizePass : public Pass { std::set ExternalNames; From lattner at cs.uiuc.edu Thu May 22 15:37:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:37:01 2003 Subject: [llvm-commits] CVS: llvm/www/docs/CommandLine.html Message-ID: <200305222036.PAA13273@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: CommandLine.html updated: 1.7 -> 1.8 --- Log message: Add documentation for the new cl::CommaSeparated modifier --- Diffs of the changes: Index: llvm/www/docs/CommandLine.html diff -u llvm/www/docs/CommandLine.html:1.7 llvm/www/docs/CommandLine.html:1.8 --- llvm/www/docs/CommandLine.html:1.7 Tue May 20 16:01:22 2003 +++ llvm/www/docs/CommandLine.html Thu May 22 15:36:06 2003 @@ -36,6 +36,7 @@
  • Controlling whether or not a value must be specified
  • Controlling other formatting options +
  • Miscellaneous option modifiers
  • Top-Level Classes and Functions
      @@ -961,7 +962,7 @@ tweak how options are parsed and how --help output is generated to fit your application well.

      -These options naturally fall into four main catagories:

      +These options fall into five main catagories:

      1. Hiding an option from --help output @@ -970,12 +971,14 @@
      2. Controlling whether or not a value must be specified
      3. Controlling other formatting options +
      4. Miscellaneous option modifiers

      It is not possible to specify two options from the same catagory (you'll get a -runtime error) to a single option. The CommandLine library specifies defaults -for all of these settings that are the most useful in practice and the most -common, which mean that you usually shouldn't have to worry about these.

      +runtime error) to a single option, except for options in the miscellaneous +catagory. The CommandLine library specifies defaults for all of these settings +that are the most useful in practice and the most common, which mean that you +usually shouldn't have to worry about these.

      @@ -1153,6 +1156,29 @@ }

      + + +


    Miscellaneous option modifiers

       Top-Level Classes and Functions @@ -1469,7 +1495,7 @@
    Chris Lattner
    -Last modified: Wed Aug 7 13:22:40 CDT 2002 +Last modified: Thu May 22 15:35:19 CDT 2003
    From lattner at cs.uiuc.edu Thu May 22 15:44:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:44:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c Message-ID: <200305222043.PAA06623@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-22-VarSizeArray.c updated: 1.1 -> 1.2 --- Log message: Fix testcase --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c diff -u llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c:1.1 llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c:1.2 --- llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c:1.1 Thu May 22 15:43:06 2003 +++ llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c Thu May 22 15:43:21 2003 @@ -1,3 +1,4 @@ +#include int test(int Num) { int Arr[Num]; From lattner at cs.uiuc.edu Thu May 22 15:44:05 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 15:44:05 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c Message-ID: <200305222043.PAA06603@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-22-VarSizeArray.c added (r1.1) --- Log message: New testcase --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c diff -c /dev/null llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c:1.1 *** /dev/null Thu May 22 15:43:16 2003 --- llvm/test/Regression/C++Frontend/2003-05-22-VarSizeArray.c Thu May 22 15:43:06 2003 *************** *** 0 **** --- 1,11 ---- + + int test(int Num) { + int Arr[Num]; + Arr[2] = 0; + return Arr[2]; + } + + int main() { + printf("%d\n", test(4)); + return 0; + } From lattner at cs.uiuc.edu Thu May 22 16:22:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 16:22:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200305222121.QAA10479@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.45 -> 1.46 --- Log message: Remove using declarations --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.45 llvm/lib/VMCore/Type.cpp:1.46 --- llvm/lib/VMCore/Type.cpp:1.45 Tue May 20 13:45:36 2003 +++ llvm/lib/VMCore/Type.cpp Thu May 22 16:21:43 2003 @@ -9,16 +9,8 @@ #include "llvm/Constants.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" -#include #include -using std::vector; -using std::string; -using std::map; -using std::swap; -using std::make_pair; -using std::cerr; - // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only // a single cannonical version of a type. @@ -26,20 +18,19 @@ //#define DEBUG_MERGE_TYPES 1 - //===----------------------------------------------------------------------===// // Type Class Implementation //===----------------------------------------------------------------------===// static unsigned CurUID = 0; -static vector UIDMappings; +static std::vector UIDMappings; void PATypeHolder::dump() const { - cerr << "PATypeHolder(" << (void*)this << ")\n"; + std::cerr << "PATypeHolder(" << (void*)this << ")\n"; } -Type::Type(const string &name, PrimitiveID id) +Type::Type(const std::string &name, PrimitiveID id) : Value(Type::TypeTy, Value::TypeVal) { setDescription(name); ID = id; @@ -48,7 +39,7 @@ UIDMappings.push_back(this); } -void Type::setName(const string &Name, SymbolTable *ST) { +void Type::setName(const std::string &Name, SymbolTable *ST) { assert(ST && "Type::setName - Must provide symbol table argument!"); if (Name.size()) ST->insert(Name, this); @@ -152,7 +143,7 @@ // type. // struct SignedIntType : public Type { - SignedIntType(const string &Name, PrimitiveID id) : Type(Name, id) {} + SignedIntType(const std::string &Name, PrimitiveID id) : Type(Name, id) {} // isSigned - Return whether a numeric type is signed. virtual bool isSigned() const { return 1; } @@ -164,7 +155,7 @@ }; struct UnsignedIntType : public Type { - UnsignedIntType(const string &N, PrimitiveID id) : Type(N, id) {} + UnsignedIntType(const std::string &N, PrimitiveID id) : Type(N, id) {} // isUnsigned - Return whether a numeric type is signed. virtual bool isUnsigned() const { return 1; } @@ -205,7 +196,7 @@ //===----------------------------------------------------------------------===// FunctionType::FunctionType(const Type *Result, - const vector &Params, + const std::vector &Params, bool IsVarArgs) : DerivedType(FunctionTyID), ResultType(PATypeHandle(Result, this)), isVarArgs(IsVarArgs) { @@ -216,7 +207,7 @@ setDerivedTypeProperties(); } -StructType::StructType(const vector &Types) +StructType::StructType(const std::vector &Types) : CompositeType(StructTyID) { ETypes.reserve(Types.size()); for (unsigned i = 0; i < Types.size(); ++i) { @@ -240,7 +231,7 @@ setAbstract(true); setDescription("opaque"+utostr(getUniqueID())); #ifdef DEBUG_MERGE_TYPES - cerr << "Derived new type: " << getDescription() << endl; + std::cerr << "Derived new type: " << getDescription() << "\n"; #endif } @@ -257,8 +248,9 @@ // some whacko opaque types, but in most cases, it will do some simple stuff // when it hits non-abstract types that aren't recursive. // -static string getTypeProps(const Type *Ty, vector &TypeStack, - bool &isAbstract, bool &isRecursive) { +static std::string getTypeProps(const Type *Ty, + std::vector &TypeStack, + bool &isAbstract, bool &isRecursive) { if (!Ty->isAbstract() && !Ty->isRecursive() && // Base case for the recursion Ty->getDescription().size()) { return Ty->getDescription(); // Primitive = leaf type @@ -278,7 +270,7 @@ isRecursive = true; // We know we are recursive return "\\" + utostr(CurSize-Slot); // Here's the upreference } else { // Recursive case: abstract derived type... - string Result; + std::string Result; TypeStack.push_back(Ty); // Add us to the stack.. switch (Ty->getPrimitiveID()) { @@ -345,7 +337,7 @@ // getTypeProps function does all the dirty work. // void DerivedType::setDerivedTypeProperties() { - vector TypeStack; + std::vector TypeStack; bool isAbstract = false, isRecursive = false; setDescription(getTypeProps(this, TypeStack, isAbstract, isRecursive)); @@ -365,20 +357,20 @@ // that assumes that two graphs are the same until proven otherwise. // static bool TypesEqual(const Type *Ty, const Type *Ty2, - map &EqTypes) { + std::map &EqTypes) { if (Ty == Ty2) return true; if (Ty->getPrimitiveID() != Ty2->getPrimitiveID()) return false; if (Ty->isPrimitiveType()) return true; if (isa(Ty)) return false; // Two nonequal opaque types are never equal - map::iterator It = EqTypes.find(Ty); + std::map::iterator It = EqTypes.find(Ty); if (It != EqTypes.end()) return It->second == Ty2; // Looping back on a type, check for equality // Otherwise, add the mapping to the table to make sure we don't get // recursion on the types... - EqTypes.insert(make_pair(Ty, Ty2)); + EqTypes.insert(std::make_pair(Ty, Ty2)); // Iterate over the types and make sure the the contents are equivalent... Type::subtype_iterator I = Ty ->subtype_begin(), IE = Ty ->subtype_end(); @@ -401,7 +393,7 @@ } static bool TypesEqual(const Type *Ty, const Type *Ty2) { - map EqTypes; + std::map EqTypes; return TypesEqual(Ty, Ty2, EqTypes); } @@ -417,19 +409,20 @@ // template class TypeMap : public AbstractTypeUser { - typedef map > MapTy; + typedef std::map > MapTy; MapTy Map; public: ~TypeMap() { print("ON EXIT"); } inline TypeClass *get(const ValType &V) { - typename map >::iterator I = Map.find(V); + typename std::map >::iterator I + = Map.find(V); // TODO: FIXME: When Types are not CONST. return (I != Map.end()) ? (TypeClass*)I->second.get() : 0; } inline void add(const ValType &V, TypeClass *T) { - Map.insert(make_pair(V, PATypeHandle(T, this))); + Map.insert(std::make_pair(V, PATypeHandle(T, this))); print("add"); } @@ -450,9 +443,9 @@ // virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { #ifdef DEBUG_MERGE_TYPES - cerr << "Removing Old type from Tab: " << (void*)OldTy << ", " - << OldTy->getDescription() << " replacement == " << (void*)NewTy - << ", " << NewTy->getDescription() << endl; + std::cerr << "Removing Old type from Tab: " << (void*)OldTy << ", " + << OldTy->getDescription() << " replacement == " << (void*)NewTy + << ", " << NewTy->getDescription() << "\n"; #endif for (typename MapTy::iterator I = Map.begin(), E = Map.end(); I != E; ++I) if (I->second == OldTy) { @@ -471,11 +464,11 @@ void print(const char *Arg) const { #ifdef DEBUG_MERGE_TYPES - cerr << "TypeMap<>::" << Arg << " table contents:\n"; + std::cerr << "TypeMap<>::" << Arg << " table contents:\n"; unsigned i = 0; for (MapTy::const_iterator I = Map.begin(), E = Map.end(); I != E; ++I) - cerr << " " << (++i) << ". " << I->second << " " - << I->second->getDescription() << endl; + std::cerr << " " << (++i) << ". " << I->second << " " + << I->second->getDescription() << "\n"; #endif } @@ -522,7 +515,7 @@ } void dump() const { - cerr << "ValTypeBase instance!\n"; + std::cerr << "ValTypeBase instance!\n"; } }; @@ -536,10 +529,10 @@ // class FunctionValType : public ValTypeBase { PATypeHandle RetTy; - vector > ArgTypes; + std::vector > ArgTypes; bool isVarArg; public: - FunctionValType(const Type *ret, const vector &args, + FunctionValType(const Type *ret, const std::vector &args, bool IVA, TypeMap &Tab) : ValTypeBase(Tab), RetTy(ret, this), isVarArg(IVA) { @@ -586,7 +579,7 @@ // FunctionType::get - The factory function for the FunctionType class... FunctionType *FunctionType::get(const Type *ReturnType, - const vector &Params, + const std::vector &Params, bool isVarArg) { FunctionValType VT(ReturnType, Params, isVarArg, FunctionTypes); FunctionType *MT = FunctionTypes.get(VT); @@ -595,7 +588,7 @@ FunctionTypes.add(VT, MT = new FunctionType(ReturnType, Params, isVarArg)); #ifdef DEBUG_MERGE_TYPES - cerr << "Derived new type: " << MT << endl; + std::cerr << "Derived new type: " << MT << "\n"; #endif return MT; } @@ -648,7 +641,7 @@ ArrayTypes.add(AVT, AT = new ArrayType(ElementType, NumElements)); #ifdef DEBUG_MERGE_TYPES - cerr << "Derived new type: " << AT->getDescription() << endl; + std::cerr << "Derived new type: " << AT->getDescription() << "\n"; #endif return AT; } @@ -660,9 +653,9 @@ // StructValType - Define a class to hold the key that goes into the TypeMap // class StructValType : public ValTypeBase { - vector > ElTypes; + std::vector > ElTypes; public: - StructValType(const vector &args, + StructValType(const std::vector &args, TypeMap &Tab) : ValTypeBase(Tab) { ElTypes.reserve(args.size()); @@ -699,7 +692,7 @@ static TypeMap StructTypes; -StructType *StructType::get(const vector &ETypes) { +StructType *StructType::get(const std::vector &ETypes) { StructValType STV(ETypes, StructTypes); StructType *ST = StructTypes.get(STV); if (ST) return ST; @@ -708,7 +701,7 @@ StructTypes.add(STV, ST = new StructType(ETypes)); #ifdef DEBUG_MERGE_TYPES - cerr << "Derived new type: " << ST->getDescription() << endl; + std::cerr << "Derived new type: " << ST->getDescription() << "\n"; #endif return ST; } @@ -761,7 +754,7 @@ PointerTypes.add(PVT, PT = new PointerType(ValueType)); #ifdef DEBUG_MERGE_TYPES - cerr << "Derived new type: " << PT->getDescription() << endl; + std::cerr << "Derived new type: " << PT->getDescription() << "\n"; #endif return PT; } @@ -785,8 +778,9 @@ assert(isAbstract() && "addAbstractTypeUser: Current type not abstract!"); #if DEBUG_MERGE_TYPES - cerr << " addAbstractTypeUser[" << (void*)this << ", " << getDescription() - << "][" << AbstractTypeUsers.size() << "] User = " << U << endl; + std::cerr << " addAbstractTypeUser[" << (void*)this << ", " + << getDescription() << "][" << AbstractTypeUsers.size() + << "] User = " << U << "\n"; #endif AbstractTypeUsers.push_back(U); } @@ -812,14 +806,14 @@ AbstractTypeUsers.erase(AbstractTypeUsers.begin()+i); #ifdef DEBUG_MERGE_TYPES - cerr << " remAbstractTypeUser[" << (void*)this << ", " - << getDescription() << "][" << i << "] User = " << U << endl; + std::cerr << " remAbstractTypeUser[" << (void*)this << ", " + << getDescription() << "][" << i << "] User = " << U << "\n"; #endif if (AbstractTypeUsers.empty() && isAbstract()) { #ifdef DEBUG_MERGE_TYPES - cerr << "DELETEing unused abstract type: <" << getDescription() - << ">[" << (void*)this << "]" << endl; + std::cerr << "DELETEing unused abstract type: <" << getDescription() + << ">[" << (void*)this << "]" << "\n"; #endif delete this; // No users of this abstract type! } @@ -836,9 +830,9 @@ assert(this != NewType && "Can't refine to myself!"); #ifdef DEBUG_MERGE_TYPES - cerr << "REFINING abstract type [" << (void*)this << " " << getDescription() - << "] to [" << (void*)NewType << " " << NewType->getDescription() - << "]!\n"; + std::cerr << "REFINING abstract type [" << (void*)this << " " + << getDescription() << "] to [" << (void*)NewType << " " + << NewType->getDescription() << "]!\n"; #endif @@ -870,14 +864,14 @@ if (User == this) { // Move self use to the start of the list. Increment NSU. - swap(AbstractTypeUsers.back(), AbstractTypeUsers[NumSelfUses++]); + std::swap(AbstractTypeUsers.back(), AbstractTypeUsers[NumSelfUses++]); } else { unsigned OldSize = AbstractTypeUsers.size(); #ifdef DEBUG_MERGE_TYPES - cerr << " REFINING user " << OldSize-1 << "[" << (void*)User - << "] of abstract type [" - << (void*)this << " " << getDescription() << "] to [" - << (void*)NewTy.get() << " " << NewTy->getDescription() << "]!\n"; + std::cerr << " REFINING user " << OldSize-1 << "[" << (void*)User + << "] of abstract type [" << (void*)this << " " + << getDescription() << "] to [" << (void*)NewTy.get() << " " + << NewTy->getDescription() << "]!\n"; #endif User->refineAbstractType(this, NewTy); @@ -885,11 +879,11 @@ if (AbstractTypeUsers.size() == OldSize) { User->refineAbstractType(this, NewTy); if (AbstractTypeUsers.back() != User) - cerr << "User changed!\n"; - cerr << "Top of user list is:\n"; + std::cerr << "User changed!\n"; + std::cerr << "Top of user list is:\n"; AbstractTypeUsers.back()->dump(); - cerr <<"\nOld User=\n"; + std::cerr <<"\nOld User=\n"; User->dump(); } #endif @@ -917,7 +911,8 @@ ++isRefining; #ifdef DEBUG_MERGE_TYPES - cerr << "typeIsREFINED type: " << (void*)this <<" "< Refined; + std::vector Refined; while (1) { unsigned i; for (i = AbstractTypeUsers.size(); i != 0; --i) @@ -947,8 +942,9 @@ Refined.push_back(ATU); // Keep track of which users we have refined! #ifdef DEBUG_MERGE_TYPES - cerr << " typeIsREFINED user " << i << "[" << ATU << "] of abstract type [" - << (void*)this << " " << getDescription() << "]\n"; + std::cerr << " typeIsREFINED user " << i << "[" << ATU + << "] of abstract type [" << (void*)this << " " + << getDescription() << "]\n"; #endif ATU->refineAbstractType(this, this); } @@ -960,9 +956,9 @@ for (unsigned i = 0; i < AbstractTypeUsers.size(); ++i) { if (AbstractTypeUsers[i] != this) { // Debugging hook - cerr << "FOUND FAILURE\nUser: "; + std::cerr << "FOUND FAILURE\nUser: "; AbstractTypeUsers[i]->dump(); - cerr << "\nCatch:\n"; + std::cerr << "\nCatch:\n"; AbstractTypeUsers[i]->refineAbstractType(this, this); assert(0 && "Type became concrete," " but it still has abstract type users hanging around!"); @@ -981,9 +977,9 @@ void FunctionType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { #ifdef DEBUG_MERGE_TYPES - cerr << "FunctionTy::refineAbstractTy(" << (void*)OldType << "[" - << OldType->getDescription() << "], " << (void*)NewType << " [" - << NewType->getDescription() << "])\n"; + std::cerr << "FunctionTy::refineAbstractTy(" << (void*)OldType << "[" + << OldType->getDescription() << "], " << (void*)NewType << " [" + << NewType->getDescription() << "])\n"; #endif // Find the type element we are refining... if (ResultType == OldType) { @@ -1013,9 +1009,9 @@ void ArrayType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { #ifdef DEBUG_MERGE_TYPES - cerr << "ArrayTy::refineAbstractTy(" << (void*)OldType << "[" - << OldType->getDescription() << "], " << (void*)NewType << " [" - << NewType->getDescription() << "])\n"; + std::cerr << "ArrayTy::refineAbstractTy(" << (void*)OldType << "[" + << OldType->getDescription() << "], " << (void*)NewType << " [" + << NewType->getDescription() << "])\n"; #endif assert(getElementType() == OldType); @@ -1039,9 +1035,9 @@ void StructType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { #ifdef DEBUG_MERGE_TYPES - cerr << "StructTy::refineAbstractTy(" << (void*)OldType << "[" - << OldType->getDescription() << "], " << (void*)NewType << " [" - << NewType->getDescription() << "])\n"; + std::cerr << "StructTy::refineAbstractTy(" << (void*)OldType << "[" + << OldType->getDescription() << "], " << (void*)NewType << " [" + << NewType->getDescription() << "])\n"; #endif for (int i = ETypes.size()-1; i >= 0; --i) if (ETypes[i] == OldType) { @@ -1067,9 +1063,9 @@ void PointerType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { #ifdef DEBUG_MERGE_TYPES - cerr << "PointerTy::refineAbstractTy(" << (void*)OldType << "[" - << OldType->getDescription() << "], " << (void*)NewType << " [" - << NewType->getDescription() << "])\n"; + std::cerr << "PointerTy::refineAbstractTy(" << (void*)OldType << "[" + << OldType->getDescription() << "], " << (void*)NewType << " [" + << NewType->getDescription() << "])\n"; #endif assert(ElementType == OldType); From brukman at cs.uiuc.edu Thu May 22 16:25:01 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu May 22 16:25:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp SchedGraph.cpp Message-ID: <200305222124.QAA22038@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.51 -> 1.52 SchedGraph.cpp updated: 1.41 -> 1.42 --- Log message: Kill `using' directives. --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.51 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.52 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.51 Tue Jan 14 17:05:03 2003 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Thu May 22 16:24:35 2003 @@ -14,8 +14,6 @@ #include "llvm/BasicBlock.h" #include "Support/CommandLine.h" #include -using std::cerr; -using std::vector; SchedDebugLevel_t SchedDebugLevel; @@ -64,7 +62,7 @@ /*ctor*/ InstrGroup(); // disable: DO NOT IMPLEMENT private: - vector group; + std::vector group; }; @@ -130,8 +128,8 @@ private: const unsigned int nslots; unsigned int numInstr; - vector groups; // indexed by cycle number - vector startTime; // indexed by node id + std::vector groups; // indexed by cycle number + std::vector startTime; // indexed by node id public: // iterators typedef ScheduleIterator iterator; @@ -300,7 +298,7 @@ private: const SchedGraphNode* brNode; unsigned int ndelays; - vector delayNodeVec; + std::vector delayNodeVec; cycles_t delayedNodeCycle; unsigned int delayedNodeSlotNum; @@ -314,7 +312,7 @@ return ndelays; } - inline const vector& getDelayNodeVec() { + inline const std::vector& getDelayNodeVec() { return delayNodeVec; } @@ -349,10 +347,11 @@ unsigned int totalInstrCount; cycles_t curTime; cycles_t nextEarliestIssueTime; // next cycle we can issue - vector > choicesForSlot; // indexed by slot# - vector choiceVec; // indexed by node ptr - vector numInClass; // indexed by sched class - vector nextEarliestStartTime; // indexed by opCode + // indexed by slot# + std::vector > choicesForSlot; + std::vector choiceVec; // indexed by node ptr + std::vector numInClass; // indexed by sched class + std::vector nextEarliestStartTime; // indexed by opCode hash_map delaySlotInfoForBranches; // indexed by branch node ptr @@ -987,15 +986,15 @@ { for (cycles_t c = firstCycle; c <= S.getTime(); c++) { - cerr << " Cycle " << (long)c << " : Scheduled instructions:\n"; + std::cerr << " Cycle " << (long)c <<" : Scheduled instructions:\n"; const InstrGroup* igroup = S.isched.getIGroup(c); for (unsigned int s=0; s < S.nslots; s++) { - cerr << " "; + std::cerr << " "; if ((*igroup)[s] != NULL) - cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; + std::cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; else - cerr << "\n"; + std::cerr << "\n"; } } } @@ -1141,7 +1140,7 @@ void FindUsefulInstructionsForDelaySlots(SchedulingManager& S, SchedGraphNode* brNode, - vector& sdelayNodeVec) + std::vector& sdelayNodeVec) { const TargetInstrInfo& mii = S.getInstrInfo(); unsigned ndelays = @@ -1155,7 +1154,7 @@ // Use a separate vector to hold the feasible multi-cycle nodes. // These will be used if not enough single-cycle nodes are found. // - vector mdelayNodeVec; + std::vector mdelayNodeVec; for (sg_pred_iterator P = pred_begin(brNode); P != pred_end(brNode) && sdelayNodeVec.size() < ndelays; ++P) @@ -1203,10 +1202,10 @@ // static void ReplaceNopsWithUsefulInstr(SchedulingManager& S, SchedGraphNode* node, - vector sdelayNodeVec, + std::vector sdelayNodeVec, SchedGraph* graph) { - vector nopNodeVec; // this will hold unused NOPs + std::vector nopNodeVec; // this will hold unused NOPs const TargetInstrInfo& mii = S.getInstrInfo(); const MachineInstr* brInstr = node->getMachineInstr(); unsigned ndelays= mii.getNumDelaySlots(brInstr->getOpCode()); @@ -1287,7 +1286,7 @@ Instruction *termInstr = (Instruction*)MBB.getBasicBlock()->getTerminator(); MachineCodeForInstruction &termMvec=MachineCodeForInstruction::get(termInstr); - vector delayNodeVec; + std::vector delayNodeVec; const MachineInstr* brInstr = NULL; if (termInstr->getOpcode() != Instruction::Ret) @@ -1510,7 +1509,7 @@ if (SchedDebugLevel >= Sched_PrintSchedGraphs) { - cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n"; + std::cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n"; graphSet.dump(); } @@ -1521,7 +1520,7 @@ MachineBasicBlock &MBB = graph->getBasicBlock(); if (SchedDebugLevel >= Sched_PrintSchedTrace) - cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; + std::cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; // expensive! SchedPriorities schedPrio(&F, graph, getAnalysis()); @@ -1534,7 +1533,7 @@ if (SchedDebugLevel >= Sched_PrintMachineCode) { - cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; + std::cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; MachineFunction::get(&F).dump(); } Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.41 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.42 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.41 Tue Jan 14 15:58:42 2003 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Thu May 22 16:24:35 2003 @@ -18,18 +18,15 @@ #include "Support/StringExtras.h" #include "Support/STLExtras.h" -using std::vector; -using std::pair; -using std::cerr; - //*********************** Internal Data Structures *************************/ // The following two types need to be classes, not typedefs, so we can use // opaque declarations in SchedGraph.h // -struct RefVec: public vector > { - typedef vector< pair >:: iterator iterator; - typedef vector< pair >::const_iterator const_iterator; +struct RefVec: public std::vector > { + typedef std::vector >::iterator iterator; + typedef + std::vector >::const_iterator const_iterator; }; struct RegToRefVecMap: public hash_map { @@ -126,7 +123,7 @@ } void SchedGraphEdge::dump(int indent) const { - cerr << std::string(indent*2, ' ') << *this; + std::cerr << std::string(indent*2, ' ') << *this; } @@ -160,7 +157,7 @@ } void SchedGraphNode::dump(int indent) const { - cerr << std::string(indent*2, ' ') << *this; + std::cerr << std::string(indent*2, ' ') << *this; } @@ -229,20 +226,20 @@ void SchedGraph::dump() const { - cerr << " Sched Graph for Basic Block: "; - cerr << MBB.getBasicBlock()->getName() - << " (" << MBB.getBasicBlock() << ")"; + std::cerr << " Sched Graph for Basic Block: "; + std::cerr << MBB.getBasicBlock()->getName() + << " (" << MBB.getBasicBlock() << ")"; - cerr << "\n\n Actual Root nodes : "; + std::cerr << "\n\n Actual Root nodes : "; for (unsigned i=0, N=graphRoot->outEdges.size(); i < N; i++) - cerr << graphRoot->outEdges[i]->getSink()->getNodeId() - << ((i == N-1)? "" : ", "); + std::cerr << graphRoot->outEdges[i]->getSink()->getNodeId() + << ((i == N-1)? "" : ", "); - cerr << "\n Graph Nodes:\n"; + std::cerr << "\n Graph Nodes:\n"; for (const_iterator I=begin(); I != end(); ++I) - cerr << "\n" << *I->second; + std::cerr << "\n" << *I->second; - cerr << "\n"; + std::cerr << "\n"; } @@ -431,7 +428,7 @@ // latency does not otherwise matter (true dependences enforce that). // void -SchedGraph::addMemEdges(const vector& memNodeVec, +SchedGraph::addMemEdges(const std::vector& memNodeVec, const TargetMachine& target) { const TargetInstrInfo& mii = target.getInstrInfo(); @@ -467,12 +464,12 @@ // like with control dependences. // void -SchedGraph::addCallCCEdges(const vector& memNodeVec, +SchedGraph::addCallCCEdges(const std::vector& memNodeVec, MachineBasicBlock& bbMvec, const TargetMachine& target) { const TargetInstrInfo& mii = target.getInstrInfo(); - vector callNodeVec; + std::vector callNodeVec; // Find the call instruction nodes and put them in a vector. for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++) @@ -671,7 +668,7 @@ void SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, SchedGraphNode* node, - vector& memNodeVec, + std::vector& memNodeVec, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap) { @@ -728,7 +725,7 @@ void SchedGraph::buildNodesForBB(const TargetMachine& target, MachineBasicBlock& MBB, - vector& memNodeVec, + std::vector& memNodeVec, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap) { @@ -761,7 +758,7 @@ // We use this to add memory dependence edges without a second full walk. // // vector memVec; - vector memNodeVec; + std::vector memNodeVec; // Use this data structure to note any uses or definitions of // machine registers so we can add edges for those later without @@ -858,14 +855,14 @@ void SchedGraphSet::dump() const { - cerr << "======== Sched graphs for function `" << method->getName() - << "' ========\n\n"; + std::cerr << "======== Sched graphs for function `" << method->getName() + << "' ========\n\n"; for (const_iterator I=begin(); I != end(); ++I) (*I)->dump(); - cerr << "\n====== End graphs for function `" << method->getName() - << "' ========\n\n"; + std::cerr << "\n====== End graphs for function `" << method->getName() + << "' ========\n\n"; } From lattner at cs.uiuc.edu Thu May 22 16:33:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 16:33:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200305222132.QAA10579@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.46 -> 1.47 --- Log message: Fix static constructor ordering problem --- Diffs of the changes: Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.46 llvm/lib/VMCore/Type.cpp:1.47 --- llvm/lib/VMCore/Type.cpp:1.46 Thu May 22 16:21:43 2003 +++ llvm/lib/VMCore/Type.cpp Thu May 22 16:31:52 2003 @@ -166,29 +166,47 @@ virtual bool isInteger() const { return 1; } }; +struct OtherType : public Type { + OtherType(const std::string &N, PrimitiveID id) : Type(N, id) {} +}; + static struct TypeType : public Type { TypeType() : Type("type", TypeTyID) {} -} TheTypeType; // Implement the type that is global. +} TheTypeTy; // Implement the type that is global. //===----------------------------------------------------------------------===// // Static 'Type' data //===----------------------------------------------------------------------===// -Type *Type::VoidTy = new Type("void" , VoidTyID), - *Type::BoolTy = new Type("bool" , BoolTyID), - *Type::SByteTy = new SignedIntType("sbyte" , SByteTyID), - *Type::UByteTy = new UnsignedIntType("ubyte" , UByteTyID), - *Type::ShortTy = new SignedIntType("short" , ShortTyID), - *Type::UShortTy = new UnsignedIntType("ushort", UShortTyID), - *Type::IntTy = new SignedIntType("int" , IntTyID), - *Type::UIntTy = new UnsignedIntType("uint" , UIntTyID), - *Type::LongTy = new SignedIntType("long" , LongTyID), - *Type::ULongTy = new UnsignedIntType("ulong" , ULongTyID), - *Type::FloatTy = new Type("float" , FloatTyID), - *Type::DoubleTy = new Type("double", DoubleTyID), - *Type::TypeTy = &TheTypeType, - *Type::LabelTy = new Type("label" , LabelTyID); +static OtherType TheVoidTy ("void" , Type::VoidTyID); +static OtherType TheBoolTy ("bool" , Type::BoolTyID); +static SignedIntType TheSByteTy ("sbyte" , Type::SByteTyID); +static UnsignedIntType TheUByteTy ("ubyte" , Type::UByteTyID); +static SignedIntType TheShortTy ("short" , Type::ShortTyID); +static UnsignedIntType TheUShortTy("ushort", Type::UShortTyID); +static SignedIntType TheIntTy ("int" , Type::IntTyID); +static UnsignedIntType TheUIntTy ("uint" , Type::UIntTyID); +static SignedIntType TheLongTy ("long" , Type::LongTyID); +static UnsignedIntType TheULongTy ("ulong" , Type::ULongTyID); +static OtherType TheFloatTy ("float" , Type::FloatTyID); +static OtherType TheDoubleTy("double", Type::DoubleTyID); +static OtherType TheLabelTy ("label" , Type::LabelTyID); + +Type *Type::VoidTy = &TheVoidTy; +Type *Type::BoolTy = &TheBoolTy; +Type *Type::SByteTy = &TheSByteTy; +Type *Type::UByteTy = &TheUByteTy; +Type *Type::ShortTy = &TheShortTy; +Type *Type::UShortTy = &TheUShortTy; +Type *Type::IntTy = &TheIntTy; +Type *Type::UIntTy = &TheUIntTy; +Type *Type::LongTy = &TheLongTy; +Type *Type::ULongTy = &TheULongTy; +Type *Type::FloatTy = &TheFloatTy; +Type *Type::DoubleTy = &TheDoubleTy; +Type *Type::TypeTy = &TheTypeTy; +Type *Type::LabelTy = &TheLabelTy; //===----------------------------------------------------------------------===// From lattner at cs.uiuc.edu Thu May 22 16:48:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 16:48:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp SymbolTable.cpp Message-ID: <200305222147.QAA10682@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Dominators.cpp updated: 1.43 -> 1.44 SymbolTable.cpp updated: 1.28 -> 1.29 --- Log message: Remove using declarations and extraneous #includes --- Diffs of the changes: Index: llvm/lib/VMCore/Dominators.cpp diff -u llvm/lib/VMCore/Dominators.cpp:1.43 llvm/lib/VMCore/Dominators.cpp:1.44 --- llvm/lib/VMCore/Dominators.cpp:1.43 Mon May 12 17:35:13 2003 +++ llvm/lib/VMCore/Dominators.cpp Thu May 22 16:47:17 2003 @@ -12,7 +12,6 @@ #include "llvm/Assembly/Writer.h" #include "Support/DepthFirstIterator.h" #include "Support/SetOperations.h" -using std::set; //===----------------------------------------------------------------------===// // DominatorSet Implementation @@ -127,8 +126,9 @@ } -static std::ostream &operator<<(std::ostream &o, const set &BBs) { - for (set::const_iterator I = BBs.begin(), E = BBs.end(); +static std::ostream &operator<<(std::ostream &o, + const std::set &BBs) { + for (std::set::const_iterator I = BBs.begin(), E = BBs.end(); I != E; ++I) { o << " "; WriteAsOperand(o, *I, false); Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.28 llvm/lib/VMCore/SymbolTable.cpp:1.29 --- llvm/lib/VMCore/SymbolTable.cpp:1.28 Sun Dec 15 10:41:52 2002 +++ llvm/lib/VMCore/SymbolTable.cpp Thu May 22 16:47:17 2003 @@ -7,17 +7,9 @@ #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/InstrTypes.h" #include "Support/StringExtras.h" -#include #include -using std::string; -using std::pair; -using std::make_pair; -using std::map; -using std::cerr; - #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 @@ -41,9 +33,9 @@ for (iterator i = begin(); i != end(); ++i) { for (type_iterator I = i->second.begin(); I != i->second.end(); ++I) if (!isa(I->second) && !isa(I->second)) { - cerr << "Value still in symbol table! Type = '" - << i->first->getDescription() << "' Name = '" - << I->first << "'\n"; + std::cerr << "Value still in symbol table! Type = '" + << i->first->getDescription() << "' Name = '" + << I->first << "'\n"; LeftoverValues = false; } } @@ -56,11 +48,12 @@ // it (or derived from it) that does not already occur in the symbol table for // the specified type. // -string SymbolTable::getUniqueName(const Type *Ty, const string &BaseName) { +std::string SymbolTable::getUniqueName(const Type *Ty, + const std::string &BaseName) { iterator I = find(Ty); if (I == end()) return BaseName; - string TryName = BaseName; + std::string TryName = BaseName; unsigned Counter = 0; type_iterator End = I->second.end(); @@ -72,7 +65,7 @@ // lookup - Returns null on failure... -Value *SymbolTable::lookup(const Type *Ty, const string &Name) { +Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) { iterator I = find(Ty); if (I != end()) { // We have symbols in that plane... type_iterator J = I->second.find(Name); @@ -117,8 +110,8 @@ // if (Plane->first->isAbstract()) { #if DEBUG_ABSTYPE - cerr << "Plane Empty: Removing type: " << Plane->first->getDescription() - << "\n"; + std::cerr << "Plane Empty: Removing type: " + << Plane->first->getDescription() << "\n"; #endif cast(Plane->first)->removeAbstractTypeUser(this); } @@ -132,7 +125,7 @@ const Type *T = cast(Result); if (T->isAbstract()) { #if DEBUG_ABSTYPE - cerr << "Removing abs type from symtab" << T->getDescription() << "\n"; + std::cerr << "Removing abs type from symtab" << T->getDescription()<<"\n"; #endif cast(T)->removeAbstractTypeUser(this); } @@ -144,11 +137,12 @@ // insertEntry - Insert a value into the symbol table with the specified // name... // -void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) { +void SymbolTable::insertEntry(const std::string &Name, const Type *VTy, + Value *V) { // Check to see if there is a naming conflict. If so, rename this value! if (lookup(VTy, Name)) { - string UniqueName = getUniqueName(VTy, Name); + std::string UniqueName = getUniqueName(VTy, Name); assert(InternallyInconsistent == false && "Infinite loop inserting entry!"); InternallyInconsistent = true; V->setName(UniqueName, this); @@ -158,8 +152,8 @@ #if DEBUG_SYMBOL_TABLE dump(); - cerr << " Inserting definition: " << Name << ": " - << VTy->getDescription() << "\n"; + std::cerr << " Inserting definition: " << Name << ": " + << VTy->getDescription() << "\n"; #endif iterator I = find(VTy); @@ -175,7 +169,8 @@ if (VTy->isAbstract()) { cast(VTy)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - cerr << "Added abstract type value: " << VTy->getDescription() << "\n"; + std::cerr << "Added abstract type value: " << VTy->getDescription() + << "\n"; #endif } } @@ -188,7 +183,7 @@ if (T->isAbstract()) { cast(T)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; + std::cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; #endif } } @@ -212,7 +207,8 @@ if (NewType->isAbstract()) { cast(NewType)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - cerr << "[Added] refined to abstype: "<getDescription()<<"\n"; + std::cerr << "[Added] refined to abstype: " << NewType->getDescription() + << "\n"; #endif } } @@ -220,7 +216,7 @@ VarMap &NewPlane = NewTypeIt->second; VarMap &OldPlane = TPI->second; while (!OldPlane.empty()) { - pair V = *OldPlane.begin(); + std::pair V = *OldPlane.begin(); // Check to see if there is already a value in the symbol table that this // would collide with. @@ -281,7 +277,7 @@ // Ok, now we are not referencing the type anymore... take me off your user // list please! #if DEBUG_ABSTYPE - cerr << "Removing type " << OldType->getDescription() << "\n"; + std::cerr << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); @@ -290,7 +286,7 @@ } else if (TPI != end()) { assert(OldType == NewType); #if DEBUG_ABSTYPE - cerr << "Removing SELF type " << OldType->getDescription() << "\n"; + std::cerr << "Removing SELF type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); } @@ -306,14 +302,14 @@ for (VarMap::iterator I = TyPlane.begin(), E = TyPlane.end(); I != E; ++I) if (I->second == (Value*)OldType) { // FIXME when Types aren't const. #if DEBUG_ABSTYPE - cerr << "Removing type " << OldType->getDescription() << "\n"; + std::cerr << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); I->second = (Value*)NewType; // TODO FIXME when types aren't const if (NewType->isAbstract()) { #if DEBUG_ABSTYPE - cerr << "Added type " << NewType->getDescription() << "\n"; + std::cerr << "Added type " << NewType->getDescription() << "\n"; #endif cast(NewType)->addAbstractTypeUser(this); } @@ -321,13 +317,14 @@ } } -static void DumpVal(const pair &V) { +static void DumpVal(const std::pair &V) { std::cout << " '" << V.first << "' = "; V.second->dump(); std::cout << "\n"; } -static void DumpPlane(const pair >&P) { +static void DumpPlane(const std::pair >&P){ std::cout << " Plane: "; P.first->dump(); std::cout << "\n"; From brukman at cs.uiuc.edu Thu May 22 16:50:01 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu May 22 16:50:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp SchedGraph.cpp Message-ID: <200305222149.QAA22155@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.52 -> 1.53 SchedGraph.cpp updated: 1.42 -> 1.43 --- Log message: Cleaned up code layout. No functional changes. --- Diffs of the changes: Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.52 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.53 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.52 Thu May 22 16:24:35 2003 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Thu May 22 16:49:18 2003 @@ -221,16 +221,15 @@ while (cycleNum < S.groups.size() && (*S.groups[cycleNum])[slotNum] == NULL) - { - ++slotNum; - if (slotNum == S.nslots) - { - ++cycleNum; - slotNum = 0; - while(cycleNum < S.groups.size() && S.groups[cycleNum] == NULL) - ++cycleNum; // skip cycles with no instructions - } + { + ++slotNum; + if (slotNum == S.nslots) { + ++cycleNum; + slotNum = 0; + while(cycleNum < S.groups.size() && S.groups[cycleNum] == NULL) + ++cycleNum; // skip cycles with no instructions } + } } template @@ -239,11 +238,10 @@ ScheduleIterator<_NodeType>::operator++() // Preincrement { ++slotNum; - if (slotNum == S.nslots) - { - ++cycleNum; - slotNum = 0; - } + if (slotNum == S.nslots) { + ++cycleNum; + slotNum = 0; + } skipToNextInstr(); return *this; } @@ -574,11 +572,11 @@ // If only one instruction can be issued, do so. if (maxIssue == 1) for (unsigned s=startSlot; s < S.nslots; s++) - if (S.getChoicesForSlot(s).size() > 0) - {// found the one instruction - S.scheduleInstr(*S.getChoicesForSlot(s).begin(), s, curTime); - return; - } + if (S.getChoicesForSlot(s).size() > 0) { + // found the one instruction + S.scheduleInstr(*S.getChoicesForSlot(s).begin(), s, curTime); + return; + } // Otherwise, choose from the choices for each slot // @@ -589,31 +587,28 @@ // If all slots have 0 or multiple choices, pick the first slot with // choices and use its last instruction (just to avoid shifting the vector). unsigned numIssued; - for (numIssued = 0; numIssued < maxIssue; numIssued++) - { - int chosenSlot = -1; + for (numIssued = 0; numIssued < maxIssue; numIssued++) { + int chosenSlot = -1; + for (unsigned s=startSlot; s < S.nslots; s++) + if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() == 1) { + chosenSlot = (int) s; + break; + } + + if (chosenSlot == -1) for (unsigned s=startSlot; s < S.nslots; s++) - if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() == 1) - { - chosenSlot = (int) s; - break; - } - - if (chosenSlot == -1) - for (unsigned s=startSlot; s < S.nslots; s++) - if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() > 0) - { - chosenSlot = (int) s; - break; - } - - if (chosenSlot != -1) - { // Insert the chosen instr in the chosen slot and - // erase it from all slots. - const SchedGraphNode* node= *S.getChoicesForSlot(chosenSlot).begin(); - S.scheduleInstr(node, chosenSlot, curTime); - } + if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() > 0) { + chosenSlot = (int) s; + break; + } + + if (chosenSlot != -1) { + // Insert the chosen instr in the chosen slot and + // erase it from all slots. + const SchedGraphNode* node= *S.getChoicesForSlot(chosenSlot).begin(); + S.scheduleInstr(node, chosenSlot, curTime); } + } assert(numIssued > 0 && "Should not happen when maxIssue > 0!"); } @@ -673,20 +668,19 @@ if (! (*SI)->isDummyNode() && ! S.isScheduled(*SI) && ! S.schedPrio.nodeIsReady(*SI)) - {// successor not scheduled and not marked ready; check *its* preds. + { + // successor not scheduled and not marked ready; check *its* preds. - bool succIsReady = true; - for (sg_pred_const_iterator P=pred_begin(*SI); P != pred_end(*SI); ++P) - if (! (*P)->isDummyNode() - && ! S.isScheduled(*P)) - { - succIsReady = false; - break; - } + bool succIsReady = true; + for (sg_pred_const_iterator P=pred_begin(*SI); P != pred_end(*SI); ++P) + if (! (*P)->isDummyNode() && ! S.isScheduled(*P)) { + succIsReady = false; + break; + } - if (succIsReady) // add the successor to the ready list - S.schedPrio.insertReady(*SI); - } + if (succIsReady) // add the successor to the ready list + S.schedPrio.insertReady(*SI); + } } @@ -710,11 +704,10 @@ unsigned int startSlot = 0; InstrGroup* igroup = S.isched.getIGroup(S.getTime()); for (int s = S.nslots - 1; s >= 0; s--) - if ((*igroup)[s] != NULL) - { - startSlot = s+1; - break; - } + if ((*igroup)[s] != NULL) { + startSlot = s+1; + break; + } // Make sure we pick at most one instruction that would break the group. // Also, if we do pick one, remember which it was. @@ -729,49 +722,42 @@ // we choose them so that subsequent choices will be correctly tested // for feasibility, w.r.t. higher priority choices for the same cycle. // - while (S.getNumChoices() < S.nslots - startSlot) - { - const SchedGraphNode* nextNode=S.schedPrio.getNextHighest(S,S.getTime()); - if (nextNode == NULL) - break; // no more instructions for this cycle - - if (S.getInstrInfo().getNumDelaySlots(nextNode->getOpCode()) > 0) - { - delaySlotInfo = S.getDelaySlotInfoForInstr(nextNode); - if (delaySlotInfo != NULL) - { - if (indexForBreakingNode < S.nslots) - // cannot issue a delayed instr in the same cycle as one - // that breaks the issue group or as another delayed instr - nextNode = NULL; - else - indexForDelayedInstr = S.getNumChoices(); - } - } - else if (S.schedInfo.breaksIssueGroup(nextNode->getOpCode())) - { - if (indexForBreakingNode < S.nslots) - // have a breaking instruction already so throw this one away - nextNode = NULL; - else - indexForBreakingNode = S.getNumChoices(); - } - - if (nextNode != NULL) - { - S.addChoice(nextNode); - - if (S.schedInfo.isSingleIssue(nextNode->getOpCode())) - { - assert(S.getNumChoices() == 1 && - "Prioritizer returned invalid instr for this cycle!"); - break; - } - } - - if (indexForDelayedInstr < S.nslots) - break; // leave the rest for delay slots + while (S.getNumChoices() < S.nslots - startSlot) { + const SchedGraphNode* nextNode=S.schedPrio.getNextHighest(S,S.getTime()); + if (nextNode == NULL) + break; // no more instructions for this cycle + + if (S.getInstrInfo().getNumDelaySlots(nextNode->getOpCode()) > 0) { + delaySlotInfo = S.getDelaySlotInfoForInstr(nextNode); + if (delaySlotInfo != NULL) { + if (indexForBreakingNode < S.nslots) + // cannot issue a delayed instr in the same cycle as one + // that breaks the issue group or as another delayed instr + nextNode = NULL; + else + indexForDelayedInstr = S.getNumChoices(); + } + } else if (S.schedInfo.breaksIssueGroup(nextNode->getOpCode())) { + if (indexForBreakingNode < S.nslots) + // have a breaking instruction already so throw this one away + nextNode = NULL; + else + indexForBreakingNode = S.getNumChoices(); + } + + if (nextNode != NULL) { + S.addChoice(nextNode); + + if (S.schedInfo.isSingleIssue(nextNode->getOpCode())) { + assert(S.getNumChoices() == 1 && + "Prioritizer returned invalid instr for this cycle!"); + break; + } } + + if (indexForDelayedInstr < S.nslots) + break; // leave the rest for delay slots + } assert(S.getNumChoices() <= S.nslots); assert(! (indexForDelayedInstr < S.nslots && @@ -783,176 +769,158 @@ // if (indexForDelayedInstr >= S.nslots && indexForBreakingNode >= S.nslots) - { // No instructions that break the issue group or that have delay slots. - // This is the common case, so handle it separately for efficiency. + { // No instructions that break the issue group or that have delay slots. + // This is the common case, so handle it separately for efficiency. - if (S.getNumChoices() == 1) - { - MachineOpCode opCode = S.getChoice(0)->getOpCode(); - unsigned int s; - for (s=startSlot; s < S.nslots; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - break; - assert(s < S.nslots && "No feasible slot for this opCode?"); - S.addChoiceToSlot(s, S.getChoice(0)); - } - else - { - for (unsigned i=0; i < S.getNumChoices(); i++) - { - MachineOpCode opCode = S.getChoice(i)->getOpCode(); - for (unsigned int s=startSlot; s < S.nslots; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - S.addChoiceToSlot(s, S.getChoice(i)); - } - } + if (S.getNumChoices() == 1) { + MachineOpCode opCode = S.getChoice(0)->getOpCode(); + unsigned int s; + for (s=startSlot; s < S.nslots; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) + break; + assert(s < S.nslots && "No feasible slot for this opCode?"); + S.addChoiceToSlot(s, S.getChoice(0)); + } else { + for (unsigned i=0; i < S.getNumChoices(); i++) { + MachineOpCode opCode = S.getChoice(i)->getOpCode(); + for (unsigned int s=startSlot; s < S.nslots; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) + S.addChoiceToSlot(s, S.getChoice(i)); + } } - else if (indexForDelayedInstr < S.nslots) - { - // There is an instruction that needs delay slots. - // Try to assign that instruction to a higher slot than any other - // instructions in the group, so that its delay slots can go - // right after it. - // - - assert(indexForDelayedInstr == S.getNumChoices() - 1 && - "Instruction with delay slots should be last choice!"); - assert(delaySlotInfo != NULL && "No delay slot info for instr?"); - - const SchedGraphNode* delayedNode = S.getChoice(indexForDelayedInstr); - MachineOpCode delayOpCode = delayedNode->getOpCode(); - unsigned ndelays= S.getInstrInfo().getNumDelaySlots(delayOpCode); - - unsigned delayedNodeSlot = S.nslots; - int highestSlotUsed; - - // Find the last possible slot for the delayed instruction that leaves - // at least `d' slots vacant after it (d = #delay slots) - for (int s = S.nslots-ndelays-1; s >= (int) startSlot; s--) - if (S.schedInfo.instrCanUseSlot(delayOpCode, s)) - { - delayedNodeSlot = s; - break; - } - - highestSlotUsed = -1; - for (unsigned i=0; i < S.getNumChoices() - 1; i++) - { - // Try to assign every other instruction to a lower numbered - // slot than delayedNodeSlot. - MachineOpCode opCode =S.getChoice(i)->getOpCode(); - bool noSlotFound = true; - unsigned int s; - for (s=startSlot; s < delayedNodeSlot; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - { - S.addChoiceToSlot(s, S.getChoice(i)); - noSlotFound = false; - } + } else if (indexForDelayedInstr < S.nslots) { + // There is an instruction that needs delay slots. + // Try to assign that instruction to a higher slot than any other + // instructions in the group, so that its delay slots can go + // right after it. + // + + assert(indexForDelayedInstr == S.getNumChoices() - 1 && + "Instruction with delay slots should be last choice!"); + assert(delaySlotInfo != NULL && "No delay slot info for instr?"); + + const SchedGraphNode* delayedNode = S.getChoice(indexForDelayedInstr); + MachineOpCode delayOpCode = delayedNode->getOpCode(); + unsigned ndelays= S.getInstrInfo().getNumDelaySlots(delayOpCode); + + unsigned delayedNodeSlot = S.nslots; + int highestSlotUsed; + + // Find the last possible slot for the delayed instruction that leaves + // at least `d' slots vacant after it (d = #delay slots) + for (int s = S.nslots-ndelays-1; s >= (int) startSlot; s--) + if (S.schedInfo.instrCanUseSlot(delayOpCode, s)) { + delayedNodeSlot = s; + break; + } + + highestSlotUsed = -1; + for (unsigned i=0; i < S.getNumChoices() - 1; i++) { + // Try to assign every other instruction to a lower numbered + // slot than delayedNodeSlot. + MachineOpCode opCode =S.getChoice(i)->getOpCode(); + bool noSlotFound = true; + unsigned int s; + for (s=startSlot; s < delayedNodeSlot; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) { + S.addChoiceToSlot(s, S.getChoice(i)); + noSlotFound = false; + } - // No slot before `delayedNodeSlot' was found for this opCode - // Use a later slot, and allow some delay slots to fall in - // the next cycle. - if (noSlotFound) - for ( ; s < S.nslots; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - { - S.addChoiceToSlot(s, S.getChoice(i)); - break; - } + // No slot before `delayedNodeSlot' was found for this opCode + // Use a later slot, and allow some delay slots to fall in + // the next cycle. + if (noSlotFound) + for ( ; s < S.nslots; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) { + S.addChoiceToSlot(s, S.getChoice(i)); + break; + } - assert(s < S.nslots && "No feasible slot for instruction?"); + assert(s < S.nslots && "No feasible slot for instruction?"); - highestSlotUsed = std::max(highestSlotUsed, (int) s); - } + highestSlotUsed = std::max(highestSlotUsed, (int) s); + } - assert(highestSlotUsed <= (int) S.nslots-1 && "Invalid slot used?"); + assert(highestSlotUsed <= (int) S.nslots-1 && "Invalid slot used?"); - // We will put the delayed node in the first slot after the - // highest slot used. But we just mark that for now, and - // schedule it separately because we want to schedule the delay - // slots for the node at the same time. - cycles_t dcycle = S.getTime(); - unsigned int dslot = highestSlotUsed + 1; - if (dslot == S.nslots) - { - dslot = 0; - ++dcycle; - } - delaySlotInfo->recordChosenSlot(dcycle, dslot); - getDelaySlotInfo = delaySlotInfo; - } - else - { // There is an instruction that breaks the issue group. - // For such an instruction, assign to the last possible slot in - // the current group, and then don't assign any other instructions - // to later slots. - assert(indexForBreakingNode < S.nslots); - const SchedGraphNode* breakingNode=S.getChoice(indexForBreakingNode); - unsigned breakingSlot = INT_MAX; - unsigned int nslotsToUse = S.nslots; + // We will put the delayed node in the first slot after the + // highest slot used. But we just mark that for now, and + // schedule it separately because we want to schedule the delay + // slots for the node at the same time. + cycles_t dcycle = S.getTime(); + unsigned int dslot = highestSlotUsed + 1; + if (dslot == S.nslots) { + dslot = 0; + ++dcycle; + } + delaySlotInfo->recordChosenSlot(dcycle, dslot); + getDelaySlotInfo = delaySlotInfo; + } else { + // There is an instruction that breaks the issue group. + // For such an instruction, assign to the last possible slot in + // the current group, and then don't assign any other instructions + // to later slots. + assert(indexForBreakingNode < S.nslots); + const SchedGraphNode* breakingNode=S.getChoice(indexForBreakingNode); + unsigned breakingSlot = INT_MAX; + unsigned int nslotsToUse = S.nslots; - // Find the last possible slot for this instruction. - for (int s = S.nslots-1; s >= (int) startSlot; s--) - if (S.schedInfo.instrCanUseSlot(breakingNode->getOpCode(), s)) - { - breakingSlot = s; - break; - } - assert(breakingSlot < S.nslots && - "No feasible slot for `breakingNode'?"); - - // Higher priority instructions than the one that breaks the group: - // These can be assigned to all slots, but will be assigned only - // to earlier slots if possible. - for (unsigned i=0; - i < S.getNumChoices() && i < indexForBreakingNode; i++) - { - MachineOpCode opCode =S.getChoice(i)->getOpCode(); + // Find the last possible slot for this instruction. + for (int s = S.nslots-1; s >= (int) startSlot; s--) + if (S.schedInfo.instrCanUseSlot(breakingNode->getOpCode(), s)) { + breakingSlot = s; + break; + } + assert(breakingSlot < S.nslots && + "No feasible slot for `breakingNode'?"); + + // Higher priority instructions than the one that breaks the group: + // These can be assigned to all slots, but will be assigned only + // to earlier slots if possible. + for (unsigned i=0; + i < S.getNumChoices() && i < indexForBreakingNode; i++) + { + MachineOpCode opCode =S.getChoice(i)->getOpCode(); - // If a higher priority instruction cannot be assigned to - // any earlier slots, don't schedule the breaking instruction. - // - bool foundLowerSlot = false; - nslotsToUse = S.nslots; // May be modified in the loop - for (unsigned int s=startSlot; s < nslotsToUse; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - { - if (breakingSlot < S.nslots && s < breakingSlot) - { - foundLowerSlot = true; - nslotsToUse = breakingSlot; // RESETS LOOP UPPER BOUND! - } + // If a higher priority instruction cannot be assigned to + // any earlier slots, don't schedule the breaking instruction. + // + bool foundLowerSlot = false; + nslotsToUse = S.nslots; // May be modified in the loop + for (unsigned int s=startSlot; s < nslotsToUse; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) { + if (breakingSlot < S.nslots && s < breakingSlot) { + foundLowerSlot = true; + nslotsToUse = breakingSlot; // RESETS LOOP UPPER BOUND! + } - S.addChoiceToSlot(s, S.getChoice(i)); - } + S.addChoiceToSlot(s, S.getChoice(i)); + } - if (!foundLowerSlot) - breakingSlot = INT_MAX; // disable breaking instr - } - - // Assign the breaking instruction (if any) to a single slot - // Otherwise, just ignore the instruction. It will simply be - // scheduled in a later cycle. - if (breakingSlot < S.nslots) - { - S.addChoiceToSlot(breakingSlot, breakingNode); - nslotsToUse = breakingSlot; - } - else - nslotsToUse = S.nslots; + if (!foundLowerSlot) + breakingSlot = INT_MAX; // disable breaking instr + } + + // Assign the breaking instruction (if any) to a single slot + // Otherwise, just ignore the instruction. It will simply be + // scheduled in a later cycle. + if (breakingSlot < S.nslots) { + S.addChoiceToSlot(breakingSlot, breakingNode); + nslotsToUse = breakingSlot; + } else + nslotsToUse = S.nslots; - // For lower priority instructions than the one that breaks the - // group, only assign them to slots lower than the breaking slot. - // Otherwise, just ignore the instruction. - for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++) - { - MachineOpCode opCode = S.getChoice(i)->getOpCode(); - for (unsigned int s=startSlot; s < nslotsToUse; s++) - if (S.schedInfo.instrCanUseSlot(opCode, s)) - S.addChoiceToSlot(s, S.getChoice(i)); - } - } // endif (no delay slots and no breaking slots) + // For lower priority instructions than the one that breaks the + // group, only assign them to slots lower than the breaking slot. + // Otherwise, just ignore the instruction. + for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++) { + MachineOpCode opCode = S.getChoice(i)->getOpCode(); + for (unsigned int s=startSlot; s < nslotsToUse; s++) + if (S.schedInfo.instrCanUseSlot(opCode, s)) + S.addChoiceToSlot(s, S.getChoice(i)); + } + } // endif (no delay slots and no breaking slots) return S.getNumChoices(); } @@ -970,11 +938,10 @@ // Choose up to `nslots' feasible instructions and their possible slots. unsigned numIssued = FindSlotChoices(S, getDelaySlotInfo); - while (numIssued == 0) - { - S.updateTime(S.getTime()+1); - numIssued = FindSlotChoices(S, getDelaySlotInfo); - } + while (numIssued == 0) { + S.updateTime(S.getTime()+1); + numIssued = FindSlotChoices(S, getDelaySlotInfo); + } AssignInstructionsToSlots(S, numIssued); @@ -982,22 +949,19 @@ numIssued += getDelaySlotInfo->scheduleDelayedNode(S); // Print trace of scheduled instructions before newly ready ones - if (SchedDebugLevel >= Sched_PrintSchedTrace) - { - for (cycles_t c = firstCycle; c <= S.getTime(); c++) - { - std::cerr << " Cycle " << (long)c <<" : Scheduled instructions:\n"; - const InstrGroup* igroup = S.isched.getIGroup(c); - for (unsigned int s=0; s < S.nslots; s++) - { - std::cerr << " "; - if ((*igroup)[s] != NULL) - std::cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; - else - std::cerr << "\n"; - } - } + if (SchedDebugLevel >= Sched_PrintSchedTrace) { + for (cycles_t c = firstCycle; c <= S.getTime(); c++) { + std::cerr << " Cycle " << (long)c <<" : Scheduled instructions:\n"; + const InstrGroup* igroup = S.isched.getIGroup(c); + for (unsigned int s=0; s < S.nslots; s++) { + std::cerr << " "; + if ((*igroup)[s] != NULL) + std::cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; + else + std::cerr << "\n"; + } } + } return numIssued; } @@ -1011,40 +975,37 @@ S.schedPrio.initialize(); - while ((N = S.schedPrio.getNumReady()) > 0) - { - cycles_t nextCycle = S.getTime(); - - // Choose one group of instructions for a cycle, plus any delay slot - // instructions (which may overflow into successive cycles). - // This will advance S.getTime() to the last cycle in which - // instructions are actually issued. - // - unsigned numIssued = ChooseOneGroup(S); - assert(numIssued > 0 && "Deadlock in list scheduling algorithm?"); + while ((N = S.schedPrio.getNumReady()) > 0) { + cycles_t nextCycle = S.getTime(); - // Notify the priority manager of scheduled instructions and mark - // any successors that may now be ready - // - for (cycles_t c = nextCycle; c <= S.getTime(); c++) - { - const InstrGroup* igroup = S.isched.getIGroup(c); - for (unsigned int s=0; s < S.nslots; s++) - if ((node = (*igroup)[s]) != NULL) - { - S.schedPrio.issuedReadyNodeAt(S.getTime(), node); - MarkSuccessorsReady(S, node); - } + // Choose one group of instructions for a cycle, plus any delay slot + // instructions (which may overflow into successive cycles). + // This will advance S.getTime() to the last cycle in which + // instructions are actually issued. + // + unsigned numIssued = ChooseOneGroup(S); + assert(numIssued > 0 && "Deadlock in list scheduling algorithm?"); + + // Notify the priority manager of scheduled instructions and mark + // any successors that may now be ready + // + for (cycles_t c = nextCycle; c <= S.getTime(); c++) { + const InstrGroup* igroup = S.isched.getIGroup(c); + for (unsigned int s=0; s < S.nslots; s++) + if ((node = (*igroup)[s]) != NULL) { + S.schedPrio.issuedReadyNodeAt(S.getTime(), node); + MarkSuccessorsReady(S, node); } - - // Move to the next the next earliest cycle for which - // an instruction can be issued, or the next earliest in which - // one will be ready, or to the next cycle, whichever is latest. - // - S.updateTime(std::max(S.getTime() + 1, - std::max(S.getEarliestIssueTime(), - S.schedPrio.getEarliestReadyTime()))); } + + // Move to the next the next earliest cycle for which + // an instruction can be issued, or the next earliest in which + // one will be ready, or to the next cycle, whichever is latest. + // + S.updateTime(std::max(S.getTime() + 1, + std::max(S.getEarliestIssueTime(), + S.schedPrio.getEarliestReadyTime()))); + } } @@ -1092,22 +1053,21 @@ // instruction can be reordered relative to the branch. We simply check // if the instr. has only 1 outgoing edge, viz., a CD edge to the branch. // - if (nodeIsPredecessor) - { - bool onlyCDEdgeToBranch = true; - for (SchedGraphNode::const_iterator OEI = node->beginOutEdges(); - OEI != node->endOutEdges(); ++OEI) - if (! (*OEI)->getSink()->isDummyNode() - && ((*OEI)->getSink() != brNode - || (*OEI)->getDepType() != SchedGraphEdge::CtrlDep)) - { - onlyCDEdgeToBranch = false; - break; - } + if (nodeIsPredecessor) { + bool onlyCDEdgeToBranch = true; + for (SchedGraphNode::const_iterator OEI = node->beginOutEdges(); + OEI != node->endOutEdges(); ++OEI) + if (! (*OEI)->getSink()->isDummyNode() + && ((*OEI)->getSink() != brNode + || (*OEI)->getDepType() != SchedGraphEdge::CtrlDep)) + { + onlyCDEdgeToBranch = false; + break; + } - if (!onlyCDEdgeToBranch) - return false; - } + if (!onlyCDEdgeToBranch) + return false; + } return true; } @@ -1120,17 +1080,16 @@ const SchedGraphNode* brNode, bool nodeIsPredecessor) { - if (nodeIsPredecessor) - { // If node is in the same basic block (i.e., preceeds brNode), - // remove it and all its incident edges from the graph. Make sure we - // add dummy edges for pred/succ nodes that become entry/exit nodes. - graph->eraseIncidentEdges(node, /*addDummyEdges*/ true); - } - else - { // If the node was from a target block, add the node to the graph - // and add a CD edge from brNode to node. - assert(0 && "NOT IMPLEMENTED YET"); - } + if (nodeIsPredecessor) { + // If node is in the same basic block (i.e., preceeds brNode), + // remove it and all its incident edges from the graph. Make sure we + // add dummy edges for pred/succ nodes that become entry/exit nodes. + graph->eraseIncidentEdges(node, /*addDummyEdges*/ true); + } else { + // If the node was from a target block, add the node to the graph + // and add a CD edge from brNode to node. + assert(0 && "NOT IMPLEMENTED YET"); + } DelaySlotInfo* dinfo = S.getDelaySlotInfoForInstr(brNode, /*create*/ true); dinfo->addDelayNode(node); @@ -1161,37 +1120,36 @@ if (! (*P)->isDummyNode() && ! mii.isNop((*P)->getOpCode()) && NodeCanFillDelaySlot(S, *P, brNode, /*pred*/ true)) - { - if (mii.maxLatency((*P)->getOpCode()) > 1) - mdelayNodeVec.push_back(*P); - else - sdelayNodeVec.push_back(*P); - } + { + if (mii.maxLatency((*P)->getOpCode()) > 1) + mdelayNodeVec.push_back(*P); + else + sdelayNodeVec.push_back(*P); + } // If not enough single-cycle instructions were found, select the // lowest-latency multi-cycle instructions and use them. // Note that this is the most efficient code when only 1 (or even 2) // values need to be selected. // - while (sdelayNodeVec.size() < ndelays && mdelayNodeVec.size() > 0) + while (sdelayNodeVec.size() < ndelays && mdelayNodeVec.size() > 0) { + unsigned lmin = + mii.maxLatency(mdelayNodeVec[0]->getOpCode()); + unsigned minIndex = 0; + for (unsigned i=1; i < mdelayNodeVec.size(); i++) { - unsigned lmin = - mii.maxLatency(mdelayNodeVec[0]->getOpCode()); - unsigned minIndex = 0; - for (unsigned i=1; i < mdelayNodeVec.size(); i++) - { - unsigned li = - mii.maxLatency(mdelayNodeVec[i]->getOpCode()); - if (lmin >= li) - { - lmin = li; - minIndex = i; - } - } - sdelayNodeVec.push_back(mdelayNodeVec[minIndex]); - if (sdelayNodeVec.size() < ndelays) // avoid the last erase! - mdelayNodeVec.erase(mdelayNodeVec.begin() + minIndex); + unsigned li = + mii.maxLatency(mdelayNodeVec[i]->getOpCode()); + if (lmin >= li) + { + lmin = li; + minIndex = i; + } } + sdelayNodeVec.push_back(mdelayNodeVec[minIndex]); + if (sdelayNodeVec.size() < ndelays) // avoid the last erase! + mdelayNodeVec.erase(mdelayNodeVec.begin() + minIndex); + } } @@ -1202,6 +1160,7 @@ // static void ReplaceNopsWithUsefulInstr(SchedulingManager& S, SchedGraphNode* node, + // FIXME: passing vector BY VALUE!!! std::vector sdelayNodeVec, SchedGraph* graph) { @@ -1234,21 +1193,20 @@ if (mii.isNop(MBB[i]->getOpCode())) if (sdelayNodeVec.size() < ndelays) sdelayNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); - else - { - nopNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); + else { + nopNodeVec.push_back(graph->getGraphNodeForInstr(MBB[i])); - //remove the MI from the Machine Code For Instruction - TerminatorInst *TI = MBB.getBasicBlock()->getTerminator(); - MachineCodeForInstruction& llvmMvec = - MachineCodeForInstruction::get((Instruction *)TI); + //remove the MI from the Machine Code For Instruction + TerminatorInst *TI = MBB.getBasicBlock()->getTerminator(); + MachineCodeForInstruction& llvmMvec = + MachineCodeForInstruction::get((Instruction *)TI); - for(MachineCodeForInstruction::iterator mciI=llvmMvec.begin(), - mciE=llvmMvec.end(); mciI!=mciE; ++mciI){ - if (*mciI==MBB[i]) - llvmMvec.erase(mciI); - } - } + for(MachineCodeForInstruction::iterator mciI=llvmMvec.begin(), + mciE=llvmMvec.end(); mciI!=mciE; ++mciI){ + if (*mciI==MBB[i]) + llvmMvec.erase(mciI); + } + } assert(sdelayNodeVec.size() >= ndelays); @@ -1290,33 +1248,32 @@ const MachineInstr* brInstr = NULL; if (termInstr->getOpcode() != Instruction::Ret) + { + // To find instructions that need delay slots without searching the full + // machine code, we assume that the only delayed instructions are CALLs + // or instructions generated for the terminator inst. + // Find the first branch instr in the sequence of machine instrs for term + // + unsigned first = 0; + while (first < termMvec.size() && + ! mii.isBranch(termMvec[first]->getOpCode())) { - // To find instructions that need delay slots without searching the full - // machine code, we assume that the only delayed instructions are CALLs - // or instructions generated for the terminator inst. - // Find the first branch instr in the sequence of machine instrs for term - // - unsigned first = 0; - while (first < termMvec.size() && - ! mii.isBranch(termMvec[first]->getOpCode())) - { - ++first; - } - assert(first < termMvec.size() && - "No branch instructions for BR? Ok, but weird! Delete assertion."); + ++first; + } + assert(first < termMvec.size() && + "No branch instructions for BR? Ok, but weird! Delete assertion."); - brInstr = (first < termMvec.size())? termMvec[first] : NULL; + brInstr = (first < termMvec.size())? termMvec[first] : NULL; - // Compute a vector of the nodes chosen for delay slots and then - // mark delay slots to replace NOPs with these useful instructions. - // - if (brInstr != NULL) - { - SchedGraphNode* brNode = graph->getGraphNodeForInstr(brInstr); - FindUsefulInstructionsForDelaySlots(S, brNode, delayNodeVec); - ReplaceNopsWithUsefulInstr(S, brNode, delayNodeVec, graph); - } + // Compute a vector of the nodes chosen for delay slots and then + // mark delay slots to replace NOPs with these useful instructions. + // + if (brInstr != NULL) { + SchedGraphNode* brNode = graph->getGraphNodeForInstr(brInstr); + FindUsefulInstructionsForDelaySlots(S, brNode, delayNodeVec); + ReplaceNopsWithUsefulInstr(S, brNode, delayNodeVec, graph); } + } // Also mark delay slots for other delayed instructions to hold NOPs. // Simply passing in an empty delayNodeVec will have this effect. @@ -1325,10 +1282,10 @@ for (unsigned i=0; i < MBB.size(); ++i) if (MBB[i] != brInstr && mii.getNumDelaySlots(MBB[i]->getOpCode()) > 0) - { - SchedGraphNode* node = graph->getGraphNodeForInstr(MBB[i]); - ReplaceNopsWithUsefulInstr(S, node, delayNodeVec, graph); - } + { + SchedGraphNode* node = graph->getGraphNodeForInstr(MBB[i]); + ReplaceNopsWithUsefulInstr(S, node, delayNodeVec, graph); + } } @@ -1347,35 +1304,32 @@ S.scheduleInstr(brNode, nextSlot, nextTime); - for (unsigned d=0; d < ndelays; d++) - { - ++nextSlot; - if (nextSlot == S.nslots) - { - nextSlot = 0; - nextTime++; - } - - // Find the first feasible instruction for this delay slot - // Note that we only check for issue restrictions here. - // We do *not* check for flow dependences but rely on pipeline - // interlocks to resolve them. Machines without interlocks - // will require this code to be modified. - for (unsigned i=0; i < delayNodeVec.size(); i++) - { - const SchedGraphNode* dnode = delayNodeVec[i]; - if ( ! S.isScheduled(dnode) - && S.schedInfo.instrCanUseSlot(dnode->getOpCode(), nextSlot) - && instrIsFeasible(S, dnode->getOpCode())) - { - assert(S.getInstrInfo().hasOperandInterlock(dnode->getOpCode()) - && "Instructions without interlocks not yet supported " - "when filling branch delay slots"); - S.scheduleInstr(dnode, nextSlot, nextTime); - break; - } - } + for (unsigned d=0; d < ndelays; d++) { + ++nextSlot; + if (nextSlot == S.nslots) { + nextSlot = 0; + nextTime++; + } + + // Find the first feasible instruction for this delay slot + // Note that we only check for issue restrictions here. + // We do *not* check for flow dependences but rely on pipeline + // interlocks to resolve them. Machines without interlocks + // will require this code to be modified. + for (unsigned i=0; i < delayNodeVec.size(); i++) { + const SchedGraphNode* dnode = delayNodeVec[i]; + if ( ! S.isScheduled(dnode) + && S.schedInfo.instrCanUseSlot(dnode->getOpCode(), nextSlot) + && instrIsFeasible(S, dnode->getOpCode())) + { + assert(S.getInstrInfo().hasOperandInterlock(dnode->getOpCode()) + && "Instructions without interlocks not yet supported " + "when filling branch delay slots"); + S.scheduleInstr(dnode, nextSlot, nextTime); + break; + } } + } // Update current time if delay slots overflowed into later cycles. // Do this here because we know exactly which cycle is the last cycle @@ -1388,20 +1342,18 @@ nextSlot = delayedNodeSlotNum; nextTime = delayedNodeCycle; for (unsigned i=0; i < delayNodeVec.size(); i++) - if (! S.isScheduled(delayNodeVec[i])) - { - do { // find the next empty slot - ++nextSlot; - if (nextSlot == S.nslots) - { - nextSlot = 0; - nextTime++; - } - } while (S.isched.getInstr(nextSlot, nextTime) != NULL); + if (! S.isScheduled(delayNodeVec[i])) { + do { // find the next empty slot + ++nextSlot; + if (nextSlot == S.nslots) { + nextSlot = 0; + nextTime++; + } + } while (S.isched.getInstr(nextSlot, nextTime) != NULL); - S.scheduleInstr(delayNodeVec[i], nextSlot, nextTime); - break; - } + S.scheduleInstr(delayNodeVec[i], nextSlot, nextTime); + break; + } return 1 + ndelays; } @@ -1507,35 +1459,33 @@ { SchedGraphSet graphSet(&F, target); - if (SchedDebugLevel >= Sched_PrintSchedGraphs) - { + if (SchedDebugLevel >= Sched_PrintSchedGraphs) { std::cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n"; graphSet.dump(); } for (SchedGraphSet::const_iterator GI=graphSet.begin(), GE=graphSet.end(); GI != GE; ++GI) - { - SchedGraph* graph = (*GI); - MachineBasicBlock &MBB = graph->getBasicBlock(); + { + SchedGraph* graph = (*GI); + MachineBasicBlock &MBB = graph->getBasicBlock(); - if (SchedDebugLevel >= Sched_PrintSchedTrace) - std::cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; + if (SchedDebugLevel >= Sched_PrintSchedTrace) + std::cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; - // expensive! - SchedPriorities schedPrio(&F, graph, getAnalysis()); - SchedulingManager S(target, graph, schedPrio); + // expensive! + SchedPriorities schedPrio(&F, graph, getAnalysis()); + SchedulingManager S(target, graph, schedPrio); - ChooseInstructionsForDelaySlots(S, MBB, graph); // modifies graph - ForwardListSchedule(S); // computes schedule in S - RecordSchedule(MBB, S); // records schedule in BB - } + ChooseInstructionsForDelaySlots(S, MBB, graph); // modifies graph + ForwardListSchedule(S); // computes schedule in S + RecordSchedule(MBB, S); // records schedule in BB + } - if (SchedDebugLevel >= Sched_PrintMachineCode) - { - std::cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; - MachineFunction::get(&F).dump(); - } + if (SchedDebugLevel >= Sched_PrintMachineCode) { + std::cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; + MachineFunction::get(&F).dump(); + } return false; } Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.42 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.43 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.42 Thu May 22 16:24:35 2003 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Thu May 22 16:49:18 2003 @@ -249,20 +249,21 @@ // Delete and disconnect all in-edges for the node for (SchedGraphNode::iterator I = node->beginInEdges(); I != node->endInEdges(); ++I) - { - SchedGraphNode* srcNode = (*I)->getSrc(); - srcNode->removeOutEdge(*I); - delete *I; - - if (addDummyEdges && - srcNode != getRoot() && - srcNode->beginOutEdges() == srcNode->endOutEdges()) - { // srcNode has no more out edges, so add an edge to dummy EXIT node - assert(node != getLeaf() && "Adding edge that was just removed?"); - (void) new SchedGraphEdge(srcNode, getLeaf(), - SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0); - } + { + SchedGraphNode* srcNode = (*I)->getSrc(); + srcNode->removeOutEdge(*I); + delete *I; + + if (addDummyEdges && + srcNode != getRoot() && + srcNode->beginOutEdges() == srcNode->endOutEdges()) + { + // srcNode has no more out edges, so add an edge to dummy EXIT node + assert(node != getLeaf() && "Adding edge that was just removed?"); + (void) new SchedGraphEdge(srcNode, getLeaf(), + SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0); } + } node->inEdges.clear(); } @@ -273,20 +274,20 @@ // Delete and disconnect all out-edges for the node for (SchedGraphNode::iterator I = node->beginOutEdges(); I != node->endOutEdges(); ++I) - { - SchedGraphNode* sinkNode = (*I)->getSink(); - sinkNode->removeInEdge(*I); - delete *I; - - if (addDummyEdges && - sinkNode != getLeaf() && - sinkNode->beginInEdges() == sinkNode->endInEdges()) - { //sinkNode has no more in edges, so add an edge from dummy ENTRY node - assert(node != getRoot() && "Adding edge that was just removed?"); - (void) new SchedGraphEdge(getRoot(), sinkNode, - SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0); - } + { + SchedGraphNode* sinkNode = (*I)->getSink(); + sinkNode->removeInEdge(*I); + delete *I; + + if (addDummyEdges && + sinkNode != getLeaf() && + sinkNode->beginInEdges() == sinkNode->endInEdges()) + { //sinkNode has no more in edges, so add an edge from dummy ENTRY node + assert(node != getRoot() && "Adding edge that was just removed?"); + (void) new SchedGraphEdge(getRoot(), sinkNode, + SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0); } + } node->outEdges.clear(); } @@ -305,16 +306,16 @@ assert(graphRoot->outEdges.size() == 0); for (const_iterator I=begin(); I != end(); ++I) - { - SchedGraphNode* node = (*I).second; - assert(node != graphRoot && node != graphLeaf); - if (node->beginInEdges() == node->endInEdges()) - (void) new SchedGraphEdge(graphRoot, node, SchedGraphEdge::CtrlDep, - SchedGraphEdge::NonDataDep, 0); - if (node->beginOutEdges() == node->endOutEdges()) - (void) new SchedGraphEdge(node, graphLeaf, SchedGraphEdge::CtrlDep, - SchedGraphEdge::NonDataDep, 0); - } + { + SchedGraphNode* node = (*I).second; + assert(node != graphRoot && node != graphLeaf); + if (node->beginInEdges() == node->endInEdges()) + (void) new SchedGraphEdge(graphRoot, node, SchedGraphEdge::CtrlDep, + SchedGraphEdge::NonDataDep, 0); + if (node->beginOutEdges() == node->endOutEdges()) + (void) new SchedGraphEdge(node, graphLeaf, SchedGraphEdge::CtrlDep, + SchedGraphEdge::NonDataDep, 0); + } } @@ -343,65 +344,65 @@ // Use a latency of 0 because we only need to prevent out-of-order issue. // for (unsigned i = termMvec.size(); i > first+1; --i) - { - SchedGraphNode* toNode = getGraphNodeForInstr(termMvec[i-1]); - assert(toNode && "No node for instr generated for branch/ret?"); - - for (unsigned j = i-1; j != 0; --j) - if (mii.isBranch(termMvec[j-1]->getOpCode()) || - mii.isReturn(termMvec[j-1]->getOpCode())) - { - SchedGraphNode* brNode = getGraphNodeForInstr(termMvec[j-1]); - assert(brNode && "No node for instr generated for branch/ret?"); - (void) new SchedGraphEdge(brNode, toNode, SchedGraphEdge::CtrlDep, - SchedGraphEdge::NonDataDep, 0); - break; // only one incoming edge is enough - } - } + { + SchedGraphNode* toNode = getGraphNodeForInstr(termMvec[i-1]); + assert(toNode && "No node for instr generated for branch/ret?"); + + for (unsigned j = i-1; j != 0; --j) + if (mii.isBranch(termMvec[j-1]->getOpCode()) || + mii.isReturn(termMvec[j-1]->getOpCode())) + { + SchedGraphNode* brNode = getGraphNodeForInstr(termMvec[j-1]); + assert(brNode && "No node for instr generated for branch/ret?"); + (void) new SchedGraphEdge(brNode, toNode, SchedGraphEdge::CtrlDep, + SchedGraphEdge::NonDataDep, 0); + break; // only one incoming edge is enough + } + } // Add CD edges from each instruction preceding the first branch // to the first branch. Use a latency of 0 as above. // for (unsigned i = first; i != 0; --i) - { - SchedGraphNode* fromNode = getGraphNodeForInstr(termMvec[i-1]); - assert(fromNode && "No node for instr generated for branch?"); - (void) new SchedGraphEdge(fromNode, firstBrNode, SchedGraphEdge::CtrlDep, - SchedGraphEdge::NonDataDep, 0); - } + { + SchedGraphNode* fromNode = getGraphNodeForInstr(termMvec[i-1]); + assert(fromNode && "No node for instr generated for branch?"); + (void) new SchedGraphEdge(fromNode, firstBrNode, SchedGraphEdge::CtrlDep, + SchedGraphEdge::NonDataDep, 0); + } // Now add CD edges to the first branch instruction in the sequence from // all preceding instructions in the basic block. Use 0 latency again. // for (unsigned i=0, N=MBB.size(); i < N; i++) - { - if (MBB[i] == termMvec[first]) // reached the first branch - break; - - SchedGraphNode* fromNode = this->getGraphNodeForInstr(MBB[i]); - if (fromNode == NULL) - continue; // dummy instruction, e.g., PHI - - (void) new SchedGraphEdge(fromNode, firstBrNode, + { + if (MBB[i] == termMvec[first]) // reached the first branch + break; + + SchedGraphNode* fromNode = this->getGraphNodeForInstr(MBB[i]); + if (fromNode == NULL) + continue; // dummy instruction, e.g., PHI + + (void) new SchedGraphEdge(fromNode, firstBrNode, + SchedGraphEdge::CtrlDep, + SchedGraphEdge::NonDataDep, 0); + + // If we find any other machine instructions (other than due to + // the terminator) that also have delay slots, add an outgoing edge + // from the instruction to the instructions in the delay slots. + // + unsigned d = mii.getNumDelaySlots(MBB[i]->getOpCode()); + assert(i+d < N && "Insufficient delay slots for instruction?"); + + for (unsigned j=1; j <= d; j++) + { + SchedGraphNode* toNode = this->getGraphNodeForInstr(MBB[i+j]); + assert(toNode && "No node for machine instr in delay slot?"); + (void) new SchedGraphEdge(fromNode, toNode, SchedGraphEdge::CtrlDep, SchedGraphEdge::NonDataDep, 0); - - // If we find any other machine instructions (other than due to - // the terminator) that also have delay slots, add an outgoing edge - // from the instruction to the instructions in the delay slots. - // - unsigned d = mii.getNumDelaySlots(MBB[i]->getOpCode()); - assert(i+d < N && "Insufficient delay slots for instruction?"); - - for (unsigned j=1; j <= d; j++) - { - SchedGraphNode* toNode = this->getGraphNodeForInstr(MBB[i+j]); - assert(toNode && "No node for machine instr in delay slot?"); - (void) new SchedGraphEdge(fromNode, toNode, - SchedGraphEdge::CtrlDep, - SchedGraphEdge::NonDataDep, 0); - } } + } } static const int SG_LOAD_REF = 0; @@ -437,24 +438,24 @@ // so simply look at all pairs i]>. // for (unsigned im=0, NM=memNodeVec.size(); im < NM; im++) - { - MachineOpCode fromOpCode = memNodeVec[im]->getOpCode(); - int fromType = mii.isCall(fromOpCode)? SG_CALL_REF - : mii.isLoad(fromOpCode)? SG_LOAD_REF - : SG_STORE_REF; - for (unsigned jm=im+1; jm < NM; jm++) - { - MachineOpCode toOpCode = memNodeVec[jm]->getOpCode(); - int toType = mii.isCall(toOpCode)? SG_CALL_REF - : mii.isLoad(toOpCode)? SG_LOAD_REF - : SG_STORE_REF; + { + MachineOpCode fromOpCode = memNodeVec[im]->getOpCode(); + int fromType = mii.isCall(fromOpCode)? SG_CALL_REF + : mii.isLoad(fromOpCode)? SG_LOAD_REF + : SG_STORE_REF; + for (unsigned jm=im+1; jm < NM; jm++) + { + MachineOpCode toOpCode = memNodeVec[jm]->getOpCode(); + int toType = mii.isCall(toOpCode)? SG_CALL_REF + : mii.isLoad(toOpCode)? SG_LOAD_REF + : SG_STORE_REF; - if (fromType != SG_LOAD_REF || toType != SG_LOAD_REF) - (void) new SchedGraphEdge(memNodeVec[im], memNodeVec[jm], - SchedGraphEdge::MemoryDep, - SG_DepOrderArray[fromType][toType], 1); - } + if (fromType != SG_LOAD_REF || toType != SG_LOAD_REF) + (void) new SchedGraphEdge(memNodeVec[im], memNodeVec[jm], + SchedGraphEdge::MemoryDep, + SG_DepOrderArray[fromType][toType], 1); } + } } // Add edges from/to CC reg instrs to/from call instrs. @@ -484,24 +485,23 @@ int lastCallNodeIdx = -1; for (unsigned i=0, N=bbMvec.size(); i < N; i++) if (mii.isCall(bbMvec[i]->getOpCode())) - { - ++lastCallNodeIdx; - for ( ; lastCallNodeIdx < (int)callNodeVec.size(); ++lastCallNodeIdx) - if (callNodeVec[lastCallNodeIdx]->getMachineInstr() == bbMvec[i]) - break; - assert(lastCallNodeIdx < (int)callNodeVec.size() && "Missed Call?"); - } - else if (mii.isCCInstr(bbMvec[i]->getOpCode())) - { // Add incoming/outgoing edges from/to preceding/later calls - SchedGraphNode* ccNode = this->getGraphNodeForInstr(bbMvec[i]); - int j=0; - for ( ; j <= lastCallNodeIdx; j++) - (void) new SchedGraphEdge(callNodeVec[j], ccNode, - MachineCCRegsRID, 0); - for ( ; j < (int) callNodeVec.size(); j++) - (void) new SchedGraphEdge(ccNode, callNodeVec[j], - MachineCCRegsRID, 0); - } + { + ++lastCallNodeIdx; + for ( ; lastCallNodeIdx < (int)callNodeVec.size(); ++lastCallNodeIdx) + if (callNodeVec[lastCallNodeIdx]->getMachineInstr() == bbMvec[i]) + break; + assert(lastCallNodeIdx < (int)callNodeVec.size() && "Missed Call?"); + } else if (mii.isCCInstr(bbMvec[i]->getOpCode())) { + // Add incoming/outgoing edges from/to preceding/later calls + SchedGraphNode* ccNode = this->getGraphNodeForInstr(bbMvec[i]); + int j=0; + for ( ; j <= lastCallNodeIdx; j++) + (void) new SchedGraphEdge(callNodeVec[j], ccNode, + MachineCCRegsRID, 0); + for ( ; j < (int) callNodeVec.size(); j++) + (void) new SchedGraphEdge(ccNode, callNodeVec[j], + MachineCCRegsRID, 0); + } } @@ -517,47 +517,43 @@ // for (RegToRefVecMap::iterator I = regToRefVecMap.begin(); I != regToRefVecMap.end(); ++I) - { - int regNum = (*I).first; - RefVec& regRefVec = (*I).second; - - // regRefVec is ordered by control flow order in the basic block - for (unsigned i=0; i < regRefVec.size(); ++i) - { - SchedGraphNode* node = regRefVec[i].first; - unsigned int opNum = regRefVec[i].second; - bool isDef = node->getMachineInstr()->operandIsDefined(opNum); - bool isDefAndUse = - node->getMachineInstr()->operandIsDefinedAndUsed(opNum); + { + int regNum = (*I).first; + RefVec& regRefVec = (*I).second; + + // regRefVec is ordered by control flow order in the basic block + for (unsigned i=0; i < regRefVec.size(); ++i) { + SchedGraphNode* node = regRefVec[i].first; + unsigned int opNum = regRefVec[i].second; + bool isDef = node->getMachineInstr()->operandIsDefined(opNum); + bool isDefAndUse = + node->getMachineInstr()->operandIsDefinedAndUsed(opNum); - for (unsigned p=0; p < i; ++p) - { - SchedGraphNode* prevNode = regRefVec[p].first; - if (prevNode != node) - { - unsigned int prevOpNum = regRefVec[p].second; - bool prevIsDef = - prevNode->getMachineInstr()->operandIsDefined(prevOpNum); - bool prevIsDefAndUse = - prevNode->getMachineInstr()->operandIsDefinedAndUsed(prevOpNum); - if (isDef) - { - if (prevIsDef) - new SchedGraphEdge(prevNode, node, regNum, - SchedGraphEdge::OutputDep); - if (!prevIsDef || prevIsDefAndUse) - new SchedGraphEdge(prevNode, node, regNum, - SchedGraphEdge::AntiDep); - } + for (unsigned p=0; p < i; ++p) { + SchedGraphNode* prevNode = regRefVec[p].first; + if (prevNode != node) { + unsigned int prevOpNum = regRefVec[p].second; + bool prevIsDef = + prevNode->getMachineInstr()->operandIsDefined(prevOpNum); + bool prevIsDefAndUse = + prevNode->getMachineInstr()->operandIsDefinedAndUsed(prevOpNum); + if (isDef) { + if (prevIsDef) + new SchedGraphEdge(prevNode, node, regNum, + SchedGraphEdge::OutputDep); + if (!prevIsDef || prevIsDefAndUse) + new SchedGraphEdge(prevNode, node, regNum, + SchedGraphEdge::AntiDep); + } - if (prevIsDef) - if (!isDef || isDefAndUse) - new SchedGraphEdge(prevNode, node, regNum, - SchedGraphEdge::TrueDep); - } - } + if (prevIsDef) + if (!isDef || isDefAndUse) + new SchedGraphEdge(prevNode, node, regNum, + SchedGraphEdge::TrueDep); } + } } + } } @@ -578,29 +574,28 @@ // Add true or output dep edges from all def nodes before refNode in BB. // Add anti or output dep edges to all def nodes after refNode. for (RefVec::const_iterator I=defVec.begin(), E=defVec.end(); I != E; ++I) - { - if ((*I).first == refNode) - continue; // Dont add any self-loops - - if ((*I).first->getOrigIndexInBB() < refNode->getOrigIndexInBB()) - { // (*).first is before refNode - if (refNodeIsDef) - (void) new SchedGraphEdge((*I).first, refNode, defValue, - SchedGraphEdge::OutputDep); - if (refNodeIsUse) - (void) new SchedGraphEdge((*I).first, refNode, defValue, - SchedGraphEdge::TrueDep); - } - else - { // (*).first is after refNode - if (refNodeIsDef) - (void) new SchedGraphEdge(refNode, (*I).first, defValue, - SchedGraphEdge::OutputDep); - if (refNodeIsUse) - (void) new SchedGraphEdge(refNode, (*I).first, defValue, - SchedGraphEdge::AntiDep); - } + { + if ((*I).first == refNode) + continue; // Dont add any self-loops + + if ((*I).first->getOrigIndexInBB() < refNode->getOrigIndexInBB()) { + // (*).first is before refNode + if (refNodeIsDef) + (void) new SchedGraphEdge((*I).first, refNode, defValue, + SchedGraphEdge::OutputDep); + if (refNodeIsUse) + (void) new SchedGraphEdge((*I).first, refNode, defValue, + SchedGraphEdge::TrueDep); + } else { + // (*).first is after refNode + if (refNodeIsDef) + (void) new SchedGraphEdge(refNode, (*I).first, defValue, + SchedGraphEdge::OutputDep); + if (refNodeIsUse) + (void) new SchedGraphEdge(refNode, (*I).first, defValue, + SchedGraphEdge::AntiDep); } + } } @@ -616,35 +611,35 @@ // Add edges for all operands of the machine instruction. // for (unsigned i = 0, numOps = MI.getNumOperands(); i != numOps; ++i) + { + switch (MI.getOperandType(i)) { - switch (MI.getOperandType(i)) - { - case MachineOperand::MO_VirtualRegister: - case MachineOperand::MO_CCRegister: - if (const Instruction* srcI = - dyn_cast_or_null(MI.getOperand(i).getVRegValue())) - { - ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI); - if (I != valueToDefVecMap.end()) - addEdgesForValue(node, I->second, srcI, - MI.operandIsDefined(i), - MI.operandIsDefinedAndUsed(i), target); - } - break; + case MachineOperand::MO_VirtualRegister: + case MachineOperand::MO_CCRegister: + if (const Instruction* srcI = + dyn_cast_or_null(MI.getOperand(i).getVRegValue())) + { + ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI); + if (I != valueToDefVecMap.end()) + addEdgesForValue(node, I->second, srcI, + MI.operandIsDefined(i), + MI.operandIsDefinedAndUsed(i), target); + } + break; - case MachineOperand::MO_MachineRegister: - break; + case MachineOperand::MO_MachineRegister: + break; - case MachineOperand::MO_SignExtendedImmed: - case MachineOperand::MO_UnextendedImmed: - case MachineOperand::MO_PCRelativeDisp: - break; // nothing to do for immediate fields + case MachineOperand::MO_SignExtendedImmed: + case MachineOperand::MO_UnextendedImmed: + case MachineOperand::MO_PCRelativeDisp: + break; // nothing to do for immediate fields - default: - assert(0 && "Unknown machine operand type in SchedGraph builder"); - break; - } + default: + assert(0 && "Unknown machine operand type in SchedGraph builder"); + break; } + } // Add edges for values implicitly used by the machine instruction. // Examples include function arguments to a Call instructions or the return @@ -655,13 +650,13 @@ MI.implicitRefIsDefinedAndUsed(i)) if (const Instruction *srcI = dyn_cast_or_null(MI.getImplicitRef(i))) - { - ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI); - if (I != valueToDefVecMap.end()) - addEdgesForValue(node, I->second, srcI, - MI.implicitRefIsDefined(i), - MI.implicitRefIsDefinedAndUsed(i), target); - } + { + ValueToDefVecMap::const_iterator I = valueToDefVecMap.find(srcI); + if (I != valueToDefVecMap.end()) + addEdgesForValue(node, I->second, srcI, + MI.implicitRefIsDefined(i), + MI.implicitRefIsDefinedAndUsed(i), target); + } } @@ -683,32 +678,32 @@ // const MachineInstr& minstr = *node->getMachineInstr(); for (int i=0, numOps = (int) minstr.getNumOperands(); i < numOps; i++) - { - const MachineOperand& mop = minstr.getOperand(i); + { + const MachineOperand& mop = minstr.getOperand(i); - // if this references a register other than the hardwired - // "zero" register, record the reference. - if (mop.getType() == MachineOperand::MO_MachineRegister) - { - int regNum = mop.getMachineRegNum(); - if (regNum != target.getRegInfo().getZeroRegNum()) - regToRefVecMap[mop.getMachineRegNum()].push_back( - std::make_pair(node, i)); - continue; // nothing more to do - } - - // ignore all other non-def operands - if (! minstr.operandIsDefined(i)) - continue; - - // We must be defining a value. - assert((mop.getType() == MachineOperand::MO_VirtualRegister || - mop.getType() == MachineOperand::MO_CCRegister) - && "Do not expect any other kind of operand to be defined!"); + // if this references a register other than the hardwired + // "zero" register, record the reference. + if (mop.getType() == MachineOperand::MO_MachineRegister) + { + int regNum = mop.getMachineRegNum(); + if (regNum != target.getRegInfo().getZeroRegNum()) + regToRefVecMap[mop.getMachineRegNum()] + .push_back(std::make_pair(node, i)); + continue; // nothing more to do + } + + // ignore all other non-def operands + if (! minstr.operandIsDefined(i)) + continue; + + // We must be defining a value. + assert((mop.getType() == MachineOperand::MO_VirtualRegister || + mop.getType() == MachineOperand::MO_CCRegister) + && "Do not expect any other kind of operand to be defined!"); - const Instruction* defInstr = cast(mop.getVRegValue()); - valueToDefVecMap[defInstr].push_back(std::make_pair(node, i)); - } + const Instruction* defInstr = cast(mop.getVRegValue()); + valueToDefVecMap[defInstr].push_back(std::make_pair(node, i)); + } // // Collect value defs. for implicit operands. The interface to extract @@ -903,18 +898,17 @@ if (node.getMachineInstr() == NULL) os << "(Dummy node)\n"; - else - { - os << *node.getMachineInstr() << "\n" << std::string(12, ' '); - os << node.inEdges.size() << " Incoming Edges:\n"; - for (unsigned i=0, N=node.inEdges.size(); i < N; i++) - os << std::string(16, ' ') << *node.inEdges[i]; - - os << std::string(12, ' ') << node.outEdges.size() - << " Outgoing Edges:\n"; - for (unsigned i=0, N=node.outEdges.size(); i < N; i++) - os << std::string(16, ' ') << *node.outEdges[i]; - } + else { + os << *node.getMachineInstr() << "\n" << std::string(12, ' '); + os << node.inEdges.size() << " Incoming Edges:\n"; + for (unsigned i=0, N=node.inEdges.size(); i < N; i++) + os << std::string(16, ' ') << *node.inEdges[i]; + + os << std::string(12, ' ') << node.outEdges.size() + << " Outgoing Edges:\n"; + for (unsigned i=0, N=node.outEdges.size(); i < N; i++) + os << std::string(16, ' ') << *node.outEdges[i]; + } return os; } From lattner at cs.uiuc.edu Thu May 22 17:00:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:00:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/Annotation.cpp NameMangling.cpp Signals.cpp Message-ID: <200305222159.QAA11262@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Annotation.cpp updated: 1.8 -> 1.9 NameMangling.cpp updated: 1.5 -> 1.6 Signals.cpp updated: 1.3 -> 1.4 --- Log message: Add using declarations --- Diffs of the changes: Index: llvm/lib/Support/Annotation.cpp diff -u llvm/lib/Support/Annotation.cpp:1.8 llvm/lib/Support/Annotation.cpp:1.9 --- llvm/lib/Support/Annotation.cpp:1.8 Tue Jan 14 15:26:46 2003 +++ llvm/lib/Support/Annotation.cpp Thu May 22 16:59:35 2003 @@ -6,12 +6,8 @@ #include #include "Support/Annotation.h" -using std::string; -using std::map; -using std::pair; -using std::make_pair; -typedef map IDMapType; +typedef std::map IDMapType; static unsigned IDCounter = 0; // Unique ID counter // Static member to ensure initialiation on demand. @@ -19,7 +15,7 @@ // On demand annotation creation support... typedef Annotation *(*AnnFactory)(AnnotationID, const Annotable *, void *); -typedef map > FactMapType; +typedef std::map > FactMapType; static FactMapType *TheFactMap = 0; static FactMapType &getFactMap() { @@ -38,7 +34,7 @@ } -AnnotationID AnnotationManager::getID(const string &Name) { // Name -> ID +AnnotationID AnnotationManager::getID(const std::string &Name) { // Name -> ID IDMapType::iterator I = getIDMap().find(Name); if (I == getIDMap().end()) { getIDMap()[Name] = IDCounter++; // Add a new element @@ -49,7 +45,7 @@ // getID - Name -> ID + registration of a factory function for demand driven // annotation support. -AnnotationID AnnotationManager::getID(const string &Name, Factory Fact, +AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact, void *Data) { AnnotationID Result(getID(Name)); registerAnnotationFactory(Result, Fact, Data); @@ -60,7 +56,7 @@ // getName - This function is especially slow, but that's okay because it should // only be used for debugging. // -const string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name +const std::string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name IDMapType &TheMap = getIDMap(); for (IDMapType::iterator I = TheMap.begin(); ; ++I) { assert(I != TheMap.end() && "Annotation ID is unknown!"); @@ -77,7 +73,7 @@ AnnFactory F, void *ExtraData) { if (F) - getFactMap()[ID.ID] = make_pair(F, ExtraData); + getFactMap()[ID.ID] = std::make_pair(F, ExtraData); else eraseFromFactMap(ID.ID); } Index: llvm/lib/Support/NameMangling.cpp diff -u llvm/lib/Support/NameMangling.cpp:1.5 llvm/lib/Support/NameMangling.cpp:1.6 --- llvm/lib/Support/NameMangling.cpp:1.5 Wed Jun 5 12:55:27 2002 +++ llvm/lib/Support/NameMangling.cpp Thu May 22 16:59:35 2003 @@ -7,28 +7,27 @@ #include "llvm/Support/NameMangling.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalValue.h" -using std::string; // MangleTypeName - Implement a consistent name-mangling scheme for // a given type. // -string MangleTypeName(const Type *Ty) { - string mangledName; +std::string MangleTypeName(const Type *Ty) { + std::string mangledName; if (Ty->isPrimitiveType()) { - const string &longName = Ty->getDescription(); - return string(longName.c_str(), (longName.length() < 2) ? 1 : 2); + const std::string &longName = Ty->getDescription(); + return std::string(longName.c_str(), (longName.length() < 2) ? 1 : 2); } else if (const PointerType *PTy = dyn_cast(Ty)) { - mangledName = string("P_" + MangleTypeName(PTy->getElementType())); + mangledName = std::string("P_" + MangleTypeName(PTy->getElementType())); } else if (const StructType *STy = dyn_cast(Ty)) { - mangledName = string("S_"); + mangledName = std::string("S_"); for (unsigned i=0; i < STy->getNumContainedTypes(); ++i) mangledName += MangleTypeName(STy->getContainedType(i)); } else if (const ArrayType *ATy = dyn_cast(Ty)) { - mangledName = string("A_" +MangleTypeName(ATy->getElementType())); + mangledName = std::string("A_" +MangleTypeName(ATy->getElementType())); } else if (const FunctionType *FTy = dyn_cast(Ty)) { - mangledName = string("M_") + MangleTypeName(FTy->getReturnType()); + mangledName = std::string("M_") + MangleTypeName(FTy->getReturnType()); for (unsigned i = 1; i < FTy->getNumContainedTypes(); ++i) - mangledName += string(MangleTypeName(FTy->getContainedType(i))); + mangledName += std::string(MangleTypeName(FTy->getContainedType(i))); } return mangledName; @@ -38,7 +37,7 @@ // externally visible (i.e., global) objects. // privateName should be unique within the module. // -string MangleName(const string &privateName, const Value *V) { +std::string MangleName(const std::string &privateName, const Value *V) { // Lets drop the P_ before every global name since all globals are ptrs return privateName + "_" + MangleTypeName(isa(V) Index: llvm/lib/Support/Signals.cpp diff -u llvm/lib/Support/Signals.cpp:1.3 llvm/lib/Support/Signals.cpp:1.4 --- llvm/lib/Support/Signals.cpp:1.3 Fri Sep 13 09:57:24 2002 +++ llvm/lib/Support/Signals.cpp Thu May 22 16:59:35 2003 @@ -11,9 +11,8 @@ #include #include #include -using std::string; -static std::vector FilesToRemove; +static std::vector FilesToRemove; // IntSigs - Signals that may interrupt the program at any time. static const int IntSigs[] = { @@ -48,7 +47,7 @@ static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); } // RemoveFileOnSignal - The public API -void RemoveFileOnSignal(const string &Filename) { +void RemoveFileOnSignal(const std::string &Filename) { FilesToRemove.push_back(Filename); std::for_each(IntSigs, IntSigsEnd, RegisterHandler); From lattner at cs.uiuc.edu Thu May 22 17:01:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:01:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp MutateStructTypes.cpp Message-ID: <200305222200.RAA11306@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: DeadTypeElimination.cpp updated: 1.43 -> 1.44 MutateStructTypes.cpp updated: 1.35 -> 1.36 --- Log message: Remove using declarations --- Diffs of the changes: Index: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp diff -u llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.43 llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.44 --- llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.43 Thu Feb 13 23:34:35 2003 +++ llvm/lib/Transforms/IPO/DeadTypeElimination.cpp Thu May 22 17:00:04 2003 @@ -12,8 +12,6 @@ #include "llvm/DerivedTypes.h" #include "Support/Statistic.h" -using std::vector; - namespace { struct DTE : public Pass { // doPassInitialization - For this pass, it removes global symbol table Index: llvm/lib/Transforms/IPO/MutateStructTypes.cpp diff -u llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.35 llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.36 --- llvm/lib/Transforms/IPO/MutateStructTypes.cpp:1.35 Wed Apr 16 15:28:39 2003 +++ llvm/lib/Transforms/IPO/MutateStructTypes.cpp Thu May 22 17:00:04 2003 @@ -15,18 +15,12 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" -#include "llvm/iPHINode.h" -#include "llvm/iMemory.h" -#include "llvm/iTerminators.h" -#include "llvm/iOther.h" +#include "llvm/Instructions.h" #include "llvm/Constants.h" #include "Support/STLExtras.h" #include "Support/Statistic.h" #include -using std::map; -using std::vector; - // ValuePlaceHolder - A stupid little marker value. It appears as an // instruction of type Instruction::UserOp1. // @@ -43,7 +37,7 @@ if (Ty->isPrimitiveType() || isa(Ty)) return Ty; // Don't convert primitives - map::iterator I = TypeMap.find(Ty); + std::map::iterator I = TypeMap.find(Ty); if (I != TypeMap.end()) return I->second; const Type *DestTy = 0; @@ -55,7 +49,7 @@ case Type::FunctionTyID: { const FunctionType *MT = cast(Ty); const Type *RetTy = ConvertType(MT->getReturnType()); - vector ArgTypes; + std::vector ArgTypes; for (FunctionType::ParamTypes::const_iterator I = MT->getParamTypes().begin(), E = MT->getParamTypes().end(); I != E; ++I) @@ -67,7 +61,7 @@ case Type::StructTyID: { const StructType *ST = cast(Ty); const StructType::ElementTypes &El = ST->getElementTypes(); - vector Types; + std::vector Types; for (StructType::ElementTypes::const_iterator I = El.begin(), E = El.end(); I != E; ++I) @@ -103,7 +97,7 @@ // using the specified OldTy as the base type being indexed into. // void MutateStructTypes::AdjustIndices(const CompositeType *OldTy, - vector &Idx, + std::vector &Idx, unsigned i) { assert(i < Idx.size() && "i out of range!"); const CompositeType *NewCT = cast(ConvertType(OldTy)); @@ -114,7 +108,8 @@ unsigned ElNum = cast(Idx[i])->getValue(); assert(ElNum < OldST->getElementTypes().size()); - map::iterator I = Transforms.find(OldST); + std::map::iterator + I = Transforms.find(OldST); if (I != Transforms.end()) { assert(ElNum < I->second.second.size()); // Apply the XForm specified by Transforms map... @@ -149,13 +144,13 @@ // Check to see if this is an out of function reference first... if (const GlobalValue *GV = dyn_cast(V)) { // Check to see if the value is in the map... - map::iterator I = GlobalMap.find(GV); + std::map::iterator I = GlobalMap.find(GV); if (I == GlobalMap.end()) return (Value*)GV; // Not mapped, just return value itself return I->second; } - map::iterator I = LocalValueMap.find(V); + std::map::iterator I = LocalValueMap.find(V); if (I != LocalValueMap.end()) return I->second; if (const BasicBlock *BB = dyn_cast(V)) { @@ -182,26 +177,26 @@ // Loop over the types and insert dummy entries into the type map so that // recursive types are resolved properly... - for (map >::const_iterator I = XForm.begin(), - E = XForm.end(); I != E; ++I) { + for (std::map >::const_iterator + I = XForm.begin(), E = XForm.end(); I != E; ++I) { const StructType *OldTy = I->first; TypeMap.insert(std::make_pair(OldTy, OpaqueType::get())); } // Loop over the type specified and figure out what types they should become - for (map >::const_iterator I = XForm.begin(), - E = XForm.end(); I != E; ++I) { + for (std::map >::const_iterator + I = XForm.begin(), E = XForm.end(); I != E; ++I) { const StructType *OldTy = I->first; - const vector &InVec = I->second; + const std::vector &InVec = I->second; assert(OldTy->getElementTypes().size() == InVec.size() && "Action not specified for every element of structure type!"); - vector NewType; + std::vector NewType; // Convert the elements of the type over, including the new position mapping int Idx = 0; - vector::const_iterator TI = find(InVec.begin(), InVec.end(), Idx); + std::vector::const_iterator TI = find(InVec.begin(), InVec.end(), Idx); while (TI != InVec.end()) { unsigned Offset = TI-InVec.begin(); const Type *NewEl = ConvertType(OldTy->getContainedType(Offset)); @@ -308,7 +303,7 @@ // void MutateStructTypes::transformFunction(Function *m) { const Function *M = m; - map::iterator GMI = GlobalMap.find(M); + std::map::iterator GMI = GlobalMap.find(M); if (GMI == GlobalMap.end()) return; // Do not affect one of our new functions that we are creating @@ -417,7 +412,7 @@ break; case Instruction::GetElementPtr: { const GetElementPtrInst &GEP = cast(I); - vector Indices(GEP.idx_begin(), GEP.idx_end()); + std::vector Indices(GEP.idx_begin(), GEP.idx_end()); if (!Indices.empty()) { const Type *PTy = cast(GEP.getOperand(0)->getType())->getElementType(); @@ -444,7 +439,7 @@ break; case Instruction::Call: { Value *Meth = ConvertValue(I.getOperand(0)); - vector Operands; + std::vector Operands; for (unsigned i = 1; i < I.getNumOperands(); ++i) Operands.push_back(ConvertValue(I.getOperand(i))); NewI = new CallInst(Meth, Operands); @@ -460,7 +455,7 @@ NewBB->getInstList().push_back(NewI); // Check to see if we had to make a placeholder for this value... - map::iterator LVMI = LocalValueMap.find(&I); + std::map::iterator LVMI = LocalValueMap.find(&I); if (LVMI != LocalValueMap.end()) { // Yup, make sure it's a placeholder... Instruction *I = cast(LVMI->second); From lattner at cs.uiuc.edu Thu May 22 17:01:08 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:01:08 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Message-ID: <200305222200.RAA11313@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: EmitFunctions.cpp updated: 1.6 -> 1.7 --- Log message: Remove using declarations --- Diffs of the changes: Index: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp diff -u llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.6 llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.7 --- llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.6 Wed Apr 16 15:28:40 2003 +++ llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Thu May 22 17:00:05 2003 @@ -9,8 +9,6 @@ #include "llvm/Module.h" #include "llvm/Pass.h" -using std::vector; - namespace { struct EmitFunctionTable : public Pass { bool run(Module &M); @@ -21,13 +19,12 @@ // Per Module pass for inserting function table bool EmitFunctionTable::run(Module &M){ - vector vType; - vector vConsts; - for(Module::iterator MI = M.begin(), ME = M.end(); MI!=ME; ++MI) + std::vector vType; + std::vector vConsts; + for(Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) if (!MI->isExternal()) { - ConstantPointerRef *CP = ConstantPointerRef::get(MI); vType.push_back(MI->getType()); - vConsts.push_back(CP); + vConsts.push_back(ConstantPointerRef::get(MI)); } StructType *sttype = StructType::get(vType); From lattner at cs.uiuc.edu Thu May 22 17:01:14 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:01:14 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp Message-ID: <200305222200.RAA11320@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.52 -> 1.53 --- Log message: Remove using declarations --- Diffs of the changes: Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.52 llvm/lib/Transforms/Scalar/ADCE.cpp:1.53 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.52 Fri Apr 25 17:53:27 2003 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Thu May 22 17:00:06 2003 @@ -19,8 +19,6 @@ #include "Support/DepthFirstIterator.h" #include "Support/Statistic.h" #include -using std::cerr; -using std::vector; namespace { Statistic<> NumBlockRemoved("adce", "Number of basic blocks removed"); @@ -77,13 +75,13 @@ inline void markInstructionLive(Instruction *I) { if (LiveSet.count(I)) return; - DEBUG(cerr << "Insn Live: " << I); + DEBUG(std::cerr << "Insn Live: " << I); LiveSet.insert(I); WorkList.push_back(I); } inline void markTerminatorLive(const BasicBlock *BB) { - DEBUG(cerr << "Terminat Live: " << BB->getTerminator()); + DEBUG(std::cerr << "Terminat Live: " << BB->getTerminator()); markInstructionLive((Instruction*)BB->getTerminator()); } }; @@ -168,7 +166,7 @@ } } - DEBUG(cerr << "Processing work list\n"); + DEBUG(std::cerr << "Processing work list\n"); // AliveBlocks - Set of basic blocks that we know have instructions that are // alive in them... @@ -208,14 +206,14 @@ markInstructionLive(Operand); } - if (DebugFlag) { - cerr << "Current Function: X = Live\n"; + DEBUG( + std::cerr << "Current Function: X = Live\n"; for (Function::iterator I = Func->begin(), E = Func->end(); I != E; ++I) for (BasicBlock::iterator BI = I->begin(), BE = I->end(); BI != BE; ++BI){ - if (LiveSet.count(BI)) cerr << "X "; - cerr << *BI; + if (LiveSet.count(BI)) std::cerr << "X "; + std::cerr << *BI; } - } + ); // Find the first postdominator of the entry node that is alive. Make it the // new entry node... @@ -346,7 +344,7 @@ if (!AliveBlocks.count(BB)) { // Remove all outgoing edges from this basic block and convert the // terminator into a return instruction. - vector Succs(succ_begin(BB), succ_end(BB)); + std::vector Succs(succ_begin(BB), succ_end(BB)); if (!Succs.empty()) { // Loop over all of the successors, removing this block from PHI node From lattner at cs.uiuc.edu Thu May 22 17:01:20 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:01:20 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Message-ID: <200305222200.RAA11327@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: UnifyFunctionExitNodes.cpp updated: 1.23 -> 1.24 --- Log message: Remove using declarations --- Diffs of the changes: Index: llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp diff -u llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.23 llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.24 --- llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp:1.23 Mon Mar 31 11:30:25 2003 +++ llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp Thu May 22 17:00:07 2003 @@ -14,7 +14,6 @@ #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" #include "llvm/Type.h" -using std::vector; static RegisterOpt X("mergereturn", "Unify function exit nodes"); @@ -34,7 +33,7 @@ // Loop over all of the blocks in a function, tracking all of the blocks that // return. // - vector ReturningBlocks; + std::vector ReturningBlocks; for(Function::iterator I = F.begin(), E = F.end(); I != E; ++I) if (isa(I->getTerminator())) ReturningBlocks.push_back(I); @@ -67,8 +66,8 @@ // Loop over all of the blocks, replacing the return instruction with an // unconditional branch. // - for (vector::iterator I = ReturningBlocks.begin(), - E = ReturningBlocks.end(); I != E; ++I) { + for (std::vector::iterator I = ReturningBlocks.begin(), + E = ReturningBlocks.end(); I != E; ++I) { BasicBlock *BB = *I; // Add an incoming element to the PHI node for every return instruction that From lattner at cs.uiuc.edu Thu May 22 17:02:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:02:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/NameMangling.cpp Message-ID: <200305222201.RAA11343@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: NameMangling.cpp (r1.6) removed --- Log message: Remove long dead code --- Diffs of the changes: From lattner at cs.uiuc.edu Thu May 22 17:02:07 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu May 22 17:02:07 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/NameMangling.h Message-ID: <200305222201.RAA11348@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: NameMangling.h (r1.2) removed --- Log message: Remove long dead code --- Diffs of the changes: From jstanley at cs.uiuc.edu Thu May 22 22:26:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 22:26:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Reoptimizer/inst/Makefile Test1.c Message-ID: <200305230325.WAA12679@trinity.cs.uiuc.edu> Changes in directory llvm/test/Regression/Reoptimizer/inst: Makefile updated: 1.4 -> 1.5 Test1.c updated: 1.3 -> 1.4 --- Log message: Modified to link against the PAPI library; Test1.c uses perf prims implemented using the PAPI lib. --- Diffs of the changes: Index: llvm/test/Regression/Reoptimizer/inst/Makefile diff -u llvm/test/Regression/Reoptimizer/inst/Makefile:1.4 llvm/test/Regression/Reoptimizer/inst/Makefile:1.5 --- llvm/test/Regression/Reoptimizer/inst/Makefile:1.4 Thu May 22 08:16:53 2003 +++ llvm/test/Regression/Reoptimizer/inst/Makefile Thu May 22 22:25:43 2003 @@ -3,17 +3,24 @@ CC = /usr/dcs/software/evaluation/bin/gcc CXX = /usr/dcs/software/evaluation/bin/g++ LLVMGCC = /home/vadve/lattner/local/sparc/llvm-gcc/bin/gcc +PAPIDIR = /home/vadve/shared/papi-2.3.4.1/lib PERFOBJS = $(LEVEL)/lib/Debug/libpprtl.a \ $(LEVEL)/lib/Debug/libperfinst.a \ $(LEVEL)/lib/Debug/libtracecache.a \ $(LEVEL)/lib/Debug/libbininterface.a + LIBINSTRBC = /home/vadve/lattner/cvs/gcc_install_sparc/llvm/lib/libinstr.bc Test1: Test1.o $(PERFOBJS) + # NB: The only reason we don't include the PAPI library in the list of exclusions + # is that the current phase2 (etc.) does not look at the dynamic symbol + # tables, and thus will never try to instrument the PAPI functions, which are + # dynamically linked. + mkexcl $(PERFOBJS) libinstr.o > mkexcl.cpp - $(CXX) -o Test1 -lelf mkexcl.cpp $^ + $(CXX) -o Test1 $^ mkexcl.cpp -L$(PAPIDIR) -lpapi -lelf Test1.o: Test1.opt.c $(CC) -c Test1.opt.c -o Test1.o @@ -23,7 +30,6 @@ Test1.opt.bc: Test1.bc libinstr.o $(LEVEL)/lib/Debug/libperf.so opt -load $(LEVEL)/lib/Debug/libperf.so -pp1 -emitfuncs -deadtypeelim < Test1.bc > Test1.opt.o -# $(LLVMGCC) -Wl,-disable-internalize Test1.opt.o -o Test1.opt gccld -disable-internalize $(LIBINSTRBC) Test1.opt.o -o Test1.opt Test1.bc: Test1.c Index: llvm/test/Regression/Reoptimizer/inst/Test1.c diff -u llvm/test/Regression/Reoptimizer/inst/Test1.c:1.3 llvm/test/Regression/Reoptimizer/inst/Test1.c:1.4 --- llvm/test/Regression/Reoptimizer/inst/Test1.c:1.3 Thu May 22 08:16:54 2003 +++ llvm/test/Regression/Reoptimizer/inst/Test1.c Thu May 22 22:25:43 2003 @@ -5,6 +5,7 @@ double elapsedTime = 0; double elapsedTime2 = 0; +int l1cachemiss = 0; #include @@ -13,6 +14,15 @@ int fib(int n); void fibs(); +void someOtherFunction() +{ + int x; + pp_L1_cache_miss_start(&x); + printf("this statement resides within a region!\n"); + pp_L1_cache_miss_end(&l1cachemiss, &x); + printf("someOtherFunction complete: retval is %d\n", l1cachemiss); +} + int main(int argc, char** argv) { phase2(); @@ -20,7 +30,14 @@ printf("Just about to call fibs()...\n"); fibs(); + printf("Just about to call someOtherFunction()...\n"); + someOtherFunction(); + printf("Leaving main...\n"); + + pp_regionPair(pp_elapsed_time_start, pp_elapsed_time_end); + pp_regionPair(pp_L1_cache_miss_start, pp_L1_cache_miss_end); + return 0; } From jstanley at cs.uiuc.edu Thu May 22 22:27:01 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 22:27:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/rtl/Makefile pprtl.cpp pprtl.h Message-ID: <200305230326.WAA12720@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/rtl: Makefile updated: 1.2 -> 1.3 pprtl.cpp updated: 1.1 -> 1.2 pprtl.h updated: 1.2 -> 1.3 --- Log message: Bug fixes; PAPI "support" added to RTL. --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/rtl/Makefile diff -u llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.2 llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.3 --- llvm/lib/Reoptimizer/Inst/rtl/Makefile:1.2 Thu May 22 08:16:40 2003 +++ llvm/lib/Reoptimizer/Inst/rtl/Makefile Thu May 22 22:26:13 2003 @@ -1,6 +1,8 @@ LEVEL = ../../../.. LIBRARYNAME = pprtl BUILD_ARCHIVE = 1 -CXXFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ +PAPIDIR = /home/vadve/shared/papi-2.3.4.1 +CPPFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ -I$(PAPIDIR)/include +CXXFLAGS += -D_BUILDING_RUNTIME_LIBRARY_ -I$(PAPIDIR)/include include $(LEVEL)/Makefile.common Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp diff -u llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.1 llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.2 --- llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp:1.1 Thu May 22 08:08:59 2003 +++ llvm/lib/Reoptimizer/Inst/rtl/pprtl.cpp Thu May 22 22:26:13 2003 @@ -1,6 +1,11 @@ // Implementation of the performance primtive runtime library / "library of metrics" #include "pprtl.h" +#include "papi.h" + +#include +#include +#include void pp_elapsed_time_start(double* retVal) { @@ -28,4 +33,42 @@ end = (tv.tv_sec * 1000000 + tv.tv_usec) / 1000.0; // convert to ms *retVal = end - *start; // compute diff printf("pp_elapsed_time_end returning %f\n", *retVal); +} + +static void start_papi_sample(int* events, int numEvents) +{ + if(PAPI_start_counters(events, numEvents) != PAPI_OK) { + fprintf(stderr, "Failed to start counter(s)!\n"); + exit(1); + } +} + +static void end_papi_sample(long_long* values, int numEvents) +{ + if(PAPI_stop_counters(values, numEvents) != PAPI_OK) { + fprintf(stderr, "Failed to stop counter(s)!\n"); + exit(1); + } +} + +void pp_L1_cache_miss_start(int* retVal) +{ + int events[1] = { PAPI_L1_ICM }; + printf("pp_L1_cache_miss_start invoked: retVal addr is 0x%lx\n", (unsigned long) retVal); + start_papi_sample(events, 1); + *retVal = PAPI_L1_ICM; + printf("pp_L1_cache_miss_start returning!\n"); +} + +void pp_L1_cache_miss_end(int* retVal, int* start) +{ + long_long values[1]; + + printf("pp_L1_cache_miss_end invoked!\n"); + printf("Address of start is 0x%lx, value is %x\n", (unsigned long) start, *start); + fflush(stdout); + + end_papi_sample(values, 1); + *retVal = values[0]; + printf("pp_L1_cache_miss_end returning %d\n", *retVal); } Index: llvm/lib/Reoptimizer/Inst/rtl/pprtl.h diff -u llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.2 llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.3 --- llvm/lib/Reoptimizer/Inst/rtl/pprtl.h:1.2 Thu May 22 08:16:40 2003 +++ llvm/lib/Reoptimizer/Inst/rtl/pprtl.h Thu May 22 22:26:13 2003 @@ -3,9 +3,6 @@ #ifndef _INCLUDED_PPLIB_H #define _INCLUDED_PPLIB_H -#include -#include - #ifdef _BUILDING_RUNTIME_LIBRARY_ extern "C" { #endif @@ -15,6 +12,8 @@ long pp_timestamp(void); void pp_elapsed_time_start(double* retVal); void pp_elapsed_time_end(double* retVal, double* start); + void pp_L1_cache_miss_start(int* retVal); + void pp_L1_cache_miss_end(int* retVal, int* start); unsigned pp_counterPrim(void); // significant functions From jstanley at cs.uiuc.edu Thu May 22 22:27:06 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 22:27:06 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp Message-ID: <200305230326.WAA12708@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/lib/Phase1: Phase1.cpp updated: 1.25 -> 1.26 --- Log message: Bug fixes; PAPI "support" added to RTL. --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp diff -u llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp:1.25 llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp:1.26 --- llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp:1.25 Sat May 10 15:54:54 2003 +++ llvm/lib/Reoptimizer/Inst/lib/Phase1/Phase1.cpp Thu May 22 22:26:13 2003 @@ -12,6 +12,7 @@ #include #include #include +#include #include "llvm/Pass.h" #include "llvm/Module.h" @@ -118,24 +119,37 @@ } +static Function* extractFunctionArg(Value* rpairParam) +{ + if(ConstantExpr* ce = dyn_cast(rpairParam)) { + assert(ce->getNumOperands() == 1 && + "ConstantExpr encountered with unexpected #opds"); + if(ConstantPointerRef* cpr = + dyn_cast(ce->getOperand(0))) { + if(Function* func = dyn_cast(cpr->getValue())) { + return func; + } + } + } + + return 0; +} + void Phase1::findRegionPairs(vector >& rpairs) { while(!m_regionPairDeclFunc->use_empty()) { CallInst* ci = dyn_cast(m_regionPairDeclFunc->use_back()); assert(ci && "Expect to see region pairs sigfun only in a call"); - CastInst* arg1 = dyn_cast(ci->getOperand(1)); - CastInst* arg2 = dyn_cast(ci->getOperand(2)); - assert(arg1 && arg2 && "Expect both call operands are results of cast insts"); - - Function* startFunc = dyn_cast(arg1->getOperand(0)); - Function* endFunc = dyn_cast(arg2->getOperand(0)); - assert(startFunc && endFunc && "Expect operands of casts are functions"); + Function* startFunc = extractFunctionArg(ci->getOperand(1)); + Function* endFunc = extractFunctionArg(ci->getOperand(2)); + assert(startFunc && endFunc && + "Failed to obtain Function* params of region pair sigfun"); + rpairs.push_back(std::make_pair(startFunc, endFunc)); - PurgeInst(arg1); - PurgeInst(arg2); + PurgeInst(ci); } } @@ -160,28 +174,16 @@ void Phase1::transformSites() { //////////////// - // Build list of region pair sigfuns; finding pp_regionPair will yield user-defined - // instances of them. + // Build list of region pair sigfuns + vector > rpairs; vector params; // Populate with builtins - // TODO: Replace this hard-coded mechanism for builtins with a - // different mechanism that registers functions as "significant" (i.e. pp_metricSpec - // directive or some such thing). - - // elapsed time builtin - params.push_back(PointerType::get(Type::DoubleTy)); - FunctionType* ftype = FunctionType::get(Type::VoidTy, params, false); - Function* elapsed1 = m_module->getOrInsertFunction("pp_elapsed_time_start", ftype); - - params.clear(); - params.push_back(PointerType::get(Type::DoubleTy)); - params.push_back(PointerType::get(Type::DoubleTy)); - ftype = FunctionType::get(Type::VoidTy, params, false); - Function* elapsed2 = m_module->getOrInsertFunction("pp_elapsed_time_end", ftype); - rpairs.push_back(std::make_pair(elapsed1, elapsed2)); + // TODO: Replace the hard-coded mechanism for the point metrics with a + // sigfun registration mechanism like that which exists for region metrics + // (pp_regionPair()). // Find user-declared region-pairs and add them to the list findRegionPairs(rpairs); @@ -193,7 +195,7 @@ // counter builtin params.clear(); - ftype = FunctionType::get(Type::UIntTy, params, false); + FunctionType* ftype = FunctionType::get(Type::UIntTy, params, false); metricSpecs.push_back(m_module->getOrInsertFunction("pp_counterPrim", ftype)); // timestamp builtin @@ -286,14 +288,17 @@ for(Value::use_iterator u = startFunc->use_begin(), ue = startFunc->use_end(); u != ue; ++u) { - CallInst* startCall = dyn_cast(*u); + if(isa(*u)) { + continue; // skips forward declarations of sigfun + } + + CallInst* startCall = dyn_cast(*u); assert(startCall && "Use of a registered pp sigfun not in a call"); // Find call to endpoint: The first operand of the start function is used in only // two places: the call to the start function, and the call to the end // function. Find the call to the end function. - assert(startCall->getNumOperands() == 2 && "Start-region call insts should only have 2 operands"); From jstanley at cs.uiuc.edu Thu May 22 22:27:11 2003 From: jstanley at cs.uiuc.edu (Joel Stanley) Date: Thu May 22 22:27:11 2003 Subject: [llvm-commits] CVS: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp Message-ID: <200305230326.WAA12700@trinity.cs.uiuc.edu> Changes in directory llvm/lib/Reoptimizer/Inst/lib: Phases.cpp updated: 1.34 -> 1.35 --- Log message: Bug fixes; PAPI "support" added to RTL. --- Diffs of the changes: Index: llvm/lib/Reoptimizer/Inst/lib/Phases.cpp diff -u llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.34 llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.35 --- llvm/lib/Reoptimizer/Inst/lib/Phases.cpp:1.34 Sun May 18 20:35:30 2003 +++ llvm/lib/Reoptimizer/Inst/lib/Phases.cpp Thu May 22 22:26:12 2003 @@ -71,7 +71,9 @@ using std::cerr; using std::endl; -// The function generated at compile-time by the 'mkexcl' command line utility. +// The function generated at compile-time by the 'mkexcl' command line utility; the +// command line utility must be run on any object/archive files containing symbols that +// must be excluded, and the generated file compiled and linked in. void makeExcludedSymbolSet(std::set& set); // Description of GBT contents emitted by phase 1. The extern reference to the GBT will be From gaeke at cs.uiuc.edu Fri May 23 00:35:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri May 23 00:35:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/BugDriver.cpp Message-ID: <200305230534.AAA07898@gally.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: BugDriver.cpp updated: 1.6 -> 1.7 --- Log message: Clarify BugDriver.cpp:BugDriver::ParseInputFile()'s return values in its explanatory comment. --- Diffs of the changes: Index: llvm/tools/bugpoint/BugDriver.cpp diff -u llvm/tools/bugpoint/BugDriver.cpp:1.6 llvm/tools/bugpoint/BugDriver.cpp:1.7 --- llvm/tools/bugpoint/BugDriver.cpp:1.6 Fri May 2 21:16:43 2003 +++ llvm/tools/bugpoint/BugDriver.cpp Fri May 23 00:34:32 2003 @@ -60,7 +60,9 @@ } // This method takes the specified list of LLVM input files, attempts to load -// them, either as assembly or bytecode, then link them together. +// them, either as assembly or bytecode, then link them together. It returns +// true on failure (if, for example, an input bytecode file could not be +// parsed), and false on success. // bool BugDriver::addSources(const std::vector &Filenames) { assert(Program == 0 && "Cannot call addSources multiple times!"); From lattner at cs.uiuc.edu Fri May 23 09:50:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 09:50:01 2003 Subject: [llvm-commits] CVS: llvm/www/docs/HowToSubmitABug.html Message-ID: <200305231449.JAA18413@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: HowToSubmitABug.html updated: 1.1 -> 1.2 --- Log message: Fix a problem brian identified. --- Diffs of the changes: Index: llvm/www/docs/HowToSubmitABug.html diff -u llvm/www/docs/HowToSubmitABug.html:1.1 llvm/www/docs/HowToSubmitABug.html:1.2 --- llvm/www/docs/HowToSubmitABug.html:1.1 Wed May 21 17:21:07 2003 +++ llvm/www/docs/HowToSubmitABug.html Fri May 23 09:49:32 2003 @@ -135,7 +135,8 @@ the full list of objects linked). Then run:

    -  gccld -debug-pass=Arguments < /dev/null -o - > /dev/null
    +  as < /dev/null > null.bc
    +  gccld -debug-pass=Arguments null.bc
     

    ... which will print a list of arguments, indicating the list of passes that @@ -192,6 +193,6 @@

    Chris Lattner
    -Last modified: Wed May 21 17:20:13 CDT 2003 +Last modified: Fri May 23 09:48:53 CDT 2003 From lattner at cs.uiuc.edu Fri May 23 10:08:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 10:08:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/C++Frontend/2003-05-23-TransparentUnion.c Message-ID: <200305231507.KAA25562@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/C++Frontend: 2003-05-23-TransparentUnion.c added (r1.1) --- Log message: New testcase identified by Brian Gaeke. Gotta love GCC extensions. :( --- Diffs of the changes: Index: llvm/test/Regression/C++Frontend/2003-05-23-TransparentUnion.c diff -c /dev/null llvm/test/Regression/C++Frontend/2003-05-23-TransparentUnion.c:1.1 *** /dev/null Fri May 23 10:07:41 2003 --- llvm/test/Regression/C++Frontend/2003-05-23-TransparentUnion.c Fri May 23 10:07:31 2003 *************** *** 0 **** --- 1,20 ---- + #include + + typedef union { + float *__fptr; + int *__iptr; + } UNION __attribute__ ((__transparent_union__)); + + int try(UNION U) { + return 1; + } + int test() { + int I; + float F; + return try(&I) | try(&F); + } + + int main() { + if (test()) printf("ok"); + return 0; + } From lattner at cs.uiuc.edu Fri May 23 12:14:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 12:14:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200305231713.MAA30602@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.23 -> 1.24 --- Log message: Minor rewording/cleanups --- Diffs of the changes: Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.23 llvm/include/llvm/Constants.h:1.24 --- llvm/include/llvm/Constants.h:1.23 Wed May 21 12:49:08 2003 +++ llvm/include/llvm/Constants.h Fri May 23 12:13:15 2003 @@ -458,27 +458,29 @@ }; -// ConstantExpr - a constant value that is initialized with -// an expression using other constant values. This is only used -// to represent values that cannot be evaluated at compile-time -// (e.g., something derived from an address) because it does -// not have a mechanism to store the actual value. -// Use the appropriate Constant subclass above for known constants. +// ConstantExpr - a constant value that is initialized with an expression using +// other constant values. This is only used to represent values that cannot be +// evaluated at compile-time (e.g., something derived from an address) because +// it does not have a mechanism to store the actual value. Use the appropriate +// Constant subclass above for known constants. // class ConstantExpr : public Constant { unsigned iType; // Operation type -protected: - ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); +protected: + // Cast creation ctor + ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); + // Binary/Shift instruction creation ctor ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2); + // GEP instruction creation ctor ConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy); - ~ConstantExpr() {} public: // Static methods to construct a ConstantExpr of different kinds. Note that - // these methods can return a constant of an arbitrary type, because they will - // attempt to fold the constant expression into something simple if they can. + // these methods may return a object that is not an instance of the + // ConstantExpr class, because they will attempt to fold the constant + // expression into something simpler if possible. /// Cast constant expr static Constant *getCast(Constant *C, const Type *Ty); From brukman at cs.uiuc.edu Fri May 23 14:22:02 2003 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri May 23 14:22:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp Message-ID: <200305231921.OAA23674@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/PostOpts: PeepholeOpts.cpp updated: 1.6 -> 1.7 --- Log message: Cleaned up code layout; no functional changes. --- Diffs of the changes: Index: llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp diff -u llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.6 llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.7 --- llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp:1.6 Tue Jan 14 15:58:47 2003 +++ llvm/lib/CodeGen/PostOpts/PeepholeOpts.cpp Fri May 23 14:20:57 2003 @@ -22,21 +22,19 @@ const TargetMachine& target) { // Check if this instruction is in a delay slot of its predecessor. - if (BBI != mvec.begin()) - { + if (BBI != mvec.begin()) { const TargetInstrInfo& mii = target.getInstrInfo(); MachineInstr* predMI = *(BBI-1); - if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) - { - // This instruction is in a delay slot of its predecessor, so - // replace it with a nop. By replacing in place, we save having - // to update the I-I maps. - // - assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets"); - (*BBI)->replace(mii.getNOPOpCode(), 0); - return; - } - } + if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) { + // This instruction is in a delay slot of its predecessor, so + // replace it with a nop. By replacing in place, we save having + // to update the I-I maps. + // + assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets"); + (*BBI)->replace(mii.getNOPOpCode(), 0); + return; + } + } // The instruction is not in a delay slot, so we can simply erase it. mvec.erase(BBI); @@ -51,11 +49,10 @@ MachineBasicBlock::iterator& BBI, const TargetMachine& target) { - if (target.getOptInfo().IsUselessCopy(*BBI)) - { - DeleteInstruction(mvec, BBI, target); - return true; - } + if (target.getOptInfo().IsUselessCopy(*BBI)) { + DeleteInstruction(mvec, BBI, target); + return true; + } return false; } @@ -117,11 +114,11 @@ // for (MachineBasicBlock::reverse_iterator RI=mvec.rbegin(), RE=mvec.rend(); RI != RE; ) - { - MachineBasicBlock::iterator BBI = RI.base()-1; // save before incr - ++RI; // pre-increment to delete MI or after it - visit(mvec, BBI); - } + { + MachineBasicBlock::iterator BBI = RI.base()-1; // save before incr + ++RI; // pre-increment to delete MI or after it + visit(mvec, BBI); + } return true; } @@ -136,4 +133,3 @@ { return new PeepholeOpts(T); } - From lattner at cs.uiuc.edu Fri May 23 15:03:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 15:03:02 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200305232002.PAA02431@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.24 -> 1.25 --- Log message: Remove some cruft, add some methods to allow implementation of bugfix for Bug: Linker/2003-04-26-NullPtrLinkProblem.ll --- Diffs of the changes: Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.24 llvm/include/llvm/Constants.h:1.25 --- llvm/include/llvm/Constants.h:1.24 Fri May 23 12:13:15 2003 +++ llvm/include/llvm/Constants.h Fri May 23 15:02:05 2003 @@ -15,6 +15,8 @@ class StructType; class PointerType; +template +struct ConstantCreator; //===--------------------------------------------------------------------------- /// ConstantIntegral - Shared superclass of boolean and integer constants. @@ -67,7 +69,6 @@ class ConstantBool : public ConstantIntegral { bool Val; ConstantBool(bool V); - ~ConstantBool() {} public: static ConstantBool *True, *False; // The True & False values @@ -113,7 +114,6 @@ } Val; ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT ConstantInt(const Type *Ty, uint64_t V); - ~ConstantInt() {} public: /// equalsInt - Provide a helper method that can be used to determine if the /// constant contained within is equal to a constant. This only works for @@ -151,9 +151,10 @@ /// class ConstantSInt : public ConstantInt { ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT + friend struct ConstantCreator; + protected: ConstantSInt(const Type *Ty, int64_t V); - ~ConstantSInt() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantSInt *get(const Type *Ty, int64_t V); @@ -199,9 +200,9 @@ /// class ConstantUInt : public ConstantInt { ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT + friend struct ConstantCreator; protected: ConstantUInt(const Type *Ty, uint64_t V); - ~ConstantUInt() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantUInt *get(const Type *Ty, uint64_t V); @@ -233,10 +234,10 @@ /// class ConstantFP : public Constant { double Val; + friend struct ConstantCreator; ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT protected: ConstantFP(const Type *Ty, double V); - ~ConstantFP() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantFP *get(const Type *Ty, double V); @@ -262,11 +263,12 @@ /// ConstantArray - Constant Array Declarations /// class ConstantArray : public Constant { + friend struct ConstantCreator >; ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector &Val); - ~ConstantArray() {} - + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: /// get() - Static factory methods - Return objects of the specified value static ConstantArray *get(const ArrayType *T, const std::vector &); @@ -316,11 +318,12 @@ // ConstantStruct - Constant Struct Declarations // class ConstantStruct : public Constant { + friend struct ConstantCreator >; ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector &Val); - ~ConstantStruct() {} - + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: /// get() - Static factory methods - Return objects of the specified value static ConstantStruct *get(const StructType *T, @@ -367,8 +370,7 @@ class ConstantPointer : public Constant { ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT protected: - inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){} - ~ConstantPointer() {} + inline ConstantPointer(const PointerType *T) : Constant((const Type*)T) {} public: inline const PointerType *getType() const { return (PointerType*)Value::getType(); @@ -389,10 +391,12 @@ /// ConstantPointerNull - a constant pointer value that points to null /// class ConstantPointerNull : public ConstantPointer { + friend struct ConstantCreator; ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT protected: - inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} - inline ~ConstantPointerNull() {} + ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); + public: /// get() - Static factory methods - Return objects of the specified value @@ -427,7 +431,6 @@ protected: ConstantPointerRef(GlobalValue *GV); - ~ConstantPointerRef() {} public: /// get() - Static factory methods - Return objects of the specified value static ConstantPointerRef *get(GlobalValue *GV); @@ -457,7 +460,6 @@ } }; - // ConstantExpr - a constant value that is initialized with an expression using // other constant values. This is only used to represent values that cannot be // evaluated at compile-time (e.g., something derived from an address) because @@ -465,9 +467,11 @@ // Constant subclass above for known constants. // class ConstantExpr : public Constant { - unsigned iType; // Operation type + unsigned iType; // Operation type (an Instruction opcode) + friend struct ConstantCreator > >; -protected: +protected: // Cast creation ctor ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); // Binary/Shift instruction creation ctor @@ -475,6 +479,7 @@ // GEP instruction creation ctor ConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy); + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); public: // Static methods to construct a ConstantExpr of different kinds. Note that From lattner at cs.uiuc.edu Fri May 23 15:04:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 15:04:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200305232003.PAA02450@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.40 -> 1.41 --- Log message: Fix Bug: Linker/2003-04-26-NullPtrLinkProblem.ll This was a problem with constants having their types resolved to some new type, but there was already a constant of the new type created. Before, these types were never merged together, now they are. --- Diffs of the changes: Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.40 llvm/lib/VMCore/Constants.cpp:1.41 --- llvm/lib/VMCore/Constants.cpp:1.40 Wed May 21 12:49:25 2003 +++ llvm/lib/VMCore/Constants.cpp Fri May 23 15:03:32 2003 @@ -451,52 +451,72 @@ destroyConstant(); } - - //===----------------------------------------------------------------------===// // Factory Function Implementation -template -struct ValueMap { - typedef std::pair ConstHashKey; - std::map Map; - - inline ConstantClass *get(const Type *Ty, ValType V) { - typename std::map::iterator I = - Map.find(ConstHashKey(Ty, V)); - return (I != Map.end()) ? I->second : 0; +// ConstantCreator - A class that is used to create constants by +// ValueMap*. This class should be partially specialized if there is +// something strange that needs to be done to interface to the ctor for the +// constant. +// +template +struct ConstantCreator { + static ConstantClass *create(const TypeClass *Ty, const ValType &V) { + return new ConstantClass(Ty, V); } +}; + +namespace { + template + class ValueMap { + protected: + typedef std::pair ConstHashKey; + std::map Map; + public: + // getOrCreate - Return the specified constant from the map, creating it if + // necessary. + ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { + ConstHashKey Lookup(Ty, V); + typename std::map::iterator I = + Map.lower_bound(Lookup); + if (I != Map.end() && I->first == Lookup) + return I->second; // Is it in the map? + + // If no preexisting value, create one now... + ConstantClass *Result = + ConstantCreator::create(Ty, V); + + Map.insert(I, std::make_pair(ConstHashKey(Ty, V), Result)); + return Result; + } + + void remove(ConstantClass *CP) { + // FIXME: This could be sped up a LOT. If this gets to be a performance + // problem, someone should look at this. + for (typename std::map::iterator + I = Map.begin(), E = Map.end(); I != E; ++I) + if (I->second == CP) { + Map.erase(I); + return; + } + assert(0 && "Constant not found in constant table!"); + } + }; +} - inline void add(const Type *Ty, ValType V, ConstantClass *CP) { - Map.insert(std::make_pair(ConstHashKey(Ty, V), CP)); - } - inline void remove(ConstantClass *CP) { - for (typename std::map::iterator - I = Map.begin(), E = Map.end(); I != E; ++I) - if (I->second == CP) { - Map.erase(I); - return; - } - } -}; //---- ConstantUInt::get() and ConstantSInt::get() implementations... // -static ValueMap IntConstants; +static ValueMap< int64_t, Type, ConstantSInt> SIntConstants; +static ValueMap UIntConstants; ConstantSInt *ConstantSInt::get(const Type *Ty, int64_t V) { - ConstantSInt *Result = (ConstantSInt*)IntConstants.get(Ty, (uint64_t)V); - if (!Result) // If no preexisting value, create one now... - IntConstants.add(Ty, V, Result = new ConstantSInt(Ty, V)); - return Result; + return SIntConstants.getOrCreate(Ty, V); } ConstantUInt *ConstantUInt::get(const Type *Ty, uint64_t V) { - ConstantUInt *Result = (ConstantUInt*)IntConstants.get(Ty, V); - if (!Result) // If no preexisting value, create one now... - IntConstants.add(Ty, V, Result = new ConstantUInt(Ty, V)); - return Result; + return UIntConstants.getOrCreate(Ty, V); } ConstantInt *ConstantInt::get(const Type *Ty, unsigned char V) { @@ -507,27 +527,46 @@ //---- ConstantFP::get() implementation... // -static ValueMap FPConstants; +static ValueMap FPConstants; ConstantFP *ConstantFP::get(const Type *Ty, double V) { - ConstantFP *Result = FPConstants.get(Ty, V); - if (!Result) // If no preexisting value, create one now... - FPConstants.add(Ty, V, Result = new ConstantFP(Ty, V)); - return Result; + return FPConstants.getOrCreate(Ty, V); } //---- ConstantArray::get() implementation... // -static ValueMap, ConstantArray> ArrayConstants; +static ValueMap, ArrayType, + ConstantArray> ArrayConstants; ConstantArray *ConstantArray::get(const ArrayType *Ty, const std::vector &V) { - ConstantArray *Result = ArrayConstants.get(Ty, V); - if (!Result) // If no preexisting value, create one now... - ArrayConstants.add(Ty, V, Result = new ConstantArray(Ty, V)); - return Result; + return ArrayConstants.getOrCreate(Ty, V); +} + +// destroyConstant - Remove the constant from the constant table... +// +void ConstantArray::destroyConstant() { + ArrayConstants.remove(this); + destroyConstantImpl(); } +/// refineAbstractType - If this callback is invoked, then this constant is of a +/// derived type, change all users to use a concrete constant of the new type. +/// +void ConstantArray::refineAbstractType(const DerivedType *OldTy, + const Type *NewTy) { + Value::refineAbstractType(OldTy, NewTy); + + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + C.push_back(cast(getOperand(i))); + replaceAllUsesWith(ConstantArray::get(cast(NewTy), + C)); + destroyConstant(); // This constant is now dead, destroy it. +} + + // ConstantArray::get(const string&) - Return an array that is initialized to // contain the specified string. A null terminator is added to the specified // string so that it may be used in a natural way... @@ -545,14 +584,6 @@ return ConstantArray::get(ATy, ElementVals); } - -// destroyConstant - Remove the constant from the constant table... -// -void ConstantArray::destroyConstant() { - ArrayConstants.remove(this); - destroyConstantImpl(); -} - // getAsString - If the sub-element type of this array is either sbyte or ubyte, // then this method converts the array to an std::string and returns it. // Otherwise, it asserts out. @@ -573,14 +604,12 @@ //---- ConstantStruct::get() implementation... // -static ValueMap, ConstantStruct> StructConstants; +static ValueMap, StructType, + ConstantStruct> StructConstants; ConstantStruct *ConstantStruct::get(const StructType *Ty, const std::vector &V) { - ConstantStruct *Result = StructConstants.get(Ty, V); - if (!Result) // If no preexisting value, create one now... - StructConstants.add(Ty, V, Result = new ConstantStruct(Ty, V)); - return Result; + return StructConstants.getOrCreate(Ty, V); } // destroyConstant - Remove the constant from the constant table... @@ -590,16 +619,38 @@ destroyConstantImpl(); } +/// refineAbstractType - If this callback is invoked, then this constant is of a +/// derived type, change all users to use a concrete constant of the new type. +/// +void ConstantStruct::refineAbstractType(const DerivedType *OldTy, + const Type *NewTy) { + Value::refineAbstractType(OldTy, NewTy); + + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + C.push_back(cast(getOperand(i))); + replaceAllUsesWith(ConstantStruct::get(cast(NewTy), + C)); + destroyConstant(); // This constant is now dead, destroy it. +} + //---- ConstantPointerNull::get() implementation... // -static ValueMap NullPtrConstants; + +// ConstantPointerNull does not take extra "value" argument... +template +struct ConstantCreator { + static ConstantPointerNull *create(const PointerType *Ty, const ValType &V){ + return new ConstantPointerNull(Ty); + } +}; + +static ValueMap NullPtrConstants; ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) { - ConstantPointerNull *Result = NullPtrConstants.get(Ty, 0); - if (!Result) // If no preexisting value, create one now... - NullPtrConstants.add(Ty, 0, Result = new ConstantPointerNull(Ty)); - return Result; + return NullPtrConstants.getOrCreate(Ty, 0); } // destroyConstant - Remove the constant from the constant table... @@ -609,6 +660,21 @@ destroyConstantImpl(); } +/// refineAbstractType - If this callback is invoked, then this constant is of a +/// derived type, change all users to use a concrete constant of the new type. +/// +void ConstantPointerNull::refineAbstractType(const DerivedType *OldTy, + const Type *NewTy) { + Value::refineAbstractType(OldTy, NewTy); + + // Make everyone now use a constant of the new type... + replaceAllUsesWith(ConstantPointerNull::get(cast(NewTy))); + + // This constant is now dead, destroy it. + destroyConstant(); +} + + //---- ConstantPointerRef::get() implementation... // @@ -630,7 +696,31 @@ //---- ConstantExpr::get() implementations... // typedef std::pair > ExprMapKeyType; -static ValueMap ExprConstants; + +template<> +struct ConstantCreator { + static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V) { + if (V.first == Instruction::Cast) + return new ConstantExpr(Instruction::Cast, V.second[0], Ty); + if ((V.first >= Instruction::BinaryOpsBegin && + V.first < Instruction::BinaryOpsEnd) || + V.first == Instruction::Shl || V.first == Instruction::Shr) + return new ConstantExpr(V.first, V.second[0], V.second[1]); + + assert(V.first == Instruction::GetElementPtr && "Invalid ConstantExpr!"); + + // Check that the indices list is valid... + std::vector ValIdxList(V.second.begin()+1, V.second.end()); + const Type *DestTy = GetElementPtrInst::getIndexedType(Ty, ValIdxList, + true); + assert(DestTy && "Invalid index list for GetElementPtr expression"); + + std::vector IdxList(V.second.begin()+1, V.second.end()); + return new ConstantExpr(V.second[0], IdxList, PointerType::get(DestTy)); + } +}; + +static ValueMap ExprConstants; Constant *ConstantExpr::getCast(Constant *C, const Type *Ty) { if (Constant *FC = ConstantFoldCastInstruction(C, Ty)) @@ -638,14 +728,8 @@ // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C); - const ExprMapKeyType &Key = std::make_pair(Instruction::Cast, argVec); - ConstantExpr *Result = ExprConstants.get(Ty, Key); - if (Result) return Result; - - // Its not in the table so create a new one and put it in the table. - Result = new ConstantExpr(Instruction::Cast, C, Ty); - ExprConstants.add(Ty, Key, Result); - return Result; + ExprMapKeyType Key = std::make_pair(Instruction::Cast, argVec); + return ExprConstants.getOrCreate(Ty, Key); } Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) { @@ -659,16 +743,9 @@ if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2)) return FC; // Fold a few common cases... - // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C1); argVec.push_back(C2); - const ExprMapKeyType &Key = std::make_pair(Opcode, argVec); - ConstantExpr *Result = ExprConstants.get(C1->getType(), Key); - if (Result) return Result; - - // It's not in the table so create a new one and put it in the table. - Result = new ConstantExpr(Opcode, C1, C2); - ExprConstants.add(C1->getType(), Key, Result); - return Result; + ExprMapKeyType Key = std::make_pair(Opcode, argVec); + return ExprConstants.getOrCreate(C1->getType(), Key); } /// getShift - Return a shift left or shift right constant expr @@ -685,14 +762,8 @@ // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C1); argVec.push_back(C2); - const ExprMapKeyType &Key = std::make_pair(Opcode, argVec); - ConstantExpr *Result = ExprConstants.get(C1->getType(), Key); - if (Result) return Result; - - // It's not in the table so create a new one and put it in the table. - Result = new ConstantExpr(Opcode, C1, C2); - ExprConstants.add(C1->getType(), Key, Result); - return Result; + ExprMapKeyType Key = std::make_pair(Opcode, argVec); + return ExprConstants.getOrCreate(C1->getType(), Key); } @@ -701,29 +772,15 @@ if (Constant *FC = ConstantFoldGetElementPtr(C, IdxList)) return FC; // Fold a few common cases... const Type *Ty = C->getType(); + assert(isa(Ty) && + "Non-pointer type for constant GetElementPtr expression"); // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C); argVec.insert(argVec.end(), IdxList.begin(), IdxList.end()); const ExprMapKeyType &Key = std::make_pair(Instruction::GetElementPtr,argVec); - ConstantExpr *Result = ExprConstants.get(Ty, Key); - if (Result) return Result; - - // Its not in the table so create a new one and put it in the table. - // Check the operands for consistency first - // - assert(isa(Ty) && - "Non-pointer type for constant GelElementPtr expression"); - - // Check that the indices list is valid... - std::vector ValIdxList(IdxList.begin(), IdxList.end()); - const Type *DestTy = GetElementPtrInst::getIndexedType(Ty, ValIdxList, true); - assert(DestTy && "Invalid index list for constant GelElementPtr expression"); - - Result = new ConstantExpr(C, IdxList, PointerType::get(DestTy)); - ExprConstants.add(Ty, Key, Result); - return Result; + return ExprConstants.getOrCreate(Ty, Key); } // destroyConstant - Remove the constant from the constant table... @@ -732,6 +789,40 @@ ExprConstants.remove(this); destroyConstantImpl(); } + +/// refineAbstractType - If this callback is invoked, then this constant is of a +/// derived type, change all users to use a concrete constant of the new type. +/// +void ConstantExpr::refineAbstractType(const DerivedType *OldTy, + const Type *NewTy) { + Value::refineAbstractType(OldTy, NewTy); + + // FIXME: These need to use a lower-level implementation method, because the + // ::get methods intuit the type of the result based on the types of the + // operands. The operand types may not have had their types resolved yet. + // + if (getOpcode() == Instruction::Cast) { + replaceAllUsesWith(getCast(getOperand(0), NewTy)); + } else if (getOpcode() >= Instruction::BinaryOpsBegin && + getOpcode() < Instruction::BinaryOpsEnd) { + replaceAllUsesWith(get(getOpcode(), getOperand(0), getOperand(0))); + } else if (getOpcode() == Instruction::Shl || getOpcode() ==Instruction::Shr){ + replaceAllUsesWith(getShift(getOpcode(), getOperand(0), getOperand(0))); + } else { + assert(getOpcode() == Instruction::GetElementPtr); + + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 1, e = getNumOperands(); i != e; ++i) + C.push_back(cast(getOperand(i))); + replaceAllUsesWith(ConstantExpr::getGetElementPtr(getOperand(0), + C)); + } + destroyConstant(); // This constant is now dead, destroy it. +} + + + const char *ConstantExpr::getOpcodeName() const { return Instruction::getOpcodeName(getOpcode()); From lattner at cs.uiuc.edu Fri May 23 15:08:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri May 23 15:08:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200305232007.PAA02616@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.2 -> 1.3 --- Log message: Add new bytecode pseudo target --- Diffs of the changes: Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.2 llvm/test/Programs/External/SPEC/Makefile.spec:1.3 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.2 Sat May 17 17:32:43 2003 +++ llvm/test/Programs/External/SPEC/Makefile.spec Fri May 23 15:07:10 2003 @@ -34,6 +34,10 @@ PROG := $(BENCH_NAME) Source := $(wildcard $(SPEC_BENCH_DIR)/src/*.c) +# Pseudo target to build just the bytecode file. +bytecode: Output/$(PROG).llvm.bc + + # Disable the default Output/%.out-* targets... PROGRAMS_HAVE_CUSTOM_RUN_RULES := 1 SourceDir := $(SPEC_BENCH_DIR)/src/ @@ -49,6 +53,7 @@ REF_IN_DIR := $(SPEC_BENCH_DIR)/data/$(RUN_TYPE)/input/ REF_OUT_DIR := $(SPEC_BENCH_DIR)/data/$(RUN_TYPE)/output/ LOCAL_OUTPUTS := $(notdir $(wildcard $(REF_OUT_DIR)/*)) + # Specify how to generate output from the SPEC programs. Basically we just run # the program in a sandbox (a special directory we create), then we cat all of From gaeke at cs.uiuc.edu Fri May 23 15:28:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri May 23 15:28:01 2003 Subject: [llvm-commits] CVS: llvm/tools/gccld/gccld.cpp Message-ID: <200305232027.PAA10072@gally.cs.uiuc.edu> Changes in directory llvm/tools/gccld: gccld.cpp updated: 1.30 -> 1.31 --- Log message: gccld.cpp: Fix typo in header. Add IsArchive static method. Roll LoadLibraryFromDirectory() into LoadLibrary(), and factor LoadLibraryExactName() out of the result. Instead of treating the current directory specially, just insert it into LibPaths in the beginning of main(). Make LoadLibrary() take a "search" flag that says whether to search for the correct library, or just trust that LibName is right. Make LinkLibrary() take a "search" flag, and pass it to LoadLibrary(). Change the for-loop over InputFilenames to detect ar archives and link them in as libraries without searching. Change the for-loop over Libraries to explicitly turn on the "search" flag to LinkLibrary() that makes LoadLibrary() search for the correct library (i.e., when processing -lNAME options.) --- Diffs of the changes: Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.30 llvm/tools/gccld/gccld.cpp:1.31 --- llvm/tools/gccld/gccld.cpp:1.30 Tue May 13 17:14:13 2003 +++ llvm/tools/gccld/gccld.cpp Fri May 23 15:27:07 2003 @@ -9,7 +9,7 @@ // // Note that if someone (or a script) deletes the executable program generated, // the .bc file will be left around. Considering that this is a temporary hack, -// I'm not to worried about this. +// I'm not too worried about this. // //===----------------------------------------------------------------------===// @@ -117,70 +117,80 @@ return M.release(); } +// IsArchive - Returns true iff FILENAME appears to be the name of an ar +// archive file. It determines this by checking the magic string at the +// beginning of the file. +static bool IsArchive (const std::string &filename) { + static const std::string ArchiveMagic ("!\012"); + char buf[1 + ArchiveMagic.size ()]; + std::ifstream f (filename.c_str ()); + f.read (buf, ArchiveMagic.size ()); + buf[ArchiveMagic.size ()] = '\0'; + return (ArchiveMagic == buf); +} -// LoadLibraryFromDirectory - This looks for a .a, .so, or .bc file in a -// particular directory. It returns true if no library is found, otherwise it -// puts the loaded modules into the Objects list, and sets isArchive to true if -// a .a file was loaded. -// -static inline bool LoadLibraryFromDirectory(const std::string &LibName, - const std::string &Directory, - std::vector &Objects, - bool &isArchive) { - if (FileExists(Directory + "lib" + LibName + ".a")) { - std::string ErrorMessage; - if (Verbose) std::cerr << " Loading '" << Directory << "lib" - << LibName << ".a'\n"; - if (!ReadArchiveFile(Directory + "lib" + LibName + ".a", Objects, - &ErrorMessage)) { // Read the archive file - isArchive = true; - return false; // Success! - } - - if (Verbose) { - std::cerr << " Error loading archive '" + Directory +"lib"+LibName+".a'"; - if (!ErrorMessage.empty()) std::cerr << ": " << ErrorMessage; - std::cerr << "\n"; +// LoadLibraryExactName - This looks for a file with a known name and tries to +// load it, similarly to LoadLibraryFromDirectory(). +static inline bool LoadLibraryExactName (const std::string &FileName, + std::vector &Objects, bool &isArchive) { + if (Verbose) std::cerr << " Considering '" << FileName << "'\n"; + if (FileExists(FileName)) { + if (IsArchive (FileName)) { + std::string ErrorMessage; + if (Verbose) std::cerr << " Loading '" << FileName << "'\n"; + if (!ReadArchiveFile(FileName, Objects, &ErrorMessage)) { + isArchive = true; + return false; // Success! + } + if (Verbose) { + std::cerr << " Error loading archive '" + FileName + "'"; + if (!ErrorMessage.empty()) std::cerr << ": " << ErrorMessage; + std::cerr << "\n"; + } + } else { + if (Module *M = LoadSingleLibraryObject(FileName)) { + isArchive = false; + Objects.push_back(M); + return false; + } } } - - if (FileExists(Directory + "lib" + LibName + ".so")) - if (Module *M = LoadSingleLibraryObject(Directory + "lib" + LibName+".so")){ - isArchive = false; - Objects.push_back(M); - return false; - } - - if (FileExists(Directory + "lib" + LibName + ".bc")) - if (Module *M = LoadSingleLibraryObject(Directory + "lib" + LibName+".bc")){ - isArchive = false; - Objects.push_back(M); - return false; - } return true; } -// LoadLibrary - This searches for a .a, .so, or .bc file which provides the -// LLVM bytecode for the library. It returns true if no library is found, -// otherwise it puts the loaded modules into the Objects list, and sets -// isArchive to true if a .a file was loaded. +// LoadLibrary - Try to load a library named LIBNAME that contains +// LLVM bytecode. If SEARCH is true, then search for a file named +// libLIBNAME.{a,so,bc} in the current library search path. Otherwise, +// assume LIBNAME is the real name of the library file. This method puts +// the loaded modules into the Objects list, and sets isArchive to true if +// a .a file was loaded. It returns true if no library is found or if an +// error occurs; otherwise it returns false. // static inline bool LoadLibrary(const std::string &LibName, std::vector &Objects, bool &isArchive, - std::string &ErrorMessage) { - std::string Directory; - unsigned NextLibPathIdx = 0; - - while (1) { - // Try loading from the current directory... - if (Verbose) std::cerr << " Looking in directory '" << Directory << "'\n"; - if (!LoadLibraryFromDirectory(LibName, Directory, Objects, isArchive)) + bool search, std::string &ErrorMessage) { + if (search) { + // First, try the current directory. Then, iterate over the + // directories in LibPaths, looking for a suitable match for LibName + // in each one. + for (unsigned NextLibPathIdx = 0; NextLibPathIdx != LibPaths.size(); + ++NextLibPathIdx) { + std::string Directory = LibPaths[NextLibPathIdx] + "/"; + if (!LoadLibraryExactName(Directory + "lib" + LibName + ".a", + Objects, isArchive)) + return false; + if (!LoadLibraryExactName(Directory + "lib" + LibName + ".so", + Objects, isArchive)) + return false; + if (!LoadLibraryExactName(Directory + "lib" + LibName + ".bc", + Objects, isArchive)) + return false; + } + } else { + // If they said no searching, then assume LibName is the real name. + if (!LoadLibraryExactName(LibName, Objects, isArchive)) return false; - - if (NextLibPathIdx == LibPaths.size()) break; - Directory = LibPaths[NextLibPathIdx++]+"/"; } - ErrorMessage = "error linking library '-l" + LibName+ "': library not found!"; return true; } @@ -231,7 +241,7 @@ static bool LinkLibrary(Module *M, const std::string &LibName, - std::string &ErrorMessage) { + bool search, std::string &ErrorMessage) { std::set UndefinedSymbols; GetAllUndefinedSymbols(M, UndefinedSymbols); if (UndefinedSymbols.empty()) { @@ -241,7 +251,8 @@ std::vector Objects; bool isArchive; - if (LoadLibrary(LibName, Objects, isArchive, ErrorMessage)) return true; + if (LoadLibrary(LibName, Objects, isArchive, search, ErrorMessage)) + return true; // Figure out which symbols are defined by all of the modules in the .a file std::vector > DefinedSymbols; @@ -307,11 +318,25 @@ if (Composite.get() == 0) return PrintAndReturn(argv[0], ErrorMessage); + // We always look first in the current directory when searching for libraries. + LibPaths.insert(LibPaths.begin(), "."); + // If the user specied an extra search path in their environment, respect it. if (char *SearchPath = getenv("LLVM_LIB_SEARCH_PATH")) LibPaths.push_back(SearchPath); for (unsigned i = 1; i < InputFilenames.size(); ++i) { + // A user may specify an ar archive without -l, perhaps because it + // is not installed as a library. Detect that and link the library. + if (IsArchive (InputFilenames[i])) { + if (Verbose) std::cerr << "Linking archive '" << InputFilenames[i] + << "'\n"; + if (LinkLibrary (Composite.get(), InputFilenames[i], false, ErrorMessage)) + return PrintAndReturn(argv[0], ErrorMessage, + ": error linking in '" + InputFilenames[i] + "'"); + continue; + } + std::auto_ptr M(LoadObject(InputFilenames[i], ErrorMessage)); if (M.get() == 0) return PrintAndReturn(argv[0], ErrorMessage); @@ -330,7 +355,7 @@ // Link in all of the libraries next... for (unsigned i = 0; i != Libraries.size(); ++i) { if (Verbose) std::cerr << "Linking in library: -l" << Libraries[i] << "\n"; - if (LinkLibrary(Composite.get(), Libraries[i], ErrorMessage)) + if (LinkLibrary(Composite.get(), Libraries[i], true, ErrorMessage)) return PrintAndReturn(argv[0], ErrorMessage); } From gaeke at cs.uiuc.edu Fri May 23 15:29:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri May 23 15:29:01 2003 Subject: [llvm-commits] CVS: llvm/tools/lli/lli.cpp Message-ID: <200305232028.PAA10083@gally.cs.uiuc.edu> Changes in directory llvm/tools/lli: lli.cpp updated: 1.17 -> 1.18 --- Log message: Remove ".bc" from the end of InputFile if it is there, in tools/lli/lli.cpp:main(). --- Diffs of the changes: Index: llvm/tools/lli/lli.cpp diff -u llvm/tools/lli/lli.cpp:1.17 llvm/tools/lli/lli.cpp:1.18 --- llvm/tools/lli/lli.cpp:1.17 Mon May 12 09:31:57 2003 +++ llvm/tools/lli/lli.cpp Fri May 23 15:28:07 2003 @@ -88,6 +88,13 @@ EE = ExecutionEngine::createInterpreter(M, Config, DebugMode, TraceMode); // Add the module name to the start of the argv vector... + // But delete .bc first, since programs (and users) might not expect to + // see it. + const std::string ByteCodeFileSuffix (".bc"); + if (InputFile.rfind (ByteCodeFileSuffix) == + InputFile.length () - ByteCodeFileSuffix.length ()) { + InputFile.erase (InputFile.length () - ByteCodeFileSuffix.length ()); + } InputArgv.insert(InputArgv.begin(), InputFile); // Run the main function! From gaeke at cs.uiuc.edu Fri May 23 16:05:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri May 23 16:05:01 2003 Subject: [llvm-commits] CVS: llvm/www/docs/HowToSubmitABug.html Message-ID: <200305232104.QAA19738@tank.cs.uiuc.edu> Changes in directory llvm/www/docs: HowToSubmitABug.html updated: 1.2 -> 1.3 --- Log message: Suggest -save-temps instead of -S, -E. --- Diffs of the changes: Index: llvm/www/docs/HowToSubmitABug.html diff -u llvm/www/docs/HowToSubmitABug.html:1.2 llvm/www/docs/HowToSubmitABug.html:1.3 --- llvm/www/docs/HowToSubmitABug.html:1.2 Fri May 23 09:49:32 2003 +++ llvm/www/docs/HowToSubmitABug.html Fri May 23 16:03:50 2003 @@ -95,11 +95,14 @@ Front-end bugs
      -If the problem is in the front-end, pretty much the only thing you can do is -preprocess the input (compile with the -E option) and send us the -results. There is no good way to reduce source-level test-cases that I know -of... if you do know, send me information and we can extend this section. :)

      - +If the problem is in the front-end, you should re-run the same +llvm-gcc command that resulted in the crash, but add the +-save-temps option. The compiler will crash again, but it +will leave behind a foo.i file (containing preprocessed +C source code) and possibly foo.s (containing LLVM +assembly code), for each compiled foo.c file. Send us +the foo.i file, along with a brief description of the +error it caused.

    @@ -109,8 +112,8 @@
      If you find that a bug crashes in the gccas stage of -compilation, compile your test-case to a .s file with the -S -option to llvm-gcc. Then run:

      +compilation, compile your test-case to a .s file with the +-save-temps option to llvm-gcc. Then run:

         gccas -debug-pass=Arguments < /dev/null -o - > /dev/null
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 19:09:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 19:09:01 2003
      Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h
      Message-ID: <200305240008.TAA04500@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/include/llvm/Target:
      
      TargetInstrInfo.h updated: 1.42 -> 1.43
      
      ---
      Log message:
      
      NOP instructions are pseudo-instructions. We should not have them explicitly in
      our representation, since they are usually special cases of already-existing
      instructions.
      
      This abstracts away methods that let a pass create and verify a NOP instruction,
      without relying on a `NOP' enum to be in existence in the target's instruction
      info descriptor.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/include/llvm/Target/TargetInstrInfo.h
      diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.42 llvm/include/llvm/Target/TargetInstrInfo.h:1.43
      --- llvm/include/llvm/Target/TargetInstrInfo.h:1.42	Tue Jan 14 15:59:58 2003
      +++ llvm/include/llvm/Target/TargetInstrInfo.h	Fri May 23 19:08:39 2003
      @@ -273,6 +273,20 @@
           return true;                        // safe but very conservative
         }
       
      +
      +  /// createNOPinstr - returns the target's implementation of NOP, which is
      +  /// usually a pseudo-instruction, implemented by a degenerate version of
      +  /// another instruction, e.g. X86: xchg ax, ax; SparcV9: sethi g0, 0
      +  ///
      +  virtual MachineInstr* createNOPinstr() const = 0;
      +
      +  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      +  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      +  /// there may be more than one way to `do nothing' but only one canonical
      +  /// way to slack off.
      +  ///
      +  virtual bool isNOPinstr(const MachineInstr &MI) const = 0;
      +
         //-------------------------------------------------------------------------
         // Code generation support for creating individual machine instructions
         //
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 19:10:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 19:10:01 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp X86InstrInfo.h
      Message-ID: <200305240009.TAA04975@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/X86:
      
      X86InstrInfo.cpp updated: 1.12 -> 1.13
      X86InstrInfo.h updated: 1.21 -> 1.22
      
      ---
      Log message:
      
      Implement the TargetInstrInfo's createNOPinstr() and isNOPinstr() interface.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/X86/X86InstrInfo.cpp
      diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.12 llvm/lib/Target/X86/X86InstrInfo.cpp:1.13
      --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.12	Tue Jan 14 15:59:16 2003
      +++ llvm/lib/Target/X86/X86InstrInfo.cpp	Fri May 23 19:09:13 2003
      @@ -6,7 +6,7 @@
       
       #include "X86InstrInfo.h"
       #include "X86.h"
      -#include "llvm/CodeGen/MachineInstr.h"
      +#include "llvm/CodeGen/MachineInstrBuilder.h"
       
       #define I(ENUM, NAME, BASEOPCODE, FLAGS, TSFLAGS, IMPDEFS, IMPUSES)
       #define IMPREGSLIST(NAME, ...) \
      @@ -36,6 +36,34 @@
       
       X86InstrInfo::X86InstrInfo()
         : TargetInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0]), 0) {
      +}
      +
      +
      +// createNOPinstr - returns the target's implementation of NOP, which is
      +// usually a pseudo-instruction, implemented by a degenerate version of
      +// another instruction, e.g. X86: `xchg ax, ax'; SparcV9: `sethi r0, r0, r0'
      +//
      +MachineInstr* X86InstrInfo::createNOPinstr() const {
      +  return BuildMI(X86::XCHGrr16, 2).addReg(X86::AX).addReg(X86::AX);
      +}
      +
      +
      +// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      +// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      +// there may be more than one way to `do nothing' but only one canonical
      +// way to slack off.
      +//
      +bool X86InstrInfo::isNOPinstr(const MachineInstr &MI) const {
      +  // Make sure the instruction is EXACTLY `xchg ax, ax'
      +  if (MI.getOpcode() == X86::XCHGrr16 && MI.getNumOperands() == 2) {
      +    const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1);
      +    if (op0.isMachineRegister() && op0.getMachineRegNum() == X86::AX &&
      +        op1.isMachineRegister() && op1.getMachineRegNum() == X86::AX)
      +    {
      +      return true;
      +    }
      +  }
      +  return false;
       }
       
       
      
      
      Index: llvm/lib/Target/X86/X86InstrInfo.h
      diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.21 llvm/lib/Target/X86/X86InstrInfo.h:1.22
      --- llvm/lib/Target/X86/X86InstrInfo.h:1.21	Tue Jan 14 15:59:16 2003
      +++ llvm/lib/Target/X86/X86InstrInfo.h	Fri May 23 19:09:13 2003
      @@ -148,6 +148,19 @@
         ///
         virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
       
      +  /// createNOPinstr - returns the target's implementation of NOP, which is
      +  /// usually a pseudo-instruction, implemented by a degenerate version of
      +  /// another instruction, e.g. X86: `xchg ax, ax'; SparcV9: `sethi r0, r0, r0'
      +  ///
      +  MachineInstr* createNOPinstr() const;
      +
      +  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      +  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      +  /// there may be more than one way to `do nothing' but only one canonical
      +  /// way to slack off.
      +  ///
      +  bool isNOPinstr(const MachineInstr &MI) const;
      +
         /// print - Print out an x86 instruction in intel syntax
         ///
         virtual void print(const MachineInstr *MI, std::ostream &O,
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 19:11:00 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 19:11:00 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInternals.h
      Message-ID: <200305240010.TAA05163@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      SparcInternals.h updated: 1.81 -> 1.82
      
      ---
      Log message:
      
      Implement the TargetInstrInfo's createNOPinstr() and isNOPinstr() interface.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/SparcInternals.h
      diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.81 llvm/lib/Target/Sparc/SparcInternals.h:1.82
      --- llvm/lib/Target/Sparc/SparcInternals.h:1.81	Tue May 20 15:32:24 2003
      +++ llvm/lib/Target/Sparc/SparcInternals.h	Fri May 23 19:09:50 2003
      @@ -8,6 +8,7 @@
       #ifndef SPARC_INTERNALS_H
       #define SPARC_INTERNALS_H
       
      +#include "llvm/CodeGen/MachineInstrBuilder.h"
       #include "llvm/Target/TargetMachine.h"
       #include "llvm/Target/TargetSchedInfo.h"
       #include "llvm/Target/TargetFrameInfo.h"
      @@ -15,6 +16,7 @@
       #include "llvm/Target/TargetRegInfo.h"
       #include "llvm/Target/TargetOptInfo.h"
       #include "llvm/Type.h"
      +#include "SparcRegClassInfo.h"
       #include 
       
       class LiveRange;
      @@ -101,6 +103,33 @@
           }
           else
             return -1;
      +  }
      +
      +  /// createNOPinstr - returns the target's implementation of NOP, which is
      +  /// usually a pseudo-instruction, implemented by a degenerate version of
      +  /// another instruction, e.g. X86: xchg ax, ax; SparcV9: sethi g0, 0
      +  ///
      +  MachineInstr* createNOPinstr() const {
      +    return BuildMI(V9::SETHI, 2).addReg(SparcIntRegClass::g0).addZImm(0);
      +  }
      +
      +  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      +  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      +  /// there may be more than one way to `do nothing' but only one canonical
      +  /// way to slack off.
      +  ///
      +  bool isNOPinstr(const MachineInstr &MI) const {
      +    // Make sure the instruction is EXACTLY `sethi g0, 0'
      +    if (MI.getOpcode() == V9::SETHI && MI.getNumOperands() == 2) {
      +      const MachineOperand &op0 = MI.getOperand(0), &op1 = MI.getOperand(1);
      +      if (op0.isMachineRegister() &&
      +          op0.getMachineRegNum() == SparcIntRegClass::g0 &&
      +          op1.isImmediate() && op1.getImmedValue() == 0)
      +      {
      +        return true;
      +      }
      +    }
      +    return false;
         }
         
         virtual bool hasResultInterlock(MachineOpCode opCode) const
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 19:17:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 19:17:01 2003
      Subject: [llvm-commits] CVS: llvm/utils/TableGen/CodeEmitterGen.cpp CodeEmitterGen.h
      Message-ID: <200305240016.TAA05897@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/utils/TableGen:
      
      CodeEmitterGen.cpp added (r1.1)
      CodeEmitterGen.h added (r1.1)
      
      ---
      Log message:
      
      First cut at the Code Generator using the TableGen methodology.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/utils/TableGen/CodeEmitterGen.cpp
      diff -c /dev/null llvm/utils/TableGen/CodeEmitterGen.cpp:1.1
      *** /dev/null	Fri May 23 19:16:03 2003
      --- llvm/utils/TableGen/CodeEmitterGen.cpp	Fri May 23 19:15:53 2003
      ***************
      *** 0 ****
      --- 1,105 ----
      + #include "Record.h"
      + #include "CodeEmitterGen.h"
      + #include 
      + 
      + void CodeEmitterGen::createEmitter(std::ostream &o) {
      +   std::vector Insts;
      + 
      +   const std::map &Defs = Records.getDefs();
      +   Record *Inst = Records.getClass("Instruction");
      +   assert(Inst && "Couldn't find Instruction class!");
      + 
      +   for (std::map::const_iterator I = Defs.begin(),
      + 	 E = Defs.end(); I != E; ++I)
      +     if (I->second->isSubClassOf(Inst))
      +       Insts.push_back(I->second);
      + 
      +   std::string Namespace = "V9::";
      +   std::string ClassName = "SparcV9CodeEmitter::";
      + 
      +   //const std::string &Namespace = Inst->getValue("Namespace")->getName();
      +   o << "unsigned " << ClassName
      +     << "getBinaryCodeForInstr(MachineInstr &MI) {\n"
      +     << "  unsigned Value = 0;\n"
      +     << "  switch (MI.getOpcode()) {\n";
      +   for (std::vector::iterator I = Insts.begin(), E = Insts.end();
      +        I != E; ++I)
      +   {
      +     Record *R = *I;
      +     o << "    case " << Namespace << R->getName() << ": {\n";
      + 
      +     const RecordVal *InstVal = R->getValue("Inst");
      +     Init *InitVal = InstVal->getValue();
      + 
      +     assert(dynamic_cast(InitVal) &&
      +            "Can only handle undefined bits<> types!");
      +     BitsInit *BI = (BitsInit*)InitVal;
      + 
      +     unsigned Value = 0;
      +     const std::vector &Vals = R->getValues();
      + 
      +     // Start by filling in fixed values...
      +     for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i)
      +       if (BitInit *B = dynamic_cast(BI->getBit(i)))
      +         Value |= B->getValue() << i;
      + 
      +     o << "      Value = " << Value << "U;\n";
      +     o << "      // " << *InstVal << "\n";
      +     
      +     // Loop over all of the fields in the instruction adding in any
      +     // contributions to this value (due to bit references).
      +     //
      +     unsigned Offset = 31, opNum=0;
      +     std::map OpOrder;
      +     for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
      +       if (Vals[i].getName() != "Inst" && 
      +           !Vals[i].getValue()->isComplete() &&
      +           Vals[i].getName() != "annul" && 
      +           Vals[i].getName() != "cc" &&
      +           Vals[i].getName() != "predict")
      +       {
      +         o << "      // " << opNum << ": " << Vals[i].getName() << "\n";
      +         OpOrder[Vals[i].getName()] = opNum++;
      +       }
      +     }
      + 
      +     for (int f = Vals.size()-1; f >= 0; --f) {
      +       if (Vals[f].getPrefix()) {
      +         BitsInit *FieldInitializer = (BitsInit*)Vals[f].getValue();
      + 
      +         // Scan through the field looking for bit initializers of the current
      +         // variable...
      +         for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) {
      +           
      +           if (BitInit *BI=dynamic_cast(FieldInitializer->getBit(i))){
      +             --Offset;
      +           } else if (UnsetInit *UI = 
      +                      dynamic_cast(FieldInitializer->getBit(i))) {
      +             --Offset;
      +           } else if (VarBitInit *VBI =
      +                      dynamic_cast(FieldInitializer->getBit(i))) {
      +             TypedInit *TI = VBI->getVariable();
      +             if (VarInit *VI = dynamic_cast(TI)) {
      +               o << "      Value |= getValueBit(MI.getOperand(" 
      +                 << OpOrder[VI->getName()]
      +                 << "), " << VBI->getBitNum()
      +                 << ")" << " << " << Offset << ";\n";
      +               --Offset;
      +             } else if (FieldInit *FI = dynamic_cast(TI)) {
      +               // FIXME: implement this!
      +               o << "FIELD INIT not implemented yet!\n";
      +             } else {
      +               o << "something else\n";
      +             }
      +           }
      +         }
      +       }
      +     }
      + 
      +     o << "      break;\n"
      +       << "    }\n";
      +   }
      +   o << "  }\n"
      +     << "  return Value;\n"
      +     << "}\n";
      + }
      
      
      Index: llvm/utils/TableGen/CodeEmitterGen.h
      diff -c /dev/null llvm/utils/TableGen/CodeEmitterGen.h:1.1
      *** /dev/null	Fri May 23 19:16:03 2003
      --- llvm/utils/TableGen/CodeEmitterGen.h	Fri May 23 19:15:53 2003
      ***************
      *** 0 ****
      --- 1,23 ----
      + //===- CodeEmitterGen.h - Code Emitter Generator ----------------*- C++ -*-===//
      + //
      + //
      + //===----------------------------------------------------------------------===//
      + 
      + #ifndef CODEMITTERGEN_H
      + #define CODEMITTERGEN_H
      + 
      + #include "Record.h"
      + #include 
      + 
      + struct CodeEmitterGen {
      +   RecordKeeper &Records;
      +   
      + public:
      +   CodeEmitterGen(RecordKeeper &R) : Records(R) {}
      +   
      +   void createEmitter(std::ostream &o);
      +   void emitMachineOpEmitter(std::ostream &o, const std::string &Namespace);
      +   void emitGetValueBit(std::ostream &o, const std::string &Namespace);
      + };
      + 
      + #endif
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 19:18:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 19:18:01 2003
      Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp
      Message-ID: <200305240017.TAA05937@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/utils/TableGen:
      
      TableGen.cpp updated: 1.3 -> 1.4
      
      ---
      Log message:
      
      Add ability to utilize the code emitter generator (CodeEmitterGen).
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/utils/TableGen/TableGen.cpp
      diff -u llvm/utils/TableGen/TableGen.cpp:1.3 llvm/utils/TableGen/TableGen.cpp:1.4
      --- llvm/utils/TableGen/TableGen.cpp:1.3	Tue Dec  3 14:01:04 2002
      +++ llvm/utils/TableGen/TableGen.cpp	Fri May 23 19:17:12 2003
      @@ -1,9 +1,11 @@
       #include "Record.h"
       #include "Support/CommandLine.h"
      +#include "CodeEmitterGen.h"
       #include 
       
       static cl::opt Class("class", cl::desc("Print Enum list for this class"));
       static cl::opt        Parse("parse");
      +static cl::opt        GenEmitter("gen-emitter");
       
       void ParseFile();
       
      @@ -289,6 +291,7 @@
       }
       
       static void ParseMachineCode() {
      +  // X86 code
         unsigned char Buffer[] = {
                                    0x55,             // push EBP
       			     0x89, 0xE5,       // mov EBP, ESP
      @@ -307,7 +310,18 @@
       			     0x85, 0xC0,       // test EAX, EAX
       			     0xF4,             // hlt
         };
      -  
      +
      +#if 0
      +  // SparcV9 code
      +  unsigned char Buffer[] = { 0xbf, 0xe0, 0x20, 0x1f, 0x1, 0x0, 0x0, 0x1, 
      +                             0x0, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x20, 0x1, 0x1,
      +                             0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      +                             0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1,
      +                             0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
      +                             0x0, 0x0, 0xaf, 0xe8, 0x20, 0x17
      +  };
      +#endif
      +
         std::vector Insts;
       
         const std::map &Defs = Records.getDefs();
      @@ -341,6 +355,12 @@
       
         if (Parse) {
           ParseMachineCode();
      +    return 0;
      +  }
      +
      +  if (GenEmitter) {
      +    CodeEmitterGen CEG(Records);
      +    CEG.createEmitter(std::cout);
           return 0;
         }
       
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 20:09:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 20:09:01 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.h X86InstrInfo.cpp
      Message-ID: <200305240108.UAA07949@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/X86:
      
      X86InstrInfo.h updated: 1.22 -> 1.23
      X86InstrInfo.cpp updated: 1.13 -> 1.14
      
      ---
      Log message:
      
      Reword to remove reference to how things worked in the past.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/X86/X86InstrInfo.h
      diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.22 llvm/lib/Target/X86/X86InstrInfo.h:1.23
      --- llvm/lib/Target/X86/X86InstrInfo.h:1.22	Fri May 23 19:09:13 2003
      +++ llvm/lib/Target/X86/X86InstrInfo.h	Fri May 23 20:08:43 2003
      @@ -154,10 +154,9 @@
         ///
         MachineInstr* createNOPinstr() const;
       
      -  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      -  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      -  /// there may be more than one way to `do nothing' but only one canonical
      -  /// way to slack off.
      +  /// isNOPinstr - not having a special NOP opcode, we need to know if a given
      +  /// instruction is interpreted as an `official' NOP instr, i.e., there may be
      +  /// more than one way to `do nothing' but only one canonical way to slack off.
         ///
         bool isNOPinstr(const MachineInstr &MI) const;
       
      
      
      Index: llvm/lib/Target/X86/X86InstrInfo.cpp
      diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.13 llvm/lib/Target/X86/X86InstrInfo.cpp:1.14
      --- llvm/lib/Target/X86/X86InstrInfo.cpp:1.13	Fri May 23 19:09:13 2003
      +++ llvm/lib/Target/X86/X86InstrInfo.cpp	Fri May 23 20:08:43 2003
      @@ -48,10 +48,9 @@
       }
       
       
      -// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      -// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      -// there may be more than one way to `do nothing' but only one canonical
      -// way to slack off.
      +/// isNOPinstr - not having a special NOP opcode, we need to know if a given
      +/// instruction is interpreted as an `official' NOP instr, i.e., there may be
      +/// more than one way to `do nothing' but only one canonical way to slack off.
       //
       bool X86InstrInfo::isNOPinstr(const MachineInstr &MI) const {
         // Make sure the instruction is EXACTLY `xchg ax, ax'
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 20:09:07 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 20:09:07 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInternals.h
      Message-ID: <200305240108.UAA07940@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      SparcInternals.h updated: 1.82 -> 1.83
      
      ---
      Log message:
      
      Reword to remove reference to how things worked in the past.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/SparcInternals.h
      diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.82 llvm/lib/Target/Sparc/SparcInternals.h:1.83
      --- llvm/lib/Target/Sparc/SparcInternals.h:1.82	Fri May 23 19:09:50 2003
      +++ llvm/lib/Target/Sparc/SparcInternals.h	Fri May 23 20:08:42 2003
      @@ -113,10 +113,9 @@
           return BuildMI(V9::SETHI, 2).addReg(SparcIntRegClass::g0).addZImm(0);
         }
       
      -  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      -  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      -  /// there may be more than one way to `do nothing' but only one canonical
      -  /// way to slack off.
      +  /// isNOPinstr - not having a special NOP opcode, we need to know if a given
      +  /// instruction is interpreted as an `official' NOP instr, i.e., there may be
      +  /// more than one way to `do nothing' but only one canonical way to slack off.
         ///
         bool isNOPinstr(const MachineInstr &MI) const {
           // Make sure the instruction is EXACTLY `sethi g0, 0'
      
      
      
      
      From brukman at cs.uiuc.edu  Fri May 23 20:09:13 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Fri May 23 20:09:13 2003
      Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetInstrInfo.h
      Message-ID: <200305240108.UAA07933@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/include/llvm/Target:
      
      TargetInstrInfo.h updated: 1.43 -> 1.44
      
      ---
      Log message:
      
      Reword to remove reference to how things worked in the past.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/include/llvm/Target/TargetInstrInfo.h
      diff -u llvm/include/llvm/Target/TargetInstrInfo.h:1.43 llvm/include/llvm/Target/TargetInstrInfo.h:1.44
      --- llvm/include/llvm/Target/TargetInstrInfo.h:1.43	Fri May 23 19:08:39 2003
      +++ llvm/include/llvm/Target/TargetInstrInfo.h	Fri May 23 20:08:40 2003
      @@ -280,10 +280,9 @@
         ///
         virtual MachineInstr* createNOPinstr() const = 0;
       
      -  /// isNOPinstr - since we no longer have a special NOP opcode, we need to know
      -  /// if a given instruction is interpreted as an `official' NOP instr, i.e.,
      -  /// there may be more than one way to `do nothing' but only one canonical
      -  /// way to slack off.
      +  /// isNOPinstr - not having a special NOP opcode, we need to know if a given
      +  /// instruction is interpreted as an `official' NOP instr, i.e., there may be
      +  /// more than one way to `do nothing' but only one canonical way to slack off.
         ///
         virtual bool isNOPinstr(const MachineInstr &MI) const = 0;
       
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 10:58:01 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 10:58:01 2003
      Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
      Message-ID: <200305251557.KAA13144@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/test/Programs/SingleSource/UnitTests:
      
      2003-05-07-VarArgs.c updated: 1.3 -> 1.4
      
      ---
      Log message:
      
      Add tests for passing structures by value through varargs.
      Also modify test to pass more arguments than fit in the argument registers.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
      diff -u llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.3 llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.4
      --- llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.3	Thu May  8 14:43:55 2003
      +++ llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c	Sun May 25 10:56:54 2003
      @@ -1,10 +1,23 @@
       #include 
       #include 
       
      +/* 5 bytes. */
      +typedef struct DWordS_struct    { int i; char c; } DWordS;
      +
      +/* 12 bytes if d is 4-byte aligned; 16 bytes if d is 8-byte aligned. */
      +typedef struct QuadWordS_struct { int i; double d; } QuadWordS;
      +
      +/* 20 bytes if d is 4-byte aligned; 28 bytes if d is 8-byte aligned
      + * (assuming pointer size is 4 bytes and 8 bytes respectively). */
      +typedef struct LargeS_struct { int i; double d; DWordS* ptr; int j; } LargeS;
      +
       void test(char *fmt, ...) {
         va_list ap, aq;
         int d;
         char c, *s;
      +  DWordS dw;
      +  QuadWordS qw;
      +  LargeS ls;
       
         va_start(ap, fmt);
       
      @@ -33,14 +46,35 @@
             c = (char) va_arg(ap, int);
             printf("char %c\n", c);
             break;
      +    case 'D':
      +      /* dw = va_arg(ap, DWordS);
      +      printf("DWord { %d, %c }\n", dw.i, dw.c);
      +      */ break;
      +    case 'Q':
      +      /* qw = va_arg(ap, QuadWordS);
      +      printf("QuadWord { %d, %f }\n", qw.i, qw.d);
      +      */ break;
      +    case 'L':
      +      /* ls = va_arg(ap, LargeS);
      +      printf("LargeS { %d, %f, 0x%p, %d }\n", ls.i, ls.d, ls.ptr, ls.j);
      +      */ break;
           }
         va_end(ap);
       }
       
       int main() {
      -  test("ssici", "abc", "def", -123, 'a', 123);
      +  DWordS dw = { 18, 'a' };
      +  DWordS dw2;
      +  QuadWordS qw = { 19, 20.0 };
      +  LargeS ls = { 21, 22.0, &dw, 23 };
      +
      +  test("ssiciiiiis", "abc", "def", -123, 'a', 123, 6, 7, 8, 9, "10 args done!");
       
         /* test promotion & 64-bit types */
         test("ddil", 1.0, 2.0f, (short)32764, 12345677823423LL);
      +
      +  /* test passing structs by value to varargs */
      +  test("DQL", dw2, qw, ls);
      +
         return 0;
       }
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 11:00:01 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 11:00:01 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp Sparc.burg.in SparcInstrSelection.cpp SparcInternals.h
      Message-ID: <200305251559.KAA13171@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      PrologEpilogCodeInserter.cpp updated: 1.24 -> 1.25
      Sparc.burg.in updated: 1.4 -> 1.5
      SparcInstrSelection.cpp updated: 1.91 -> 1.92
      SparcInternals.h updated: 1.83 -> 1.84
      
      ---
      Log message:
      
      Add support for compiling varargs functions.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp
      diff -u llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.24 llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.25
      --- llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp:1.24	Tue May 20 15:32:23 2003
      +++ llvm/lib/Target/Sparc/PrologEpilogCodeInserter.cpp	Sun May 25 10:59:47 2003
      @@ -17,6 +17,8 @@
       #include "llvm/CodeGen/MachineInstrBuilder.h"
       #include "llvm/Pass.h"
       #include "llvm/Function.h"
      +#include "llvm/DerivedTypes.h"
      +#include "llvm/Intrinsics.h"
       
       namespace {
         struct InsertPrologEpilogCode : public MachineFunctionPass {
      @@ -91,6 +93,34 @@
           // Now generate the SAVE using the value in register %g1
           M = BuildMI(V9::SAVE, 3).addMReg(SP).addMReg(uregNum).addMReg(SP,MOTy::Def);
           mvec.push_back(M);
      +  }
      +
      +  // For varargs function bodies, insert instructions to copy incoming
      +  // register arguments for the ... list to the stack.
      +  // The first K=6 arguments are always received via int arg regs
      +  // (%i0 ... %i5 if K=6) .
      +  // By copying the varargs arguments to the stack, va_arg() then can
      +  // simply assume that all vararg arguments are in an array on the stack. 
      +  // 
      +  if (MF.getFunction()->getFunctionType()->isVarArg()) {
      +    int numFixedArgs    = MF.getFunction()->getFunctionType()->getNumParams();
      +    int numArgRegs      = TM.getRegInfo().getNumOfIntArgRegs();
      +    if (numFixedArgs < numArgRegs) {
      +      bool ignore;
      +      int firstArgReg   = TM.getRegInfo().getUnifiedRegNum(
      +                             TM.getRegInfo().getRegClassIDOfType(Type::IntTy),
      +                             SparcIntRegClass::i0);
      +      int fpReg         = TM.getFrameInfo().getIncomingArgBaseRegNum();
      +      int argSize       = TM.getFrameInfo().getSizeOfEachArgOnStack();
      +      int firstArgOffset=TM.getFrameInfo().getFirstIncomingArgOffset(MF,ignore);
      +      int nextArgOffset = firstArgOffset + numFixedArgs * argSize;
      +
      +      for (int i=numFixedArgs; i < numArgRegs; ++i) {
      +        mvec.push_back(BuildMI(V9::STX, 3).addMReg(firstArgReg+i).
      +                       addMReg(fpReg).addSImm(nextArgOffset));
      +        nextArgOffset += argSize;
      +      }
      +    }
         }
       
         MF.front().insert(MF.front().begin(), mvec.begin(), mvec.end());
      
      
      Index: llvm/lib/Target/Sparc/Sparc.burg.in
      diff -u llvm/lib/Target/Sparc/Sparc.burg.in:1.4 llvm/lib/Target/Sparc/Sparc.burg.in:1.5
      --- llvm/lib/Target/Sparc/Sparc.burg.in:1.4	Sat Aug 24 15:58:04 2002
      +++ llvm/lib/Target/Sparc/Sparc.burg.in	Sun May 25 10:59:47 2003
      @@ -87,7 +87,8 @@
       %term Call=CallOPCODE
       %term Shl=ShlOPCODE
       %term Shr=ShrOPCODE
      -		/* 30...46 are unused */
      +%term VaArg=VarArgOPCODE
      +		/* 32...46 are unused */
           /*
            * The foll. values should match the constants in InstrForest.h
            */
      @@ -256,6 +257,7 @@
       reg:	Shl(reg,reg)		=   62 (20);	/* 1 for issue restrictions */
       reg:	Shr(reg,reg)		=   63 (20);	/* 1 for issue restrictions */
       reg:	Phi(reg,reg)		=   64 (0);
      +reg:	VaArg(reg)		=   65 (40);	/* load from stack then incr */
       
       	/*
       	 * Finally, leaf nodes of expression trees.
      
      
      Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
      diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.91 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.92
      --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.91	Wed May 21 13:48:06 2003
      +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp	Sun May 25 10:59:47 2003
      @@ -22,6 +22,7 @@
       #include "llvm/Function.h"
       #include "llvm/Constants.h"
       #include "llvm/ConstantHandling.h"
      +#include "llvm/Intrinsics.h"
       #include "Support/MathExtras.h"
       #include 
       
      @@ -1298,6 +1299,46 @@
         return true;
       }
       
      +// Generate code for any intrinsic that needs a special code sequence
      +// instead of a regular call.  If not that kind of intrinsic, do nothing.
      +// Returns true if code was generated, otherwise false.
      +// 
      +bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr,
      +                      TargetMachine &target,
      +                      std::vector& mvec)
      +{
      +  switch (iid) {
      +  case LLVMIntrinsic::va_start: {
      +    // Get the address of the first vararg value on stack and copy it to
      +    // the argument of va_start(va_list* ap).
      +    bool ignore;
      +    Function* func = cast(callInstr.getParent()->getParent());
      +    int numFixedArgs   = func->getFunctionType()->getNumParams();
      +    int fpReg          = target.getFrameInfo().getIncomingArgBaseRegNum();
      +    int argSize        = target.getFrameInfo().getSizeOfEachArgOnStack();
      +    int firstVarArgOff = numFixedArgs * argSize + target.getFrameInfo().
      +      getFirstIncomingArgOffset(MachineFunction::get(func), ignore);
      +    mvec.push_back(BuildMI(V9::ADD, 3).addMReg(fpReg).addSImm(firstVarArgOff).
      +                   addReg(callInstr.getOperand(1)));
      +    return true;
      +  }
      +
      +  case LLVMIntrinsic::va_end:
      +    return true;                        // no-op on Sparc
      +
      +  case LLVMIntrinsic::va_copy:
      +    // Simple copy of current va_list (arg2) to new va_list (arg1)
      +    mvec.push_back(BuildMI(V9::OR, 3).
      +                   addMReg(target.getRegInfo().getZeroRegNum()).
      +                   addReg(callInstr.getOperand(2)).
      +                   addReg(callInstr.getOperand(1)));
      +    return true;
      +
      +  default:
      +    return false;
      +  }
      +}
      +
       //******************* Externally Visible Functions *************************/
       
       //------------------------------------------------------------------------ 
      @@ -2101,96 +2142,112 @@
                       // 
               CallInst *callInstr = cast(subtreeRoot->getInstruction());
               Value *callee = callInstr->getCalledValue();
      +        Function* calledFunc = dyn_cast(callee);
       
      -        // Create hidden virtual register for return address with type void*
      -        TmpInstruction* retAddrReg =
      -          new TmpInstruction(PointerType::get(Type::VoidTy), callInstr);
      -        MachineCodeForInstruction::get(callInstr).addTemp(retAddrReg);
      -
      -        // Generate the machine instruction and its operands.
      -        // Use CALL for direct function calls; this optimistically assumes
      -        // the PC-relative address fits in the CALL address field (22 bits).
      -        // Use JMPL for indirect calls.
      +        // Check if this is an intrinsic function that needs a special code
      +        // sequence (e.g., va_start).  Indirect calls cannot be special.
               // 
      -        if (isa(callee))      // direct function call
      -          M = BuildMI(V9::CALL, 1).addPCDisp(callee);
      -        else                            // indirect function call
      -          M = BuildMI(V9::JMPLCALL, 3).addReg(callee).addSImm((int64_t)0)
      -            .addRegDef(retAddrReg);
      -        mvec.push_back(M);
      +        bool specialIntrinsic = false;
      +        LLVMIntrinsic::ID iid;
      +        if (calledFunc && (iid=(LLVMIntrinsic::ID)calledFunc->getIntrinsicID()))
      +          specialIntrinsic = CodeGenIntrinsic(iid, *callInstr, target, mvec);
       
      -        const FunctionType* funcType =
      -          cast(cast(callee->getType())
      -                             ->getElementType());
      -        bool isVarArgs = funcType->isVarArg();
      -        bool noPrototype = isVarArgs && funcType->getNumParams() == 0;
      -        
      -        // Use a descriptor to pass information about call arguments
      -        // to the register allocator.  This descriptor will be "owned"
      -        // and freed automatically when the MachineCodeForInstruction
      -        // object for the callInstr goes away.
      -        CallArgsDescriptor* argDesc = new CallArgsDescriptor(callInstr,
      -                                         retAddrReg, isVarArgs, noPrototype);
      -        
      -        assert(callInstr->getOperand(0) == callee
      -               && "This is assumed in the loop below!");
      -        
      -        for (unsigned i=1, N=callInstr->getNumOperands(); i < N; ++i)
      +        // If not, generate the normal call sequence for the function.
      +        // This can also handle any intrinsics that are just function calls.
      +        // 
      +        if (! specialIntrinsic)
                 {
      -            Value* argVal = callInstr->getOperand(i);
      -            Instruction* intArgReg = NULL;
      +            // Create hidden virtual register for return address with type void*
      +            TmpInstruction* retAddrReg =
      +              new TmpInstruction(PointerType::get(Type::VoidTy), callInstr);
      +            MachineCodeForInstruction::get(callInstr).addTemp(retAddrReg);
      +
      +            // Generate the machine instruction and its operands.
      +            // Use CALL for direct function calls; this optimistically assumes
      +            // the PC-relative address fits in the CALL address field (22 bits).
      +            // Use JMPL for indirect calls.
      +            // 
      +            if (calledFunc)             // direct function call
      +              M = BuildMI(V9::CALL, 1).addPCDisp(callee);
      +            else                        // indirect function call
      +              M = BuildMI(V9::JMPLCALL, 3).addReg(callee).addSImm((int64_t)0)
      +                .addRegDef(retAddrReg);
      +            mvec.push_back(M);
      +
      +            const FunctionType* funcType =
      +              cast(cast(callee->getType())
      +                                 ->getElementType());
      +            bool isVarArgs = funcType->isVarArg();
      +            bool noPrototype = isVarArgs && funcType->getNumParams() == 0;
      +        
      +            // Use a descriptor to pass information about call arguments
      +            // to the register allocator.  This descriptor will be "owned"
      +            // and freed automatically when the MachineCodeForInstruction
      +            // object for the callInstr goes away.
      +            CallArgsDescriptor* argDesc = new CallArgsDescriptor(callInstr,
      +                                             retAddrReg, isVarArgs,noPrototype);
                   
      -            // Check for FP arguments to varargs functions.
      -            // Any such argument in the first $K$ args must be passed in an
      -            // integer register, where K = #integer argument registers.
      -            if (isVarArgs && argVal->getType()->isFloatingPoint())
      +            assert(callInstr->getOperand(0) == callee
      +                   && "This is assumed in the loop below!");
      +            
      +            for (unsigned i=1, N=callInstr->getNumOperands(); i < N; ++i)
                     {
      -                // If it is a function with no prototype, pass value
      -                // as an FP value as well as a varargs value
      -                if (noPrototype)
      -                  argDesc->getArgInfo(i-1).setUseFPArgReg();
      -                
      -                // If this arg. is in the first $K$ regs, add a copy
      -                // float-to-int instruction to pass the value as an integer.
      -                if (i <= target.getRegInfo().GetNumOfIntArgRegs())
      +                Value* argVal = callInstr->getOperand(i);
      +                Instruction* intArgReg = NULL;
      +            
      +                // Check for FP arguments to varargs functions.
      +                // Any such argument in the first $K$ args must be passed in an
      +                // integer register, where K = #integer argument registers.
      +                if (isVarArgs && argVal->getType()->isFloatingPoint())
                         {
      -                    MachineCodeForInstruction &destMCFI = 
      -                      MachineCodeForInstruction::get(callInstr);   
      -                    intArgReg = new TmpInstruction(Type::IntTy, argVal);
      -                    destMCFI.addTemp(intArgReg);
      +                    // If it is a function with no prototype, pass value
      +                    // as an FP value as well as a varargs value
      +                    if (noPrototype)
      +                      argDesc->getArgInfo(i-1).setUseFPArgReg();
      +                
      +                    // If this arg. is in the first $K$ regs, add a copy
      +                    // float-to-int instruction to pass the value as an integer.
      +                    if (i <= target.getRegInfo().getNumOfIntArgRegs())
      +                      {
      +                        MachineCodeForInstruction &destMCFI = 
      +                          MachineCodeForInstruction::get(callInstr);   
      +                        intArgReg = new TmpInstruction(Type::IntTy, argVal);
      +                        destMCFI.addTemp(intArgReg);
                           
      -                    std::vector copyMvec;
      -                    target.getInstrInfo().CreateCodeToCopyFloatToInt(target,
      -                                           callInstr->getParent()->getParent(),
      -                                           argVal, (TmpInstruction*) intArgReg,
      -                                           copyMvec, destMCFI);
      -                    mvec.insert(mvec.begin(),copyMvec.begin(),copyMvec.end());
      +                        std::vector copyMvec;
      +                        target.getInstrInfo().CreateCodeToCopyFloatToInt(target,
      +                                         callInstr->getParent()->getParent(),
      +                                         argVal, (TmpInstruction*) intArgReg,
      +                                         copyMvec, destMCFI);
      +                        mvec.insert(mvec.begin(),copyMvec.begin(),copyMvec.end());
                           
      -                    argDesc->getArgInfo(i-1).setUseIntArgReg();
      -                    argDesc->getArgInfo(i-1).setArgCopy(intArgReg);
      +                        argDesc->getArgInfo(i-1).setUseIntArgReg();
      +                        argDesc->getArgInfo(i-1).setArgCopy(intArgReg);
      +                      }
      +                    else
      +                      // Cannot fit in first $K$ regs so pass arg on stack
      +                      argDesc->getArgInfo(i-1).setUseStackSlot();
                         }
      -                else
      -                  // Cannot fit in first $K$ regs so pass the arg on the stack
      -                  argDesc->getArgInfo(i-1).setUseStackSlot();
      -              }
                   
      -            if (intArgReg)
      -              mvec.back()->addImplicitRef(intArgReg);
      +                if (intArgReg)
      +                  mvec.back()->addImplicitRef(intArgReg);
                   
      -            mvec.back()->addImplicitRef(argVal);
      -          }
      +                mvec.back()->addImplicitRef(argVal);
      +              }
               
      -        // Add the return value as an implicit ref.  The call operands
      -        // were added above.
      -        if (callInstr->getType() != Type::VoidTy)
      -          mvec.back()->addImplicitRef(callInstr, /*isDef*/ true);
      -        
      -        // For the CALL instruction, the ret. addr. reg. is also implicit
      -        if (isa(callee))
      -          mvec.back()->addImplicitRef(retAddrReg, /*isDef*/ true);
      +            // Add the return value as an implicit ref.  The call operands
      +            // were added above.
      +            if (callInstr->getType() != Type::VoidTy)
      +              mvec.back()->addImplicitRef(callInstr, /*isDef*/ true);
      +        
      +            // For the CALL instruction, the ret. addr. reg. is also implicit
      +            if (isa(callee))
      +              mvec.back()->addImplicitRef(retAddrReg, /*isDef*/ true);
               
      -        // delay slot
      -        mvec.push_back(BuildMI(V9::NOP, 0));
      +            // delay slot
      +            mvec.push_back(BuildMI(V9::NOP, 0));
      +          }
      +
               break;
             }
             
      @@ -2225,6 +2282,19 @@
             case 64:	// reg:   Phi(reg,reg)
               break;                          // don't forward the value
       
      +      case 65:	// reg:   VaArg(reg)
      +      {
      +        // Use value initialized by va_start as pointer to args on the stack.
      +        // Load argument via current pointer value, then increment pointer.
      +        int argSize = target.getFrameInfo().getSizeOfEachArgOnStack();
      +        Instruction* vaArgI = subtreeRoot->getInstruction();
      +        mvec.push_back(BuildMI(V9::LDX, 3).addReg(vaArgI->getOperand(0)).
      +                       addSImm(0).addRegDef(vaArgI));
      +        mvec.push_back(BuildMI(V9::ADD, 3).addReg(vaArgI->getOperand(0)).
      +                       addSImm(argSize).addRegDef(vaArgI->getOperand(0)));
      +        break;
      +      }
      +      
             case 71:	// reg:     VReg
             case 72:	// reg:     Constant
               break;                          // don't forward the value
      
      
      Index: llvm/lib/Target/Sparc/SparcInternals.h
      diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.83 llvm/lib/Target/Sparc/SparcInternals.h:1.84
      --- llvm/lib/Target/Sparc/SparcInternals.h:1.83	Fri May 23 20:08:42 2003
      +++ llvm/lib/Target/Sparc/SparcInternals.h	Sun May 25 10:59:47 2003
      @@ -374,8 +374,8 @@
         // Number of registers used for passing int args (usually 6: %o0 - %o5)
         // and float args (usually 32: %f0 - %f31)
         //
      -  unsigned const GetNumOfIntArgRegs() const   { return NumOfIntArgRegs; }
      -  unsigned const GetNumOfFloatArgRegs() const { return NumOfFloatArgRegs; }
      +  unsigned const getNumOfIntArgRegs() const   { return NumOfIntArgRegs; }
      +  unsigned const getNumOfFloatArgRegs() const { return NumOfFloatArgRegs; }
         
         // The following methods are used to color special live ranges (e.g.
         // function args and return values etc.) with specific hardware registers
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 11:03:01 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 11:03:01 2003
      Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetRegInfo.h
      Message-ID: <200305251602.LAA13195@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/include/llvm/Target:
      
      TargetRegInfo.h updated: 1.32 -> 1.33
      
      ---
      Log message:
      
      Make case of GetNumOfInt/FloatArgRegs functions to be use lower case
      like all the other functions.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/include/llvm/Target/TargetRegInfo.h
      diff -u llvm/include/llvm/Target/TargetRegInfo.h:1.32 llvm/include/llvm/Target/TargetRegInfo.h:1.33
      --- llvm/include/llvm/Target/TargetRegInfo.h:1.32	Wed Jan 15 15:13:32 2003
      +++ llvm/include/llvm/Target/TargetRegInfo.h	Sun May 25 11:02:05 2003
      @@ -94,8 +94,8 @@
         // Number of registers used for passing int args (usually 6: %o0 - %o5)
         // and float args (usually 32: %f0 - %f31)
         //
      -  virtual unsigned const GetNumOfIntArgRegs() const   = 0;
      -  virtual unsigned const GetNumOfFloatArgRegs() const = 0;
      +  virtual unsigned const getNumOfIntArgRegs() const   = 0;
      +  virtual unsigned const getNumOfFloatArgRegs() const = 0;
       
         // The following methods are used to color special live ranges (e.g.
         // method args and return values etc.) with specific hardware registers
      
      
      
      
      From lattner at cs.uiuc.edu  Sun May 25 11:16:00 2003
      From: lattner at cs.uiuc.edu (Chris Lattner)
      Date: Sun May 25 11:16:00 2003
      Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
      Message-ID: <200305251615.LAA13756@apoc.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/VMCore:
      
      Constants.cpp updated: 1.41 -> 1.42
      
      ---
      Log message:
      
      Fix problem with last checkin.
      
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/VMCore/Constants.cpp
      diff -u llvm/lib/VMCore/Constants.cpp:1.41 llvm/lib/VMCore/Constants.cpp:1.42
      --- llvm/lib/VMCore/Constants.cpp:1.41	Fri May 23 15:03:32 2003
      +++ llvm/lib/VMCore/Constants.cpp	Sun May 25 11:15:32 2003
      @@ -668,10 +668,12 @@
         Value::refineAbstractType(OldTy, NewTy);
       
         // Make everyone now use a constant of the new type...
      -  replaceAllUsesWith(ConstantPointerNull::get(cast(NewTy)));
      -  
      -  // This constant is now dead, destroy it.
      -  destroyConstant();
      +  if (NewTy != OldTy) {
      +    replaceAllUsesWith(ConstantPointerNull::get(cast(NewTy)));
      +    
      +    // This constant is now dead, destroy it.
      +    destroyConstant();
      +  }
       }
       
       
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 11:16:07 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 11:16:07 2003
      Subject: [llvm-commits] CVS: llvm/test/Programs/DiffOutput.sh
      Message-ID: <200305251615.LAA24411@trinity.cs.uiuc.edu>
      
      
      Changes in directory llvm/test/Programs:
      
      DiffOutput.sh updated: 1.7 -> 1.8
      
      ---
      Log message:
      
      Replace -u with -C 2.  -u is not supported by diff (on Solaris at least).
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/test/Programs/DiffOutput.sh
      diff -u llvm/test/Programs/DiffOutput.sh:1.7 llvm/test/Programs/DiffOutput.sh:1.8
      --- llvm/test/Programs/DiffOutput.sh:1.7	Sun May 11 14:13:38 2003
      +++ llvm/test/Programs/DiffOutput.sh	Sun May 25 11:15:26 2003
      @@ -20,7 +20,7 @@
       fi
       
       # Diff the two files.
      -$DIFF -u Output/$2.out-nat Output/$2.out-$1 > $DIFFOUTPUT || (
      +$DIFF -C 2 Output/$2.out-nat Output/$2.out-$1 > $DIFFOUTPUT || (
         # They are different!
         echo "******************** TEST '$2' FAILED! ********************"
         echo "Execution Context Diff:"
      
      
      
      
      From lattner at cs.uiuc.edu  Sun May 25 11:31:01 2003
      From: lattner at cs.uiuc.edu (Chris Lattner)
      Date: Sun May 25 11:31:01 2003
      Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
      Message-ID: <200305251630.LAA13844@apoc.cs.uiuc.edu>
      
      
      Changes in directory llvm/test/Programs/SingleSource/UnitTests:
      
      2003-05-07-VarArgs.c updated: 1.4 -> 1.5
      
      ---
      Log message:
      
      Uncomment out code, fix misleading comment.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
      diff -u llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.4 llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.5
      --- llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.4	Sun May 25 10:56:54 2003
      +++ llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c	Sun May 25 11:30:15 2003
      @@ -1,7 +1,7 @@
       #include 
       #include 
       
      -/* 5 bytes. */
      +/* 8 bytes if alignon(int) is 4. */
       typedef struct DWordS_struct    { int i; char c; } DWordS;
       
       /* 12 bytes if d is 4-byte aligned; 16 bytes if d is 8-byte aligned. */
      @@ -47,17 +47,17 @@
             printf("char %c\n", c);
             break;
           case 'D':
      -      /* dw = va_arg(ap, DWordS);
      +      dw = va_arg(ap, DWordS);
             printf("DWord { %d, %c }\n", dw.i, dw.c);
      -      */ break;
      +      break;
           case 'Q':
      -      /* qw = va_arg(ap, QuadWordS);
      +      qw = va_arg(ap, QuadWordS);
             printf("QuadWord { %d, %f }\n", qw.i, qw.d);
      -      */ break;
      +      break;
           case 'L':
      -      /* ls = va_arg(ap, LargeS);
      +      ls = va_arg(ap, LargeS);
             printf("LargeS { %d, %f, 0x%p, %d }\n", ls.i, ls.d, ls.ptr, ls.j);
      -      */ break;
      +      break;
           }
         va_end(ap);
       }
      
      
      
      
      From brukman at cs.uiuc.edu  Sun May 25 11:39:01 2003
      From: brukman at cs.uiuc.edu (Misha Brukman)
      Date: Sun May 25 11:39:01 2003
      Subject: [llvm-commits] CVS: llvm/utils/cvsupdate
      Message-ID: <200305251638.LAA20377@zion.cs.uiuc.edu>
      
      
      Changes in directory llvm/utils:
      
      cvsupdate updated: 1.5 -> 1.6
      
      ---
      Log message:
      
      Do not show errors when moving file. The error is shown the first time anyone
      runs `utils/cvsupdate' since there is no `cvs.out' file for mv to move, and it
      is reported as such.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/utils/cvsupdate
      diff -u llvm/utils/cvsupdate:1.5 llvm/utils/cvsupdate:1.6
      --- llvm/utils/cvsupdate:1.5	Thu Oct 31 09:32:24 2002
      +++ llvm/utils/cvsupdate	Sun May 25 11:38:24 2003
      @@ -32,7 +32,7 @@
       end
       
       if ($doit == 1) then
      -    /bin/mv -f cvs.out cvs.out.bak
      +    /bin/mv -f cvs.out cvs.out.bak >&/dev/null
           cvs update -P -d >& cvs.out
       ##    if ($status != 0) then
       ##        echo "ERROR: CVS update failed: "
      
      
      
      
      From lattner at cs.uiuc.edu  Sun May 25 11:53:01 2003
      From: lattner at cs.uiuc.edu (Chris Lattner)
      Date: Sun May 25 11:53:01 2003
      Subject: [llvm-commits] CVS: llvm/Makefile.Linux Makefile.SunOS
      Message-ID: <200305251652.LAA13941@apoc.cs.uiuc.edu>
      
      
      Changes in directory llvm:
      
      Makefile.Linux updated: 1.9 -> 1.10
      Makefile.SunOS updated: 1.8 -> 1.9
      
      ---
      Log message:
      
      Predicate things better
      
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/Makefile.Linux
      diff -u llvm/Makefile.Linux:1.9 llvm/Makefile.Linux:1.10
      --- llvm/Makefile.Linux:1.9	Thu May  8 23:17:06 2003
      +++ llvm/Makefile.Linux	Sun May 25 11:52:41 2003
      @@ -25,8 +25,8 @@
       # Path to location for LLVM front-end for this architecture.  This setting may
       # be overriden by the Makefile.config option, and should not override it if set.
       #
      -ifndef LLVMGCCDIR
       LLVMGCCARCH := i686-pc-linux-gnu/3.4-llvm
      +ifndef LLVMGCCDIR
       LLVMGCCDIR := /home/vadve/lattner/local/x86/llvm-gcc/
       endif
       
      
      
      Index: llvm/Makefile.SunOS
      diff -u llvm/Makefile.SunOS:1.8 llvm/Makefile.SunOS:1.9
      --- llvm/Makefile.SunOS:1.8	Sun May 11 16:41:09 2003
      +++ llvm/Makefile.SunOS	Sun May 25 11:52:41 2003
      @@ -27,7 +27,7 @@
       # Path to location for LLVM front-end for this architecture.  This setting may
       # be overriden by the Makefile.config option, and should not override it if set.
       #
      -ifndef LLVMGCCDIR
       LLVMGCCARCH := sparcv9-sun-solaris2.8/3.4-llvm
      +ifndef LLVMGCCDIR
       LLVMGCCDIR  := /home/vadve/lattner/local/sparc/llvm-gcc/
       endif
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 16:59:00 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 16:59:00 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
      Message-ID: <200305252158.QAA20405@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      SparcInstrInfo.cpp updated: 1.42 -> 1.43
      
      ---
      Log message:
      
      Bug fix: sign-extension was not happening for C = -MININT since C == -C!
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
      diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.42 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.43
      --- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.42	Wed May 21 13:48:06 2003
      +++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp	Sun May 25 16:58:11 2003
      @@ -142,8 +142,9 @@
         // Set the low 32 bits of dest
         CreateSETUWConst(target, (uint32_t) C,  dest, mvec, /*isSigned*/true);
       
      -  // Sign-extend to the high 32 bits if needed
      -  if (C < 0 && (-C) > (int32_t) MAXSIMM)
      +  // Sign-extend to the high 32 bits if needed.
      +  // NOTE: The value C = 0x80000000 is bad: -C == C and so -C is < MAXSIMM
      +  if (C < 0 && (C == -C || -C > (int32_t) MAXSIMM))
           mvec.push_back(BuildMI(V9::SRA, 3).addReg(dest).addZImm(0).addRegDef(dest));
       }
       
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 17:00:00 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 17:00:00 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
      Message-ID: <200305252159.QAA20430@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      SparcInstrSelection.cpp updated: 1.92 -> 1.93
      
      ---
      Log message:
      
      Bug fix: right shift for int divide-by-power-of-2 was incorrect for
      negative values.  Need to add one to a negative value before right shift!
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/SparcInstrSelection.cpp
      diff -u llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.92 llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.93
      --- llvm/lib/Target/Sparc/SparcInstrSelection.cpp:1.92	Sun May 25 10:59:47 2003
      +++ llvm/lib/Target/Sparc/SparcInstrSelection.cpp	Sun May 25 16:59:47 2003
      @@ -774,7 +774,7 @@
       // create a cheaper instruction.
       // This returns the approximate cost of the instructions generated,
       // which is used to pick the cheapest when both operands are constant.
      -static inline unsigned
      +static unsigned
       CreateMulConstInstruction(const TargetMachine &target, Function* F,
                                 Value* lval, Value* rval, Instruction* destVal,
                                 std::vector& mvec,
      @@ -927,7 +927,7 @@
       
       
       // Return if we cannot exploit constant to create a cheaper instruction
      -static inline void
      +static void
       CreateDivConstInstruction(TargetMachine &target,
                                 const InstructionNode* instrNode,
                                 std::vector& mvec)
      @@ -937,7 +937,7 @@
         if (!isa(constOp))
           return;
       
      -  Value* DestVal = instrNode->getValue();
      +  Instruction* destVal = instrNode->getInstruction();
         unsigned ZeroReg = target.getRegInfo().getZeroRegNum();
         
         // Cases worth optimizing are:
      @@ -960,18 +960,55 @@
                 
             if (C == 1) {
               mvec.push_back(BuildMI(V9::ADD, 3).addReg(LHS).addMReg(ZeroReg)
      -                       .addRegDef(DestVal));
      +                       .addRegDef(destVal));
             } else if (isPowerOf2(C, pow)) {
      -        unsigned opCode= ((resultType->isSigned())
      -                          ? (resultType==Type::LongTy) ? V9::SRAX : V9::SRA
      -                          : (resultType==Type::LongTy) ? V9::SRLX : V9::SRL);
      -        mvec.push_back(BuildMI(opCode, 3).addReg(LHS).addZImm(pow)
      -                       .addRegDef(DestVal));
      +        unsigned opCode;
      +        Value* shiftOperand;
      +
      +        if (resultType->isSigned()) {
      +          // The result may be negative and we need to add one before shifting 
      +          // a negative value.  Use:
      +          //      srl i0, 31, x0; add x0, i0, i1         (if i0 is <= 32 bits)
      +          // or
      +          //      srlx i0, 63, x0; add x0, i0, i1         (if i0 is 64 bits)
      +          // to compute i1=i0+1 if i0 < 0 and i1=i0 otherwise.  
      +          // 
      +          TmpInstruction *srlTmp, *addTmp;
      +          MachineCodeForInstruction& mcfi
      +            = MachineCodeForInstruction::get(destVal);
      +          srlTmp = new TmpInstruction(resultType, LHS, 0, "getSign");
      +          addTmp = new TmpInstruction(resultType, LHS, srlTmp, "incIfNeg");
      +          mcfi.addTemp(srlTmp);
      +          mcfi.addTemp(addTmp);
      +
      +          // Create the SRL or SRLX instruction to get the sign bit
      +          mvec.push_back(BuildMI((resultType==Type::LongTy)? V9::SRLX:V9::SRL,3)
      +                         .addReg(LHS)
      +                         .addSImm((resultType==Type::LongTy)? 63 : 31)
      +                         .addRegDef(srlTmp));
      +
      +          // Create the ADD instruction to add 1 for negative values
      +          mvec.push_back(BuildMI(V9::ADD, 3).addReg(LHS).addReg(srlTmp)
      +                         .addRegDef(addTmp));
      +
      +          // Get the shift operand and "right-shift" opcode to do the divide
      +          shiftOperand = addTmp;
      +          opCode = (resultType==Type::LongTy) ? V9::SRAX : V9::SRA;
      +        }
      +        else {
      +          // Get the shift operand and "right-shift" opcode to do the divide
      +          shiftOperand = LHS;
      +          opCode = (resultType==Type::LongTy) ? V9::SRLX : V9::SRL;
      +        }
      +
      +        // Now do the actual shift!
      +        mvec.push_back(BuildMI(opCode, 3).addReg(shiftOperand).addZImm(pow)
      +                       .addRegDef(destVal));
             }
                 
             if (needNeg && (C == 1 || isPowerOf2(C, pow))) {
               // insert  after the instr to flip the sign
      -        mvec.push_back(CreateIntNegInstruction(target, DestVal));
      +        mvec.push_back(CreateIntNegInstruction(target, destVal));
             }
           }
         } else {
      @@ -982,7 +1019,7 @@
                 (dval < 0) ? (resultType == Type::FloatTy? V9::FNEGS : V9::FNEGD)
                 : (resultType == Type::FloatTy? V9::FMOVS : V9::FMOVD);
                     
      -        mvec.push_back(BuildMI(opCode, 2).addReg(LHS).addRegDef(DestVal));
      +        mvec.push_back(BuildMI(opCode, 2).addReg(LHS).addRegDef(destVal));
             } 
           }
         }
      
      
      
      
      From vadve at cs.uiuc.edu  Sun May 25 17:00:07 2003
      From: vadve at cs.uiuc.edu (Vikram Adve)
      Date: Sun May 25 17:00:07 2003
      Subject: [llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp
      Message-ID: <200305252159.QAA20420@psmith.cs.uiuc.edu>
      
      
      Changes in directory llvm/lib/Target/Sparc:
      
      EmitAssembly.cpp updated: 1.74 -> 1.75
      
      ---
      Log message:
      
      Bug fix: padding bytes within a structure should go after each field!
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
      diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.74 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.75
      --- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.74	Tue May 20 15:32:23 2003
      +++ llvm/lib/Target/Sparc/EmitAssembly.cpp	Sun May 25 16:59:09 2003
      @@ -544,7 +544,7 @@
         void printGlobalVariable      (const GlobalVariable *GV);
         void PrintZeroBytesToPad      (int numBytes);
         void printSingleConstantValue (const Constant* CV);
      -  void printConstantValueOnly   (const Constant* CV, int numPadBytes = 0);
      +  void printConstantValueOnly   (const Constant* CV, int numPadBytesAfter = 0);
         void printConstant            (const Constant* CV, string valID = "");
       
         static void FoldConstants     (const Module &M,
      @@ -786,13 +786,10 @@
       // Uses printSingleConstantValue() to print each individual value.
       void
       SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV,
      -                                              int numPadBytes /* = 0*/)
      +                                              int numPadBytesAfter /* = 0*/)
       {
         const ConstantArray *CVA = dyn_cast(CV);
       
      -  if (numPadBytes)
      -    PrintZeroBytesToPad(numPadBytes);
      -
         if (CVA && isStringCompatible(CVA))
           { // print the string alone and return
             toAsm << "\t" << ".ascii" << "\t" << getAsCString(CVA) << "\n";
      @@ -829,6 +826,9 @@
           }
         else
           printSingleConstantValue(CV);
      +
      +  if (numPadBytesAfter)
      +    PrintZeroBytesToPad(numPadBytesAfter);
       }
       
       // Print a constant (which may be an aggregate) prefixed by all the
      
      
      
      
      From brukman at cs.uiuc.edu  Sun May 25 19:19:01 2003
      From: brukman at cs.uiuc.edu (Michael Brukman)
      Date: Sun May 25 19:19:01 2003
      Subject: [llvm-commits] CVS: llvm/www/docs/GettingStarted.html
      Message-ID: <200305260018.TAA00403@tank.cs.uiuc.edu>
      
      
      Changes in directory llvm/www/docs:
      
      GettingStarted.html updated: 1.10 -> 1.11
      
      ---
      Log message:
      
      Changed http://tank... => http://llvm, and removed an extraneous mailto:.
      
      
      ---
      Diffs of the changes:
      
      Index: llvm/www/docs/GettingStarted.html
      diff -u llvm/www/docs/GettingStarted.html:1.10 llvm/www/docs/GettingStarted.html:1.11
      --- llvm/www/docs/GettingStarted.html:1.10	Tue May 20 16:01:22 2003
      +++ llvm/www/docs/GettingStarted.html	Sun May 25 19:17:49 2003
      @@ -460,14 +460,13 @@
       
           
       
           
      If you have any questions or run into any snags (or you have any additions...), please send an email to - Nicholas Hildenbrandt or Chris Lattner.