From lattner at cs.uiuc.edu Mon Dec 1 01:06:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Dec 1 01:06:02 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp ReaderInternals.h Message-ID: <200312010705.BAA15678@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.90 -> 1.91 ReaderInternals.h updated: 1.68 -> 1.69 --- Log message: Emit & read more compressed bytecode by not emitting a bytecodeblock for each basic block in function. Instead, just emit a stream of instructions, chopping up basic blocks based on when we find terminator instructions. This saves a fairly substantial chunk of bytecode space. In stripped, sample cases, for example, we get this reduction in size: 197.parser: 163036 -> 137180: 18.8% reduction 254.gap : 844936 -> 689392: 22.6% 255.vortex: 621724 -> 528444: 17.7% ... Not bad for something this simple. :) Note that this doesn't require a new bytecode version number at all, though version 1.1 should not need to support the old format. --- Diffs of the changes: (+44 -2) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.90 llvm/lib/Bytecode/Reader/Reader.cpp:1.91 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.90 Wed Nov 19 11:27:18 2003 +++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Dec 1 01:05:30 2003 @@ -188,7 +188,8 @@ } } - +/// ParseBasicBlock - In LLVM 1.0 bytecode files, we used to output one +/// basicblock at a time. This method reads in one of the basicblock packets. BasicBlock *BytecodeParser::ParseBasicBlock(const unsigned char *&Buf, const unsigned char *EndBuf, unsigned BlockNo) { @@ -207,6 +208,38 @@ return BB; } + +/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the +/// body of a function. In post 1.0 bytecode files, we no longer emit basic +/// block individually, in order to avoid per-basic-block overhead. +unsigned BytecodeParser::ParseInstructionList(Function *F, + const unsigned char *&Buf, + const unsigned char *EndBuf) { + unsigned BlockNo = 0; + std::vector Args; + + while (Buf < EndBuf) { + BasicBlock *BB; + if (ParsedBasicBlocks.size() == BlockNo) + ParsedBasicBlocks.push_back(BB = new BasicBlock()); + else if (ParsedBasicBlocks[BlockNo] == 0) + BB = ParsedBasicBlocks[BlockNo] = new BasicBlock(); + else + BB = ParsedBasicBlocks[BlockNo]; + ++BlockNo; + F->getBasicBlockList().push_back(BB); + + // Read instructions into this basic block until we get to a terminator + while (Buf < EndBuf && !BB->getTerminator()) + ParseInstruction(Buf, EndBuf, Args, BB); + + if (!BB->getTerminator()) + throw std::string("Non-terminated basic block found!"); + } + + return BlockNo; +} + void BytecodeParser::ParseSymbolTable(const unsigned char *&Buf, const unsigned char *EndBuf, SymbolTable *ST, @@ -342,6 +375,13 @@ BCR_TRACE(2, "BLOCK BytecodeFormat::BasicBlock: {\n"); BasicBlock *BB = ParseBasicBlock(Buf, Buf+Size, BlockNum++); F->getBasicBlockList().push_back(BB); + break; + } + + case BytecodeFormat::InstructionList: { + BCR_TRACE(2, "BLOCK BytecodeFormat::InstructionList: {\n"); + if (BlockNum) throw std::string("Already parsed basic blocks!"); + BlockNum = ParseInstructionList(F, Buf, Buf+Size); break; } Index: llvm/lib/Bytecode/Reader/ReaderInternals.h diff -u llvm/lib/Bytecode/Reader/ReaderInternals.h:1.68 llvm/lib/Bytecode/Reader/ReaderInternals.h:1.69 --- llvm/lib/Bytecode/Reader/ReaderInternals.h:1.68 Wed Nov 19 11:27:18 2003 +++ llvm/lib/Bytecode/Reader/ReaderInternals.h Mon Dec 1 01:05:30 2003 @@ -162,7 +162,9 @@ BasicBlock *ParseBasicBlock(const unsigned char *&Buf, const unsigned char *End, unsigned BlockNo); - + unsigned ParseInstructionList(Function *F, const unsigned char *&Buf, + const unsigned char *EndBuf); + void ParseInstruction(const unsigned char *&Buf, const unsigned char *End, std::vector &Args, BasicBlock *BB); From lattner at cs.uiuc.edu Mon Dec 1 01:06:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Dec 1 01:06:04 2003 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp WriterInternals.h Message-ID: <200312010705.BAA15677@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.45 -> 1.46 WriterInternals.h updated: 1.14 -> 1.15 --- Log message: Emit & read more compressed bytecode by not emitting a bytecodeblock for each basic block in function. Instead, just emit a stream of instructions, chopping up basic blocks based on when we find terminator instructions. This saves a fairly substantial chunk of bytecode space. In stripped, sample cases, for example, we get this reduction in size: 197.parser: 163036 -> 137180: 18.8% reduction 254.gap : 844936 -> 689392: 22.6% 255.vortex: 621724 -> 528444: 17.7% ... Not bad for something this simple. :) Note that this doesn't require a new bytecode version number at all, though version 1.1 should not need to support the old format. --- Diffs of the changes: (+7 -12) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.45 llvm/lib/Bytecode/Writer/Writer.cpp:1.46 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.45 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Bytecode/Writer/Writer.cpp Mon Dec 1 01:05:30 2003 @@ -225,23 +225,19 @@ // Output information about the constants in the function... outputConstants(true); - // Output basic block nodes... - for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) - processBasicBlock(*I); + { // Output all of the instructions in the body of the function + BytecodeBlock ILBlock(BytecodeFormat::InstructionList, Out); + + for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E;++BB) + for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I) + processInstruction(*I); + } // If needed, output the symbol table for the function... outputSymbolTable(F->getSymbolTable()); Table.purgeFunction(); } -} - - -void BytecodeWriter::processBasicBlock(const BasicBlock &BB) { - BytecodeBlock FunctionBlock(BytecodeFormat::BasicBlock, Out); - // Process all the instructions in the bb... - for(BasicBlock::const_iterator I = BB.begin(), E = BB.end(); I != E; ++I) - processInstruction(*I); } void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { Index: llvm/lib/Bytecode/Writer/WriterInternals.h diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.14 llvm/lib/Bytecode/Writer/WriterInternals.h:1.15 --- llvm/lib/Bytecode/Writer/WriterInternals.h:1.14 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Bytecode/Writer/WriterInternals.h Mon Dec 1 01:05:31 2003 @@ -36,7 +36,6 @@ protected: void outputConstants(bool isFunction); void outputFunction(const Function *F); - void processBasicBlock(const BasicBlock &BB); void processInstruction(const Instruction &I); private : From lattner at cs.uiuc.edu Mon Dec 1 01:09:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Dec 1 01:09:00 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/Format.h Message-ID: <200312010708.BAA15755@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: Format.h updated: 1.7 -> 1.8 --- Log message: Add new block number --- Diffs of the changes: (+4 -0) Index: llvm/include/llvm/Bytecode/Format.h diff -u llvm/include/llvm/Bytecode/Format.h:1.7 llvm/include/llvm/Bytecode/Format.h:1.8 --- llvm/include/llvm/Bytecode/Format.h:1.7 Sun Nov 30 23:40:37 2003 +++ llvm/include/llvm/Bytecode/Format.h Mon Dec 1 01:08:06 2003 @@ -37,6 +37,10 @@ // Can also have ConstantPool block // Can also have SymbolTable block BasicBlock = 0x31, // May contain many basic blocks + + // InstructionList - The instructions in the body of a function. This + // superceeds the old BasicBlock node. + InstructionList = 0x32, }; }; From lattner at cs.uiuc.edu Mon Dec 1 01:27:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Dec 1 01:27:00 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200312010726.BAA24681@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.102 -> 1.103 --- Log message: Provide rules to build stripped .bc files --- Diffs of the changes: (+4 -0) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.102 llvm/test/Programs/Makefile.programs:1.103 --- llvm/test/Programs/Makefile.programs:1.102 Sat Nov 29 04:25:55 2003 +++ llvm/test/Programs/Makefile.programs Mon Dec 1 01:26:38 2003 @@ -187,6 +187,9 @@ Output/%.linked.bc: Output/%.linked.rll $(LGCCAS) $(LGCCAS) $(STATS) $< -o $@ +Output/%.llvm.stripped.bc: Output/%.llvm.bc $(LOPT) + $(LOPT) -mstrip $< -o $@ -f + ifndef DISABLE_FOR_LLVM_PROGRAMS # Rule to produce final program bytecode file from linked, optimized, bytecode. # Link the program to the libraries it uses, then perform postlink @@ -285,6 +288,7 @@ JIT_OPTS = -force-interpreter=false $(EXTRA_LLI_OPTS) native: $(PROGRAMS_TO_TEST:%=Output/%.native) +stripped-bytecode:: $(PROGRAMS_TO_TEST:%=Output/%.llvm.stripped.bc) ifndef PROGRAMS_HAVE_CUSTOM_RUN_RULES From lattner at cs.uiuc.edu Mon Dec 1 01:29:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Dec 1 01:29:01 2003 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200312010728.BAA24849@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.162 -> 1.163 --- Log message: Make stripped-bytecode a recursive target --- Diffs of the changes: (+4 -3) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.162 llvm/Makefile.rules:1.163 --- llvm/Makefile.rules:1.162 Sat Nov 29 03:50:15 2003 +++ llvm/Makefile.rules Mon Dec 1 01:28:25 2003 @@ -393,7 +393,7 @@ #--------------------------------------------------------- ifdef DIRS -all install clean test bytecode :: +all install clean test bytecode stripped-bytecode:: $(VERB) for dir in ${DIRS}; do \ if [ ! -f $$dir/Makefile ]; \ then \ @@ -411,8 +411,9 @@ clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS)) test :: $(addsuffix /.maketest , $(PARALLEL_DIRS)) bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS)) +stripped-bytecode :: $(addsuffix /.makestripped-bytecode, $(PARALLEL_DIRS)) -%/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode: +%/.makeall %/.makeinstall %/.makeclean %/.maketest %/.makebytecode %/.makestripped-bytecode: $(VERB) if [ ! -f $(@D)/Makefile ]; \ then \ $(MKDIR) $(@D); \ @@ -423,7 +424,7 @@ # Handle directories that may or may not exist ifdef OPTIONAL_DIRS -all install clean test bytecode :: +all install clean test bytecode stripped-bytecode:: $(VERB) for dir in ${OPTIONAL_DIRS}; do \ if [ -d $(SourceDir)/$$dir ]; \ then\ From gaeke at cs.uiuc.edu Mon Dec 1 15:34:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Dec 1 15:34:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Support/Lock.cpp Message-ID: <200312012133.PAA24893@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Lock.cpp added (r1.1) --- Log message: Lock abstraction, introduced with a view toward making the JIT thread-safe. Eventually. --- Diffs of the changes: (+24 -0) Index: llvm/lib/Support/Lock.cpp diff -c /dev/null llvm/lib/Support/Lock.cpp:1.1 *** /dev/null Mon Dec 1 15:33:41 2003 --- llvm/lib/Support/Lock.cpp Mon Dec 1 15:33:31 2003 *************** *** 0 **** --- 1,24 ---- + //===-- Support/Lock.cpp - Platform-agnostic mutual exclusion -------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // Implementation of various methods supporting platform-agnostic lock + // abstraction. See Support/Lock.h for details. + // + //===----------------------------------------------------------------------===// + + #include "Support/Lock.h" + + using namespace llvm; + + Lock Lock::create () { + // Currently we only support creating POSIX pthread_mutex_t locks. + // In the future we might want to construct different kinds of locks + // based on what OS is running. + return POSIXLock (); + } From gaeke at cs.uiuc.edu Mon Dec 1 15:34:03 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Dec 1 15:34:03 2003 Subject: [llvm-commits] CVS: llvm/include/Support/Lock.h Message-ID: <200312012133.PAA24886@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: Lock.h added (r1.1) --- Log message: Lock abstraction, introduced with a view toward making the JIT thread-safe. Eventually. --- Diffs of the changes: (+69 -0) Index: llvm/include/Support/Lock.h diff -c /dev/null llvm/include/Support/Lock.h:1.1 *** /dev/null Mon Dec 1 15:33:40 2003 --- llvm/include/Support/Lock.h Mon Dec 1 15:33:29 2003 *************** *** 0 **** --- 1,69 ---- + //===-- Support/Lock.h - Platform-agnostic mutual exclusion -----*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains classes that implement locks (mutual exclusion + // variables) in a platform-agnostic way. Basically the user should + // just call Lock::create() to get a Lock object of the correct sort + // for the current platform, and use its acquire() and release() + // methods, or a LockHolder, to protect critical sections of code for + // thread-safety. + // + //===----------------------------------------------------------------------===// + + #ifndef SUPPORT_LOCK_H + #define SUPPORT_LOCK_H + + #include + #include + + namespace llvm { + + /// Lock - Abstract class that provides mutual exclusion (also known + /// as a mutex.) + /// + class Lock { + protected: + virtual ~Lock() {} // Derive from me + public: + virtual void acquire () { abort (); } + virtual void release () { abort (); } + + /// create - Static method that returns a Lock of the correct class + /// for the current host OS. + /// + static Lock create (); + }; + + /// POSIXLock - Specialization of Lock class implemented using + /// pthread_mutex_t objects. + /// + class POSIXLock : public Lock { + pthread_mutex_t mutex; + public: + POSIXLock () { pthread_mutex_init (&mutex, 0); } + virtual ~POSIXLock () { pthread_mutex_destroy (&mutex); } + virtual void acquire () { pthread_mutex_lock (&mutex); } + virtual void release () { pthread_mutex_unlock (&mutex); } + }; + + /// LockHolder - Instances of this class acquire a given Lock when + /// constructed and hold that lock until destruction. Uncle Bjarne + /// says, "Resource acquisition is allocation." Or is it the other way + /// around? I never can remember. + /// + class LockHolder { + Lock &L; + public: + LockHolder (Lock &_L) : L (_L) { L.acquire (); } + ~LockHolder () { L.release (); } + }; + + } // end namespace llvm + + #endif // SUPPORT_LOCK_H From criswell at cs.uiuc.edu Mon Dec 1 17:06:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon Dec 1 17:06:01 2003 Subject: [llvm-commits] CVS: llvm-www/status/index.html Message-ID: <200312012305.RAA03079@choi.cs.uiuc.edu> Changes in directory llvm-www/status: index.html updated: 1.35 -> 1.36 --- Log message: Added hbd (program that converts java class files to java source code). Updated webcpp and kimwitu++. --- Diffs of the changes: (+18 -9) Index: llvm-www/status/index.html diff -u llvm-www/status/index.html:1.35 llvm-www/status/index.html:1.36 --- llvm-www/status/index.html:1.35 Fri Nov 21 17:34:12 2003 +++ llvm-www/status/index.html Mon Dec 1 17:05:27 2003 @@ -45,6 +45,14 @@ Status Notes + + + hbd + 0.2.3 + 26 Nov 2003 + WORKS + Did not try the install target. + webcpp - 0.8 - 18 Nov 2003 - FAILS - Segfaults before exit on x86 JIT, see bug 124. + 0.8.0 + 26 Nov 2003 + WORKS + Did not try the install target. kimwitu++ 2.3.8 - 18 Nov 2003 - ??? - At least one bug fixed: bug 123. Still looking for - the inefficiency: bug 127. + 26 Nov 2003 + Compiles and runs. + Compiles and can print version number through the JIT. + Seems to detect valid input. Have not tried a valid + Kimwitu++ input file. @@ -435,7 +444,7 @@
Misha Brukman
The LLVM Compiler Infrastructure
- Last modified: $Date: 2003/11/21 23:34:12 $ + Last modified: $Date: 2003/12/01 23:05:27 $ From criswell at cs.uiuc.edu Tue Dec 2 08:53:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 08:53:01 2003 Subject: [llvm-commits] CVS: llvm/test/QMTest/llvmdb.py Message-ID: <200312021452.IAA17052@choi.cs.uiuc.edu> Changes in directory llvm/test/QMTest: llvmdb.py updated: 1.10 -> 1.11 --- Log message: Fixed Bug 161. The temporary directory (llvm/test/tmp) is no longer considered when looking for test suites and tests. --- Diffs of the changes: (+1 -1) Index: llvm/test/QMTest/llvmdb.py diff -u llvm/test/QMTest/llvmdb.py:1.10 llvm/test/QMTest/llvmdb.py:1.11 --- llvm/test/QMTest/llvmdb.py:1.10 Wed Nov 19 14:22:09 2003 +++ llvm/test/QMTest/llvmdb.py Tue Dec 2 08:52:12 2003 @@ -164,7 +164,7 @@ # Record names of invalid directories and files. # invalid_dirs = ['CVS', 'QMTest', 'QMTestDB', 'Scripts', 'Programs', - 'Fragments', 'Reoptimizer'] + 'Fragments', 'Reoptimizer', 'tmp'] invalid_files = ['Makefile', 'README.txt', '.cvsignore', 'opaquetypes.ll'] From criswell at cs.uiuc.edu Tue Dec 2 09:41:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 09:41:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile Message-ID: <200312021540.JAA26242@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile updated: 1.21 -> 1.22 --- Log message: Removed commented out LLVMSource directory. --- Diffs of the changes: (+0 -1) Index: llvm/test/Programs/Makefile diff -u llvm/test/Programs/Makefile:1.21 llvm/test/Programs/Makefile:1.22 --- llvm/test/Programs/Makefile:1.21 Mon Aug 18 00:08:59 2003 +++ llvm/test/Programs/Makefile Tue Dec 2 09:40:28 2003 @@ -7,7 +7,6 @@ LEVEL = ../.. PARALLEL_DIRS = SingleSource MultiSource External -#LLVMSource include ${LEVEL}/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Dec 2 11:00:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 11:00:01 2003 Subject: [llvm-commits] CVS: llvm-www/releases/1.0/register.html Message-ID: <200312021659.KAA31544@choi.cs.uiuc.edu> Changes in directory llvm-www/releases/1.0: register.html updated: 1.6 -> 1.7 --- Log message: Fixed grammar. --- Diffs of the changes: (+1 -1) Index: llvm-www/releases/1.0/register.html diff -u llvm-www/releases/1.0/register.html:1.6 llvm-www/releases/1.0/register.html:1.7 --- llvm-www/releases/1.0/register.html:1.6 Fri Oct 24 18:17:39 2003 +++ llvm-www/releases/1.0/register.html Tue Dec 2 10:59:33 2003 @@ -67,7 +67,7 @@

We would be interested to know how you plan to use LLVM.
-This information is strictly optional and will kept completely confidential:
+This information is strictly optional and will be kept completely confidential:

From criswell at cs.uiuc.edu Tue Dec 2 11:10:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 11:10:01 2003 Subject: [llvm-commits] CVS: llvm-www/releases/1.0/register.cgi Message-ID: <200312021709.LAA31643@choi.cs.uiuc.edu> Changes in directory llvm-www/releases/1.0: register.cgi updated: 1.4 -> 1.5 --- Log message: Added Chris to the list of people to email. --- Diffs of the changes: (+1 -1) Index: llvm-www/releases/1.0/register.cgi diff -u llvm-www/releases/1.0/register.cgi:1.4 llvm-www/releases/1.0/register.cgi:1.5 --- llvm-www/releases/1.0/register.cgi:1.4 Mon Oct 27 10:17:25 2003 +++ llvm-www/releases/1.0/register.cgi Tue Dec 2 11:09:09 2003 @@ -7,7 +7,7 @@ import sys # List of email addresses that want to know when people download -notifylist=['vadve at cs.uiuc.edu', 'criswell at uiuc.edu'] +notifylist=['vadve at cs.uiuc.edu', 'criswell at uiuc.edu', 'sabre at nondot.org'] # # Function: Subscribe() From criswell at cs.uiuc.edu Tue Dec 2 11:11:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 11:11:01 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Makefile Message-ID: <200312021710.LAA31677@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource: Makefile updated: 1.3 -> 1.4 --- Log message: Fixed the building of subdirectories with the new configure script. --- Diffs of the changes: (+1 -2) Index: llvm/test/Programs/MultiSource/Makefile diff -u llvm/test/Programs/MultiSource/Makefile:1.3 llvm/test/Programs/MultiSource/Makefile:1.4 --- llvm/test/Programs/MultiSource/Makefile:1.3 Mon Aug 18 00:06:25 2003 +++ llvm/test/Programs/MultiSource/Makefile Tue Dec 2 11:10:45 2003 @@ -1,6 +1,5 @@ # MultiSource Makefile: Build all subdirectories automatically LEVEL = ../../.. -PARALLEL_DIRS := $(filter-out %-disabled/, $(sort $(filter-out CVS/, $(wildcard */)))) - +PARALLEL_DIRS := Applications Benchmarks include $(LEVEL)/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Dec 2 11:11:03 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 11:11:03 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Applications/Makefile Message-ID: <200312021710.LAA31684@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Applications: Makefile updated: 1.1 -> 1.2 --- Log message: Fixed the building of subdirectories with the new configure script. --- Diffs of the changes: (+2 -1) Index: llvm/test/Programs/MultiSource/Applications/Makefile diff -u llvm/test/Programs/MultiSource/Applications/Makefile:1.1 llvm/test/Programs/MultiSource/Applications/Makefile:1.2 --- llvm/test/Programs/MultiSource/Applications/Makefile:1.1 Fri Sep 12 11:02:44 2003 +++ llvm/test/Programs/MultiSource/Applications/Makefile Tue Dec 2 11:10:46 2003 @@ -1,6 +1,7 @@ # MultiSource/Applications Makefile: Build all subdirectories automatically LEVEL = ../../../.. -PARALLEL_DIRS := $(filter-out %-disabled/, $(sort $(filter-out CVS/, $(wildcard */)))) + +PARALLEL_DIRS := Burg aha sgefa siod include $(LEVEL)/test/Programs/Makefile.programs From criswell at cs.uiuc.edu Tue Dec 2 11:11:05 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 11:11:05 2003 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/Makefile Message-ID: <200312021710.LAA31692@choi.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks: Makefile updated: 1.1 -> 1.2 --- Log message: Fixed the building of subdirectories with the new configure script. --- Diffs of the changes: (+3 -1) Index: llvm/test/Programs/MultiSource/Benchmarks/Makefile diff -u llvm/test/Programs/MultiSource/Benchmarks/Makefile:1.1 llvm/test/Programs/MultiSource/Benchmarks/Makefile:1.2 --- llvm/test/Programs/MultiSource/Benchmarks/Makefile:1.1 Fri Sep 12 11:01:51 2003 +++ llvm/test/Programs/MultiSource/Benchmarks/Makefile Tue Dec 2 11:10:47 2003 @@ -1,6 +1,8 @@ # MultiSource/Benchmarks Makefile: Build all subdirectories automatically LEVEL = ../../../.. -PARALLEL_DIRS := $(filter-out %-disabled/, $(sort $(filter-out CVS/, $(wildcard */)))) +include $(LEVEL)/Makefile.config + +PARALLEL_DIRS := $(basename $(shell ls $(SourceDir) | grep -v CVS | grep -v Makefile)) include $(LEVEL)/test/Programs/Makefile.programs From lattner at cs.uiuc.edu Tue Dec 2 11:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Dec 2 11:45:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Message-ID: <200312021744.LAA30239@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ScalarReplAggregates.cpp updated: 1.19 -> 1.20 --- Log message: Finegrainify namespacification Fix regressions ScalarRepl/basictest.ll & arraytest.ll --- Diffs of the changes: (+3 -6) Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.19 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.20 --- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.19 Tue Nov 25 15:09:18 2003 +++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Dec 2 11:43:55 2003 @@ -32,8 +32,7 @@ #include "Support/Debug.h" #include "Support/Statistic.h" #include "Support/StringExtras.h" - -namespace llvm { +using namespace llvm; namespace { Statistic<> NumReplaced("scalarrepl", "Number of allocas broken up"); @@ -65,7 +64,7 @@ } // Public interface to the ScalarReplAggregates pass -Pass *createScalarReplAggregatesPass() { return new SROA(); } +Pass *llvm::createScalarReplAggregatesPass() { return new SROA(); } bool SROA::runOnFunction(Function &F) { @@ -234,7 +233,7 @@ return false; ++I; - if (I != E || !isa(I.getOperand())) + if (I == E || !isa(I.getOperand())) return false; // If this is a use of an array allocation, do a bit more checking for sanity. @@ -301,5 +300,3 @@ } return true; } - -} // End llvm namespace From criswell at cs.uiuc.edu Tue Dec 2 15:52:02 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 15:52:02 2003 Subject: [llvm-commits] CVS: llvm/test/QMTest/expectations.sunos.qmr Message-ID: <200312022151.PAA26763@seraph.cs.uiuc.edu> Changes in directory llvm/test/QMTest: expectations.sunos.qmr updated: 1.1 -> 1.2 --- Log message: Regression.CFrontend.2003-08-30-LargeIntegerBitfieldMember now passes. The following tests are expected to fail: Regression.C++Frontend.2003-11-04-CatchLabelName Regression.C++Frontend.2003-11-25-ReturningOpaqueByValue Regression.CFrontend.2003-01-30-UnionInit Regression.CFrontend.2003-08-30-AggregateInitializer Regression.ExecutionEngine.test-cast Regression.Transforms.BasicAA.2003-11-04-SimpleCases --- Diffs of the changes: (+0 -0) Index: llvm/test/QMTest/expectations.sunos.qmr From criswell at cs.uiuc.edu Tue Dec 2 16:23:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Tue Dec 2 16:23:01 2003 Subject: [llvm-commits] CVS: llvm/test/QMTest/expectations.linux.qmr Message-ID: <200312022222.QAA08739@choi.cs.uiuc.edu> Changes in directory llvm/test/QMTest: expectations.linux.qmr updated: 1.2 -> 1.3 --- Log message: Made the following tests expect to fail: Regression.CFrontend.2003-01-30-UnionInit Regression.CFrontend.2003-08-30-AggregateInitializer Regression.Transforms.BasicAA.2003-11-04-SimpleCases --- Diffs of the changes: (+1 -1) Index: llvm/test/QMTest/expectations.linux.qmr diff -u llvm/test/QMTest/expectations.linux.qmr:1.2 llvm/test/QMTest/expectations.linux.qmr:1.3 --- llvm/test/QMTest/expectations.linux.qmr:1.2 Tue Nov 25 16:41:35 2003 +++ llvm/test/QMTest/expectations.linux.qmr Tue Dec 2 16:21:59 2003 @@ -3,13 +3,13 @@ qoq}q(U _Result__kindqUtestqU_Result__outcomeqUPASSqU_Result__annotationsq}U _Result__idq U0Regression.Assembler.2002-08-16-ConstExprInlinedq U_Result__contextq (cqm.test.context Context -q o}q (U_Context__propertiesq}U_Context__temporariesq}ubub.(hoq}q(hhhhh}h U(Regression.Transforms.PruneEH.simpletestqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h U/Regression.CBackend.2002-08-19-HardConstantExprqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h URegression.Jello.test-shiftqh (h o}q(h}h}ubub.(hoq}q(hhhUFAILqh}h U.Regression.Transforms.CorrelatedExprs.looptestqh (h o}q (h}h}ubub.(hoq!}q"(hhhhh}h U-Regression.Linker.2003-08-23-GlobalVarLinkingq#h (h o}q$(h}h}ubub.(hoq%}q&(hhhhh}h U?Regression.Transforms.Inline.2003-09-22-PHINodesInExceptionDestq'h (h o}q((h}h}ubub.(hoq)}q*(hhhhh}h U,Regression.CFrontend.2003-02-12-NonlocalGotoq+h (h o}q,(h}h}ubub.(hoq-}q.(hhhhh}h U2Regression.Transforms.FunctionResolve.retmismatch1q/h (h o}q0(h}h}ubub.(hoq1}q2(hhhhh}h U8Regression.Transforms.ADCE.2003-01-22-PredecessorProblemq3h (h o}q4(h}h}ubub.(hoq5}q6(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-! VarArgCallInfLoopq7h (h o}q8(h}h}ubub.(hoq9}q:(hhhhh}h U5Regression.CFrontend.2003-07-22-ArrayAccessTypeSafetyq;h (h o}q<(h}h}ubub.(hoq=}q>(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U-Regression.C++Frontend.2003-08-28-SaveExprBugqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U"Regression.Jello.2003-06-05-PHIBugqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Transforms.Reassociate.subtestqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq_h (h o}q`(h}h}ubub.(! hoqa}qb(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10- 07-DominatorProblemqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U$Regression.Jello.2003-01-04-LoopTestqoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U)Regression.CFrontend.2002-07-14-MiscTestsqwh (h o}qx(h}h}ubub.(hoqy}qz(hhhhh}h U(hhhhh}h U Regression.Reoptimizer.ticm.ticmq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U)Regression.Transforms.Reassociate.subtestqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemq_! h (h o}q`(h}h}ubub.(hoqa}qb(hhhhh}h U3Regression.Transforms.Pi NodeInserter.substitutetestqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U-Regression.CFrontend.2002-02-18-64bitConstantqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U(Regression.Reoptimizer.BinInterface.testqsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20031202/cd1511bd/attachment.html From wfau34uo at bigpond.com Tue Dec 2 22:13:01 2003 From: wfau34uo at bigpond.com (Clifton Mccabe) Date: Tue Dec 2 22:13:01 2003 Subject: [llvm-commits] Clean Colons u olwy Message-ID: An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20031202/6789b1ce/attachment.html From alkis at cs.uiuc.edu Wed Dec 3 21:58:02 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Dec 3 21:58:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200312040357.VAA26688@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.4 -> 1.5 --- Log message: Improve debugging output and clean up some code. --- Diffs of the changes: (+14 -17) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.4 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.5 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.4 Sun Nov 30 17:40:39 2003 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Wed Dec 3 21:57:28 2003 @@ -150,10 +150,9 @@ /// stack slot void assignVirt2StackSlot(unsigned virtReg); - /// findOrCreateStackSlot - returns the offset of the - /// specified register on the stack allocating space if - /// necessary - int findOrCreateStackSlot(unsigned virtReg); + /// getStackSlot - returns the offset of the specified + /// register on the stack + int getStackSlot(unsigned virtReg); /// spillVirtReg - spills the virtual register void spillVirtReg(unsigned virtReg); @@ -749,29 +748,27 @@ if (v2pMap_.find(virtReg) != v2pMap_.end()) { clearVirtReg(virtReg); } + else { + v2pMap_[virtReg] = 0; // this marks that this virtual register + // lives on the stack + } } -int RA::findOrCreateStackSlot(unsigned virtReg) +int RA::getStackSlot(unsigned virtReg) { // use lower_bound so that we can do a possibly O(1) insert later // if necessary - Virt2StackSlotMap::iterator it = v2ssMap_.lower_bound(virtReg); - if (it != v2ssMap_.end() && it->first == virtReg) { - return it->second; - } - const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - int frameIndex = mf_->getFrameInfo()->CreateStackObject(rc); - - v2ssMap_.insert(it, std::make_pair(virtReg, frameIndex)); - - return frameIndex; + Virt2StackSlotMap::iterator it = v2ssMap_.find(virtReg); + assert(it != v2ssMap_.end() && + "attempt to get stack slot on register that does not live on the stack"); + return it->second; } void RA::spillVirtReg(unsigned virtReg) { DEBUG(std::cerr << "\t\t\tspilling register: " << virtReg); const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - int frameIndex = findOrCreateStackSlot(virtReg); + int frameIndex = getStackSlot(virtReg); DEBUG(std::cerr << " to stack slot #" << frameIndex << '\n'); ++numSpilled; instrAdded_ += mri_->storeRegToStackSlot(*currentMbb_, currentInstr_, @@ -783,7 +780,7 @@ { DEBUG(std::cerr << "\t\t\tloading register: " << virtReg); const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(virtReg); - int frameIndex = findOrCreateStackSlot(virtReg); + int frameIndex = getStackSlot(virtReg); DEBUG(std::cerr << " from stack slot #" << frameIndex << '\n'); instrAdded_ += mri_->loadRegFromStackSlot(*currentMbb_, currentInstr_, physReg, frameIndex, rc); From alkis at cs.uiuc.edu Fri Dec 5 04:33:02 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Dec 5 04:33:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200312051032.EAA29094@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.2 -> 1.3 --- Log message: Sort live intervals by increasing start point. --- Diffs of the changes: (+1 -0) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.2 llvm/lib/CodeGen/LiveIntervals.cpp:1.3 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.2 Wed Nov 19 21:32:25 2003 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Dec 5 04:32:01 2003 @@ -297,6 +297,7 @@ } } + std::sort(intervals_.begin(), intervals_.end(), StartPointComp()); DEBUG(std::copy(intervals_.begin(), intervals_.end(), std::ostream_iterator(std::cerr, "\n"))); } From alkis at cs.uiuc.edu Fri Dec 5 04:39:00 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Dec 5 04:39:00 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveIntervals.h Message-ID: <200312051038.EAA29142@morpheus.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: LiveIntervals.h updated: 1.2 -> 1.3 --- Log message: Move operator<<(std::ostream&, const LiveInterval&) out of the header file. --- Diffs of the changes: (+2 -9) Index: llvm/include/llvm/CodeGen/LiveIntervals.h diff -u llvm/include/llvm/CodeGen/LiveIntervals.h:1.2 llvm/include/llvm/CodeGen/LiveIntervals.h:1.3 --- llvm/include/llvm/CodeGen/LiveIntervals.h:1.2 Wed Nov 19 21:32:25 2003 +++ llvm/include/llvm/CodeGen/LiveIntervals.h Fri Dec 5 04:38:28 2003 @@ -196,15 +196,8 @@ return lhs.reg == rhs.reg; } - inline std::ostream& operator<<(std::ostream& os, - const LiveIntervals::Interval& li) { - os << "%reg" << li.reg << " = "; - for (LiveIntervals::Interval::Ranges::const_iterator - i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { - os << "[" << i->first << ", " << i->second << "]"; - } - return os; - } + std::ostream& operator<<(std::ostream& os, + const LiveIntervals::Interval& li); } // End llvm namespace From alkis at cs.uiuc.edu Fri Dec 5 04:39:02 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Dec 5 04:39:02 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200312051038.EAA29135@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.3 -> 1.4 --- Log message: Move operator<<(std::ostream&, const LiveInterval&) out of the header file. --- Diffs of the changes: (+11 -0) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.3 llvm/lib/CodeGen/LiveIntervals.cpp:1.4 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.3 Fri Dec 5 04:32:01 2003 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Dec 5 04:38:27 2003 @@ -301,3 +301,14 @@ DEBUG(std::copy(intervals_.begin(), intervals_.end(), std::ostream_iterator(std::cerr, "\n"))); } + +std::ostream& llvm::operator<<(std::ostream& os, + const LiveIntervals::Interval& li) +{ + os << "%reg" << li.reg << " = "; + for (LiveIntervals::Interval::Ranges::const_iterator + i = li.ranges.begin(), e = li.ranges.end(); i != e; ++i) { + os << "[" << i->first << "," << i->second << "]"; + } + return os; +} From alkis at cs.uiuc.edu Fri Dec 5 05:19:01 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Dec 5 05:19:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200312051118.FAA29220@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.5 -> 1.6 --- Log message: Fix bug in register spilling when a preallocated live range overlaps a potential register assignment. --- Diffs of the changes: (+3 -13) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.5 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.6 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.5 Wed Dec 3 21:57:28 2003 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Fri Dec 5 05:17:55 2003 @@ -251,16 +251,6 @@ // if this register is preallocated, look for an interval that // overlaps with it and assign it to a memory location if (i->reg < MRegisterInfo::FirstVirtualRegister) { - for (IntervalPtrs::iterator - ai = active_.begin(), ae = active_.end(); ai != ae; ++ai) { - unsigned virtReg = (*ai)->reg; - Virt2PhysMap::const_iterator it = v2pMap_.find(virtReg); - if (it != v2pMap_.end() && it->second == i->reg) { - active_.erase(ai); - clearVirtReg(virtReg); - break; - } - } reservePhysReg(i->reg); active_.push_back(&*i); } @@ -607,7 +597,7 @@ void RA::reservePhysReg(unsigned physReg) { - DEBUG(std::cerr << "\t\t\treserving physical physical register: " + DEBUG(std::cerr << "\t\t\treserving physical register: " << mri_->getName(physReg) << '\n'); // if this register holds a value spill it unsigned virtReg = p2vMap_[physReg]; @@ -621,14 +611,14 @@ break; } } - spillVirtReg(virtReg); + assignVirt2StackSlot(virtReg); } p2vMap_[physReg] = physReg; // this denotes a reserved physical register } void RA::clearReservedPhysReg(unsigned physReg) { - DEBUG(std::cerr << "\t\t\tclearing reserved physical physical register: " + DEBUG(std::cerr << "\t\t\tclearing reserved physical register: " << mri_->getName(physReg) << '\n'); assert(p2vMap_[physReg] == physReg && "attempt to clear a non reserved physical register"); From alkis at cs.uiuc.edu Fri Dec 5 05:32:01 2003 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Dec 5 05:32:01 2003 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp Message-ID: <200312051131.FAA29273@morpheus.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLocal.cpp updated: 1.31 -> 1.32 --- Log message: Make assertion stricter. Since the source operands are allocated at this point, the second operand must be a physical register (it cannot be a virtual one). --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/RegAllocLocal.cpp diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.31 llvm/lib/CodeGen/RegAllocLocal.cpp:1.32 --- llvm/lib/CodeGen/RegAllocLocal.cpp:1.31 Tue Nov 11 16:41:32 2003 +++ llvm/lib/CodeGen/RegAllocLocal.cpp Fri Dec 5 05:31:39 2003 @@ -583,7 +583,7 @@ if (TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) && i == 0) { // must be same register number as the first operand // This maps a = b + c into b += c, and saves b into a's spot - assert(MI->getOperand(1).isRegister() && + assert(MI->getOperand(1).isPhysicalRegister() && MI->getOperand(1).getAllocatedRegNum() && MI->getOperand(1).opIsUse() && "Two address instruction invalid!"); From gaeke at cs.uiuc.edu Fri Dec 5 13:30:02 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Dec 5 13:30:02 2003 Subject: [llvm-commits] CVS: llvm/configure Message-ID: <200312051929.NAA29399@gally.cs.uiuc.edu> Changes in directory llvm: configure updated: 1.59 -> 1.60 --- Log message: Add check for pthread_mutex_lock() in -lpthread (or otherwise). Regenerated configure w/ autoconf-2.57. --- Diffs of the changes: (+111 -0) Index: llvm/configure diff -u llvm/configure:1.59 llvm/configure:1.60 --- llvm/configure:1.59 Tue Nov 25 14:36:44 2003 +++ llvm/configure Fri Dec 5 13:29:01 2003 @@ -18956,6 +18956,117 @@ fi +echo "$as_me:$LINENO: checking for library containing pthread_mutex_lock" >&5 +echo $ECHO_N "checking for library containing pthread_mutex_lock... $ECHO_C" >&6 +if test "${ac_cv_search_pthread_mutex_lock+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +ac_cv_search_pthread_mutex_lock=no +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_mutex_lock (); +int +main () +{ +pthread_mutex_lock (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_pthread_mutex_lock="none required" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +if test "$ac_cv_search_pthread_mutex_lock" = no; then + for ac_lib in pthread; do + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char pthread_mutex_lock (); +int +main () +{ +pthread_mutex_lock (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_pthread_mutex_lock="-l$ac_lib" +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + done +fi +LIBS=$ac_func_search_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_search_pthread_mutex_lock" >&5 +echo "${ECHO_T}$ac_cv_search_pthread_mutex_lock" >&6 +if test "$ac_cv_search_pthread_mutex_lock" != no; then + test "$ac_cv_search_pthread_mutex_lock" = "none required" || LIBS="$ac_cv_search_pthread_mutex_lock $LIBS" + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTHREAD_MUTEX_LOCK 1 +_ACEOF + +fi + + echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 From gaeke at cs.uiuc.edu Fri Dec 5 13:30:05 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Dec 5 13:30:05 2003 Subject: [llvm-commits] CVS: llvm/autoconf/configure.ac Message-ID: <200312051929.NAA29370@gally.cs.uiuc.edu> Changes in directory llvm/autoconf: configure.ac updated: 1.59 -> 1.60 --- Log message: Add check for pthread_mutex_lock() in -lpthread (or otherwise). Regenerated configure w/ autoconf-2.57. --- Diffs of the changes: (+4 -0) Index: llvm/autoconf/configure.ac diff -u llvm/autoconf/configure.ac:1.59 llvm/autoconf/configure.ac:1.60 --- llvm/autoconf/configure.ac:1.59 Tue Nov 25 14:36:46 2003 +++ llvm/autoconf/configure.ac Fri Dec 5 13:28:58 2003 @@ -294,6 +294,10 @@ dnl mallinfo is optional; the code can compile (minus features) without it AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],[Define if mallinfo() is available on this platform.])) +dnl pthread locking functions are optional - but llvm will not be thread-safe +dnl without locks. +AC_SEARCH_LIBS(pthread_mutex_lock,pthread,AC_DEFINE(HAVE_PTHREAD_MUTEX_LOCK,1,[Define if PThread mutexes (e.g., pthread_mutex_lock) are available in the system's thread library.])) + dnl dnl The math libraries are used by the test code, but not by the actual LLVM dnl code. From criswell at cs.uiuc.edu Fri Dec 5 17:52:01 2003 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri Dec 5 17:52:01 2003 Subject: [llvm-commits] CVS: llvm/test/QMTest/expectations.sunos.qmr Message-ID: <200312052351.RAA20310@seraph.cs.uiuc.edu> Changes in directory llvm/test/QMTest: expectations.sunos.qmr updated: 1.2 -> 1.3 --- Log message: Reverted back to 1.0 expectations. The last round of expectations was horribly incorrect. --- Diffs of the changes: (+0 -0) Index: llvm/test/QMTest/expectations.sunos.qmr From lattner at cs.uiuc.edu Sat Dec 6 13:57:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 13:57:01 2003 Subject: [llvm-commits] CVS: llvm-www/releases/1.0/index.html Message-ID: <200312061956.NAA06968@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.0: index.html updated: 1.11 -> 1.12 --- Log message: Eliminate tables, making the page look a lot better on my mozilla 1.1. Misha and his tables, geeze. --- Diffs of the changes: (+3 -9) Index: llvm-www/releases/1.0/index.html diff -u llvm-www/releases/1.0/index.html:1.11 llvm-www/releases/1.0/index.html:1.12 --- llvm-www/releases/1.0/index.html:1.11 Thu Nov 13 21:15:45 2003 +++ llvm-www/releases/1.0/index.html Sat Dec 6 13:56:04 2003 @@ -24,9 +24,7 @@ - - -
License
+
License
@@ -37,9 +35,7 @@
- - -
Download
+
Download
@@ -49,9 +45,7 @@
- - -
Documentation
+
Documentation
From lattner at cs.uiuc.edu Sat Dec 6 14:23:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 14:23:01 2003 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200312062022.OAA32736@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.69 -> 1.70 --- Log message: Cleanup the release notes in preparation for the release. --- Diffs of the changes: (+75 -42) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.69 llvm/docs/ReleaseNotes.html:1.70 --- llvm/docs/ReleaseNotes.html:1.69 Thu Nov 27 03:52:03 2003 +++ llvm/docs/ReleaseNotes.html Sat Dec 6 14:22:41 2003 @@ -71,22 +71,44 @@

This is the second public release of the LLVM compiler infrastructure. This -release implements the following new features:

+release is primarily a bugfix release, dramatically improving the C/C++ +front-end, and improving support for C++ in the LLVM core. This release also +features a few new features, such as a simple profiler, support for Mac OS/X, +and better interoperability with external source bases.

+ +

At this time, LLVM is known to correctly compile the SPEC CPU2000 benchmarks +(X86 only), the Olden benchmarks, and the Ptrdist benchmarks along with +many other programs. LLVM now also works with a fairly broad variety of +C++ programs, though it has still received much less testing than the C +front-end. +

+ +

+Note that the Sparc and X86 backends do not currently support exception throwing +or long jumping (including 253.perlbmk in SPEC). For these programs, you must +use the C backend. Support for unwinding will be added in a future release. +

+ + + +
+This release implements the following new features: +
  1. A new LLVM profiler, similar to gprof is available
  2. -
  3. LLVM and the C/C++ front-end now compile on Mac OSX! Mac OSX users can +
  4. LLVM and the C/C++ front-end now compile on Mac OS/X! Mac OS/X users can now explore the LLVM optimizer with the C backend (note that LLVM requires GCC -3.3 on Mac OSX).
  5. +3.3 on Mac OS/X).
  6. LLVM has been moved into an 'llvm' C++ namespace, for easier integration with third-party -code. Note that due to a bug in GDB 5.x, to debug namespacified LLVM code, -you will need to upgrade to GDB 6.
  7. +code. Note that lack of namespace handling in GDB 5.x, you will probably want to +upgrade to GDB 6 or better to debug LLVM code.
  8. The build system now copies Makefiles dynamically from the source tree to the @@ -110,7 +132,11 @@
-

In this release, the following missing features were implemented:

+ + +
+In this release, the following missing features were implemented: +
  1. The interpreter does not support @@ -124,8 +150,12 @@
-

In this release, the following Quality of Implementation issues were -fixed:

+ + +
+In this release, the following Quality of Implementation issues were +fixed: +
    @@ -152,57 +182,69 @@ generated N^2 amounts of duplicated cleanup code in some cases.
-

In this release, the following bugs in the previous release were fixed:

+ + +
+In this release, the following bugs in the previous release were fixed: +
+ +

Bugs in the LLVM Core:

  1. [inliner] Inlining invoke with PHI in unwind target is broken
  2. [linker] linkonce globals should link successfully to external globals
  3. -
  4. C++ frontend can crash when compiling virtual base classes
  5. -
  6. C backend fails on constant cast expr to ptr-to-anonymous struct
  7. -
  8. #ident is not recognized by C frontend
  9. [constmerge] Constant merging pass merges constants with external linkage
  10. -
  11. C front-end miscompiles the builtin_expect intrinsic!
  12. [scalarrepl] Scalar Replacement of aggregates is decimating structures it shouldn't be
  13. -
  14. 1.0 precompiled libstdc++ does not include wchar_t support
  15. -
  16. llvmgcc asserts when compiling functions renamed with asm's
  17. -
  18. C frontend crashes on some programs with lots of types.
  19. [instcombine] Resolving invoke inserts cast after terminator
  20. llvm-as crashes when labels are used in phi nodes
  21. [build problem] Callgraph.cpp not pulled in from libipa.a
  22. Variables in scope of output setjmp -calls should be volatile. Note that this does not effect correctness on -many platforms, such as X86.
  23. -
  24. llvm-gcc crashes compiling global union initializer
  25. -
  26. C front-end crash on empty structure
  27. -
  28. CFrontend crashes when compiling C99 compound expressions
  29. +calls should be volatile (Note that this does not effect correctness on +many platforms, such as X86).
  30. [X86] Emission of global bool initializers broken
  31. -
  32. llvm-gcc infinite loops on "case MAXINT:"
  33. -
  34. [C++] Catch blocks make unparsable labels
  35. -
  36. [C++] Initializing array with constructable objects fail
  37. [gccld] The -r (relinking) option does not work correctly
  38. [bcreader] Cannot read shift constant expressions from bytecode file
  39. [lowersetjmp] Lowersetjmp pass breaks dominance properties!
  40. -
  41. llvm-gcc tries to add bools
  42. SymbolTable::getUniqueName is very inefficient
  43. [buildscripts] Building into objdir with .o in it fails
  44. [setjmp/longjmp] Linking C programs which use setjmp/longjmp sometimes fail with references to the C++ runtime library!
  45. -
  46. [c++] C++ Frontend lays out superclasses like anonymous bitfields!
  47. AsmParser Misses Symbol Redefinition Error
  48. gccld -Lfoo -lfoo fails to find ./foo/libfoo.a
  49. [bcreader] Incorrect cast causes misread forward constant references
  50. -
  51. Casting a string constant to void crashes llvm-gcc
  52. [adce] ADCE considers blocks without postdominators to be unreachable
  53. -
  54. C front-end miscompiles unsigned enums whose LLVM types are signed
  55. [X86] div and rem constant exprs invalidate iterators!
  56. +
  57. [vmcore] Symbol table doesn't rename colliding variables during type resolution
  58. +
  59. bugpoint must not pass -R<directory> to Mach-O linker
  60. +
  61. gccld produces a runner script that includes command-line options to load the necessary shared objects
  62. +
+ + +

Bugs in the C/C++ front-end:

+ +
    +
  1. C++ frontend can crash when compiling virtual base classes
  2. +
  3. C backend fails on constant cast expr to ptr-to-anonymous struct
  4. +
  5. #ident is not recognized by C frontend
  6. +
  7. C front-end miscompiles the builtin_expect intrinsic!
  8. +
  9. 1.0 precompiled libstdc++ does not include wchar_t support
  10. +
  11. llvmgcc asserts when compiling functions renamed with asm's
  12. +
  13. C frontend crashes on some programs with lots of types.
  14. +
  15. llvm-gcc crashes compiling global union initializer
  16. +
  17. C front-end crash on empty structure
  18. +
  19. CFrontend crashes when compiling C99 compound expressions
  20. +
  21. llvm-gcc infinite loops on "case MAXINT:"
  22. +
  23. [C++] Catch blocks make unparsable labels
  24. +
  25. [C++] Initializing array with constructable objects fail
  26. +
  27. llvm-gcc tries to add bools
  28. +
  29. [c++] C++ Frontend lays out superclasses like anonymous bitfields!
  30. +
  31. C front-end miscompiles unsigned enums whose LLVM types are signed
  32. +
  33. Casting a string constant to void crashes llvm-gcc
  34. [llvmg++] Enum types are incorrectly shrunk to smaller than 'int' size
  35. [llvmg++] Cannot use pointer to member to initialize global
  36. -
  37. [vmcore] Symbol table doesn't rename colliding variables during type resolution
  38. [llvm-gcc] ?: operator as lvalue not implemented
  39. [C/C++] Bogus warning about taking the address of 'register' variable
  40. -
  41. bugpoint must not pass -R<directory> to Mach-O linker
  42. crash assigning into an array in a struct which contains a bitfield.
  43. Oversized integer bitfields cause crash
  44. -
  45. gccld produces a runner script that includes command-line options to load the necessary shared objects
  46. [llvm-gcc] Bitfields & large array don't mix well
  47. [llvm-gcc] Complex division is not supported
  48. [llvm-gcc] Illegal union field reference
  49. @@ -211,13 +253,8 @@
  50. [llvm-gcc] crash on union initialization
  51. [llvm-g++] ?: expressions do not run correct number of destructors!
  52. [llvm-gcc] Pointer & constant results in invalid shift
  53. -

-

At this time, LLVM is known to work properly with SPEC CPU 2000 (X86 only), -the Olden benchmarks, and the Ptrdist benchmarks among many other programs. -Note however that the Sparc and X86 backends do not currently support exception -throwing or long jumping (including 253.perlbmk in SPEC). For these programs, -you must use the C backend.

+
@@ -577,10 +614,6 @@ supported. This should not affect LLVM produced by the C or C++ frontends. -
  • The code produces by the C back-end has only been tested with the Sun CC, -GCC, and Intel compilers. It is possible that it will have to be adjusted to -support other C compilers.
  • -
    @@ -615,7 +648,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2003/11/27 09:52:03 $ + Last modified: $Date: 2003/12/06 20:22:41 $ From lattner at cs.uiuc.edu Sat Dec 6 14:25:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 14:25:01 2003 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200312062024.OAA01947@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.70 -> 1.71 --- Log message: Fix awkward wording --- Diffs of the changes: (+2 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.70 llvm/docs/ReleaseNotes.html:1.71 --- llvm/docs/ReleaseNotes.html:1.70 Sat Dec 6 14:22:41 2003 +++ llvm/docs/ReleaseNotes.html Sat Dec 6 14:24:46 2003 @@ -73,7 +73,7 @@

    This is the second public release of the LLVM compiler infrastructure. This release is primarily a bugfix release, dramatically improving the C/C++ front-end, and improving support for C++ in the LLVM core. This release also -features a few new features, such as a simple profiler, support for Mac OS/X, +includes a few new features, such as a simple profiler, support for Mac OS/X, and better interoperability with external source bases.

    At this time, LLVM is known to correctly compile the SPEC CPU2000 benchmarks @@ -648,7 +648,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2003/12/06 20:22:41 $ + Last modified: $Date: 2003/12/06 20:24:46 $ From lattner at cs.uiuc.edu Sat Dec 6 15:00:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 15:00:01 2003 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200312062059.OAA15651@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.163 -> 1.164 --- Log message: Stop using the -fshort-enum compile option --- Diffs of the changes: (+3 -4) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.163 llvm/Makefile.rules:1.164 --- llvm/Makefile.rules:1.163 Mon Dec 1 01:28:25 2003 +++ llvm/Makefile.rules Sat Dec 6 14:59:45 2003 @@ -294,8 +294,7 @@ # Pull in limit macros from stdint.h, even in C++: CPPFLAGS += -D__STDC_LIMIT_MACROS -CompileWarnings := -Wall -W -Wwrite-strings -Wno-unused -CompileCommonOpts := $(CompileWarnings) -fshort-enums +CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions # @@ -720,11 +719,11 @@ $(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.cpp $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LCC1XX) @${ECHO} "Compiling `basename $<` to bytecode" - $(VERB) $(LLVMGXX) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@ + $(VERB) $(LLVMGXX) $(CompileCommonOpts) $(CPPFLAGS) -c $< -o $@ $(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.c $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LCC1) @${ECHO} "Compiling `basename $<` to bytecode" - $(VERB) $(LLVMGCC) $(CompileWarnings) $(CPPFLAGS) -c $< -o $@ + $(VERB) $(LLVMGCC) $(CompileCommonOpts) $(CPPFLAGS) -c $< -o $@ $(BUILD_OBJ_DIR)/BytecodeObj/%.bc: %.ll $(BUILD_OBJ_DIR)/BytecodeObj/.dir $(LLVMAS) @${ECHO} "Compiling `basename $<` to bytecode" From tbrethou at cs.uiuc.edu Sat Dec 6 17:02:01 2003 From: tbrethou at cs.uiuc.edu (Tanya Brethour) Date: Sat Dec 6 17:02:01 2003 Subject: [llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp Message-ID: <200312062301.RAA15903@seraph.cs.uiuc.edu> Changes in directory llvm/tools/llvm-ar: llvm-ar.cpp updated: 1.8 -> 1.9 --- Log message: New command line parsing. This isn't as perfect as I would have liked. The CommandLine Library needs to be extended, in order to parse the options and allow for optional dashes. In addition, the help option isn't correct since I do the parsing mostly myself. But this is in the ocorrect ar format. --- Diffs of the changes: (+246 -57) Index: llvm/tools/llvm-ar/llvm-ar.cpp diff -u llvm/tools/llvm-ar/llvm-ar.cpp:1.8 llvm/tools/llvm-ar/llvm-ar.cpp:1.9 --- llvm/tools/llvm-ar/llvm-ar.cpp:1.8 Tue Nov 11 16:41:34 2003 +++ llvm/tools/llvm-ar/llvm-ar.cpp Sat Dec 6 17:01:25 2003 @@ -35,58 +35,68 @@ #define ARFMAG "\n" /* header trailer string */ #define ARMAG "!\n" /* magic string */ #define SARMAG 8 /* length of magic string */ +#define VERSION "llvm-ar is a part of the LLVM compiler infrastructure.\nPlease see http://llvm.cs.uiuc.edu for more information.\n"; -namespace { - // Each file member is preceded by a file member header. Which is - // of the following format: - // - // char ar_name[16] - '/' terminated file member name. - // If the file name does not fit, a dummy name is used. - // char ar_date[12] - file date in decimal - // char ar_uid[6] - User id of file owner in decimal. - // char ar_gid[6] - Group ID file belongs to in decimal. - // char ar_mode[8] - File mode in octal. - // char ar_size[10] - Size of file in decimal. - // char ar_fmag[2] - Trailer of header file, a newline. - struct ar_hdr { - char name[16]; - char date[12]; - char uid[6]; - char gid[6]; - char mode[8]; - char size[10]; - char fmag[2]; - void init() { - memset(name,' ',16); - memset(date,' ',12); - memset(uid,' ',6); - memset(gid,' ',6); - memset(mode,' ',8); - memset(size,' ',10); - memset(fmag,' ',2); +// Each file member is preceded by a file member header. Which is +// of the following format: +// +// char ar_name[16] - '/' terminated file member name. +// If the file name does not fit, a dummy name is used. +// char ar_date[12] - file date in decimal +// char ar_uid[6] - User id of file owner in decimal. +// char ar_gid[6] - Group ID file belongs to in decimal. +// char ar_mode[8] - File mode in octal. +// char ar_size[10] - Size of file in decimal. +// char ar_fmag[2] - Trailer of header file, a newline. +struct ar_hdr { + char name[16]; + char date[12]; + char uid[6]; + char gid[6]; + char mode[8]; + char size[10]; + char fmag[2]; + void init() { + memset(name,' ',16); + memset(date,' ',12); + memset(uid,' ',6); + memset(gid,' ',6); + memset(mode,' ',8); + memset(size,' ',10); + memset(fmag,' ',2); } - }; -} +}; -//Option to generate symbol table or not -//running llvm-ar -s is the same as ranlib -cl::opt SymbolTableOption ("s", cl::desc("Generate an archive symbol table")); -//Archive name -cl::opt Archive (cl::Positional, cl::desc(""), - cl::Required); +//Option for X32_64, not used but must allow it to be present. +cl::opt X32Option ("X32_64", cl::desc("Ignored option spelt -X32_64, for compatibility with AIX"), cl::Optional); -//For now we require one or more member files, this should change so -//we can just run llvm-ar -s on an archive to generate the symbol -//table -cl::list Members(cl::ConsumeAfter, cl::desc("...")); +//llvm-ar options +cl::opt Options(cl::Positional, cl::desc("{dmpqrstx}[abcfilNoPsSuvV] "), cl::Required); +//llvm-ar options +cl::list RestofArgs(cl::Positional, cl::desc("[relpos] [count]] [members..]"), cl::Optional); -static inline bool Error(std::string *ErrorStr, const char *Message) { - if (ErrorStr) *ErrorStr = Message; - return true; -} +//booleans to represent Operation, only one can be preformed at a time +bool Print, Delete, Move, QuickAppend, InsertWithReplacement, DisplayTable; +bool Extract; + +//Modifiers to follow operation to vary behavior +bool AddAfter, AddBefore, Create, TruncateNames, InsertBefore, UseCount; +bool OriginalDates, FullPath, SymTable, OnlyUpdate, Verbose; + +//Realtive Pos Arg +string RelPos; + +//Count, use for multiple entries in the archive with the same name +int Count; + +//Archive +string Archive; + +//Member Files +vector Members; // WriteSymbolTable - Writes symbol table to ArchiveFile, return false @@ -248,13 +258,15 @@ // 4) Keep track of total offset into file, and insert a newline if it is odd. // bool AddMemberToArchive(string Member, std::ofstream &ArchiveFile) { - + + cout << "Member File Start: " << ArchiveFile.tellp() << "\n"; + ar_hdr Hdr; //Header for archive member file. - + //stat the file to get info struct stat StatBuf; if (stat(Member.c_str(), &StatBuf) == -1 || StatBuf.st_size == 0) - cout << "ERROR\n"; + return false; //fill in header @@ -312,9 +324,11 @@ //write to archive file ArchiveFile.write((char*)buf,Length); - + // Unmmap the memberfile munmap((char*)buf, Length); + + cout << "Member File End: " << ArchiveFile.tellp() << "\n"; return true; } @@ -324,6 +338,8 @@ // void CreateArchive() { + std::cerr << "Archive File: " << Archive << "\n"; + //Create archive file for output. std::ofstream ArchiveFile(Archive.c_str()); @@ -337,7 +353,7 @@ ArchiveFile << ARMAG; //If the '-s' option was specified, generate symbol table. - if(SymbolTableOption) { + if(SymTable) { cout << "Symbol Table Start: " << ArchiveFile.tellp() << "\n"; if(!WriteSymbolTable(ArchiveFile)) { std::cerr << "Error creating symbol table. Exiting program."; @@ -346,31 +362,204 @@ cout << "Symbol Table End: " << ArchiveFile.tellp() << "\n"; } //Loop over all member files, and add to the archive. - for(unsigned i=0; i 0) { + RelPos = RestofArgs[0]; + RestofArgs.erase(RestofArgs.begin()); + } + //Throw error if needed and not present + else + printUse(); +} + +//Extract count from the command line +void getCount() { + if(RestofArgs.size() > 0) { + Count = atoi(RestofArgs[0].c_str()); + RestofArgs.erase(RestofArgs.begin()); + } + //Throw error if needed and not present + else + printUse(); +} + +//Get the Archive File Name from the command line +void getArchive() { + std::cerr << RestofArgs.size() << "\n"; + if(RestofArgs.size() > 0) { + Archive = RestofArgs[0]; + RestofArgs.erase(RestofArgs.begin()); + } + //Throw error if needed and not present + else + printUse(); +} + + +//Copy over remaining items in RestofArgs to our Member File vector. +//This is just for clarity. +void getMembers() { + std::cerr << RestofArgs.size() << "\n"; + if(RestofArgs.size() > 0) + Members = vector(RestofArgs); +} + +// Parse the operations and operation modifiers +// FIXME: Not all of these options has been implemented, but we still +// do all the command line parsing for them. +void parseCL() { + + //Keep track of number of operations. We can only specify one + //per execution + unsigned NumOperations = 0; + + for(unsigned i=0; i 1) + printUse(); + + getArchive(); + getMembers(); + +} int main(int argc, char **argv) { //Parse Command line options - cl::ParseCommandLineOptions(argc, argv, " llvm-ar\n"); + cl::ParseCommandLineOptions(argc, argv); + parseCL(); //Create archive! - CreateArchive(); + if(Create) + CreateArchive(); return 0; } + From lattner at cs.uiuc.edu Sat Dec 6 18:36:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:36:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Analysis/PostDominators.cpp Message-ID: <200312070035.SAA24922@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: PostDominators.cpp updated: 1.45 -> 1.46 --- Log message: Finegrainify namespacification Move method out of generic dominators construction code --- Diffs of the changes: (+38 -3) Index: llvm/lib/Analysis/PostDominators.cpp diff -u llvm/lib/Analysis/PostDominators.cpp:1.45 llvm/lib/Analysis/PostDominators.cpp:1.46 --- llvm/lib/Analysis/PostDominators.cpp:1.45 Tue Nov 11 16:41:31 2003 +++ llvm/lib/Analysis/PostDominators.cpp Sat Dec 6 18:35:42 2003 @@ -16,8 +16,7 @@ #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/SetOperations.h" - -namespace llvm { +using namespace llvm; //===----------------------------------------------------------------------===// // PostDominatorSet Implementation @@ -110,6 +109,43 @@ static RegisterAnalysis D("postidom", "Immediate Post-Dominators Construction", true); + +// calcIDoms - Calculate the immediate dominator mapping, given a set of +// dominators for every basic block. +void ImmediatePostDominators::calcIDoms(const DominatorSetBase &DS) { + // Loop over all of the nodes that have dominators... figuring out the IDOM + // for each node... + // + for (DominatorSet::const_iterator DI = DS.begin(), DEnd = DS.end(); + DI != DEnd; ++DI) { + BasicBlock *BB = DI->first; + const DominatorSet::DomSetType &Dominators = DI->second; + unsigned DomSetSize = Dominators.size(); + if (DomSetSize == 1) continue; // Root node... IDom = null + + // Loop over all dominators of this node. This corresponds to looping over + // nodes in the dominator chain, looking for a node whose dominator set is + // equal to the current nodes, except that the current node does not exist + // in it. This means that it is one level higher in the dom chain than the + // current node, and it is our idom! + // + DominatorSet::DomSetType::const_iterator I = Dominators.begin(); + DominatorSet::DomSetType::const_iterator End = Dominators.end(); + for (; I != End; ++I) { // Iterate over dominators... + // All of our dominators should form a chain, where the number of elements + // in the dominator set indicates what level the node is at in the chain. + // We want the node immediately above us, so it will have an identical + // dominator set, except that BB will not dominate it... therefore it's + // dominator set size will be one less than BB's... + // + if (DS.getDominators(*I).size() == DomSetSize - 1) { + IDoms[BB] = *I; + break; + } + } + } +} + //===----------------------------------------------------------------------===// // PostDominatorTree Implementation //===----------------------------------------------------------------------===// @@ -217,4 +253,3 @@ void PostDominanceFrontier::stub() { } -} // End llvm namespace From lattner at cs.uiuc.edu Sat Dec 6 18:36:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:36:03 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/PostDominators.h Message-ID: <200312070035.SAA24911@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: PostDominators.h updated: 1.6 -> 1.7 --- Log message: Move this method out of the generic dominators calculation code --- Diffs of the changes: (+2 -0) Index: llvm/include/llvm/Analysis/PostDominators.h diff -u llvm/include/llvm/Analysis/PostDominators.h:1.6 llvm/include/llvm/Analysis/PostDominators.h:1.7 --- llvm/include/llvm/Analysis/PostDominators.h:1.6 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Analysis/PostDominators.h Sat Dec 6 18:35:19 2003 @@ -59,6 +59,8 @@ AU.setPreservesAll(); AU.addRequired(); } +private: + void calcIDoms(const DominatorSetBase &DS); }; From lattner at cs.uiuc.edu Sat Dec 6 18:37:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:37:01 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h Message-ID: <200312070036.SAA24937@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Dominators.h updated: 1.41 -> 1.42 --- Log message: Rewrite dominators implementation. Now domset is constructed from immdom, instead of the other way around. --- Diffs of the changes: (+111 -95) Index: llvm/include/llvm/Analysis/Dominators.h diff -u llvm/include/llvm/Analysis/Dominators.h:1.41 llvm/include/llvm/Analysis/Dominators.h:1.42 --- llvm/include/llvm/Analysis/Dominators.h:1.41 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Analysis/Dominators.h Sat Dec 6 18:36:16 2003 @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// // // This file defines the following classes: -// 1. DominatorSet: Calculates the [reverse] dominator set for a function -// 2. ImmediateDominators: Calculates and holds a mapping between BasicBlocks +// 1. ImmediateDominators: Calculates and holds a mapping between BasicBlocks // and their immediate dominator. +// 2. DominatorSet: Calculates the [reverse] dominator set for a function // 3. DominatorTree: Represent the ImmediateDominator as an explicit tree // structure. // 4. DominanceFrontier: Calculate and hold the dominance frontier for a @@ -55,6 +55,108 @@ bool isPostDominator() const { return IsPostDominators; } }; + +//===----------------------------------------------------------------------===// +// +// ImmediateDominators - Calculate the immediate dominator for each node in a +// function. +// +class ImmediateDominatorsBase : public DominatorBase { +protected: + std::map IDoms; +public: + ImmediateDominatorsBase(bool isPostDom) : DominatorBase(isPostDom) {} + + virtual void releaseMemory() { IDoms.clear(); } + + // Accessor interface: + typedef std::map IDomMapType; + typedef IDomMapType::const_iterator const_iterator; + inline const_iterator begin() const { return IDoms.begin(); } + inline const_iterator end() const { return IDoms.end(); } + inline const_iterator find(BasicBlock* B) const { return IDoms.find(B);} + + // operator[] - Return the idom for the specified basic block. The start + // node returns null, because it does not have an immediate dominator. + // + inline BasicBlock *operator[](BasicBlock *BB) const { + return get(BB); + } + + // get() - Synonym for operator[]. + inline BasicBlock *get(BasicBlock *BB) const { + std::map::const_iterator I = IDoms.find(BB); + return I != IDoms.end() ? I->second : 0; + } + + //===--------------------------------------------------------------------===// + // API to update Immediate(Post)Dominators information based on modifications + // to the CFG... + + /// addNewBlock - Add a new block to the CFG, with the specified immediate + /// dominator. + /// + void addNewBlock(BasicBlock *BB, BasicBlock *IDom) { + assert(get(BB) == 0 && "BasicBlock already in idom info!"); + IDoms[BB] = IDom; + } + + /// setImmediateDominator - Update the immediate dominator information to + /// change the current immediate dominator for the specified block to another + /// block. This method requires that BB already have an IDom, otherwise just + /// use addNewBlock. + void setImmediateDominator(BasicBlock *BB, BasicBlock *NewIDom) { + assert(IDoms.find(BB) != IDoms.end() && "BB doesn't have idom yet!"); + IDoms[BB] = NewIDom; + } + + // print - Convert to human readable form + virtual void print(std::ostream &OS) const; +}; + +//===------------------------------------- +// ImmediateDominators Class - Concrete subclass of ImmediateDominatorsBase that +// is used to compute a normal immediate dominator set. +// +struct ImmediateDominators : public ImmediateDominatorsBase { + ImmediateDominators() : ImmediateDominatorsBase(false) {} + + BasicBlock *getRoot() const { + assert(Roots.size() == 1 && "Should always have entry node!"); + return Roots[0]; + } + + virtual bool runOnFunction(Function &F); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + +private: + struct InfoRec { + unsigned Semi; + unsigned Size; + BasicBlock *Label, *Parent, *Child, *Ancestor; + + std::vector Bucket; + + InfoRec() : Semi(0), Size(0), Label(0), Parent(0), Child(0), Ancestor(0){} + }; + + // Vertex - Map the DFS number to the BasicBlock* + std::vector Vertex; + + // Info - Collection of information used during the computation of idoms. + std::map Info; + + unsigned DFSPass(BasicBlock *V, InfoRec &VInfo, unsigned N); + void Compress(BasicBlock *V, InfoRec &VInfo); + BasicBlock *Eval(BasicBlock *v); + void Link(BasicBlock *V, BasicBlock *W, InfoRec &WInfo); +}; + + + //===----------------------------------------------------------------------===// // // DominatorSet - Maintain a set for every basic block in a @@ -162,96 +264,9 @@ // getAnalysisUsage - This simply provides a dominator set virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); AU.setPreservesAll(); } -private: - void calculateDominatorsFromBlock(BasicBlock *BB); -}; - - -//===----------------------------------------------------------------------===// -// -// ImmediateDominators - Calculate the immediate dominator for each node in a -// function. -// -class ImmediateDominatorsBase : public DominatorBase { -protected: - std::map IDoms; - void calcIDoms(const DominatorSetBase &DS); -public: - ImmediateDominatorsBase(bool isPostDom) : DominatorBase(isPostDom) {} - - virtual void releaseMemory() { IDoms.clear(); } - - // Accessor interface: - typedef std::map IDomMapType; - typedef IDomMapType::const_iterator const_iterator; - inline const_iterator begin() const { return IDoms.begin(); } - inline const_iterator end() const { return IDoms.end(); } - inline const_iterator find(BasicBlock* B) const { return IDoms.find(B);} - - // operator[] - Return the idom for the specified basic block. The start - // node returns null, because it does not have an immediate dominator. - // - inline BasicBlock *operator[](BasicBlock *BB) const { - return get(BB); - } - - // get() - Synonym for operator[]. - inline BasicBlock *get(BasicBlock *BB) const { - std::map::const_iterator I = IDoms.find(BB); - return I != IDoms.end() ? I->second : 0; - } - - //===--------------------------------------------------------------------===// - // API to update Immediate(Post)Dominators information based on modifications - // to the CFG... - - /// addNewBlock - Add a new block to the CFG, with the specified immediate - /// dominator. - /// - void addNewBlock(BasicBlock *BB, BasicBlock *IDom) { - assert(get(BB) == 0 && "BasicBlock already in idom info!"); - IDoms[BB] = IDom; - } - - /// setImmediateDominator - Update the immediate dominator information to - /// change the current immediate dominator for the specified block to another - /// block. This method requires that BB already have an IDom, otherwise just - /// use addNewBlock. - void setImmediateDominator(BasicBlock *BB, BasicBlock *NewIDom) { - assert(IDoms.find(BB) != IDoms.end() && "BB doesn't have idom yet!"); - IDoms[BB] = NewIDom; - } - - // print - Convert to human readable form - virtual void print(std::ostream &OS) const; -}; - -//===------------------------------------- -// ImmediateDominators Class - Concrete subclass of ImmediateDominatorsBase that -// is used to compute a normal immediate dominator set. -// -struct ImmediateDominators : public ImmediateDominatorsBase { - ImmediateDominators() : ImmediateDominatorsBase(false) {} - - BasicBlock *getRoot() const { - assert(Roots.size() == 1 && "Should always have entry node!"); - return Roots[0]; - } - - virtual bool runOnFunction(Function &F) { - IDoms.clear(); // Reset from the last time we were run... - DominatorSet &DS = getAnalysis(); - Roots = DS.getRoots(); - calcIDoms(DS); - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - AU.addRequired(); - } }; @@ -374,18 +389,19 @@ virtual bool runOnFunction(Function &F) { reset(); // Reset from the last time we were run... - DominatorSet &DS = getAnalysis(); - Roots = DS.getRoots(); - calculate(DS); + ImmediateDominators &ID = getAnalysis(); + Roots = ID.getRoots(); + calculate(ID); return false; } virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired(); + AU.addRequired(); } private: - void calculate(const DominatorSet &DS); + void calculate(const ImmediateDominators &ID); + Node *getNodeForBlock(BasicBlock *BB); }; //===------------------------------------- From lattner at cs.uiuc.edu Sat Dec 6 18:39:00 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:39:00 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp Message-ID: <200312070038.SAA24959@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Dominators.cpp updated: 1.52 -> 1.53 --- Log message: Completely rewrite domset, idom, and domtree implementation. Now it is based on the algorithm for directly computing immediate dominators presented in this paper: A Fast Algorithm for Finding Dominators in a Flowgraph T. Lengauer & R. Tarjan, ACM TOPLAS July 1979, pgs 121-141. This _substantially_ speeds up construction of all dominator related information. Post-dominators to follow. --- Diffs of the changes: (+266 -159) Index: llvm/lib/VMCore/Dominators.cpp diff -u llvm/lib/VMCore/Dominators.cpp:1.52 llvm/lib/VMCore/Dominators.cpp:1.53 --- llvm/lib/VMCore/Dominators.cpp:1.52 Fri Nov 21 14:23:48 2003 +++ llvm/lib/VMCore/Dominators.cpp Sat Dec 6 18:38:08 2003 @@ -22,11 +22,218 @@ using namespace llvm; //===----------------------------------------------------------------------===// +// ImmediateDominators Implementation +//===----------------------------------------------------------------------===// +// +// Immediate Dominators construction - This pass constructs immediate dominator +// information for a flow-graph based on the algorithm described in this +// document: +// +// A Fast Algorithm for Finding Dominators in a Flowgraph +// T. Lengauer & R. Tarjan, ACM TOPLAS July 1979, pgs 121-141. +// +// This implements both the O(n*ack(n)) and the O(n*log(n)) versions of EVAL and +// LINK, but it turns out that the theoretically slower O(n*log(n)) +// implementation is actually faster than the "efficient" algorithm (even for +// large CFGs) because the constant overheads are substantially smaller. The +// lower-complexity version can be enabled with the following #define: +// +#define BALANCE_IDOM_TREE 0 +// +//===----------------------------------------------------------------------===// + +static RegisterAnalysis +C("idom", "Immediate Dominators Construction", true); + +unsigned ImmediateDominators::DFSPass(BasicBlock *V, InfoRec &VInfo, + unsigned N) { + VInfo.Semi = ++N; + VInfo.Label = V; + + Vertex.push_back(V); // Vertex[n] = V; + //Info[V].Ancestor = 0; // Ancestor[n] = 0 + //Child[V] = 0; // Child[v] = 0 + VInfo.Size = 1; // Size[v] = 1 + + for (succ_iterator SI = succ_begin(V), E = succ_end(V); SI != E; ++SI) { + InfoRec &SuccVInfo = Info[*SI]; + if (SuccVInfo.Semi == 0) { + SuccVInfo.Parent = V; + N = DFSPass(*SI, SuccVInfo, N); + } + } + return N; +} + +void ImmediateDominators::Compress(BasicBlock *V, InfoRec &VInfo) { + BasicBlock *VAncestor = VInfo.Ancestor; + InfoRec &VAInfo = Info[VAncestor]; + if (VAInfo.Ancestor == 0) + return; + + Compress(VAncestor, VAInfo); + + BasicBlock *VAncestorLabel = VAInfo.Label; + BasicBlock *VLabel = VInfo.Label; + if (Info[VAncestorLabel].Semi < Info[VLabel].Semi) + VInfo.Label = VAncestorLabel; + + VInfo.Ancestor = VAInfo.Ancestor; +} + +BasicBlock *ImmediateDominators::Eval(BasicBlock *V) { + InfoRec &VInfo = Info[V]; +#if !BALANCE_IDOM_TREE + // Higher-complexity but faster implementation + if (VInfo.Ancestor == 0) + return V; + Compress(V, VInfo); + return VInfo.Label; +#else + // Lower-complexity but slower implementation + if (VInfo.Ancestor == 0) + return VInfo.Label; + Compress(V, VInfo); + BasicBlock *VLabel = VInfo.Label; + + BasicBlock *VAncestorLabel = Info[VInfo.Ancestor].Label; + if (Info[VAncestorLabel].Semi >= Info[VLabel].Semi) + return VLabel; + else + return VAncestorLabel; +#endif +} + +void ImmediateDominators::Link(BasicBlock *V, BasicBlock *W, InfoRec &WInfo){ +#if !BALANCE_IDOM_TREE + // Higher-complexity but faster implementation + WInfo.Ancestor = V; +#else + // Lower-complexity but slower implementation + BasicBlock *WLabel = WInfo.Label; + unsigned WLabelSemi = Info[WLabel].Semi; + BasicBlock *S = W; + InfoRec *SInfo = &Info[S]; + + BasicBlock *SChild = SInfo->Child; + InfoRec *SChildInfo = &Info[SChild]; + + while (WLabelSemi < Info[SChildInfo->Label].Semi) { + BasicBlock *SChildChild = SChildInfo->Child; + if (SInfo->Size+Info[SChildChild].Size >= 2*SChildInfo->Size) { + SChildInfo->Ancestor = S; + SInfo->Child = SChild = SChildChild; + SChildInfo = &Info[SChild]; + } else { + SChildInfo->Size = SInfo->Size; + S = SInfo->Ancestor = SChild; + SInfo = SChildInfo; + SChild = SChildChild; + SChildInfo = &Info[SChild]; + } + } + + InfoRec &VInfo = Info[V]; + SInfo->Label = WLabel; + + assert(V != W && "The optimization here will not work in this case!"); + unsigned WSize = WInfo.Size; + unsigned VSize = (VInfo.Size += WSize); + + if (VSize < 2*WSize) + std::swap(S, VInfo.Child); + + while (S) { + SInfo = &Info[S]; + SInfo->Ancestor = V; + S = SInfo->Child; + } +#endif +} + + + +bool ImmediateDominators::runOnFunction(Function &F) { + IDoms.clear(); // Reset from the last time we were run... + BasicBlock *Root = &F.getEntryBlock(); + Roots.clear(); + Roots.push_back(Root); + + Vertex.push_back(0); + + // Step #1: Number blocks in depth-first order and initialize variables used + // in later stages of the algorithm. + unsigned N = 0; + for (unsigned i = 0, e = Roots.size(); i != e; ++i) + N = DFSPass(Roots[i], Info[Roots[i]], 0); + + for (unsigned i = N; i >= 2; --i) { + BasicBlock *W = Vertex[i]; + InfoRec &WInfo = Info[W]; + + // Step #2: Calculate the semidominators of all vertices + for (pred_iterator PI = pred_begin(W), E = pred_end(W); PI != E; ++PI) + if (Info.count(*PI)) { // Only if this predecessor is reachable! + unsigned SemiU = Info[Eval(*PI)].Semi; + if (SemiU < WInfo.Semi) + WInfo.Semi = SemiU; + } + + Info[Vertex[WInfo.Semi]].Bucket.push_back(W); + + BasicBlock *WParent = WInfo.Parent; + Link(WParent, W, WInfo); + + // Step #3: Implicitly define the immediate dominator of vertices + std::vector &WParentBucket = Info[WParent].Bucket; + while (!WParentBucket.empty()) { + BasicBlock *V = WParentBucket.back(); + WParentBucket.pop_back(); + BasicBlock *U = Eval(V); + IDoms[V] = Info[U].Semi < Info[V].Semi ? U : WParent; + } + } + + // Step #4: Explicitly define the immediate dominator of each vertex + for (unsigned i = 2; i <= N; ++i) { + BasicBlock *W = Vertex[i]; + BasicBlock *&WIDom = IDoms[W]; + if (WIDom != Vertex[Info[W].Semi]) + WIDom = IDoms[WIDom]; + } + + // Free temporary memory used to construct idom's + Info.clear(); + std::vector().swap(Vertex); + + return false; +} + +void ImmediateDominatorsBase::print(std::ostream &o) const { + for (const_iterator I = begin(), E = end(); I != E; ++I) { + o << " Immediate Dominator For Basic Block:"; + if (I->first) + WriteAsOperand(o, I->first, false); + else + o << " <>"; + o << " is:"; + if (I->second) + WriteAsOperand(o, I->second, false); + else + o << " <>"; + o << "\n"; + } + o << "\n"; +} + + + +//===----------------------------------------------------------------------===// // DominatorSet Implementation //===----------------------------------------------------------------------===// static RegisterAnalysis -A("domset", "Dominator Set Construction", true); +B("domset", "Dominator Set Construction", true); // dominates - Return true if A dominates B. This performs the special checks // necessary if A and B are in the same basic block. @@ -44,53 +251,45 @@ } -void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) { - bool Changed; - Doms[RootBB].insert(RootBB); // Root always dominates itself... - do { - Changed = false; - - DomSetType WorkingSet; - df_iterator It = df_begin(RootBB), End = df_end(RootBB); - for ( ; It != End; ++It) { - BasicBlock *BB = *It; - pred_iterator PI = pred_begin(BB), PEnd = pred_end(BB); - if (PI != PEnd) { // Is there SOME predecessor? - // Loop until we get to a predecessor that has had its dom set filled - // in at least once. We are guaranteed to have this because we are - // traversing the graph in DFO and have handled start nodes specially, - // except when there are unreachable blocks. - // - while (PI != PEnd && Doms[*PI].empty()) ++PI; - if (PI != PEnd) { // Not unreachable code case? - WorkingSet = Doms[*PI]; - - // Intersect all of the predecessor sets - for (++PI; PI != PEnd; ++PI) { - DomSetType &PredSet = Doms[*PI]; - if (PredSet.size()) - set_intersect(WorkingSet, PredSet); - } +void DominatorSet::recalculate() { + ImmediateDominators &ID = getAnalysis(); + Doms.clear(); + if (Roots.empty()) return; + + // Root nodes only dominate themselves. + for (unsigned i = 0, e = Roots.size(); i != e; ++i) + Doms[Roots[i]].insert(Roots[i]); + + Function *F = Roots.back()->getParent(); + + // Loop over all of the blocks in the function, calculating dominator sets for + // each function. + for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) + if (BasicBlock *IDom = ID[I]) { // Get idom if block is reachable + DomSetType &DS = Doms[I]; + assert(DS.empty() && "Domset already filled in for this block?"); + DS.insert(I); // Blocks always dominate themselves + + // Insert all dominators into the set... + while (IDom) { + // If we have already computed the dominator sets for our immediate + // dominator, just use it instead of walking all the way up to the root. + DomSetType &IDS = Doms[IDom]; + if (!IDS.empty()) { + DS.insert(IDS.begin(), IDS.end()); + break; + } else { + DS.insert(IDom); + IDom = ID[IDom]; } - } else { - assert(Roots.size() == 1 && BB == Roots[0] && - "We got into unreachable code somehow!"); - } - - WorkingSet.insert(BB); // A block always dominates itself - DomSetType &BBSet = Doms[BB]; - if (BBSet != WorkingSet) { - //assert(WorkingSet.size() > BBSet.size() && "Must only grow sets!"); - BBSet.swap(WorkingSet); // Constant time operation! - Changed = true; // The sets changed. } - WorkingSet.clear(); // Clear out the set for next iteration + } else { + // Ensure that every basic block has at least an empty set of nodes. This + // is important for the case when there is unreachable blocks. + Doms[I]; } - } while (Changed); } - - // runOnFunction - This method calculates the forward dominator sets for the // specified function. // @@ -104,21 +303,6 @@ return false; } -void DominatorSet::recalculate() { - assert(Roots.size() == 1 && "DominatorSet should have single root block!"); - Doms.clear(); // Reset from the last time we were run... - - // Calculate dominator sets for the reachable basic blocks... - calculateDominatorsFromBlock(Roots[0]); - - - // Loop through the function, ensuring that every basic block has at least an - // empty set of nodes. This is important for the case when there is - // unreachable blocks. - Function *F = Roots[0]->getParent(); - for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) Doms[I]; -} - namespace llvm { static std::ostream &operator<<(std::ostream &o, const std::set &BBs) { @@ -144,67 +328,6 @@ } //===----------------------------------------------------------------------===// -// ImmediateDominators Implementation -//===----------------------------------------------------------------------===// - -static RegisterAnalysis -C("idom", "Immediate Dominators Construction", true); - -// calcIDoms - Calculate the immediate dominator mapping, given a set of -// dominators for every basic block. -void ImmediateDominatorsBase::calcIDoms(const DominatorSetBase &DS) { - // Loop over all of the nodes that have dominators... figuring out the IDOM - // for each node... - // - for (DominatorSet::const_iterator DI = DS.begin(), DEnd = DS.end(); - DI != DEnd; ++DI) { - BasicBlock *BB = DI->first; - const DominatorSet::DomSetType &Dominators = DI->second; - unsigned DomSetSize = Dominators.size(); - if (DomSetSize == 1) continue; // Root node... IDom = null - - // Loop over all dominators of this node. This corresponds to looping over - // nodes in the dominator chain, looking for a node whose dominator set is - // equal to the current nodes, except that the current node does not exist - // in it. This means that it is one level higher in the dom chain than the - // current node, and it is our idom! - // - DominatorSet::DomSetType::const_iterator I = Dominators.begin(); - DominatorSet::DomSetType::const_iterator End = Dominators.end(); - for (; I != End; ++I) { // Iterate over dominators... - // All of our dominators should form a chain, where the number of elements - // in the dominator set indicates what level the node is at in the chain. - // We want the node immediately above us, so it will have an identical - // dominator set, except that BB will not dominate it... therefore it's - // dominator set size will be one less than BB's... - // - if (DS.getDominators(*I).size() == DomSetSize - 1) { - IDoms[BB] = *I; - break; - } - } - } -} - -void ImmediateDominatorsBase::print(std::ostream &o) const { - for (const_iterator I = begin(), E = end(); I != E; ++I) { - o << " Immediate Dominator For Basic Block:"; - if (I->first) - WriteAsOperand(o, I->first, false); - else - o << " <>"; - o << " is:"; - if (I->second) - WriteAsOperand(o, I->second, false); - else - o << " <>"; - o << "\n"; - } - o << "\n"; -} - - -//===----------------------------------------------------------------------===// // DominatorTree Implementation //===----------------------------------------------------------------------===// @@ -236,55 +359,39 @@ } } +DominatorTreeBase::Node *DominatorTree::getNodeForBlock(BasicBlock *BB) { + Node *&BBNode = Nodes[BB]; + if (BBNode) return BBNode; + + // Haven't calculated this node yet? Get or calculate the node for the + // immediate dominator. + BasicBlock *IDom = getAnalysis()[BB]; + Node *IDomNode = getNodeForBlock(IDom); + + // Add a new tree node for this BasicBlock, and link it as a child of + // IDomNode + return BBNode = IDomNode->addChild(new Node(BB, IDomNode)); +} - -void DominatorTree::calculate(const DominatorSet &DS) { +void DominatorTree::calculate(const ImmediateDominators &ID) { assert(Roots.size() == 1 && "DominatorTree should have 1 root block!"); BasicBlock *Root = Roots[0]; Nodes[Root] = RootNode = new Node(Root, 0); // Add a node for the root... - // Iterate over all nodes in depth first order... - for (df_iterator I = df_begin(Root), E = df_end(Root); + // Loop over all of the reachable blocks in the function... + for (ImmediateDominators::const_iterator I = ID.begin(), E = ID.end(); I != E; ++I) { - BasicBlock *BB = *I; - const DominatorSet::DomSetType &Dominators = DS.getDominators(BB); - unsigned DomSetSize = Dominators.size(); - if (DomSetSize == 1) continue; // Root node... IDom = null - - // Loop over all dominators of this node. This corresponds to looping over - // nodes in the dominator chain, looking for a node whose dominator set is - // equal to the current nodes, except that the current node does not exist - // in it. This means that it is one level higher in the dom chain than the - // current node, and it is our idom! We know that we have already added - // a DominatorTree node for our idom, because the idom must be a - // predecessor in the depth first order that we are iterating through the - // function. - // - DominatorSet::DomSetType::const_iterator I = Dominators.begin(); - DominatorSet::DomSetType::const_iterator End = Dominators.end(); - for (; I != End; ++I) { // Iterate over dominators... - // All of our dominators should form a chain, where the number of - // elements in the dominator set indicates what level the node is at in - // the chain. We want the node immediately above us, so it will have - // an identical dominator set, except that BB will not dominate it... - // therefore it's dominator set size will be one less than BB's... - // - if (DS.getDominators(*I).size() == DomSetSize - 1) { - // We know that the immediate dominator should already have a node, - // because we are traversing the CFG in depth first order! - // - Node *IDomNode = Nodes[*I]; - assert(IDomNode && "No node for IDOM?"); - - // Add a new tree node for this BasicBlock, and link it as a child of - // IDomNode - Nodes[BB] = IDomNode->addChild(new Node(BB, IDomNode)); - break; - } + Node *&BBNode = Nodes[I->first]; + if (!BBNode) { // Haven't calculated this node yet? + // Get or calculate the node for the immediate dominator + Node *IDomNode = getNodeForBlock(I->second); + + // Add a new tree node for this BasicBlock, and link it as a child of + // IDomNode + BBNode = IDomNode->addChild(new Node(I->first, IDomNode)); } } } - static std::ostream &operator<<(std::ostream &o, const DominatorTreeBase::Node *Node) { From lattner at cs.uiuc.edu Sat Dec 6 18:56:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:56:01 2003 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp Message-ID: <200312070055.SAA06908@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Dominators.cpp updated: 1.53 -> 1.54 --- Log message: The recalclulate method was a nasty hack that was once used by the -cee pass, which never worked itself. The cee pass still doesn't work, but it doesn't use this method anymore anyway, so eliminate the method. --- Diffs of the changes: (+12 -16) Index: llvm/lib/VMCore/Dominators.cpp diff -u llvm/lib/VMCore/Dominators.cpp:1.53 llvm/lib/VMCore/Dominators.cpp:1.54 --- llvm/lib/VMCore/Dominators.cpp:1.53 Sat Dec 6 18:38:08 2003 +++ llvm/lib/VMCore/Dominators.cpp Sat Dec 6 18:55:32 2003 @@ -251,20 +251,27 @@ } -void DominatorSet::recalculate() { +// runOnFunction - This method calculates the forward dominator sets for the +// specified function. +// +bool DominatorSet::runOnFunction(Function &F) { + BasicBlock *Root = &F.getEntryBlock(); + Roots.clear(); + Roots.push_back(Root); + assert(pred_begin(Root) == pred_end(Root) && + "Root node has predecessors in function!"); + ImmediateDominators &ID = getAnalysis(); Doms.clear(); - if (Roots.empty()) return; + if (Roots.empty()) return false; // Root nodes only dominate themselves. for (unsigned i = 0, e = Roots.size(); i != e; ++i) Doms[Roots[i]].insert(Roots[i]); - Function *F = Roots.back()->getParent(); - // Loop over all of the blocks in the function, calculating dominator sets for // each function. - for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) if (BasicBlock *IDom = ID[I]) { // Get idom if block is reachable DomSetType &DS = Doms[I]; assert(DS.empty() && "Domset already filled in for this block?"); @@ -288,18 +295,7 @@ // is important for the case when there is unreachable blocks. Doms[I]; } -} -// runOnFunction - This method calculates the forward dominator sets for the -// specified function. -// -bool DominatorSet::runOnFunction(Function &F) { - BasicBlock *Root = &F.getEntryBlock(); - Roots.clear(); - Roots.push_back(Root); - assert(pred_begin(Root) == pred_end(Root) && - "Root node has predecessors in function!"); - recalculate(); return false; } From lattner at cs.uiuc.edu Sat Dec 6 18:56:04 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 18:56:04 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h Message-ID: <200312070055.SAA06812@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: Dominators.h updated: 1.42 -> 1.43 --- Log message: The recalclulate method was a nasty hack that was once used by the -cee pass, which never worked itself. The cee pass still doesn't work, but it doesn't use this method anymore anyway, so eliminate the method. --- Diffs of the changes: (+0 -5) Index: llvm/include/llvm/Analysis/Dominators.h diff -u llvm/include/llvm/Analysis/Dominators.h:1.42 llvm/include/llvm/Analysis/Dominators.h:1.43 --- llvm/include/llvm/Analysis/Dominators.h:1.42 Sat Dec 6 18:36:16 2003 +++ llvm/include/llvm/Analysis/Dominators.h Sat Dec 6 18:55:23 2003 @@ -252,11 +252,6 @@ virtual bool runOnFunction(Function &F); - /// recalculate - This method may be called by external passes that modify the - /// CFG and then need dominator information recalculated. This method is - /// obviously really slow, so it should be avoided if at all possible. - void recalculate(); - BasicBlock *getRoot() const { assert(Roots.size() == 1 && "Should always have entry node!"); return Roots[0]; From lattner at cs.uiuc.edu Sat Dec 6 19:25:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 19:25:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200312070124.TAA09413@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.143 -> 1.144 --- Log message: * Finegrainify namespacification * Transform: free * (cast * X to *) into free * X --- Diffs of the changes: (+17 -4) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.143 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.144 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.143 Thu Nov 13 13:17:02 2003 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Dec 6 19:24:23 2003 @@ -48,8 +48,7 @@ #include "llvm/Support/CallSite.h" #include "Support/Statistic.h" #include - -namespace llvm { +using namespace llvm; namespace { Statistic<> NumCombined ("instcombine", "Number of insts combined"); @@ -104,6 +103,7 @@ Instruction *visitPHINode(PHINode &PN); Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP); Instruction *visitAllocationInst(AllocationInst &AI); + Instruction *visitFreeInst(FreeInst &FI); Instruction *visitLoadInst(LoadInst &LI); Instruction *visitBranchInst(BranchInst &BI); @@ -2044,6 +2044,20 @@ return 0; } +Instruction *InstCombiner::visitFreeInst(FreeInst &FI) { + Value *Op = FI.getOperand(0); + + // Change free * (cast * X to *) into free * X + if (CastInst *CI = dyn_cast(Op)) + if (isa(CI->getOperand(0)->getType())) { + FI.setOperand(0, CI->getOperand(0)); + return &FI; + } + + return 0; +} + + /// GetGEPGlobalInitializer - Given a constant, and a getelementptr /// constantexpr, return the constant value being addressed by the constant /// expression, or null if something is funny. @@ -2196,8 +2210,7 @@ return Changed; } -Pass *createInstructionCombiningPass() { +Pass *llvm::createInstructionCombiningPass() { return new InstCombiner(); } -} // End llvm namespace From lattner at cs.uiuc.edu Sat Dec 6 19:26:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 19:26:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/RaiseAllocations/FreeCastConstantExpr.ll Message-ID: <200312070125.TAA09446@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/RaiseAllocations: FreeCastConstantExpr.ll added (r1.1) --- Log message: New testcase that the raiseallocations pass should be able to handle. --- Diffs of the changes: (+10 -0) Index: llvm/test/Regression/Transforms/RaiseAllocations/FreeCastConstantExpr.ll diff -c /dev/null llvm/test/Regression/Transforms/RaiseAllocations/FreeCastConstantExpr.ll:1.1 *** /dev/null Sat Dec 6 19:25:46 2003 --- llvm/test/Regression/Transforms/RaiseAllocations/FreeCastConstantExpr.ll Sat Dec 6 19:25:36 2003 *************** *** 0 **** --- 1,10 ---- + ; This situation can occur due to the funcresolve pass. + ; + ; RUN: llvm-as < %s | opt -raiseallocs | llvm-dis | not grep call + + declare void %free(sbyte*) + + void %test(int *%P) { + call void(int*)* cast (void(sbyte*)* %free to void(int*)*)(int* %P) + ret void + } From lattner at cs.uiuc.edu Sat Dec 6 19:26:03 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 19:26:03 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/RaiseAllocations/ Message-ID: <200312070125.TAA09436@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/RaiseAllocations: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/Transforms/RaiseAllocations added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Sat Dec 6 19:43:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 19:43:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/RaiseAllocations.cpp Message-ID: <200312070142.TAA11317@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: RaiseAllocations.cpp updated: 1.21 -> 1.22 --- Log message: Implement RaiseAllocations/FreeCastConstantExpr.ll --- Diffs of the changes: (+37 -12) Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.21 llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.22 --- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.21 Fri Nov 21 15:54:22 2003 +++ llvm/lib/Transforms/IPO/RaiseAllocations.cpp Sat Dec 6 19:42:08 2003 @@ -13,8 +13,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/IPO.h" -#include "llvm/Module.h" +#include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/Module.h" #include "llvm/iMemory.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" @@ -124,11 +125,18 @@ // First, process all of the malloc calls... if (MallocFunc) { std::vector Users(MallocFunc->use_begin(), MallocFunc->use_end()); + std::vector EqPointers; // Values equal to MallocFunc while (!Users.empty()) { - if (Instruction *I = dyn_cast(Users.back())) { + User *U = Users.back(); + Users.pop_back(); + + if (Instruction *I = dyn_cast(U)) { CallSite CS = CallSite::get(I); - if (CS.getInstruction() && CS.getCalledFunction() == MallocFunc && - CS.arg_begin() != CS.arg_end()) { + if (CS.getInstruction() && CS.arg_begin() != CS.arg_end() && + (CS.getCalledFunction() == MallocFunc || + std::find(EqPointers.begin(), EqPointers.end(), + CS.getCalledValue()) != EqPointers.end())) { + Value *Source = *CS.arg_begin(); // If no prototype was provided for malloc, we may need to cast the @@ -150,21 +158,33 @@ Changed = true; ++NumRaised; } + } else if (ConstantPointerRef *CPR = dyn_cast(U)) { + Users.insert(Users.end(), CPR->use_begin(), CPR->use_end()); + EqPointers.push_back(CPR); + } else if (ConstantExpr *CE = dyn_cast(U)) { + if (CE->getOpcode() == Instruction::Cast) { + Users.insert(Users.end(), CE->use_begin(), CE->use_end()); + EqPointers.push_back(CE); + } } - - Users.pop_back(); } } // Next, process all free calls... if (FreeFunc) { std::vector Users(FreeFunc->use_begin(), FreeFunc->use_end()); + std::vector EqPointers; // Values equal to FreeFunc while (!Users.empty()) { - if (Instruction *I = dyn_cast(Users.back())) { + User *U = Users.back(); + Users.pop_back(); + + if (Instruction *I = dyn_cast(U)) { CallSite CS = CallSite::get(I); - if (CS.getInstruction() && CS.getCalledFunction() == FreeFunc && - CS.arg_begin() != CS.arg_end()) { + if (CS.getInstruction() && CS.arg_begin() != CS.arg_end() && + (CS.getCalledFunction() == FreeFunc || + std::find(EqPointers.begin(), EqPointers.end(), + CS.getCalledValue()) != EqPointers.end())) { // If no prototype was provided for free, we may need to cast the // source pointer. This should be really uncommon, but it's necessary @@ -187,12 +207,17 @@ Changed = true; ++NumRaised; } + } else if (ConstantPointerRef *CPR = dyn_cast(U)) { + Users.insert(Users.end(), CPR->use_begin(), CPR->use_end()); + EqPointers.push_back(CPR); + } else if (ConstantExpr *CE = dyn_cast(U)) { + if (CE->getOpcode() == Instruction::Cast) { + Users.insert(Users.end(), CE->use_begin(), CE->use_end()); + EqPointers.push_back(CE); + } } - - Users.pop_back(); } } return Changed; } - From lattner at cs.uiuc.edu Sat Dec 6 19:45:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 19:45:01 2003 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200312070144.TAA11539@zion.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.87 -> 1.88 --- Log message: It is now after pldi. This issue has been fixed, so remove the hack --- Diffs of the changes: (+0 -6) Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.87 llvm/tools/gccas/gccas.cpp:1.88 --- llvm/tools/gccas/gccas.cpp:1.87 Sat Nov 22 13:07:47 2003 +++ llvm/tools/gccas/gccas.cpp Sat Dec 6 19:44:18 2003 @@ -70,12 +70,6 @@ addPass(PM, createFunctionInliningPass()); // Inline small functions addPass(PM, createInstructionCombiningPass()); // Cleanup code for raise - - // HACK HACK HACK. This pass should be extended to support calls like 'call - // (const expr cast (free))(Ty *). Until it does so, we have to run it after - // instruction combining. This should be removed after PLDI! - addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst - addPass(PM, createRaisePointerReferencesPass());// Recover type information addPass(PM, createTailDuplicationPass()); // Simplify cfg by copying code addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs From lattner at cs.uiuc.edu Sat Dec 6 20:32:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 20:32:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExtractFunction.cpp Message-ID: <200312070231.UAA13082@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExtractFunction.cpp updated: 1.21 -> 1.22 --- Log message: Do not leave a bunch of crud lying around --- Diffs of the changes: (+2 -0) Index: llvm/tools/bugpoint/ExtractFunction.cpp diff -u llvm/tools/bugpoint/ExtractFunction.cpp:1.21 llvm/tools/bugpoint/ExtractFunction.cpp:1.22 --- llvm/tools/bugpoint/ExtractFunction.cpp:1.21 Sat Nov 22 22:51:05 2003 +++ llvm/tools/bugpoint/ExtractFunction.cpp Sat Dec 6 20:31:03 2003 @@ -24,6 +24,7 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Target/TargetData.h" #include "Support/CommandLine.h" +#include "Support/FileUtilities.h" using namespace llvm; namespace llvm { @@ -129,6 +130,7 @@ << Filename << "'!\n"; exit(1); } + removeFile(Filename); } return M; } From lattner at cs.uiuc.edu Sat Dec 6 20:44:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Dec 6 20:44:01 2003 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200312070243.UAA14406@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.24 -> 1.25 --- Log message: Bugpoint had appalingly bad grammar. Fix some of it. --- Diffs of the changes: (+8 -4) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.24 llvm/tools/bugpoint/Miscompilation.cpp:1.25 --- llvm/tools/bugpoint/Miscompilation.cpp:1.24 Tue Nov 11 16:41:34 2003 +++ llvm/tools/bugpoint/Miscompilation.cpp Sat Dec 6 20:43:09 2003 @@ -144,8 +144,10 @@ // Test to see if the function is misoptimized if we ONLY run it on the // functions listed in Funcs. if (!EmitBytecode) { - std::cout << "Checking to see if the program is misoptimized when these " - << "functions are run\nthrough the passes: "; + std::cout << "Checking to see if the program is misoptimized when " + << (Funcs.size()==1 ? "this function is" : "these functions are") + << " run through the pass" + << (BD.PassesToRun.size() == 1 ? "" : "es") << ": "; BD.PrintFunctionList(Funcs); std::cout << "\n"; } else { @@ -267,7 +269,7 @@ delete BD.Program; // Delete the hacked up program BD.Program = OldProgram; // Restore the original - std::cout << (Broken ? "nope.\n" : "yup.\n"); + std::cout << (Broken ? " nope.\n" : " yup.\n"); return Broken; } @@ -301,7 +303,9 @@ // Do the reduction... ReduceMiscompilingFunctions(*this).reduceList(MiscompiledFunctions); - std::cout << "\n*** The following functions are being miscompiled: "; + std::cout << "\n*** The following function" + << (MiscompiledFunctions.size() == 1 ? " is" : "s are") + << " being miscompiled: "; PrintFunctionList(MiscompiledFunctions); std::cout << "\n"; From gaeke at cs.uiuc.edu Sun Dec 7 18:58:01 2003 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Dec 7 18:58:01 2003 Subject: [llvm-commits] CVS: llvm/include/Config/config.h.in Message-ID: <200312080057.SAA17349@zion.cs.uiuc.edu> Changes in directory llvm/include/Config: config.h.in updated: 1.7 -> 1.8 --- Log message: Regenerated using autoheader-2.57 --- Diffs of the changes: (+4 -0) Index: llvm/include/Config/config.h.in diff -u llvm/include/Config/config.h.in:1.7 llvm/include/Config/config.h.in:1.8 --- llvm/include/Config/config.h.in:1.7 Tue Nov 18 00:21:24 2003 +++ llvm/include/Config/config.h.in Sun Dec 7 18:57:01 2003 @@ -117,6 +117,10 @@ /* Define to have the %a format string */ #undef HAVE_PRINTF_A +/* Define if PThread mutexes (e.g., pthread_mutex_lock) are available in the + system's thread library. */ +#undef HAVE_PTHREAD_MUTEX_LOCK + /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H From lattner at cs.uiuc.edu Sun Dec 7 23:30:02 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Dec 7 23:30:02 2003 Subject: [llvm-commits] CVS: llvm/include/llvm/iOther.h Message-ID: <200312080529.XAA31956@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: iOther.h updated: 1.42 -> 1.43 --- Log message: Since ssaification of the varargs builtings, the vaarg instruction no longer can write to memory. --- Diffs of the changes: (+0 -2) Index: llvm/include/llvm/iOther.h diff -u llvm/include/llvm/iOther.h:1.42 llvm/include/llvm/iOther.h:1.43 --- llvm/include/llvm/iOther.h:1.42 Sun Nov 16 14:21:15 2003 +++ llvm/include/llvm/iOther.h Sun Dec 7 23:29:33 2003 @@ -187,8 +187,6 @@ virtual Instruction *clone() const { return new VAArgInst(*this); } - bool mayWriteToMemory() const { return true; } - // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const VAArgInst *) { return true; } static inline bool classof(const Instruction *I) { From lattner at cs.uiuc.edu Sun Dec 7 23:33:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Dec 7 23:33:01 2003 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/TailCallElim/intervening-inst.ll Message-ID: <200312080532.XAA32155@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/TailCallElim: intervening-inst.ll added (r1.1) --- Log message: New testcase, this should be -tailcallelim'inated --- Diffs of the changes: (+19 -0) Index: llvm/test/Regression/Transforms/TailCallElim/intervening-inst.ll diff -c /dev/null llvm/test/Regression/Transforms/TailCallElim/intervening-inst.ll:1.1 *** /dev/null Sun Dec 7 23:32:59 2003 --- llvm/test/Regression/Transforms/TailCallElim/intervening-inst.ll Sun Dec 7 23:32:48 2003 *************** *** 0 **** --- 1,19 ---- + ; This function contains intervening instructions which should be moved out of the way + ; RUN: llvm-as < %s | opt -tailcallelim | llvm-dis | not grep call + + int %Test(int %X) { + entry: + %tmp.1 = seteq int %X, 0 + br bool %tmp.1, label %then.0, label %endif.0 + + then.0: + %tmp.4 = add int %X, 1 + ret int %tmp.4 + + endif.0: + %tmp.10 = add int %X, -1 + %tmp.8 = call int %Test(int %tmp.10) + %DUMMY = add int %X, 1 ;; This should not prevent elimination + ret int %tmp.8 + } + From lattner at cs.uiuc.edu Sun Dec 7 23:36:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Dec 7 23:36:01 2003 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp Message-ID: <200312080535.XAA32212@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: TailRecursionElimination.cpp updated: 1.8 -> 1.9 --- Log message: Cleanup and restructure the code to make it easier to read and maintain. The only functionality change is that we now implement: Regression/Transforms/TailCallElim/intervening-inst.ll Which is really kinda pointless, because it means that trivially dead code does not interfere with -tce, but trivially dead code probably wouldn't be around anytime when this pass is run anyway. The point of including this change it to support other more aggressive transformations when we have the analysis capabilities to do so. --- Diffs of the changes: (+126 -53) Index: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp diff -u llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.8 llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.9 --- llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:1.8 Fri Nov 21 10:52:01 2003 +++ llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp Sun Dec 7 23:34:54 2003 @@ -7,22 +7,40 @@ // //===----------------------------------------------------------------------===// // -// This file implements tail recursion elimination. +// This file transforms calls of the current function (self recursion) followed +// by a return instruction with a branch to the entry of the function, creating +// a loop. This pass also implements the following extensions to the basic +// algorithm: // -// Caveats: The algorithm implemented is trivially simple. There are several -// improvements that could be made: +// 1. Trivial instructions between the call and return do not prevent the +// transformation from taking place, though currently the analysis cannot +// support moving any really useful instructions (only dead ones). // -// 1. If the function has any alloca instructions, these instructions will not -// remain in the entry block of the function. Doing this requires analysis -// to prove that the alloca is not reachable by the recursively invoked -// function call. +// There are several improvements that could be made: +// +// 1. If the function has any alloca instructions, these instructions will be +// moved out of the entry block of the function, causing them to be +// evaluated each time through the tail recursion. Safely keeping allocas +// in the entry block requires analysis to proves that the tail-called +// function does not read or write the stack object. // 2. Tail recursion is only performed if the call immediately preceeds the -// return instruction. Would it be useful to generalize this somehow? +// return instruction. It's possible that there could be a jump between +// the call and the return. // 3. TRE is only performed if the function returns void or if the return // returns the result returned by the call. It is possible, but unlikely, // that the return returns something else (like constant 0), and can still // be TRE'd. It can be TRE'd if ALL OTHER return instructions in the // function return the exact same value. +// 4. There can be intervening operations between the call and the return that +// prevent the TRE from occurring. For example, there could be GEP's and +// stores to memory that will not be read or written by the call. This +// requires some substantial analysis (such as with DSA) to prove safe to +// move ahead of the call, but doing so could allow many more TREs to be +// performed, for example in TreeAdd/TreeAlloc from the treeadd benchmark. +// 5. This pass could transform functions that are prevented from being tail +// recursive by a commutative expression to use an accumulator helper +// function, thus compiling the typical naive factorial or 'fib' +// implementation into efficient code. // //===----------------------------------------------------------------------===// @@ -32,7 +50,6 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "Support/Statistic.h" - using namespace llvm; namespace { @@ -40,6 +57,11 @@ struct TailCallElim : public FunctionPass { virtual bool runOnFunction(Function &F); + + private: + bool ProcessReturningBlock(ReturnInst *RI, BasicBlock *&OldEntry, + std::vector &ArgumentPHIs); + bool CanMoveAboveCall(Instruction *I, CallInst *CI); }; RegisterOpt X("tailcallelim", "Tail Call Elimination"); } @@ -62,50 +84,101 @@ // Loop over the function, looking for any returning blocks... for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (ReturnInst *Ret = dyn_cast(BB->getTerminator())) - if (Ret != BB->begin()) // Make sure there is something before the ret... - if (CallInst *CI = dyn_cast(Ret->getPrev())) - // Make sure the tail call is to the current function, and that the - // return either returns void or returns the value computed by the - // call. - if (CI->getCalledFunction() == &F && - (Ret->getNumOperands() == 0 || Ret->getReturnValue() == CI)) { - // Ohh, it looks like we found a tail call, is this the first? - if (!OldEntry) { - // Ok, so this is the first tail call we have found in this - // function. Insert a new entry block into the function, allowing - // us to branch back to the old entry block. - OldEntry = &F.getEntryBlock(); - BasicBlock *NewEntry = new BasicBlock("tailrecurse", OldEntry); - new BranchInst(OldEntry, NewEntry); - - // Now that we have created a new block, which jumps to the entry - // block, insert a PHI node for each argument of the function. - // For now, we initialize each PHI to only have the real arguments - // which are passed in. - Instruction *InsertPos = OldEntry->begin(); - for (Function::aiterator I = F.abegin(), E = F.aend(); I!=E; ++I){ - PHINode *PN = new PHINode(I->getType(), I->getName()+".tr", - InsertPos); - I->replaceAllUsesWith(PN); // Everyone use the PHI node now! - PN->addIncoming(I, NewEntry); - ArgumentPHIs.push_back(PN); - } - } - - // Ok, now that we know we have a pseudo-entry block WITH all of the - // required PHI nodes, add entries into the PHI node for the actual - // parameters passed into the tail-recursive call. - for (unsigned i = 0, e = CI->getNumOperands()-1; i != e; ++i) - ArgumentPHIs[i]->addIncoming(CI->getOperand(i+1), BB); - - // Now that all of the PHI nodes are in place, remove the call and - // ret instructions, replacing them with an unconditional branch. - new BranchInst(OldEntry, CI); - BB->getInstList().pop_back(); // Remove return. - BB->getInstList().pop_back(); // Remove call. - MadeChange = true; - NumEliminated++; - } + MadeChange |= ProcessReturningBlock(Ret, OldEntry, ArgumentPHIs); return MadeChange; +} + + +// CanMoveAboveCall - Return true if it is safe to move the specified +// instruction from after the call to before the call, assuming that all +// instructions between the call and this instruction are movable. +// +bool TailCallElim::CanMoveAboveCall(Instruction *I, CallInst *CI) { + // FIXME: We can move load/store/call/free instructions above the call if the + // call does not mod/ref the memory location being processed. + if (I->mayWriteToMemory() || isa(I)) + return false; + + // Otherwise, if this is a side-effect free instruction, check to make sure + // that it does not use the return value of the call. If it doesn't use the + // return value of the call, it must only use things that are defined before + // the call, or movable instructions between the call and the instruction + // itself. + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (I->getOperand(i) == CI) + return false; + return true; +} + + +bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, + std::vector &ArgumentPHIs) { + BasicBlock *BB = Ret->getParent(); + Function *F = BB->getParent(); + + if (&BB->front() == Ret) // Make sure there is something before the ret... + return false; + + // Scan backwards from the return, checking to see if there is a tail call in + // this block. If so, set CI to it. + CallInst *CI; + BasicBlock::iterator BBI = Ret; + while (1) { + CI = dyn_cast(BBI); + if (CI && CI->getCalledFunction() == F) + break; + + if (BBI == BB->begin()) + return false; // Didn't find a potential tail call. + --BBI; + } + + // Ok, we found a potential tail call. We can currently only transform the + // tail call if all of the instructions between the call and the return are + // movable to above the call itself, leaving the call next to the return. + // Check that this is the case now. + for (BBI = CI, ++BBI; &*BBI != Ret; ++BBI) + if (!CanMoveAboveCall(BBI, CI)) + return false; // Cannot move this instruction out of the way. + + // We can only transform call/return pairs that either ignore the return value + // of the call and return void, or return the value returned by the tail call. + if (Ret->getNumOperands() != 0 && Ret->getReturnValue() != CI) + return false; + + // OK! We can transform this tail call. If this is the first one found, + // create the new entry block, allowing us to branch back to the old entry. + if (OldEntry == 0) { + OldEntry = &F->getEntryBlock(); + std::string OldName = OldEntry->getName(); OldEntry->setName("tailrecurse"); + BasicBlock *NewEntry = new BasicBlock(OldName, OldEntry); + new BranchInst(OldEntry, NewEntry); + + // Now that we have created a new block, which jumps to the entry + // block, insert a PHI node for each argument of the function. + // For now, we initialize each PHI to only have the real arguments + // which are passed in. + Instruction *InsertPos = OldEntry->begin(); + for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I) { + PHINode *PN = new PHINode(I->getType(), I->getName()+".tr", InsertPos); + I->replaceAllUsesWith(PN); // Everyone use the PHI node now! + PN->addIncoming(I, NewEntry); + ArgumentPHIs.push_back(PN); + } + } + + // Ok, now that we know we have a pseudo-entry block WITH all of the + // required PHI nodes, add entries into the PHI node for the actual + // parameters passed into the tail-recursive call. + for (unsigned i = 0, e = CI->getNumOperands()-1; i != e; ++i) + ArgumentPHIs[i]->addIncoming(CI->getOperand(i+1), BB); + + // Now that all of the PHI nodes are in place, remove the call and + // ret instructions, replacing them with an unconditional branch. + new BranchInst(OldEntry, Ret); + BB->getInstList().erase(Ret); // Remove return. + BB->getInstList().erase(CI); // Remove call. + NumEliminated++; + return true; } From lattner at cs.uiuc.edu Sun Dec 7 23:44:01 2003 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Dec 7 23:44:01 2003 Subject: [llvm-commits] CVS: llvm/docs/FAQ.html Message-ID: <200312080543.XAA09581@zion.cs.uiuc.edu> Changes in directory llvm/docs: FAQ.html updated: 1.13 -> 1.14 --- Log message: Add note about sucky suse compiler --- Diffs of the changes: (+11 -1) Index: llvm/docs/FAQ.html diff -u llvm/docs/FAQ.html:1.13 llvm/docs/FAQ.html:1.14 --- llvm/docs/FAQ.html:1.13 Tue Nov 18 23:53:12 2003 +++ llvm/docs/FAQ.html Sun Dec 7 23:43:19 2003 @@ -48,6 +48,7 @@ errors.

  • I've built LLVM and am testing it, but the tests freeze.
  • Why do test results differ when I perform different types of builds?
  • +
  • Compiling LLVM with GCC 3.3 on SuSE 9 fails, what should I do?
  • Using the GCC Front End @@ -327,6 +328,15 @@ +
    +

    Compiling LLVM with GCC 3.3 on SuSE 9 fails, what should I do?

    +
    + +
    +

    This is a bug in the customized version of GCC shipped with SuSE, and effects + projects other than LLVM. Complain loudly to SuSE. :)

    +
    +
    Using the GCC Front End @@ -428,7 +438,7 @@