From reid at x10sys.com Mon Feb 28 02:45:46 2005 From: reid at x10sys.com (Reid Spencer) Date: Mon, 28 Feb 2005 02:45:46 -0600 Subject: [llvm-commits] CVS: llvm/tools/gccld/GenerateCode.cpp gccld.cpp gccld.h Message-ID: <200502280845.CAA18446@zion.cs.uiuc.edu> Changes in directory llvm/tools/gccld: GenerateCode.cpp updated: 1.43 -> 1.44 gccld.cpp updated: 1.96 -> 1.97 gccld.h updated: 1.12 -> 1.13 --- Log message: Changes to enable creation of native executables directly from gccld and to ensure that -L paths don't contain both bytecode and native libraries. This patch contributed by Adam Treat. --- Diffs of the changes: (+182 -73) GenerateCode.cpp | 91 ++++++++++++++++++++++++++++++++ gccld.cpp | 152 ++++++++++++++++++++++++++++++------------------------- gccld.h | 12 +++- 3 files changed, 182 insertions(+), 73 deletions(-) Index: llvm/tools/gccld/GenerateCode.cpp diff -u llvm/tools/gccld/GenerateCode.cpp:1.43 llvm/tools/gccld/GenerateCode.cpp:1.44 --- llvm/tools/gccld/GenerateCode.cpp:1.43 Sun Feb 13 17:02:34 2005 +++ llvm/tools/gccld/GenerateCode.cpp Mon Feb 28 02:45:35 2005 @@ -20,6 +20,7 @@ #include "llvm/Analysis/LoadValueNumbering.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Verifier.h" +#include "llvm/Bytecode/Archive.h" #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO.h" @@ -127,6 +128,62 @@ if (Verify) PM.add(createVerifierPass()); } +static bool isBytecodeLibrary(const sys::Path &FullPath) { + // Check for a bytecode file + if (FullPath.isBytecodeFile()) return true; + // Check for a dynamic library file + if (FullPath.isDynamicLibrary()) return false; + // Check for a true bytecode archive file + if (FullPath.isArchive() ) { + std::string ErrorMessage; + Archive* ar = Archive::OpenAndLoadSymbols( FullPath, &ErrorMessage ); + return ar->isBytecodeArchive(); + } + return false; +} + +static bool isBytecodeLPath(const std::string &LibPath) { + bool isBytecodeLPath = false; + + // Make sure the -L path has a '/' character + // because llvm-g++ passes them without the ending + // '/' char and sys::Path doesn't think it is a + // directory (see: sys::Path::isDirectory) without it + std::string dir = LibPath; + if ( dir[dir.length()-1] != '/' ) + dir.append("/"); + + sys::Path LPath(dir); + + // Grab the contents of the -L path + std::set Files; + LPath.getDirectoryContents(Files); + + // Iterate over the contents one by one to determine + // if this -L path has any bytecode shared libraries + // or archives + std::set::iterator File = Files.begin(); + for (; File != Files.end(); ++File) { + + if ( File->isDirectory() ) + continue; + + std::string path = File->toString(); + std::string dllsuffix = sys::Path::GetDLLSuffix(); + + // Check for an ending '.dll,.so' or '.a' suffix as all + // other files are not of interest to us here + if ( path.find(dllsuffix, path.size()-dllsuffix.size()) == std::string::npos + && path.find(".a", path.size()-2) == std::string::npos ) + continue; + + // Finally, check to see if the file is a true bytecode file + if (isBytecodeLibrary(*File)) + isBytecodeLPath = true; + } + return isBytecodeLPath; +} + /// GenerateBytecode - generates a bytecode file from the specified module. /// /// Inputs: @@ -285,8 +342,12 @@ /// int llvm::GenerateNative(const std::string &OutputFilename, const std::string &InputFilename, + const std::vector &LibPaths, const std::vector &Libraries, - const sys::Path &gcc, char ** const envp) { + const sys::Path &gcc, char ** const envp, + bool Shared, + const std::string &RPath, + const std::string &SOName) { // Remove these environment variables from the environment of the // programs that we will execute. It appears that GCC sets these // environment variables so that the programs it uses can configure @@ -316,7 +377,33 @@ args.push_back("-o"); args.push_back(OutputFilename.c_str()); args.push_back(InputFilename.c_str()); - + + if (Shared) args.push_back("-shared"); + if (!RPath.empty()) { + std::string rp = "-Wl,-rpath," + RPath; + args.push_back(rp.c_str()); + } + if (!SOName.empty()) { + std::string so = "-Wl,-soname," + SOName; + args.push_back(so.c_str()); + } + + // Add in the libpaths to find the libraries. + // + // Note: + // When gccld is called from the llvm-gxx frontends, the -L paths for + // the LLVM cfrontend install paths are appended. We don't want the + // native linker to use these -L paths as they contain bytecode files. + // Further, we don't want any -L paths that contain bytecode shared + // libraries or true bytecode archive files. We omit them in all such + // cases. + for (unsigned index = 0; index < LibPaths.size(); index++) { + if (!isBytecodeLPath( LibPaths[index]) ) { + args.push_back("-L"); + args.push_back(LibPaths[index].c_str()); + } + } + // Add in the libraries to link. for (unsigned index = 0; index < Libraries.size(); index++) { if (Libraries[index] != "crtend") { Index: llvm/tools/gccld/gccld.cpp diff -u llvm/tools/gccld/gccld.cpp:1.96 llvm/tools/gccld/gccld.cpp:1.97 --- llvm/tools/gccld/gccld.cpp:1.96 Sun Feb 13 17:02:34 2005 +++ llvm/tools/gccld/gccld.cpp Mon Feb 28 02:45:35 2005 @@ -83,11 +83,21 @@ cl::opt NativeCBE("native-cbe", cl::desc("Generate a native binary with the C backend and GCC")); + + cl::opt + RPath("rpath", + cl::desc("Set runtime shared library search path (requires -native or" + " -native-cbe)"), + cl::Prefix, cl::value_desc("directory")); + + cl::opt + SOName("soname", + cl::desc("Set internal name of shared library (requires -native or" + " -native-cbe)"), + cl::Prefix, cl::value_desc("name")); // Compatibility options that are ignored but supported by LD cl::opt - CO3("soname", cl::Hidden, cl::desc("Compatibility option: ignored")); - cl::opt CO4("version-script", cl::Hidden, cl::desc("Compatibility option: ignored")); cl::opt CO5("eh-frame-hdr", cl::Hidden, cl::desc("Compatibility option: ignored")); @@ -237,7 +247,7 @@ // Create the output file. std::string RealBytecodeOutput = OutputFilename; - if (!LinkAsLibrary) RealBytecodeOutput += ".bc"; + if (!LinkAsLibrary || Native || NativeCBE) RealBytecodeOutput += ".bc"; std::ios::openmode io_mode = std::ios::out | std::ios::trunc | std::ios::binary; std::ofstream Out(RealBytecodeOutput.c_str(), io_mode); @@ -266,77 +276,83 @@ // Close the bytecode file. Out.close(); - // If we are not linking a library, generate either a native executable - // or a JIT shell script, depending upon what the user wants. - if (!LinkAsLibrary) { - // If the user wants to generate a native executable, compile it from the - // bytecode file. - // - // Otherwise, create a script that will run the bytecode through the JIT. - if (Native) { - // Name of the Assembly Language output file - sys::Path AssemblyFile ( OutputFilename); - AssemblyFile.appendSuffix("s"); - - // Mark the output files for removal if we get an interrupt. - sys::RemoveFileOnSignal(AssemblyFile); - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - - // Determine the locations of the llc and gcc programs. - sys::Path llc = FindExecutable("llc", argv[0]); - if (llc.isEmpty()) - return PrintAndReturn(argv[0], "Failed to find llc"); - - sys::Path gcc = FindExecutable("gcc", argv[0]); - if (gcc.isEmpty()) - return PrintAndReturn(argv[0], "Failed to find gcc"); - - // Generate an assembly language file for the bytecode. - if (Verbose) std::cout << "Generating Assembly Code\n"; - GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc); - if (Verbose) std::cout << "Generating Native Code\n"; - GenerateNative(OutputFilename, AssemblyFile.toString(), - Libraries, gcc, envp ); - - // Remove the assembly language file. - AssemblyFile.destroyFile(); - } else if (NativeCBE) { - sys::Path CFile (OutputFilename); - CFile.appendSuffix("cbe.c"); - - // Mark the output files for removal if we get an interrupt. - sys::RemoveFileOnSignal(CFile); - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - - // Determine the locations of the llc and gcc programs. - sys::Path llc = FindExecutable("llc", argv[0]); - if (llc.isEmpty()) - return PrintAndReturn(argv[0], "Failed to find llc"); - - sys::Path gcc = FindExecutable("gcc", argv[0]); - if (gcc.isEmpty()) - return PrintAndReturn(argv[0], "Failed to find gcc"); - - // Generate an assembly language file for the bytecode. - if (Verbose) std::cout << "Generating Assembly Code\n"; - GenerateCFile(CFile.toString(), RealBytecodeOutput, llc); - if (Verbose) std::cout << "Generating Native Code\n"; - GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp ); - - // Remove the assembly language file. - CFile.destroyFile(); + // Generate either a native file or a JIT shell script. If the user wants + // to generate a native file, compile it from the bytecode file. Otherwise, + // if the target is not a library, create a script that will run the + // bytecode through the JIT. + if (Native) { + // Name of the Assembly Language output file + sys::Path AssemblyFile (OutputFilename); + AssemblyFile.appendSuffix("s"); + + // Mark the output files for removal if we get an interrupt. + sys::RemoveFileOnSignal(AssemblyFile); + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + // Determine the locations of the llc and gcc programs. + sys::Path llc = FindExecutable("llc", argv[0]); + if (llc.isEmpty()) + return PrintAndReturn(argv[0], "Failed to find llc"); + + sys::Path gcc = FindExecutable("gcc", argv[0]); + if (gcc.isEmpty()) + return PrintAndReturn(argv[0], "Failed to find gcc"); + + // Generate an assembly language file for the bytecode. + if (Verbose) std::cout << "Generating Assembly Code\n"; + GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc); + if (Verbose) std::cout << "Generating Native Code\n"; + GenerateNative(OutputFilename, AssemblyFile.toString(), + LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, + SOName ); + + // Remove the assembly language file. + AssemblyFile.destroyFile(); + // Remove the bytecode language file. + sys::Path(RealBytecodeOutput).destroyFile(); + + } else if (NativeCBE) { + sys::Path CFile (OutputFilename); + CFile.appendSuffix("cbe.c"); + + // Mark the output files for removal if we get an interrupt. + sys::RemoveFileOnSignal(CFile); + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + // Determine the locations of the llc and gcc programs. + sys::Path llc = FindExecutable("llc", argv[0]); + if (llc.isEmpty()) + return PrintAndReturn(argv[0], "Failed to find llc"); + + sys::Path gcc = FindExecutable("gcc", argv[0]); + if (gcc.isEmpty()) + return PrintAndReturn(argv[0], "Failed to find gcc"); + + // Generate an assembly language file for the bytecode. + if (Verbose) std::cout << "Generating Assembly Code\n"; + GenerateCFile(CFile.toString(), RealBytecodeOutput, llc); + if (Verbose) std::cout << "Generating Native Code\n"; + GenerateNative(OutputFilename, CFile.toString(), + LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, + SOName ); - } else { - EmitShellScript(argv); - } + // Remove the assembly language file. + CFile.destroyFile(); - // Make the script executable... - sys::Path(OutputFilename).makeExecutable(); + // Remove the bytecode language file. + sys::Path(RealBytecodeOutput).destroyFile(); - // Make the bytecode file readable and directly executable in LLEE as well + } else if (!LinkAsLibrary) { + EmitShellScript(argv); + + // Make the bytecode file readable and directly executable in LLEE sys::Path(RealBytecodeOutput).makeExecutable(); sys::Path(RealBytecodeOutput).makeReadable(); } + + // Make the output, whether native or script, executable as well... + sys::Path(OutputFilename).makeExecutable(); + } catch (const char*msg) { std::cerr << argv[0] << ": " << msg << "\n"; exitCode = 1; Index: llvm/tools/gccld/gccld.h diff -u llvm/tools/gccld/gccld.h:1.12 llvm/tools/gccld/gccld.h:1.13 --- llvm/tools/gccld/gccld.h:1.12 Mon Dec 13 22:20:07 2004 +++ llvm/tools/gccld/gccld.h Mon Feb 28 02:45:35 2005 @@ -31,13 +31,19 @@ const std::string & InputFilename, const sys::Path & llc); -int GenerateCFile(const std::string &OutputFile, const std::string &InputFile, - const sys::Path &llc); +int +GenerateCFile (const std::string &OutputFile, + const std::string &InputFile, + const sys::Path &llc); int GenerateNative (const std::string & OutputFilename, const std::string & InputFilename, + const std::vector & LibPaths, const std::vector & Libraries, const sys::Path & gcc, - char ** const envp); + char ** const envp, + bool Shared, + const std::string & RPath, + const std::string & SOName); } // End llvm namespace From criswell at cs.uiuc.edu Mon Feb 28 09:57:56 2005 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 28 Feb 2005 09:57:56 -0600 Subject: [llvm-commits] CVS: llvm-www/releases/register.cgi Message-ID: <200502281557.JAA14460@zion.cs.uiuc.edu> Changes in directory llvm-www/releases: register.cgi updated: 1.16 -> 1.17 --- Log message: Add code to record the registering person's hostname and IP address. Also include code to grab the refering URL, but currently don't log it as it will always be our register.html page. --- Diffs of the changes: (+19 -0) register.cgi | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+) Index: llvm-www/releases/register.cgi diff -u llvm-www/releases/register.cgi:1.16 llvm-www/releases/register.cgi:1.17 --- llvm-www/releases/register.cgi:1.16 Wed Feb 23 23:49:53 2005 +++ llvm-www/releases/register.cgi Mon Feb 28 09:57:45 2005 @@ -209,6 +209,24 @@ plans = 'No plans.' # + # Extract information from the web server that we want to log. + # + try: + rhost = os.environ['REMOTE_HOST'] + except: + rhost = 'unknown' + + try: + raddr = os.environ['REMOTE_ADDR'] + except: + raddr = 'unknown' + + try: + hrefer = os.environ['HTTP_REFERER'] + except: + hrefer = 'unknown' + + # # Construct an email message describing the user who is downloading # LLVM. # @@ -217,6 +235,7 @@ msg = msg + 'Email: ' + email + '\n' msg = msg + 'Title: ' + title + '\n' msg = msg + 'Organization: ' + organization + '\n' + msg = msg + 'Host: ' + rhost + ' (' + raddr + ')\n' msg = msg + 'Plans with LLVM:\n' + plans + '\n' # From lattner at cs.uiuc.edu Mon Feb 28 10:52:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 10:52:44 -0600 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200502281652.j1SGqiIn021321@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.303 -> 1.304 --- Log message: Adam Treat implemented this :) --- Diffs of the changes: (+3 -2) ReleaseNotes.html | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.303 llvm/docs/ReleaseNotes.html:1.304 --- llvm/docs/ReleaseNotes.html:1.303 Sun Feb 27 13:31:02 2005 +++ llvm/docs/ReleaseNotes.html Mon Feb 28 10:52:28 2005 @@ -97,7 +97,8 @@
    -
  1. +
  2. LLVM can now create native shared libraries with 'llvm-gcc ... + -shared -Wl,-native' (or with -Wl,-native-cbe).
@@ -593,7 +594,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
- Last modified: $Date: 2005/02/27 19:31:02 $ + Last modified: $Date: 2005/02/28 16:52:28 $ From alenhar2 at cs.uiuc.edu Mon Feb 28 11:22:31 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Mon, 28 Feb 2005 11:22:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200502281722.j1SHMV5r021544@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.26 -> 1.27 --- Log message: fix integer division and stuff --- Diffs of the changes: (+5 -5) AlphaInstrInfo.td | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.26 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.27 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.26 Fri Feb 25 16:55:15 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Mon Feb 28 11:22:18 2005 @@ -79,13 +79,13 @@ def STT_SYM : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "stt $RA,$DISP">; //store double } -let Uses = [R28, R23, R24, R25, R26, R29], - Defs = [R29] in +let Uses = [R29], + Defs = [R28, R29, R23, R24, R25, R27] in { def REMQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remqu $RA,$RB,$RC">; //unsigned remander - def REMQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$RC">; //unsigned remander - def DIVQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divqu $RA,$RB,$RC">; //unsigned remander - def DIVQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divq $RA,$RB,$RC">; //unsigned remander + def REMQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$RC">; //signed remander + def DIVQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divqu $RA,$RB,$RC">; //unsigned division + def DIVQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divq $RA,$RB,$RC">; //signed division } //*********************** From criswell at cs.uiuc.edu Mon Feb 28 11:41:44 2005 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 28 Feb 2005 11:41:44 -0600 Subject: [llvm-commits] CVS: llvm-www/releases/register.cgi Message-ID: <200502281741.LAA15795@zion.cs.uiuc.edu> Changes in directory llvm-www/releases: register.cgi updated: 1.17 -> 1.18 --- Log message: Grep the web server's access log for information regarding the requester. This is a bit of a hack, IMHO. --- Diffs of the changes: (+10 -0) register.cgi | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm-www/releases/register.cgi diff -u llvm-www/releases/register.cgi:1.17 llvm-www/releases/register.cgi:1.18 --- llvm-www/releases/register.cgi:1.17 Mon Feb 28 09:57:45 2005 +++ llvm-www/releases/register.cgi Mon Feb 28 11:41:33 2005 @@ -227,6 +227,13 @@ hrefer = 'unknown' # + # Attempt to grab all of the relevant junk from access_log regarding + # this user. + # + acclog = os.popen ('tail -n 100 /etc/httpd/logs/access_log | grep ' + rhost) + accdata = acclog.readlines() + + # # Construct an email message describing the user who is downloading # LLVM. # @@ -237,6 +244,9 @@ msg = msg + 'Organization: ' + organization + '\n' msg = msg + 'Host: ' + rhost + ' (' + raddr + ')\n' msg = msg + 'Plans with LLVM:\n' + plans + '\n' + msg = msg + '\nWeb Server Requests:\n' + for line in accdata: + msg = msg + line # # Send email to notify that someone has downloaded LLVM yet again! From criswell at cs.uiuc.edu Mon Feb 28 13:10:15 2005 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 28 Feb 2005 13:10:15 -0600 Subject: [llvm-commits] CVS: llvm-www/releases/register.cgi Message-ID: <200502281910.NAA05579@choi.cs.uiuc.edu> Changes in directory llvm-www/releases: register.cgi updated: 1.18 -> 1.19 --- Log message: Remove items which do not interest us. --- Diffs of the changes: (+3 -1) register.cgi | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm-www/releases/register.cgi diff -u llvm-www/releases/register.cgi:1.18 llvm-www/releases/register.cgi:1.19 --- llvm-www/releases/register.cgi:1.18 Mon Feb 28 11:41:33 2005 +++ llvm-www/releases/register.cgi Mon Feb 28 13:09:59 2005 @@ -230,7 +230,9 @@ # Attempt to grab all of the relevant junk from access_log regarding # this user. # - acclog = os.popen ('tail -n 100 /etc/httpd/logs/access_log | grep ' + rhost) + cmd = 'tail -n 100 /etc/httpd/logs/access_log | grep ' + rhost + cmd = cmd + ' | grep -v favicon | grep -v llvm.css | grep -v /img' + acclog = os.popen (cmd) accdata = acclog.readlines() # From criswell at cs.uiuc.edu Mon Feb 28 13:13:41 2005 From: criswell at cs.uiuc.edu (John Criswell) Date: Mon, 28 Feb 2005 13:13:41 -0600 Subject: [llvm-commits] CVS: llvm-www/releases/register.cgi Message-ID: <200502281913.NAA17004@zion.cs.uiuc.edu> Changes in directory llvm-www/releases: register.cgi updated: 1.19 -> 1.20 --- Log message: Fixed space indentation to tab indentation. Dude. Indentation should be cosmetic. --- Diffs of the changes: (+2 -2) register.cgi | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-www/releases/register.cgi diff -u llvm-www/releases/register.cgi:1.19 llvm-www/releases/register.cgi:1.20 --- llvm-www/releases/register.cgi:1.19 Mon Feb 28 13:09:59 2005 +++ llvm-www/releases/register.cgi Mon Feb 28 13:13:30 2005 @@ -230,8 +230,8 @@ # Attempt to grab all of the relevant junk from access_log regarding # this user. # - cmd = 'tail -n 100 /etc/httpd/logs/access_log | grep ' + rhost - cmd = cmd + ' | grep -v favicon | grep -v llvm.css | grep -v /img' + cmd = 'tail -n 100 /etc/httpd/logs/access_log | grep ' + rhost + cmd = cmd + ' | grep -v favicon | grep -v llvm.css | grep -v /img' acclog = os.popen (cmd) accdata = acclog.readlines() From lattner at cs.uiuc.edu Mon Feb 28 13:24:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:24:35 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200502281924.j1SJOZln021821@apoc.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.85 -> 1.86 --- Log message: Document llvm.prefetch, patch contributed by Justin Wick! --- Diffs of the changes: (+48 -1) LangRef.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletion(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.85 llvm/docs/LangRef.html:1.86 --- llvm/docs/LangRef.html:1.85 Fri Feb 18 20:22:14 2005 +++ llvm/docs/LangRef.html Mon Feb 28 13:24:19 2005 @@ -125,6 +125,7 @@
  1. 'llvm.returnaddress' Intrinsic
  2. 'llvm.frameaddress' Intrinsic
  3. +
  4. 'llvm.prefetch' Intrinsic
  • Operating System Intrinsics @@ -2499,6 +2500,52 @@

    + + + +
    + +
    Syntax:
    +
    +  call void (sbyte *, uint, uint)* %llvm.prefetch(sbyte * <address>,
    +                                                  uint <rw>, 
    +                                                  uint <locality>)
    +
    + +
    Overview:
    + + +

    +The 'llvm.prefetch' intrinsic is a hint to the code generator to insert +a prefetch instruction if supported, otherwise it is a noop. Prefetches have no +behavior affect on the program, but can change the performance characteristics +of the code. +

    + +
    Arguments:
    + +

    +address is the address to be prefetched, rw is the specifier +determining if the fetch should be for a read (0) or write (1), and +locality is a temporal locality specifier ranging from (0) - no +locality, to (3) - exteremely local keep in cache. The rw and +locality arguments must be constant integers. +

    + +
    Semantics:
    + +

    +This intrinsic does not modify the behavior of the program. In particular, +prefetches cannot trap and do not produce a value. On targets that support this +intrinsic, the prefetch can provide hints to the processor cache for better +performance. +

    + +
    + +
    Operating System Intrinsics @@ -2924,7 +2971,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/19 02:22:14 $ + Last modified: $Date: 2005/02/28 19:24:19 $ From lattner at cs.uiuc.edu Mon Feb 28 13:26:11 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:26:11 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Intrinsics.h Message-ID: <200502281926.j1SJQBRO022434@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Intrinsics.h updated: 1.27 -> 1.28 --- Log message: Add a prefetch intrinsic, patch contributed by Justin Wick! --- Diffs of the changes: (+1 -0) Intrinsics.h | 1 + 1 files changed, 1 insertion(+) Index: llvm/include/llvm/Intrinsics.h diff -u llvm/include/llvm/Intrinsics.h:1.27 llvm/include/llvm/Intrinsics.h:1.28 --- llvm/include/llvm/Intrinsics.h:1.27 Fri Oct 29 13:43:43 2004 +++ llvm/include/llvm/Intrinsics.h Mon Feb 28 13:25:57 2005 @@ -34,6 +34,7 @@ // Code generator intrinsics. returnaddress, // Yields the return address of a dynamic call frame frameaddress, // Yields the frame address of a dynamic call frame + prefetch, // Prefetch a value into the cache // setjmp/longjmp intrinsics. setjmp, // Used to represent a setjmp call in C From lattner at cs.uiuc.edu Mon Feb 28 13:27:36 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:27:36 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200502281927.j1SJRaDp023300@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.21 -> 1.22 --- Log message: Lower prefetch to a noop, patch contributed by Justin Wick! --- Diffs of the changes: (+3 -0) IntrinsicLowering.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.21 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.22 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.21 Thu Jul 29 12:20:54 2004 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Mon Feb 28 13:27:23 2005 @@ -169,6 +169,9 @@ cast(CI->getType()))); break; + case Intrinsic::prefetch: + break; // Simply strip out prefetches on unsupported architectures + case Intrinsic::dbg_stoppoint: case Intrinsic::dbg_region_start: case Intrinsic::dbg_region_end: From lattner at cs.uiuc.edu Mon Feb 28 13:28:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:28:13 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Message-ID: <200502281928.j1SJSDL6023841@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.87 -> 1.88 --- Log message: recognize llvm.prefetch. Patch contributed by Justin Wick! --- Diffs of the changes: (+3 -0) Function.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.87 llvm/lib/VMCore/Function.cpp:1.88 --- llvm/lib/VMCore/Function.cpp:1.87 Sat Jan 29 18:08:49 2005 +++ llvm/lib/VMCore/Function.cpp Mon Feb 28 13:28:00 2005 @@ -253,6 +253,9 @@ if (getName() == "llvm.memmove") return Intrinsic::memmove; if (getName() == "llvm.memset") return Intrinsic::memset; break; + case 'p': + if (getName() == "llvm.prefetch") return Intrinsic::prefetch; + break; case 'r': if (getName() == "llvm.returnaddress") return Intrinsic::returnaddress; if (getName() == "llvm.readport") return Intrinsic::readport; From lattner at cs.uiuc.edu Mon Feb 28 13:28:25 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:28:25 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp Message-ID: <200502281928.j1SJSPp0023953@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Verifier.cpp updated: 1.126 -> 1.127 --- Log message: Verify llvm.prefetch. --- Diffs of the changes: (+2 -0) Verifier.cpp | 2 ++ 1 files changed, 2 insertions(+) Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.126 llvm/lib/VMCore/Verifier.cpp:1.127 --- llvm/lib/VMCore/Verifier.cpp:1.126 Thu Feb 24 10:58:29 2005 +++ llvm/lib/VMCore/Verifier.cpp Mon Feb 28 13:27:42 2005 @@ -747,6 +747,8 @@ case Intrinsic::memcpy: NumArgs = 4; break; case Intrinsic::memmove: NumArgs = 4; break; case Intrinsic::memset: NumArgs = 4; break; + + case Intrinsic::prefetch: NumArgs = 3; break; case Intrinsic::not_intrinsic: assert(0 && "Invalid intrinsic!"); NumArgs = 0; break; From lattner at cs.uiuc.edu Mon Feb 28 13:30:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:30:00 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200502281930.j1SJU0ht026167@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.223 -> 1.224 --- Log message: Add support to the C backend for llvm.prefetch. Patch contributed by Justin Wick! --- Diffs of the changes: (+13 -0) Writer.cpp | 13 +++++++++++++ 1 files changed, 13 insertions(+) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.223 llvm/lib/Target/CBackend/Writer.cpp:1.224 --- llvm/lib/Target/CBackend/Writer.cpp:1.223 Mon Feb 14 23:52:14 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Mon Feb 28 13:29:46 2005 @@ -807,6 +807,7 @@ << "#define LLVM_NANSF(NanStr) __builtin_nansf(NanStr) /* Float */\n" << "#define LLVM_INF __builtin_inf() /* Double */\n" << "#define LLVM_INFF __builtin_inff() /* Float */\n" + << "#define LLVM_PREFETCH(addr,rw,locality) __builtin_prefetch(addr,rw,locality)\n" << "#else\n" << "#define LLVM_NAN(NanStr) ((double)0.0) /* Double */\n" << "#define LLVM_NANF(NanStr) 0.0F /* Float */\n" @@ -814,6 +815,7 @@ << "#define LLVM_NANSF(NanStr) 0.0F /* Float */\n" << "#define LLVM_INF ((double)0.0) /* Double */\n" << "#define LLVM_INFF 0.0F /* Float */\n" + << "#define LLVM_PREFETCH(addr,rw,locality) \n" << "#endif\n"; } @@ -1430,6 +1432,7 @@ case Intrinsic::frameaddress: case Intrinsic::setjmp: case Intrinsic::longjmp: + case Intrinsic::prefetch: // We directly implement these intrinsics break; default: @@ -1504,6 +1507,16 @@ writeOperand(I.getOperand(2)); Out << ')'; return; + case Intrinsic::prefetch: + // This is only supported on GCC for now... + Out << "LLVM_PREFETCH((const void *)"; + writeOperand(I.getOperand(1)); + Out << ", "; + writeOperand(I.getOperand(2)); + Out << ", "; + writeOperand(I.getOperand(3)); + Out << ")"; + return; } } From lattner at cs.uiuc.edu Mon Feb 28 13:31:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:31:55 -0600 Subject: [llvm-commits] CVS: llvm/test/Feature/intrinsics.ll Message-ID: <200502281931.j1SJVtIJ029073@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: intrinsics.ll updated: 1.6 -> 1.7 --- Log message: Add a test for llvm.prefetch. --- Diffs of the changes: (+3 -0) intrinsics.ll | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/test/Feature/intrinsics.ll diff -u llvm/test/Feature/intrinsics.ll:1.6 llvm/test/Feature/intrinsics.ll:1.7 --- llvm/test/Feature/intrinsics.ll:1.6 Sun Nov 7 00:08:43 2004 +++ llvm/test/Feature/intrinsics.ll Mon Feb 28 13:31:42 2005 @@ -6,6 +6,8 @@ declare bool %llvm.isunordered(float, float) declare bool %llvm.isunordered(double, double) +declare void %llvm.prefetch(sbyte*, uint, uint) + implementation ; Test llvm intrinsics @@ -13,5 +15,6 @@ void %libm() { call bool %llvm.isunordered(float 0.0, float 1.0) call bool %llvm.isunordered(double 0.0, double 0x7FF8000000000000) + call void %llvm.prefetch(sbyte* null, uint 1, uint 3) ret void } From lattner at cs.uiuc.edu Mon Feb 28 13:36:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:36:28 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200502281936.j1SJaSoF029092@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.224 -> 1.225 --- Log message: Remove tabs from file. --- Diffs of the changes: (+2 -3) Writer.cpp | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.224 llvm/lib/Target/CBackend/Writer.cpp:1.225 --- llvm/lib/Target/CBackend/Writer.cpp:1.224 Mon Feb 28 13:29:46 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Mon Feb 28 13:36:15 2005 @@ -1508,15 +1508,14 @@ Out << ')'; return; case Intrinsic::prefetch: - // This is only supported on GCC for now... - Out << "LLVM_PREFETCH((const void *)"; + Out << "LLVM_PREFETCH((const void *)"; writeOperand(I.getOperand(1)); Out << ", "; writeOperand(I.getOperand(2)); Out << ", "; writeOperand(I.getOperand(3)); Out << ")"; - return; + return; } } From lattner at cs.uiuc.edu Mon Feb 28 13:47:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 28 Feb 2005 13:47:27 -0600 Subject: [llvm-commits] CVS: llvm/docs/LangRef.html Message-ID: <200502281947.j1SJlRXs029153@apoc.cs.uiuc.edu> Changes in directory llvm/docs: LangRef.html updated: 1.86 -> 1.87 --- Log message: cleanup my miswording --- Diffs of the changes: (+3 -3) LangRef.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/docs/LangRef.html diff -u llvm/docs/LangRef.html:1.86 llvm/docs/LangRef.html:1.87 --- llvm/docs/LangRef.html:1.86 Mon Feb 28 13:24:19 2005 +++ llvm/docs/LangRef.html Mon Feb 28 13:47:14 2005 @@ -2520,8 +2520,8 @@

    The 'llvm.prefetch' intrinsic is a hint to the code generator to insert a prefetch instruction if supported, otherwise it is a noop. Prefetches have no -behavior affect on the program, but can change the performance characteristics -of the code. +effect on the behavior of the program, but can change its performance +characteristics.

    Arguments:
    @@ -2971,7 +2971,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/28 19:24:19 $ + Last modified: $Date: 2005/02/28 19:47:14 $ From alkis at cs.uiuc.edu Mon Feb 28 20:08:09 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Mon, 28 Feb 2005 20:08:09 -0600 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp Message-ID: <200503010208.UAA21761@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: IntrinsicLowering.cpp updated: 1.22 -> 1.23 --- Log message: Lower llvm.isunordered(a, b) into a != a | b != b. --- Diffs of the changes: (+8 -3) IntrinsicLowering.cpp | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) Index: llvm/lib/CodeGen/IntrinsicLowering.cpp diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.22 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.23 --- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.22 Mon Feb 28 13:27:23 2005 +++ llvm/lib/CodeGen/IntrinsicLowering.cpp Mon Feb 28 20:07:58 2005 @@ -206,9 +206,14 @@ break; } case Intrinsic::isunordered: { - static Function *isunorderedFCache = 0; - ReplaceCallWith("isunordered", CI, CI->op_begin()+1, CI->op_end(), - Type::BoolTy, isunorderedFCache); + Value *L = CI->getOperand(1); + Value *R = CI->getOperand(2); + + Value *LIsNan = new SetCondInst(Instruction::SetNE, L, L, "LIsNan", CI); + Value *RIsNan = new SetCondInst(Instruction::SetNE, R, R, "RIsNan", CI); + CI->replaceAllUsesWith( + BinaryOperator::create(Instruction::Or, LIsNan, RIsNan, + "isunordered", CI)); break; } } From jeffc at jolt-lang.org Mon Feb 28 21:46:22 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Mon, 28 Feb 2005 21:46:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503010346.VAA22946@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.4 -> 1.5 --- Log message: Fixed the following LSR bugs: * Loop invariant code does not dominate the loop header, but rather the end of the loop preheader. * The base for a reduced GEP isn't a constant unless all of its operands (preceding the induction variable) are constant. * Allow induction variable elimination for the simple case after all. Also made changes recommended by Chris for properly deleting instructions. --- Diffs of the changes: (+19 -23) LoopStrengthReduce.cpp | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.4 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.5 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.4 Sun Feb 27 18:08:56 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Feb 28 21:46:11 2005 @@ -78,14 +78,9 @@ Instruction *I = *Insts.begin(); Insts.erase(Insts.begin()); if (isInstructionTriviallyDead(I)) { - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - // Note: the PHI nodes had dropAllReferences() called on it, so its - // operands will all be NULL. - Value *V = I->getOperand(i); - if (V) - if (Instruction *U = dyn_cast(V)) - Insts.insert(U); - } + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) + if (Instruction *U = dyn_cast(I->getOperand(i))) + Insts.insert(U); I->getParent()->getInstList().erase(I); Changed = true; } @@ -111,6 +106,8 @@ std::vector inc_op_vector; Value *CanonicalIndVar = L->getCanonicalInductionVariable(); BasicBlock *Header = L->getHeader(); + BasicBlock *Preheader = L->getLoopPreheader(); + bool AllConstantOperands = true; for (unsigned op = 1, e = GEPI->getNumOperands(); op != e; ++op) { Value *operand = GEPI->getOperand(op); @@ -125,9 +122,10 @@ } else if (isa(operand)) { pre_op_vector.push_back(operand); } else if (Instruction *inst = dyn_cast(operand)) { - if (!DS->dominates(inst, Header->begin())) + if (!DS->dominates(inst, Preheader->getTerminator())) return; pre_op_vector.push_back(operand); + AllConstantOperands = false; } else return; } @@ -139,7 +137,7 @@ // their constituent operations so we have explicit multiplications to work // with. if (Instruction *GepPtrOp = dyn_cast(GEPI->getOperand(0))) - if (!DS->dominates(GepPtrOp, Header->begin())) + if (!DS->dominates(GepPtrOp, Preheader->getTerminator())) return; // If all operands of the GEP we are going to insert into the preheader @@ -148,9 +146,8 @@ // If there is only one operand after the initial non-constant one, we know // that it was the induction variable, and has been replaced by a constant // null value. In this case, replace the GEP with a use of pointer directly. - BasicBlock *Preheader = L->getLoopPreheader(); Value *PreGEP; - if (isa(GEPI->getOperand(0))) { + if (AllConstantOperands && isa(GEPI->getOperand(0))) { Constant *C = dyn_cast(GEPI->getOperand(0)); PreGEP = ConstantExpr::getGetElementPtr(C, pre_op_vector); } else if (pre_op_vector.size() == 1) { @@ -177,7 +174,10 @@ GetElementPtrInst *StrGEP = new GetElementPtrInst(NewPHI, inc_op_vector, GEPI->getName()+".inc", IncrInst); - NewPHI->addIncoming(StrGEP, IncrInst->getParent()); + pred_iterator PI = pred_begin(Header); + if (*PI == Preheader) + ++PI; + NewPHI->addIncoming(StrGEP, *PI); if (GEPI->getNumOperands() - 1 == indvar) { // If there were no operands following the induction variable, replace all @@ -242,24 +242,20 @@ // 4. the add is used by the cann indvar // If all four cases above are true, then we can remove both the add and // the cann indvar. -#if 0 - // FIXME: it's not clear this code is correct. An induction variable with - // but one use, an increment, implies an infinite loop. Not illegal, but - // of questionable utility. It also does not update the loop info with the - // new induction variable. + // FIXME: this needs to eliminate an induction variable even if it's being + // compared against some value to decide loop termination. if (PN->hasOneUse()) { BinaryOperator *BO = dyn_cast(*(PN->use_begin())); if (BO && BO->getOpcode() == Instruction::Add) if (BO->hasOneUse()) { - PHINode *PotentialIndvar = dyn_cast(*(BO->use_begin())); - if (PotentialIndvar && PN == PotentialIndvar) { - PN->dropAllReferences(); + if (PN == dyn_cast(*(BO->use_begin()))) { DeadInsts.insert(BO); - DeadInsts.insert(PN); + // Break the cycle, then delete the PHI. + PN->replaceAllUsesWith(UndefValue::get(PN->getType())); + PN->eraseFromParent(); DeleteTriviallyDeadInstructions(DeadInsts); } } } -#endif } } From reid at x10sys.com Tue Mar 1 10:27:17 2005 From: reid at x10sys.com (Reid Spencer) Date: Tue, 1 Mar 2005 10:27:17 -0600 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200503011627.KAA24385@zion.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.305 -> 1.306 --- Log message: Correct a typo in Makefile.rules. Patch idea contributed by Vladimir Merzliakov. --- Diffs of the changes: (+1 -1) Makefile.rules | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.305 llvm/Makefile.rules:1.306 --- llvm/Makefile.rules:1.305 Sun Feb 27 04:21:37 2005 +++ llvm/Makefile.rules Tue Mar 1 10:27:06 2005 @@ -1528,7 +1528,7 @@ $(Echo) "TDFiles : " '$(TDFiles)' $(Echo) "INCFiles : " '$(INCFiles)' $(Echo) "INCTMPFiles : " '$(INCTMPFiles)' - $(Echo) "Preconditions: " '$(Preconditions)' + $(Echo) "PreConditions: " '$(PreConditions)' $(Echo) "Compile.CXX : " '$(Compile.CXX)' $(Echo) "Compile.C : " '$(Compile.C)' $(Echo) "Archive : " '$(Archive)' From brukman at cs.uiuc.edu Tue Mar 1 11:15:34 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 1 Mar 2005 11:15:34 -0600 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200503011715.LAA25294@zion.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.45 -> 1.46 --- Log message: Use a colon instead of a period since we're introducing a command list --- Diffs of the changes: (+2 -2) CFEBuildInstrs.html | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.45 llvm/docs/CFEBuildInstrs.html:1.46 --- llvm/docs/CFEBuildInstrs.html:1.45 Mon Feb 21 10:35:31 2005 +++ llvm/docs/CFEBuildInstrs.html Tue Mar 1 11:15:23 2005 @@ -244,7 +244,7 @@
  • Rebuild your CVS tree. This shouldn't cause the whole thing to be rebuilt, but it should build the runtime libraries. After the tree is built, install the runtime libraries into your GCC front-end build tree. - These are the commands you need.

    + These are the commands you need:

      % gmake
      % gmake -C runtime install-bytecode
    @@ -346,7 +346,7 @@
     
       Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/02/21 16:35:31 $ + Last modified: $Date: 2005/03/01 17:15:23 $ From brukman at cs.uiuc.edu Tue Mar 1 11:19:32 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Tue, 1 Mar 2005 11:19:32 -0600 Subject: [llvm-commits] CVS: llvm/docs/CFEBuildInstrs.html Message-ID: <200503011719.LAA25516@zion.cs.uiuc.edu> Changes in directory llvm/docs: CFEBuildInstrs.html updated: 1.46 -> 1.47 --- Log message: Fix HTML-4.01 Strict compliance --- Diffs of the changes: (+3 -3) CFEBuildInstrs.html | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/docs/CFEBuildInstrs.html diff -u llvm/docs/CFEBuildInstrs.html:1.46 llvm/docs/CFEBuildInstrs.html:1.47 --- llvm/docs/CFEBuildInstrs.html:1.46 Tue Mar 1 11:15:23 2005 +++ llvm/docs/CFEBuildInstrs.html Tue Mar 1 11:19:21 2005 @@ -76,11 +76,11 @@ will cause the GNU ld linker to fail an assertion when linking components of the libstdc++. It is recommended that you replace the entire binutils package with version 2.15 such that "ld --version" responds -with
    +with

    GNU ld version 2.15
    not with:
    GNU ld version 2.15.91 20040725
    -

    + @@ -346,7 +346,7 @@ Brian Gaeke
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/03/01 17:15:23 $ + Last modified: $Date: 2005/03/01 17:19:21 $ From lattner at cs.uiuc.edu Tue Mar 1 12:49:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 12:49:54 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Message-ID: <200503011849.j21InscU006612@apoc.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Benchmarks/llubenchmark: llubenchmark.c updated: 1.2 -> 1.3 --- Log message: reduce i/o --- Diffs of the changes: (+1 -1) llubenchmark.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c diff -u llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.2 llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.3 --- llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.2 Tue Mar 2 22:48:42 2004 +++ llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Tue Mar 1 12:49:38 2005 @@ -145,7 +145,7 @@ /* iterate */ for (i = 0 ; i < max_iterations ; i ++) { - if ((i % 10) == 0) { + if ((i % 1000) == 0) { printf("%d\n", i); } /* traverse lists */ From lattner at cs.uiuc.edu Tue Mar 1 12:57:32 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 12:57:32 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Message-ID: <200503011857.j21IvWv3006685@apoc.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Benchmarks/llubenchmark: llubenchmark.c updated: 1.3 -> 1.4 --- Log message: make the 'accumulate' variable non-dead and print the output. --- Diffs of the changes: (+3 -0) llubenchmark.c | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c diff -u llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.3 llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.4 --- llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.3 Tue Mar 1 12:49:38 2005 +++ llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Tue Mar 1 12:57:17 2005 @@ -167,6 +167,7 @@ for ( ; j > 0 ; j --) { for (k = 0 ; k < num_lists ; k ++) { struct element *e = allocate(); + e->count = k+j; if (tail) { struct element *trav = lists[k]; while (trav->next != NULL) { @@ -181,6 +182,8 @@ } } } + printf ("output = %d\n", accumulate); + printf ("num allocated %d\n", num_allocated); return 0; } From lattner at cs.uiuc.edu Tue Mar 1 16:42:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 16:42:20 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/PtrCompAllocator/Makefile PtrCompAllocator.h Message-ID: <200503012242.j21MgK8t008293@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/PtrCompAllocator: Makefile updated: 1.1 -> 1.2 PtrCompAllocator.h updated: 1.2 -> 1.3 --- Log message: add comments, cleanup cruft in the makefile that doesn't do anything. We don't need a bc version --- Diffs of the changes: (+7 -6) Makefile | 3 --- PtrCompAllocator.h | 10 +++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) Index: llvm-poolalloc/runtime/PtrCompAllocator/Makefile diff -u llvm-poolalloc/runtime/PtrCompAllocator/Makefile:1.1 llvm-poolalloc/runtime/PtrCompAllocator/Makefile:1.2 --- llvm-poolalloc/runtime/PtrCompAllocator/Makefile:1.1 Tue Feb 22 13:35:07 2005 +++ llvm-poolalloc/runtime/PtrCompAllocator/Makefile Tue Mar 1 16:42:05 2005 @@ -1,5 +1,4 @@ LEVEL = ../.. -BYTECODE_LIBRARY=1 SHARED_LIBRARY=1 LIBRARYNAME=ptrcomp_rt @@ -7,5 +6,3 @@ include $(LEVEL)/Makefile.common -# Always build optimized and debug versions -all:: $(LIBNAME_OBJO) $(LIBNAME_OBJG) Index: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h diff -u llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.2 llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.3 --- llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.2 Tue Feb 22 14:11:26 2005 +++ llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h Tue Mar 1 16:42:05 2005 @@ -16,8 +16,12 @@ #define PTRCOMP_ALLOCATOR_H struct PoolTy { - char *PoolBase; // The actual pool. - unsigned long *BitVector;// Bitvector of bits. This stores two bits per node. + // PoolBase - The actual pool. Note that this MUST stay as the first element + // of this structure. + char *PoolBase; + + // BitVector - Bitvector of bits. This stores two bits per node. + unsigned long *BitVector; // OrigSize - The size of the nodes in a non-compressed pool. unsigned OrigSize; @@ -35,7 +39,7 @@ unsigned long NumUsed; - // These fields are only used in debug mode. + // These fields are only used in debug mode to build stats, keep at end. unsigned BytesAllocated, NumObjects; }; From lattner at cs.uiuc.edu Tue Mar 1 16:43:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 16:43:20 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/Makefile Message-ID: <200503012243.j21MhKcI009014@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: Makefile updated: 1.2 -> 1.3 --- Log message: Don't need a .bc version, these rules don't work anymore. --- Diffs of the changes: (+0 -3) Makefile | 3 --- 1 files changed, 3 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/Makefile diff -u llvm-poolalloc/runtime/FL2Allocator/Makefile:1.2 llvm-poolalloc/runtime/FL2Allocator/Makefile:1.3 --- llvm-poolalloc/runtime/FL2Allocator/Makefile:1.2 Tue Nov 2 00:29:12 2004 +++ llvm-poolalloc/runtime/FL2Allocator/Makefile Tue Mar 1 16:43:07 2005 @@ -1,5 +1,4 @@ LEVEL = ../.. -BYTECODE_LIBRARY=1 SHARED_LIBRARY=1 LIBRARYNAME=poolalloc_rt @@ -7,5 +6,3 @@ include $(LEVEL)/Makefile.common -# Always build optimized and debug versions -all:: $(LIBNAME_OBJO) $(LIBNAME_OBJG) From lattner at cs.uiuc.edu Tue Mar 1 17:40:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 17:40:08 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503012340.j21Ne8SN010606@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.34 -> 1.35 --- Log message: Do data compression in the transformation pass instead of the runtime lib. --- Diffs of the changes: (+40 -4) PointerCompress.cpp | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 40 insertions(+), 4 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.34 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.35 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.34 Sun Feb 27 16:30:51 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Tue Mar 1 17:39:51 2005 @@ -14,6 +14,7 @@ #define DEBUG_TYPE "pointercompress" #include "EquivClassGraphs.h" #include "PoolAllocate.h" +#include "Heuristic.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Module.h" @@ -97,7 +98,7 @@ std::map ClonedFunctionInfoMap; public: - Function *PoolInitPC, *PoolDestroyPC; + Function *PoolInitPC, *PoolDestroyPC, *PoolAllocPC; typedef std::map PoolInfoMap; bool runOnModule(Module &M); @@ -507,6 +508,7 @@ void visitCallInst(CallInst &CI); void visitPoolInit(CallInst &CI); + void visitPoolAlloc(CallInst &CI); void visitPoolDestroy(CallInst &CI); void visitInstruction(Instruction &I) { @@ -769,8 +771,7 @@ std::vector Ops; Ops.push_back(CI.getOperand(1)); - // Transform to pass in the orig and compressed sizes. - Ops.push_back(CI.getOperand(2)); + // Transform to pass in the compressed size. Ops.push_back(ConstantUInt::get(Type::UIntTy, PI->getNewSize())); Ops.push_back(CI.getOperand(3)); // TODO: Compression could reduce the alignment restriction for the pool! @@ -790,6 +791,36 @@ CI.eraseFromParent(); } +void InstructionRewriter::visitPoolAlloc(CallInst &CI) { + const CompressedPoolInfo *PI = getPoolInfo(&CI); + if (PI == 0) return; // Pool isn't compressed. + + std::vector Ops; + Ops.push_back(CI.getOperand(1)); // PD + + Value *Size = CI.getOperand(2); + + // If there was a recommended size, shrink it down now. + if (unsigned OldSizeV = PA::Heuristic::getRecommendedSize(PI->getNode())) + if (OldSizeV != PI->getNewSize()) { + // Emit code to scale the allocated size down by the old size then up by + // the new size. We actually compute (N+OS-1)/OS * NS. + Value *OldSize = ConstantUInt::get(Type::UIntTy, OldSizeV); + Value *NewSize = ConstantUInt::get(Type::UIntTy, PI->getNewSize()); + + Size = BinaryOperator::createAdd(Size, + ConstantUInt::get(Type::UIntTy, OldSizeV-1), + "roundup", &CI); + Size = BinaryOperator::createDiv(Size, OldSize, "numnodes", &CI); + Size = BinaryOperator::createMul(Size, NewSize, "newbytes", &CI); + } + + Ops.push_back(Size); + Value *NC = new CallInst(PtrComp.PoolAllocPC, Ops, CI.getName(), &CI); + setTransformedValue(CI, NC); +} + + void InstructionRewriter::visitCallInst(CallInst &CI) { if (Function *F = CI.getCalledFunction()) // These functions are handled specially. @@ -799,6 +830,9 @@ } else if (F->getName() == "pooldestroy") { visitPoolDestroy(CI); return; + } else if (F->getName() == "poolalloc") { + visitPoolAlloc(CI); + return; } // Normal function call: check to see if this call produces or uses a pointer @@ -1170,10 +1204,12 @@ const Type *PoolDescPtrTy = PointerType::get(ArrayType::get(VoidPtrTy, 16)); PoolInitPC = M.getOrInsertFunction("poolinit_pc", Type::VoidTy, - PoolDescPtrTy, Type::UIntTy, + PoolDescPtrTy, Type::UIntTy, Type::UIntTy, 0); PoolDestroyPC = M.getOrInsertFunction("pooldestroy_pc", Type::VoidTy, PoolDescPtrTy, 0); + PoolAllocPC = M.getOrInsertFunction("poolalloc_pc", SCALARUINTTYPE, + PoolDescPtrTy, Type::UIntTy, 0); // FIXME: Need bumppointer versions as well as realloc??/memalign?? } From lattner at cs.uiuc.edu Tue Mar 1 17:43:13 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 17:43:13 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp PtrCompAllocator.h Message-ID: <200503012343.j21NhDTY011750@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/PtrCompAllocator: PtrCompAllocator.cpp updated: 1.5 -> 1.6 PtrCompAllocator.h updated: 1.3 -> 1.4 --- Log message: Adjust to match changes in the transformation. --- Diffs of the changes: (+18 -24) PtrCompAllocator.cpp | 30 ++++++++++++++---------------- PtrCompAllocator.h | 12 ++++-------- 2 files changed, 18 insertions(+), 24 deletions(-) Index: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp diff -u llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.5 llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.6 --- llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp:1.5 Tue Feb 22 14:20:06 2005 +++ llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.cpp Tue Mar 1 17:43:00 2005 @@ -100,10 +100,10 @@ static void PrintPoolStats(PoolTy *Pool) { fprintf(stderr, "(0x%X) BytesAlloc=%d NumObjs=%d" - " bitvectorsize=%d numused=%d OrigSize=%d NewSize=%d\n", + " bitvectorsize=%d numused=%d NodeSize=%d\n", Pool, Pool->BytesAllocated, Pool->NumObjects, - Pool->NumNodesInBitVector, Pool->NumUsed, Pool->OrigSize, - Pool->NewSize); + Pool->NumNodesInBitVector, Pool->NumUsed, + Pool->NodeSize); } #else @@ -141,16 +141,14 @@ // poolinit_pc - Initialize a pool descriptor to empty // -void poolinit_pc(PoolTy *Pool, unsigned NewSize, unsigned OldSize, - unsigned ObjAlignment) { - assert(Pool && OldSize && NewSize && ObjAlignment); +void poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { + assert(Pool && NodeSize && ObjAlignment); assert((ObjAlignment & (ObjAlignment-1)) == 0 && "Alignment not 2^k!"); DO_IF_PNP(memset(Pool, 0, sizeof(PoolTy))); - Pool->OrigSize = OldSize; // Round up to the next alignment boundary. - Pool->NewSize = (NewSize+ObjAlignment-1) & ~(ObjAlignment-1); + Pool->NodeSize = (NodeSize+ObjAlignment-1) & ~(ObjAlignment-1); Pool->PoolBase = 0; Pool->BitVector = 0; @@ -202,12 +200,12 @@ DO_IF_PNP(if (Pool->NumObjects == 0) ++PoolCounter); // Track # pools. - unsigned OrigSize = Pool->OrigSize; + unsigned NodeSize = Pool->NodeSize; unsigned NodesToAllocate; - if (NumBytes == OrigSize) + if (NumBytes == NodeSize) NodesToAllocate = 1; // Common case. else - NodesToAllocate = (NumBytes+OrigSize-1)/OrigSize; + NodesToAllocate = (NumBytes+NodeSize-1)/NodeSize; DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc_pc(%d [%d node%s]) -> ", getPoolNumber(Pool), NumBytes, NodesToAllocate, @@ -229,8 +227,8 @@ unsigned long Result = Pool->NumUsed++; MarkNodeAllocated(Pool, Result); DO_IF_TRACE(fprintf(stderr, "Node %ld: 0x%lX byte from poolbase\n", Result, - Result*Pool->NewSize)); - return Result*Pool->NewSize; + Result*Pool->NodeSize)); + return Result*Pool->NodeSize; } // Otherwise, we need to grow the bitvector. Double its size. @@ -242,9 +240,9 @@ void poolfree_pc(PoolTy *Pool, unsigned long Node) { if (Node == 0) return; - assert(Pool && (Node % Pool->NewSize == 0) && - (Node/Pool->NewSize < Pool->NumUsed) && "Node or pool incorrect!"); - Node /= Pool->NewSize; + assert(Pool && (Node % Pool->NodeSize == 0) && + (Node/Pool->NodeSize < Pool->NumUsed) && "Node or pool incorrect!"); + Node /= Pool->NodeSize; DO_IF_TRACE(fprintf(stderr, "[%d] poolfree_pc(0x%X) ", getPoolNumber(Pool), (unsigned)Node)); Index: llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h diff -u llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.3 llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.4 --- llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h:1.3 Tue Mar 1 16:42:05 2005 +++ llvm-poolalloc/runtime/PtrCompAllocator/PtrCompAllocator.h Tue Mar 1 17:43:00 2005 @@ -23,12 +23,9 @@ // BitVector - Bitvector of bits. This stores two bits per node. unsigned long *BitVector; - // OrigSize - The size of the nodes in a non-compressed pool. - unsigned OrigSize; - - // NewSize - The size of the nodes to actually allocate out of the pool. This - // size already considers object padding due to alignment. - unsigned NewSize; + // NodeSize - The size of the nodes to actually allocate out of the pool. + // This size already considers object padding due to alignment. + unsigned NodeSize; // NumNodesInBitVector - This indicates the amount of space we have for nodes // in the bitvector. We actually have space for 2* this number of bits. @@ -44,8 +41,7 @@ }; extern "C" { - void poolinit_pc(PoolTy *Pool, unsigned NewSize, unsigned OldSize, - unsigned ObjAlignment); + void poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment); void pooldestroy_pc(PoolTy *Pool); unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes); void poolfree_pc(PoolTy *Pool, unsigned long Node); From lattner at cs.uiuc.edu Tue Mar 1 21:44:11 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 21:44:11 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200503020344.j223iBXd023634@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.72 -> 1.73 --- Log message: Now that type does not derive from Value, these do not need to be virtual. --- Diffs of the changes: (+2 -2) Type.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.72 llvm/include/llvm/Type.h:1.73 --- llvm/include/llvm/Type.h:1.72 Sun Feb 27 00:15:09 2005 +++ llvm/include/llvm/Type.h Tue Mar 1 21:43:55 2005 @@ -122,10 +122,10 @@ std::vector ContainedTys; public: - virtual void print(std::ostream &O) const; + void print(std::ostream &O) const; /// @brief Debugging support: print to stderr - virtual void dump() const; + void dump() const; //===--------------------------------------------------------------------===// // Property accessors for dealing with types... Some of these virtual methods From lattner at cs.uiuc.edu Tue Mar 1 21:54:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 21:54:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200503020354.j223sxNZ023659@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.121 -> 1.122 --- Log message: Fix a nasty order of evaluation bug that Gabor Greif ran into. Here's an explanation from IRC: |sabre| I think it's an order of evaluation thing |sabre| for me, the RHS of the assignment is evaluated first |sabre| getTypeDescription checks to see if ConcreteTypeDescription[Ty] contains anything |sabre| since it doesn't, it computes and returns the value |sabre| this gets put into the map. |sabre| For you, the LHS is evaluated first. |sabre| Map[Ty] (aka ConcreteTypeDescriptions[Ty]) inserts an empty string into the map, returning a reference |sabre| getTypeDesc then sees the empty string in the map |sabre| and returns it |sabre| bork :) --- Diffs of the changes: (+2 -1) Type.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.121 llvm/lib/VMCore/Type.cpp:1.122 --- llvm/lib/VMCore/Type.cpp:1.121 Sat Jan 8 14:19:51 2005 +++ llvm/lib/VMCore/Type.cpp Tue Mar 1 21:54:43 2005 @@ -291,7 +291,8 @@ if (I != Map.end()) return I->second; std::vector TypeStack; - return Map[Ty] = getTypeDescription(Ty, TypeStack); + std::string Result = getTypeDescription(Ty, TypeStack); + return Map[Ty] = Result; } From lattner at cs.uiuc.edu Tue Mar 1 22:51:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 22:51:51 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h Message-ID: <200503020451.j224ppZn026907@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.30 -> 1.31 PoolAllocator.h updated: 1.16 -> 1.17 --- Log message: Initial implementation of the pointer compression runtime library integrated with the pool alloc runtime. --- Diffs of the changes: (+128 -7) FreeListAllocator.cpp | 113 ++++++++++++++++++++++++++++++++++++++++++++++++-- PoolAllocator.h | 22 ++++++++- 2 files changed, 128 insertions(+), 7 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.30 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.31 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.30 Fri Nov 12 14:09:43 2004 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Tue Mar 1 22:51:35 2005 @@ -66,7 +66,7 @@ for (unsigned i = 0; i != NumLivePools; ++i) if (PoolIDs[i].PD == PD) return PoolIDs[i].ID; - fprintf(stderr, "INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n", (unsigned long)PD); + fprintf(stderr, "INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n",(unsigned long)PD); return 0; } @@ -78,7 +78,7 @@ --NumLivePools; return PN; } - fprintf(stderr, "INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n", (unsigned long)PD); + fprintf(stderr, "INVALID/UNKNOWN POOL DESCRIPTOR: 0x%lX\n",(unsigned long)PD); return 0; } @@ -173,6 +173,7 @@ public: static void create(PoolTy *Pool, unsigned SizeHint); static void *create_for_bp(PoolTy *Pool); + static void create_for_ptrcomp(PoolTy *Pool, void *Mem, unsigned Size); void destroy(); PoolSlab *getNext() const { return Next; } @@ -204,7 +205,7 @@ PoolBody += Alignment-sizeof(FreedNodeHeader); Size -= Alignment-sizeof(FreedNodeHeader); } - + // Add the body of the slab to the free list. FreedNodeHeader *SlabBody = (FreedNodeHeader*)PoolBody; SlabBody->Header.Size = Size; @@ -239,6 +240,41 @@ return PoolBody; } +/// create_for_ptrcomp - Initialize a chunk of memory 'Mem' of size 'Size' for +/// pointer compression. +void PoolSlab::create_for_ptrcomp(PoolTy *Pool, void *SMem, unsigned Size) { + if (Pool->DeclaredSize == 0) { + unsigned Align = Pool->Alignment; + unsigned SizeHint = sizeof(FreedNodeHeader)-sizeof(NodeHeader); + SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1); + SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader); + Pool->DeclaredSize = SizeHint; + } + + PoolSlab *PS = (PoolSlab*)SMem; + char *PoolBody = (char*)(PS+1); + + // If the Alignment is greater than the size of the FreedNodeHeader, skip over + // some space so that the a "free pointer + sizeof(FreedNodeHeader)" is always + // aligned. + unsigned Alignment = Pool->Alignment; + if (Alignment > sizeof(FreedNodeHeader)) { + PoolBody += Alignment-sizeof(FreedNodeHeader); + Size -= Alignment-sizeof(FreedNodeHeader)-sizeof(PoolSlab); + } + + // Add the body of the slab to the free list. + FreedNodeHeader *SlabBody = (FreedNodeHeader*)PoolBody; + SlabBody->Header.Size = Size; + AddNodeToFreeList(Pool, SlabBody); + + // Make sure to add a marker at the end of the slab to prevent the coallescer + // from trying to merge off the end of the page. + FreedNodeHeader *End = + (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader) + Size); + End->Header.Size = ~0; // Looks like an allocated chunk +} + void PoolSlab::destroy() { free(this); @@ -435,7 +471,8 @@ return &Node->Header+1; } - if (NumBytes >= LARGE_SLAB_SIZE-sizeof(PoolSlab)-sizeof(NodeHeader)) + if (NumBytes >= LARGE_SLAB_SIZE-sizeof(PoolSlab)-sizeof(NodeHeader) && + !Pool->isPtrCompPool) goto LargeObject; // Fast path. In the common case, we can allocate a portion of the node at @@ -652,3 +689,71 @@ LargeArrayHeader *LAH = ((LargeArrayHeader*)Node)-1; return LAH->Size; } + +//===----------------------------------------------------------------------===// +// Pointer Compression runtime library. Most of these are just wrappers +// around the normal pool routines. +//===----------------------------------------------------------------------===// + +#include +#define POOLSIZE (256*1024*1024) + +// Pools - When we are done with a pool, don't munmap it, keep it around for +// next time. +static PoolSlab *Pools[4] = { 0, 0, 0, 0 }; + + +void poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { + poolinit(Pool, NodeSize, ObjAlignment); + Pool->isPtrCompPool = true; +} + +void pooldestroy_pc(PoolTy *Pool) { + if (Pool->Slabs == 0) + return; // no memory allocated from this pool. + + // If there is space to remember this pool, do so. + for (unsigned i = 0; i != 4; ++i) + if (Pools[i] == 0) { + Pools[i] = Pool->Slabs; + return; + } + + // Otherwise, just munmap it. + munmap(Pool->Slabs, POOLSIZE); +} + +unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes) { + if (Pool->Slabs == 0) + goto AllocPool; +Continue: + { + void *Result = poolalloc(Pool, NumBytes); + return (char*)Result-(char*)Pool->Slabs; + } + +AllocPool: + // This is the first allocation out of this pool. If we already have a pool + // mmapp'd, reuse it. + for (unsigned i = 0; i != 4; ++i) + if (Pools[i]) { + Pool->Slabs = Pools[i]; + Pools[i] = 0; + break; + } + if (Pool->Slabs == 0) { + // Didn't find an existing pool, create one. + Pool->Slabs = (PoolSlab*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0); + DO_IF_TRACE(fprintf(stderr, "RESERVED ADDR SPACE: %p -> %p\n", + Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); + } + PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, POOLSIZE); + goto Continue; +} + +void poolfree_pc(PoolTy *Pool, unsigned long Node) { + poolfree(Pool, Pool->Slabs+Node); +} + + Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.16 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.17 --- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.16 Wed Dec 1 21:42:13 2004 +++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h Tue Mar 1 22:51:35 2005 @@ -69,6 +69,10 @@ struct PoolTy { + // Slabs - the list of slabs in this pool. NOTE: This must remain the first + // memory of this structure for the pointer compression pass. + PoolSlab *Slabs; + // The free node lists for objects of various sizes. FreedNodeHeader *ObjFreeList; FreedNodeHeader *OtherFreeList; @@ -86,8 +90,9 @@ // The size to allocate for the next slab. unsigned AllocSize; - // Lists - the list of slabs in this pool. - PoolSlab *Slabs; + // isPtrCompPool - True if this pool must be kept consequtive for pointer + // compression. + bool isPtrCompPool; // NumObjects - the number of poolallocs for this pool. unsigned NumObjects; @@ -106,7 +111,7 @@ void *poolmemalign(PoolTy *Pool, unsigned Alignment, unsigned NumBytes); void poolfree(PoolTy *Pool, void *Node); - /// poolobjsize - Reutrn the size of the object at the specified address, in + /// poolobjsize - Return the size of the object at the specified address, in /// the specified pool. Note that this cannot be used in normal cases, as it /// is completely broken if things land in the system heap. Perhaps in the /// future. :( @@ -119,6 +124,17 @@ void poolinit_bp(PoolTy *Pool, unsigned ObjAlignment); void *poolalloc_bp(PoolTy *Pool, unsigned NumBytes); void pooldestroy_bp(PoolTy *Pool); + + + // Pointer Compression runtime library. Most of these are just wrappers + // around the normal pool routines. + void poolinit_pc(PoolTy *Pool, unsigned NodeSize, + unsigned ObjAlignment); + void pooldestroy_pc(PoolTy *Pool); + unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes); + void poolfree_pc(PoolTy *Pool, unsigned long Node); + //void *poolmemalign_pc(PoolTy *Pool, unsigned Alignment, unsigned NumBytes); } #endif + From lattner at cs.uiuc.edu Tue Mar 1 22:56:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 22:56:31 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Message-ID: <200503020456.j224uVPS028217@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.31 -> 1.32 --- Log message: don't scale by pool slab size! --- Diffs of the changes: (+1 -1) FreeListAllocator.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.31 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.32 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.31 Tue Mar 1 22:51:35 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Tue Mar 1 22:56:18 2005 @@ -753,7 +753,7 @@ } void poolfree_pc(PoolTy *Pool, unsigned long Node) { - poolfree(Pool, Pool->Slabs+Node); + poolfree(Pool, (char*)Pool->Slabs+Node); } From reid at x10sys.com Tue Mar 1 23:46:07 2005 From: reid at x10sys.com (Reid Spencer) Date: Tue, 1 Mar 2005 23:46:07 -0600 Subject: [llvm-commits] CVS: llvm/lib/System/Unix/Path.inc Message-ID: <200503020546.XAA32185@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/Unix: Path.inc updated: 1.29 -> 1.30 --- Log message: Be slightly more accurate in an error message. --- Diffs of the changes: (+1 -1) Path.inc | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/System/Unix/Path.inc diff -u llvm/lib/System/Unix/Path.inc:1.29 llvm/lib/System/Unix/Path.inc:1.30 --- llvm/lib/System/Unix/Path.inc:1.29 Mon Dec 27 00:17:15 2004 +++ llvm/lib/System/Unix/Path.inc Tue Mar 1 23:45:56 2005 @@ -340,7 +340,7 @@ Path::getStatusInfo(StatusInfo& info) const { struct stat buf; if (0 != stat(path.c_str(), &buf)) { - ThrowErrno(std::string("Can't get status: ")+path); + ThrowErrno(std::string("Can't get status for path: ")+path); } info.fileSize = buf.st_size; info.modTime.fromEpochTime(buf.st_mtime); From lattner at cs.uiuc.edu Tue Mar 1 23:47:14 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 1 Mar 2005 23:47:14 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Message-ID: <200503020547.j225lEs2029717@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.32 -> 1.33 --- Log message: Add some debug output, do not write the end of memory marker off the end of the allocated space! --- Diffs of the changes: (+9 -1) FreeListAllocator.cpp | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.32 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.33 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.32 Tue Mar 1 22:56:18 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Tue Mar 1 23:46:59 2005 @@ -251,6 +251,7 @@ Pool->DeclaredSize = SizeHint; } + Size -= sizeof(PoolSlab) + sizeof(NodeHeader) + sizeof(FreedNodeHeader); PoolSlab *PS = (PoolSlab*)SMem; char *PoolBody = (char*)(PS+1); @@ -260,7 +261,7 @@ unsigned Alignment = Pool->Alignment; if (Alignment > sizeof(FreedNodeHeader)) { PoolBody += Alignment-sizeof(FreedNodeHeader); - Size -= Alignment-sizeof(FreedNodeHeader)-sizeof(PoolSlab); + Size -= Alignment-sizeof(FreedNodeHeader); } // Add the body of the slab to the free list. @@ -273,6 +274,7 @@ FreedNodeHeader *End = (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader) + Size); End->Header.Size = ~0; // Looks like an allocated chunk + PS->Next = 0; } @@ -709,9 +711,13 @@ } void pooldestroy_pc(PoolTy *Pool) { + assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); if (Pool->Slabs == 0) return; // no memory allocated from this pool. + DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy", removePoolNumber(Pool))); + DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); + // If there is space to remember this pool, do so. for (unsigned i = 0; i != 4; ++i) if (Pools[i] == 0) { @@ -720,6 +726,8 @@ } // Otherwise, just munmap it. + DO_IF_TRACE(fprintf(stderr, "UNMAPPING ADDR SPACE: %p -> %p\n", + Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); munmap(Pool->Slabs, POOLSIZE); } From lattner at cs.uiuc.edu Wed Mar 2 00:19:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 00:19:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200503020619.j226JcHF030605@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.44 -> 1.45 --- Log message: Add a temporary option for llc-beta: -enable-lsr-for-ppc, which turns on Loop Strength Reduction. --- Diffs of the changes: (+10 -0) PowerPCTargetMachine.cpp | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.44 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.45 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.44 Sun Dec 12 11:40:24 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Wed Mar 2 00:19:22 2005 @@ -33,6 +33,10 @@ cl::opt AIX("aix", cl::desc("Generate AIX/xcoff instead of Darwin/MachO"), cl::Hidden); + + cl::opt EnablePPCLSR("enable-lsr-for-ppc", + cl::desc("Enable LSR for PPC (beta option!)"), + cl::Hidden); } namespace { @@ -70,6 +74,9 @@ bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { bool LP64 = (0 != dynamic_cast(this)); + + if (EnablePPCLSR) + PM.add(createLoopStrengthReducePass()); // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); @@ -113,6 +120,9 @@ } void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { + if (EnablePPCLSR) + PM.add(createLoopStrengthReducePass()); + // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); From lattner at cs.uiuc.edu Wed Mar 2 00:24:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 00:24:08 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200503020624.j226O8Tn030739@apoc.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.147 -> 1.148 --- Log message: Turn on LSR for llc-beta on ppc --- Diffs of the changes: (+4 -0) Makefile.programs | 4 ++++ 1 files changed, 4 insertions(+) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.147 llvm-test/Makefile.programs:1.148 --- llvm-test/Makefile.programs:1.147 Sun Jan 23 22:04:25 2005 +++ llvm-test/Makefile.programs Wed Mar 2 00:23:52 2005 @@ -186,7 +186,11 @@ endif endif#DISABLE_DIFFS +ifeq ($(ARCH),PowerPC) +LLCBETAOPTION := -enable-lsr-for-ppc +else LLCBETAOPTION := -disable-pattern-isel=0 +endif # Given a version of the entire program linked together into a single unit of From lattner at cs.uiuc.edu Wed Mar 2 01:05:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 01:05:08 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503020705.j22758sn031956@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.35 -> 1.36 --- Log message: Factor out some code. --- Diffs of the changes: (+13 -10) PointerCompress.cpp | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.35 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.36 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.35 Tue Mar 1 17:39:51 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Wed Mar 2 01:04:52 2005 @@ -172,6 +172,16 @@ /// Value *getPoolDesc() const { return PoolDesc; } + /// EmitPoolBaseLoad - Emit code to load the pool base value for this pool + /// before the specified instruction. + Value *EmitPoolBaseLoad(Instruction &I) const { + // Get the pool base pointer. + Constant *Zero = Constant::getNullValue(Type::UIntTy); + Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Zero, Zero, + "poolbaseptrptr", &I); + return new LoadInst(BasePtrPtr, "poolbaseptr", &I); + } + // dump - Emit a debugging dump of this pool info. void dump() const; @@ -668,12 +678,8 @@ // 1. Loading a normal value from a ptr compressed data structure. // 2. Loading a compressed ptr from a ptr compressed data structure. bool LoadingCompressedPtr = getNodeIfCompressed(&LI) != 0; - - // Get the pool base pointer. - Constant *Zero = Constant::getNullValue(Type::UIntTy); - Value *BasePtrPtr = new GetElementPtrInst(SrcPI->getPoolDesc(), Zero, Zero, - "poolbaseptrptr", &LI); - Value *BasePtr = new LoadInst(BasePtrPtr, "poolbaseptr", &LI); + + Value *BasePtr = SrcPI->EmitPoolBaseLoad(LI); // Get the pointer to load from. std::vector Ops; @@ -739,10 +745,7 @@ } // Get the pool base pointer. - Constant *Zero = Constant::getNullValue(Type::UIntTy); - Value *BasePtrPtr = new GetElementPtrInst(DestPI->getPoolDesc(), Zero, Zero, - "poolbaseptrptr", &SI); - Value *BasePtr = new LoadInst(BasePtrPtr, "poolbaseptr", &SI); + Value *BasePtr = DestPI->EmitPoolBaseLoad(SI); // Get the pointer to store to. std::vector Ops; From alkis at cs.uiuc.edu Wed Mar 2 03:49:13 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 2 Mar 2005 03:49:13 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java Message-ID: <200503020949.DAA22053@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: VirtualCall.java updated: 1.2 -> 1.3 --- Log message: Make this test a bit more interesting. --- Diffs of the changes: (+29 -20) VirtualCall.java | 49 +++++++++++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 20 deletions(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java:1.2 llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java:1.3 --- llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java:1.2 Sat Dec 11 17:31:49 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/VirtualCall.java Wed Mar 2 03:49:02 2005 @@ -1,28 +1,37 @@ -class VirtualCallBase +public class VirtualCall { - public int foo() { return 1; } - public int bar() { return 2; } -} + static class A + { + public void m1() { Test.println(1); m2(); m3(); } + public void m2() { Test.println(2); m3(); } + public void m3() { Test.println(3); } + } -class VirtualCallDerived extends VirtualCallBase -{ - public int foo() { return 100; } - public int bar() { return super.bar() + super.foo(); } -} + static class B extends A + { + public void m2() { Test.println(22); } + public void m3() { Test.println(33); } + } + + static class C extends B + { + public void m2() { Test.println(222); m3(); } + } -public class VirtualCall -{ public static void main(String[] args) { - VirtualCallBase a = new VirtualCallBase(); - Test.println(a.foo()); - Test.println(a.bar()); + A a = new A(); + a.m1(); + a.m2(); + a.m3(); - a = new VirtualCallDerived(); - Test.println(a.foo()); - Test.println(a.bar()); + a = new B(); + a.m1(); + a.m2(); + a.m3(); - VirtualCallDerived b = new VirtualCallDerived(); - Test.println(b.foo()); - Test.println(b.bar()); + a = new C(); + a.m1(); + a.m2(); + a.m3(); } } From alkis at cs.uiuc.edu Wed Mar 2 03:50:45 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 2 Mar 2005 03:50:45 -0600 Subject: [llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java Message-ID: <200503020950.DAA23711@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Programs/SingleSource/UnitTests: Arithm.java updated: 1.6 -> 1.7 --- Log message: Make this test a bit more interesting. --- Diffs of the changes: (+13 -3) Arithm.java | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) Index: llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java diff -u llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.6 llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.7 --- llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java:1.6 Sat Dec 11 17:31:49 2004 +++ llvm-java/test/Programs/SingleSource/UnitTests/Arithm.java Wed Mar 2 03:50:34 2005 @@ -1,9 +1,19 @@ public class Arithm { public static void main(String[] args) { - int one = 1; - int two = 2; + int i = 53; - Test.println((one + two) - (two * two) + (two / one) + (two % one) + (two << one) - (two >> 1) + (-two)); // = 2 + i += 53; + i *= 53; + i -= 53; + i >>= 3; + i /= 53; + i %= 53; + i = -i; + i <<= 3; + i |= 53; + i ^= 35; + i &= 53; + Test.println(i); } } From lattner at cs.uiuc.edu Wed Mar 2 09:46:50 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 09:46:50 -0600 Subject: [llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Message-ID: <200503021546.j22FkoC5000841@apoc.cs.uiuc.edu> Changes in directory llvm-test/MultiSource/Benchmarks/llubenchmark: llubenchmark.c updated: 1.4 -> 1.5 --- Log message: initialize memory, fixing this program's regression in the JIT last night. --- Diffs of the changes: (+1 -0) llubenchmark.c | 1 + 1 files changed, 1 insertion(+) Index: llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c diff -u llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.4 llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.5 --- llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c:1.4 Tue Mar 1 12:57:17 2005 +++ llvm-test/MultiSource/Benchmarks/llubenchmark/llubenchmark.c Wed Mar 2 09:46:34 2005 @@ -139,6 +139,7 @@ for (j = 0 ; j < num_lists ; j ++) { struct element *e = allocate(); e->next = lists[j]; + e->count = 0; lists[j] = e; } } From lattner at cs.uiuc.edu Wed Mar 2 10:00:41 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 10:00:41 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Message-ID: <200503021600.j22G0fIn001327@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.33 -> 1.34 --- Log message: Don't lazily create the pool slabs on the first allocation. This will break code like this: pooldesc PD; poolinit(&PD ...); void *Base = PD.Base; ... Because no allocation happens before the load of the pool base. --- Diffs of the changes: (+23 -26) FreeListAllocator.cpp | 49 +++++++++++++++++++++++-------------------------- 1 files changed, 23 insertions(+), 26 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.33 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.34 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.33 Tue Mar 1 23:46:59 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Wed Mar 2 10:00:28 2005 @@ -708,6 +708,27 @@ void poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { poolinit(Pool, NodeSize, ObjAlignment); Pool->isPtrCompPool = true; + + // Create the pool. We have to do this eagerly (instead of on the first + // allocation), because code may want to eagerly copy the pool base into a + // register. + + // If we already have a pool mmap'd, reuse it. + for (unsigned i = 0; i != 4; ++i) + if (Pools[i]) { + Pool->Slabs = Pools[i]; + Pools[i] = 0; + break; + } + + if (Pool->Slabs == 0) { + // Didn't find an existing pool, create one. + Pool->Slabs = (PoolSlab*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0); + DO_IF_TRACE(fprintf(stderr, "RESERVED ADDR SPACE: %p -> %p\n", + Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); + } + PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, POOLSIZE); } void pooldestroy_pc(PoolTy *Pool) { @@ -732,32 +753,8 @@ } unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes) { - if (Pool->Slabs == 0) - goto AllocPool; -Continue: - { - void *Result = poolalloc(Pool, NumBytes); - return (char*)Result-(char*)Pool->Slabs; - } - -AllocPool: - // This is the first allocation out of this pool. If we already have a pool - // mmapp'd, reuse it. - for (unsigned i = 0; i != 4; ++i) - if (Pools[i]) { - Pool->Slabs = Pools[i]; - Pools[i] = 0; - break; - } - if (Pool->Slabs == 0) { - // Didn't find an existing pool, create one. - Pool->Slabs = (PoolSlab*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0); - DO_IF_TRACE(fprintf(stderr, "RESERVED ADDR SPACE: %p -> %p\n", - Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); - } - PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, POOLSIZE); - goto Continue; + void *Result = poolalloc(Pool, NumBytes); + return (char*)Result-(char*)Pool->Slabs; } void poolfree_pc(PoolTy *Pool, unsigned long Node) { From lattner at cs.uiuc.edu Wed Mar 2 10:15:32 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 10:15:32 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h Message-ID: <200503021615.j22GFWxO002998@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.34 -> 1.35 PoolAllocator.h updated: 1.17 -> 1.18 --- Log message: Return the pool base from poolinit_pc. --- Diffs of the changes: (+4 -3) FreeListAllocator.cpp | 3 ++- PoolAllocator.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.34 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.35 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.34 Wed Mar 2 10:00:28 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Wed Mar 2 10:15:19 2005 @@ -705,7 +705,7 @@ static PoolSlab *Pools[4] = { 0, 0, 0, 0 }; -void poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { +void *poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { poolinit(Pool, NodeSize, ObjAlignment); Pool->isPtrCompPool = true; @@ -729,6 +729,7 @@ Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); } PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, POOLSIZE); + return Pool->Slabs; } void pooldestroy_pc(PoolTy *Pool) { Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.17 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.18 --- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.17 Tue Mar 1 22:51:35 2005 +++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h Wed Mar 2 10:15:19 2005 @@ -128,8 +128,8 @@ // Pointer Compression runtime library. Most of these are just wrappers // around the normal pool routines. - void poolinit_pc(PoolTy *Pool, unsigned NodeSize, - unsigned ObjAlignment); + void *poolinit_pc(PoolTy *Pool, unsigned NodeSize, + unsigned ObjAlignment); void pooldestroy_pc(PoolTy *Pool); unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes); void poolfree_pc(PoolTy *Pool, unsigned long Node); From lattner at cs.uiuc.edu Wed Mar 2 10:21:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 10:21:54 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503021621.j22GLsw3003407@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.36 -> 1.37 --- Log message: implement the pool base optimization, where we only load a pool base on entry to a function or right after poolinit (instead of at every load/store to the pool). --- Diffs of the changes: (+46 -11) PointerCompress.cpp | 57 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 46 insertions(+), 11 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.36 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.37 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.36 Wed Mar 2 01:04:52 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Wed Mar 2 10:21:41 2005 @@ -40,6 +40,9 @@ SmallIntCompress("compress-to-16-bits", cl::desc("Pointer compress data structures to 16 bit " "integers instead of 32-bit integers")); + cl::opt + DisablePoolBaseASR("disable-ptrcomp-poolbase-aggregation", + cl::desc("Don't optimize pool base loads")); Statistic<> NumCompressed("pointercompress", "Number of pools pointer compressed"); @@ -152,9 +155,10 @@ Value *PoolDesc; const Type *NewTy; unsigned NewSize; + mutable Value *PoolBase; public: CompressedPoolInfo(const DSNode *N, Value *PD) - : Pool(N), PoolDesc(PD), NewTy(0) {} + : Pool(N), PoolDesc(PD), NewTy(0), PoolBase(0) {} /// Initialize - When we know all of the pools in a function that are going /// to be compressed, initialize our state based on that data. @@ -174,13 +178,8 @@ /// EmitPoolBaseLoad - Emit code to load the pool base value for this pool /// before the specified instruction. - Value *EmitPoolBaseLoad(Instruction &I) const { - // Get the pool base pointer. - Constant *Zero = Constant::getNullValue(Type::UIntTy); - Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Zero, Zero, - "poolbaseptrptr", &I); - return new LoadInst(BasePtrPtr, "poolbaseptr", &I); - } + Value *EmitPoolBaseLoad(Instruction &I) const; + void setPoolBase(Value *PB) const { PoolBase = PB; } // dump - Emit a debugging dump of this pool info. void dump() const; @@ -235,6 +234,36 @@ } } +/// EmitPoolBaseLoad - Emit code to load the pool base value for this pool +/// before the specified instruction. +Value *CompressedPoolInfo::EmitPoolBaseLoad(Instruction &I) const { + if (DisablePoolBaseASR) { + assert(PoolBase == 0 && "Mixing and matching optimized vs not!"); + + // Get the pool base pointer. + Constant *Zero = Constant::getNullValue(Type::UIntTy); + Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Zero, Zero, + "poolbaseptrptr", &I); + return new LoadInst(BasePtrPtr, "poolbaseptr", &I); + } else { + // If this is a pool descriptor passed into the function, and this is the + // first use, emit a load of the pool base into the entry of the function. + if (PoolBase == 0 && (isa(PoolDesc) || + isa(PoolDesc))) { + BasicBlock::iterator IP = I.getParent()->getParent()->begin()->begin(); + while (isa(IP)) ++IP; + Constant *Zero = Constant::getNullValue(Type::UIntTy); + Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Zero, Zero, + "poolbaseptrptr", &I); + PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", &I); + } + + assert(PoolBase && "Mixing and matching optimized vs not!"); + return PoolBase; + } +} + + /// dump - Emit a debugging dump for this pool info. /// void CompressedPoolInfo::dump() const { @@ -778,7 +807,14 @@ Ops.push_back(ConstantUInt::get(Type::UIntTy, PI->getNewSize())); Ops.push_back(CI.getOperand(3)); // TODO: Compression could reduce the alignment restriction for the pool! - new CallInst(PtrComp.PoolInitPC, Ops, "", &CI); + Value *PB = new CallInst(PtrComp.PoolInitPC, Ops, "", &CI); + + if (!DisablePoolBaseASR) { // Load the pool base immediately. + PB->setName(CI.getOperand(1)->getName()+".poolbase"); + // Remember the pool base for this pool. + PI->setPoolBase(PB); + } + CI.eraseFromParent(); } @@ -1206,8 +1242,7 @@ const Type *VoidPtrTy = PointerType::get(Type::SByteTy); const Type *PoolDescPtrTy = PointerType::get(ArrayType::get(VoidPtrTy, 16)); - PoolInitPC = M.getOrInsertFunction("poolinit_pc", Type::VoidTy, - PoolDescPtrTy, + PoolInitPC = M.getOrInsertFunction("poolinit_pc", VoidPtrTy, PoolDescPtrTy, Type::UIntTy, Type::UIntTy, 0); PoolDestroyPC = M.getOrInsertFunction("pooldestroy_pc", Type::VoidTy, PoolDescPtrTy, 0); From lattner at cs.uiuc.edu Wed Mar 2 11:00:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 11:00:17 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-representation.h Message-ID: <200503021700.j22H0Heb004758@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-representation.h updated: 1.13 -> 1.14 --- Log message: reduce gcc warnings. --- Diffs of the changes: (+3 -3) llvm-representation.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-gcc/gcc/llvm-representation.h diff -u llvm-gcc/gcc/llvm-representation.h:1.13 llvm-gcc/gcc/llvm-representation.h:1.14 --- llvm-gcc/gcc/llvm-representation.h:1.13 Wed Feb 23 11:33:28 2005 +++ llvm-gcc/gcc/llvm-representation.h Wed Mar 2 11:00:02 2005 @@ -287,8 +287,8 @@ */ struct llvm_function *ForwardedFunction; - enum llvm_linkage Linkage : 4; - int MarkedNameUsed : 1; + ENUM_BITFIELD (llvm_linkage) Linkage : 4; + int MarkedNameUsed : 1; char *PrettyFunctionName; } llvm_function; @@ -310,7 +310,7 @@ llvm_constant *Init; /* Initializer or null for external */ int isConstant : 1; /* Is the global immutable? */ - enum llvm_linkage Linkage : 4; + ENUM_BITFIELD (llvm_linkage) Linkage : 4; int MarkedNameUsed : 1; /* ForwardedGlobal - This member is here only because we don't have a From lattner at cs.uiuc.edu Wed Mar 2 11:03:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 11:03:20 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-representation.h Message-ID: <200503021703.j22H3KqW005096@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-representation.h updated: 1.14 -> 1.15 --- Log message: don't break the build. --- Diffs of the changes: (+1 -0) llvm-representation.h | 1 + 1 files changed, 1 insertion(+) Index: llvm-gcc/gcc/llvm-representation.h diff -u llvm-gcc/gcc/llvm-representation.h:1.14 llvm-gcc/gcc/llvm-representation.h:1.15 --- llvm-gcc/gcc/llvm-representation.h:1.14 Wed Mar 2 11:00:02 2005 +++ llvm-gcc/gcc/llvm-representation.h Wed Mar 2 11:03:07 2005 @@ -27,6 +27,7 @@ #define GCC_LLVM_REPRESENTATION_H #include "config.h" +#include "system.h" #include "llvm-ilist.h" #include From alenhar2 at cs.uiuc.edu Wed Mar 2 11:21:51 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 2 Mar 2005 11:21:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Message-ID: <200503021721.j22HLpCQ005541@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaTargetMachine.cpp updated: 1.4 -> 1.5 --- Log message: Added LSR as a beta pass for alpha --- Diffs of the changes: (+9 -0) AlphaTargetMachine.cpp | 9 +++++++++ 1 files changed, 9 insertions(+) Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.4 llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.5 --- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.4 Tue Feb 1 14:34:54 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Wed Mar 2 11:21:38 2005 @@ -26,6 +26,12 @@ RegisterTarget X("alpha", " Alpha (incomplete)"); } +namespace llvm { + cl::opt EnableAlphaLSR("enable-lsr-for-alpha", + cl::desc("Enable LSR for Alpha (beta option!)"), + cl::Hidden); +} + unsigned AlphaTargetMachine::getModuleMatchQuality(const Module &M) { // We strongly match "alpha*". std::string TT = M.getTargetTriple(); @@ -54,6 +60,9 @@ bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { + if (EnableAlphaLSR) + PM.add(createLoopStrengthReducePass()); + // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); From alenhar2 at cs.uiuc.edu Wed Mar 2 11:23:16 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 2 Mar 2005 11:23:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200503021723.j22HNG2j005563@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.57 -> 1.58 --- Log message: remove 32 sign extend after 32 sextload and handle small negative constant --- Diffs of the changes: (+9 -4) AlphaISelPattern.cpp | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.57 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.58 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.57 Fri Feb 25 16:55:15 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Wed Mar 2 11:23:03 2005 @@ -1027,6 +1027,10 @@ } return Result; } + case ISD::SEXTLOAD: + //SelectionDag isn't deleting the signextend after sextloads + Reg = Result = SelectExpr(N.getOperand(0)); + return Result; default: break; //Fall Though; } } //Every thing else fall though too, including unhandled opcodes above @@ -1304,10 +1308,11 @@ BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addImm(Tmp2); } else if(N.getOperand(1).getOpcode() == ISD::Constant && - cast(N.getOperand(1))->getValue() <= 32767) - { //LDA //FIXME: expand the above condition a bit + (cast(N.getOperand(1))->getValue() <= 32767 || + (long)cast(N.getOperand(1))->getValue() >= -32767)) + { //LDA Tmp1 = SelectExpr(N.getOperand(0)); - Tmp2 = cast(N.getOperand(1))->getValue(); + Tmp2 = (long)cast(N.getOperand(1))->getValue(); if (!isAdd) Tmp2 = -Tmp2; BuildMI(BB, Alpha::LDA, 2, Result).addImm(Tmp2).addReg(Tmp1); @@ -1387,7 +1392,7 @@ { unsigned long val = cast(N)->getValue(); if (val < 32000 && (long)val > -32000) - BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm(val); + BuildMI(BB, Alpha::LOAD_IMM, 1, Result).addImm((long)val); else { MachineConstantPool *CP = BB->getParent()->getConstantPool(); ConstantUInt *C = ConstantUInt::get(Type::getPrimitiveType(Type::ULongTyID) , val); From alenhar2 at cs.uiuc.edu Wed Mar 2 11:24:53 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 2 Mar 2005 11:24:53 -0600 Subject: [llvm-commits] CVS: llvm-test/Makefile.programs Message-ID: <200503021724.j22HOrPb005587@apoc.cs.uiuc.edu> Changes in directory llvm-test: Makefile.programs updated: 1.148 -> 1.149 --- Log message: add lsr to alpha as llcbeta --- Diffs of the changes: (+4 -1) Makefile.programs | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm-test/Makefile.programs diff -u llvm-test/Makefile.programs:1.148 llvm-test/Makefile.programs:1.149 --- llvm-test/Makefile.programs:1.148 Wed Mar 2 00:23:52 2005 +++ llvm-test/Makefile.programs Wed Mar 2 11:24:39 2005 @@ -189,9 +189,12 @@ ifeq ($(ARCH),PowerPC) LLCBETAOPTION := -enable-lsr-for-ppc else +ifeq ($(ARCH),Alpha) +LLCBETAOPTION := -enable-lsr-for-alpha +else LLCBETAOPTION := -disable-pattern-isel=0 endif - +endif # Given a version of the entire program linked together into a single unit of # raw output from the C frontend, optimize it. From lattner at cs.uiuc.edu Wed Mar 2 12:39:40 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 12:39:40 -0600 Subject: [llvm-commits] CVS: llvm-www/img/PhotoRob.jpg Message-ID: <200503021839.j22IdegQ006347@apoc.cs.uiuc.edu> Changes in directory llvm-www/img: PhotoRob.jpg added (r1.1) --- Log message: add a picture of rob --- Diffs of the changes: (+0 -0) PhotoRob.jpg | 0 1 files changed Index: llvm-www/img/PhotoRob.jpg From bocchino at persephone.cs.uiuc.edu Wed Mar 2 12:54:58 2005 From: bocchino at persephone.cs.uiuc.edu (Robert L. Bocchino Jr.) Date: Wed, 2 Mar 2005 12:54:58 -0600 (CST) Subject: [llvm-commits] CVS: llvm-www/Developers.html Message-ID: <20050302185458.74286AE9A17@persephone.cs.uiuc.edu> Changes in directory llvm-www: Developers.html updated: 1.23 -> 1.24 --- Log message: Added my picture to developers page --- Diffs of the changes: (+21 -9) Developers.html | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions, 9 deletions Index: llvm-www/Developers.html diff -u llvm-www/Developers.html:1.23 llvm-www/Developers.html:1.24 --- llvm-www/Developers.html:1.23 Mon Feb 14 10:21:19 2005 +++ llvm-www/Developers.html Wed Mar 2 12:54:29 2005 @@ -25,6 +25,7 @@ Sabre + Nate Begeman @@ -36,50 +37,61 @@ tonic + + Rob Bocchino + Rob + + Misha Brukman Misha + + + Andrew Lenharth Andrew - - + John Criswell Dogbert + + + Duraid Madina camel_ - - - + Alkis Evlogimenos alkis + + + Reid Spencer Reid - - + Brian Gaeke brg + + Bill Wendling Bill - - + Brad Jones Changes in directory llvm-www: Developers.html updated: 1.24 -> 1.25 --- Log message: Fixed a bug in my last commit. --- Diffs of the changes: (+2 -2) Developers.html | 4 ++-- 1 files changed, 2 insertions, 2 deletions Index: llvm-www/Developers.html diff -u llvm-www/Developers.html:1.24 llvm-www/Developers.html:1.25 --- llvm-www/Developers.html:1.24 Wed Mar 2 12:54:29 2005 +++ llvm-www/Developers.html Wed Mar 2 12:57:44 2005 @@ -40,8 +40,8 @@ Rob Bocchino - Rob - + Rob + Misha Brukman From bocchino at persephone.cs.uiuc.edu Wed Mar 2 13:08:44 2005 From: bocchino at persephone.cs.uiuc.edu (Robert L. Bocchino Jr.) Date: Wed, 2 Mar 2005 13:08:44 -0600 (CST) Subject: [llvm-commits] CVS: llvm-www/Developers.html Message-ID: <20050302190844.E9D7DAE9A3E@persephone.cs.uiuc.edu> Changes in directory llvm-www: Developers.html updated: 1.25 -> 1.26 --- Log message: Fixed another bug. --- Diffs of the changes: (+25 -22) Developers.html | 47 +++++++++++++++++++++++++---------------------- 1 files changed, 25 insertions, 22 deletions Index: llvm-www/Developers.html diff -u llvm-www/Developers.html:1.25 llvm-www/Developers.html:1.26 --- llvm-www/Developers.html:1.25 Wed Mar 2 12:57:44 2005 +++ llvm-www/Developers.html Wed Mar 2 13:08:17 2005 @@ -11,7 +11,7 @@ Name Picture -   +   Name Picture @@ -21,9 +21,11 @@ vadve - Chris Lattner - - Sabre + Brad Jones + + KungFooMaster + @@ -32,10 +34,9 @@ Sampo - Tanya Lattner - - tonic - + Chris Lattner + + Sabre @@ -43,60 +44,62 @@ Rob + Tanya Lattner + + tonic + + + + Misha Brukman Misha - - - Andrew Lenharth Andrew + + + John Criswell Dogbert - - Duraid Madina camel_ + + + Alkis Evlogimenos alkis - - Reid Spencer Reid + - Brian Gaeke + + Brian Gaeke brg - Bill Wendling Bill - Brad Jones - - KungFooMaster - From lattner at cs.uiuc.edu Wed Mar 2 15:56:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 15:56:16 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200503022156.j22LuGAG007602@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.45 -> 1.46 --- Log message: cleanup the cfg after lsr --- Diffs of the changes: (+6 -2) PowerPCTargetMachine.cpp | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.45 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.46 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.45 Wed Mar 2 00:19:22 2005 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Wed Mar 2 15:56:00 2005 @@ -75,8 +75,10 @@ std::ostream &Out) { bool LP64 = (0 != dynamic_cast(this)); - if (EnablePPCLSR) + if (EnablePPCLSR) { PM.add(createLoopStrengthReducePass()); + PM.add(createCFGSimplificationPass()); + } // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); @@ -120,8 +122,10 @@ } void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { - if (EnablePPCLSR) + if (EnablePPCLSR) { PM.add(createLoopStrengthReducePass()); + PM.add(createCFGSimplificationPass()); + } // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); From lattner at cs.uiuc.edu Wed Mar 2 17:12:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 17:12:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200503022312.j22NCuc5008044@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.171 -> 1.172 --- Log message: Print the module ID as a comment. --- Diffs of the changes: (+6 -0) AsmWriter.cpp | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.171 llvm/lib/VMCore/AsmWriter.cpp:1.172 --- llvm/lib/VMCore/AsmWriter.cpp:1.171 Thu Feb 24 10:58:29 2005 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Mar 2 17:12:40 2005 @@ -765,6 +765,12 @@ void AssemblyWriter::printModule(const Module *M) { + if (!M->getModuleIdentifier().empty() && + // Don't print hte ID if it will start a new line (which would + // require a comment char before it). + M->getModuleIdentifier().find('\n') == std::string::npos) + Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n"; + switch (M->getEndianness()) { case Module::LittleEndian: Out << "target endian = little\n"; break; case Module::BigEndian: Out << "target endian = big\n"; break; From brukman at cs.uiuc.edu Wed Mar 2 17:17:42 2005 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed, 2 Mar 2005 17:17:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200503022317.RAA32583@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.172 -> 1.173 --- Log message: Fix the spelling of the word `the' --- Diffs of the changes: (+1 -1) AsmWriter.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.172 llvm/lib/VMCore/AsmWriter.cpp:1.173 --- llvm/lib/VMCore/AsmWriter.cpp:1.172 Wed Mar 2 17:12:40 2005 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Mar 2 17:17:31 2005 @@ -766,7 +766,7 @@ void AssemblyWriter::printModule(const Module *M) { if (!M->getModuleIdentifier().empty() && - // Don't print hte ID if it will start a new line (which would + // Don't print the ID if it will start a new line (which would // require a comment char before it). M->getModuleIdentifier().find('\n') == std::string::npos) Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n"; From lattner at cs.uiuc.edu Wed Mar 2 19:03:26 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 19:03:26 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200503030103.j2313Qjw010282@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.51 -> 1.52 --- Log message: Add an argument. --- Diffs of the changes: (+1 -1) Scalar.h | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.51 llvm/include/llvm/Transforms/Scalar.h:1.52 --- llvm/include/llvm/Transforms/Scalar.h:1.51 Sat Jan 8 11:21:39 2005 +++ llvm/include/llvm/Transforms/Scalar.h Wed Mar 2 19:03:10 2005 @@ -232,7 +232,7 @@ // This pass convert malloc and free instructions to %malloc & %free function // calls. // -FunctionPass *createLowerAllocationsPass(); +FunctionPass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false); //===----------------------------------------------------------------------===// // This pass converts SwitchInst instructions into a sequence of chained binary From lattner at cs.uiuc.edu Wed Mar 2 19:03:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 19:03:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerAllocations.cpp Message-ID: <200503030103.j2313upH010293@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerAllocations.cpp updated: 1.51 -> 1.52 --- Log message: Add an optional argument to lower to a specific constant value instead of to a "sizeof" expression. --- Diffs of the changes: (+14 -6) LowerAllocations.cpp | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.51 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.52 --- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.51 Mon Dec 13 14:00:02 2004 +++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp Wed Mar 2 19:03:43 2005 @@ -31,8 +31,10 @@ class LowerAllocations : public BasicBlockPass { Function *MallocFunc; // Functions in the module we are processing Function *FreeFunc; // Initialized by doInitialization + bool LowerMallocArgToInteger; public: - LowerAllocations() : MallocFunc(0), FreeFunc(0) {} + LowerAllocations(bool LowerToInt = false) + : MallocFunc(0), FreeFunc(0), LowerMallocArgToInteger(LowerToInt) {} virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); @@ -59,8 +61,8 @@ } // createLowerAllocationsPass - Interface to this file... -FunctionPass *llvm::createLowerAllocationsPass() { - return new LowerAllocations(); +FunctionPass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) { + return new LowerAllocations(LowerMallocArgToInteger); } @@ -95,7 +97,8 @@ BasicBlock::InstListType &BBIL = BB.getInstList(); - const Type *IntPtrTy = getAnalysis().getIntPtrType(); + const TargetData &TD = getAnalysis(); + const Type *IntPtrTy = TD.getIntPtrType(); // Loop over all of the instructions, looking for malloc or free instructions for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) { @@ -103,8 +106,13 @@ const Type *AllocTy = MI->getType()->getElementType(); // malloc(type) becomes sbyte *malloc(size) - Value *MallocArg = ConstantExpr::getCast(ConstantExpr::getSizeOf(AllocTy), - IntPtrTy); + Value *MallocArg; + if (LowerMallocArgToInteger) + MallocArg = ConstantUInt::get(Type::ULongTy, TD.getTypeSize(AllocTy)); + else + MallocArg = ConstantExpr::getSizeOf(AllocTy); + MallocArg = ConstantExpr::getCast(cast(MallocArg), IntPtrTy); + if (MI->isArrayAllocation()) { if (isa(MallocArg) && cast(MallocArg)->getRawValue() == 1) { From lattner at cs.uiuc.edu Wed Mar 2 19:05:05 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 19:05:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200503030105.j23155r4010355@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.225 -> 1.226 --- Log message: Do not lower malloc's to pass "sizeof" expressions like this: ltmp_0_7 = malloc(((unsigned )(&(((signed char (*)[784])/*NULL*/0)[1u])))); Instead, just emit the literal constant, like this: ltmp_0_7 = malloc(784u); This works around a bug in ICC 8.1 compiling the CBE generated code. :-( --- Diffs of the changes: (+1 -1) Writer.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.225 llvm/lib/Target/CBackend/Writer.cpp:1.226 --- llvm/lib/Target/CBackend/Writer.cpp:1.225 Mon Feb 28 13:36:15 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Wed Mar 2 19:04:50 2005 @@ -1720,7 +1720,7 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) { PM.add(createLowerGCPass()); - PM.add(createLowerAllocationsPass()); + PM.add(createLowerAllocationsPass(true)); PM.add(createLowerInvokePass()); PM.add(new CBackendNameAllUsedStructs()); PM.add(new CWriter(o, getIntrinsicLowering())); From lattner at cs.uiuc.edu Wed Mar 2 20:24:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 20:24:52 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Heuristic.h Message-ID: <200503030224.j232OqKL016923@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: Heuristic.cpp updated: 1.5 -> 1.6 Heuristic.h updated: 1.3 -> 1.4 --- Log message: Expose a new method, make sure to realize that uint64 and pointers are 64-bit aligned on 64-bit targets. --- Diffs of the changes: (+19 -3) Heuristic.cpp | 17 ++++++++++++++--- Heuristic.h | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.5 llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.6 --- llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.5 Sun Jan 30 17:51:25 2005 +++ llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Wed Mar 2 20:24:36 2005 @@ -61,8 +61,16 @@ /// Wants8ByteAlignment - FIXME: this is a complete hack for X86 right now. static bool Wants8ByteAlignment(const Type *Ty, unsigned Offs, const TargetData &TD) { - if (Ty == Type::DoubleTy && (Offs & 7) == 0) - return true; + if ((Offs & 7) == 0) { + // Doubles always want to be 8-byte aligned. + if (Ty == Type::DoubleTy) return true; + + // If we are on a 64-bit system, we want to align 8-byte integers and + // pointers. + if (TD.getTypeAlignment(Ty) == 8) + return true; + } + if (Ty->isPrimitiveType() || isa(Ty)) return false; @@ -82,7 +90,10 @@ return false; } - +unsigned Heuristic::getRecommendedAlignment(const Type *Ty, + const TargetData &TD) { + return Wants8ByteAlignment(Ty, 0, TD); +} /// getRecommendedAlignment - Return the recommended object alignment for this /// DSNode. Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.h diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.3 llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.4 --- llvm-poolalloc/lib/PoolAllocate/Heuristic.h:1.3 Sun Jan 30 17:51:25 2005 +++ llvm-poolalloc/lib/PoolAllocate/Heuristic.h Wed Mar 2 20:24:36 2005 @@ -25,6 +25,9 @@ class DSGraph; class DSNode; class PoolAllocate; + class TargetData; + class Type; + namespace PA { class Heuristic { protected: @@ -91,6 +94,8 @@ /// this DSNode. /// static unsigned getRecommendedAlignment(const DSNode *N); + static unsigned getRecommendedAlignment(const Type *Ty, + const TargetData &TD); /// create - This static ctor creates the heuristic, based on the command /// line argument to choose the heuristic. From lattner at cs.uiuc.edu Wed Mar 2 20:35:12 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 20:35:12 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503030235.j232ZCYK017794@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.37 -> 1.38 --- Log message: Pointer compression can reduce the alignment requirement of a pool. Note this. --- Diffs of the changes: (+5 -1) PointerCompress.cpp | 6 +++++- 1 files changed, 5 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.37 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.38 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.37 Wed Mar 2 10:21:41 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Wed Mar 2 20:34:57 2005 @@ -805,7 +805,11 @@ Ops.push_back(CI.getOperand(1)); // Transform to pass in the compressed size. Ops.push_back(ConstantUInt::get(Type::UIntTy, PI->getNewSize())); - Ops.push_back(CI.getOperand(3)); + + // Pointer compression can reduce the alignment restriction to 4 bytes from 8. + // Reevaluate the desired alignment. + Ops.push_back(ConstantUInt::get(Type::UIntTy, + PA::Heuristic::getRecommendedAlignment(PI->getNewType(), TD))); // TODO: Compression could reduce the alignment restriction for the pool! Value *PB = new CallInst(PtrComp.PoolInitPC, Ops, "", &CI); From lattner at cs.uiuc.edu Wed Mar 2 20:35:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 20:35:15 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Message-ID: <200503030235.j232ZFOE017801@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: Heuristic.cpp updated: 1.6 -> 1.7 --- Log message: Handle void -> 0. --- Diffs of the changes: (+4 -1) Heuristic.cpp | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.6 llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.7 --- llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.6 Wed Mar 2 20:24:36 2005 +++ llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Wed Mar 2 20:35:02 2005 @@ -92,6 +92,9 @@ unsigned Heuristic::getRecommendedAlignment(const Type *Ty, const TargetData &TD) { + if (Ty == Type::VoidTy) // Is this void or collapsed? + return 0; // No known alignment, let runtime decide. + return Wants8ByteAlignment(Ty, 0, TD); } @@ -101,7 +104,7 @@ unsigned Heuristic::getRecommendedAlignment(const DSNode *N) { if (N->getType() == Type::VoidTy) // Is this void or collapsed? return 0; // No known alignment, let runtime decide. - + const TargetData &TD = N->getParentGraph()->getTargetData(); // If there are no doubles on an 8-byte boundary in this structure, there is From lattner at cs.uiuc.edu Wed Mar 2 20:39:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 20:39:08 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Message-ID: <200503030239.j232d8JG018315@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: Heuristic.cpp updated: 1.7 -> 1.8 --- Log message: Right, use an alignment of 8/4, not 1/0 --- Diffs of the changes: (+1 -1) Heuristic.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp diff -u llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.7 llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.8 --- llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp:1.7 Wed Mar 2 20:35:02 2005 +++ llvm-poolalloc/lib/PoolAllocate/Heuristic.cpp Wed Mar 2 20:38:52 2005 @@ -95,7 +95,7 @@ if (Ty == Type::VoidTy) // Is this void or collapsed? return 0; // No known alignment, let runtime decide. - return Wants8ByteAlignment(Ty, 0, TD); + return Wants8ByteAlignment(Ty, 0, TD) ? 8 : 4; } /// getRecommendedAlignment - Return the recommended object alignment for this From lattner at cs.uiuc.edu Wed Mar 2 21:36:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 21:36:31 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h Message-ID: <200503030336.j233aVFI024858@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.35 -> 1.36 PoolAllocator.h updated: 1.18 -> 1.19 --- Log message: Convert the entire runtime library over to use templates which are instantiated on traits. The two traits classes are the normal pool traits and the compressed pool traits. The only behavioral difference between the two (so far) is that the compressed pool does not use a large array section. The difference between the two will grow soon, making this templating worthwhile. --- Diffs of the changes: (+244 -138) FreeListAllocator.cpp | 299 +++++++++++++++++++++++++++++++------------------- PoolAllocator.h | 83 +++++++++---- 2 files changed, 244 insertions(+), 138 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.35 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.36 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.35 Wed Mar 2 10:15:19 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Wed Mar 2 21:36:16 2005 @@ -40,7 +40,7 @@ #define PRINT_POOLDESTROY_STATS struct PoolID { - PoolTy *PD; + void *PD; unsigned ID; }; @@ -49,7 +49,7 @@ static unsigned NumPoolIDsAllocated = 0; static unsigned CurPoolID = 0; -static unsigned addPoolNumber(PoolTy *PD) { +static unsigned addPoolNumber(void *PD) { if (NumLivePools == NumPoolIDsAllocated) { NumPoolIDsAllocated = (10+NumPoolIDsAllocated)*2; PoolIDs = (PoolID*)realloc(PoolIDs, sizeof(PoolID)*NumPoolIDsAllocated); @@ -61,7 +61,7 @@ return CurPoolID; } -static unsigned getPoolNumber(PoolTy *PD) { +static unsigned getPoolNumber(void *PD) { if (PD == 0) return 1234567; for (unsigned i = 0; i != NumLivePools; ++i) if (PoolIDs[i].PD == PD) @@ -70,7 +70,7 @@ return 0; } -static unsigned removePoolNumber(PoolTy *PD) { +static unsigned removePoolNumber(void *PD) { for (unsigned i = 0; i != NumLivePools; ++i) if (PoolIDs[i].PD == PD) { unsigned PN = PoolIDs[i].ID; @@ -82,12 +82,12 @@ return 0; } -static void PrintPoolStats(PoolTy *Pool); +static void PrintPoolStats(void *Pool); +template static void PrintLivePoolInfo() { for (unsigned i = 0; i != NumLivePools; ++i) { - PoolTy *Pool = PoolIDs[i].PD; fprintf(stderr, "[%d] pool at exit ", PoolIDs[i].ID); - PrintPoolStats(Pool); + PrintPoolStats((PoolTy*)PoolIDs[i].PD); } } @@ -100,7 +100,8 @@ #define DO_IF_POOLDESTROY_STATS(X) X #define PRINT_NUM_POOLS -static void PrintPoolStats(PoolTy *Pool) { +template +static void PrintPoolStats(PoolTy *Pool) { fprintf(stderr, "(0x%X) BytesAlloc=%d NumObjs=%d" " AvgObjSize=%d NextAllocSize=%d DeclaredSize=%d\n", @@ -116,19 +117,22 @@ #ifdef PRINT_NUM_POOLS static unsigned PoolCounter = 0; static unsigned PoolsInited = 0; + +template static void PoolCountPrinter() { - DO_IF_TRACE(PrintLivePoolInfo()); + DO_IF_TRACE(PrintLivePoolInfo()); fprintf(stderr, "\n\n" "*** %d DYNAMIC POOLS INITIALIZED ***\n\n" "*** %d DYNAMIC POOLS ALLOCATED FROM ***\n\n", PoolsInited, PoolCounter); } +template static void InitPrintNumPools() { static bool Initialized = 0; if (!Initialized) { Initialized = 1; - atexit(PoolCountPrinter); + atexit(PoolCountPrinter); } } @@ -141,8 +145,11 @@ // PoolSlab implementation //===----------------------------------------------------------------------===// -static void AddNodeToFreeList(PoolTy *Pool, FreedNodeHeader *FreeNode) { - FreedNodeHeader **FreeList; + +template +static void AddNodeToFreeList(PoolTy *Pool, + FreedNodeHeader *FreeNode) { + FreedNodeHeader **FreeList; if (FreeNode->Header.Size == Pool->DeclaredSize) FreeList = &Pool->ObjFreeList; else @@ -155,7 +162,8 @@ FreeNode->Next->PrevP = &FreeNode->Next; } -static void UnlinkFreeNode(FreedNodeHeader *FNH) { +template +static void UnlinkFreeNode(FreedNodeHeader *FNH) { *FNH->PrevP = FNH->Next; if (FNH->Next) FNH->Next->PrevP = FNH->PrevP; @@ -165,56 +173,63 @@ // PoolSlab Structure - Hold multiple objects of the current node type. // Invariants: FirstUnused <= UsedEnd // +template struct PoolSlab { // Next - This link is used when we need to traverse the list of slabs in a // pool, for example, to destroy them all. - PoolSlab *Next; + PoolSlab *Next; public: - static void create(PoolTy *Pool, unsigned SizeHint); - static void *create_for_bp(PoolTy *Pool); - static void create_for_ptrcomp(PoolTy *Pool, void *Mem, unsigned Size); + static void create(PoolTy *Pool, unsigned SizeHint); + static void *create_for_bp(PoolTy *Pool); + static void create_for_ptrcomp(PoolTy *Pool, + void *Mem, unsigned Size); void destroy(); - PoolSlab *getNext() const { return Next; } + PoolSlab *getNext() const { return Next; } }; // create - Create a new (empty) slab and add it to the end of the Pools list. -void PoolSlab::create(PoolTy *Pool, unsigned SizeHint) { +template +void PoolSlab::create(PoolTy *Pool, unsigned SizeHint) { if (Pool->DeclaredSize == 0) { unsigned Align = Pool->Alignment; - if (SizeHint < sizeof(FreedNodeHeader)-sizeof(NodeHeader)) - SizeHint = sizeof(FreedNodeHeader)-sizeof(NodeHeader); - SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1); - SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader); + if (SizeHint < sizeof(FreedNodeHeader) - + sizeof(NodeHeader)) + SizeHint = sizeof(FreedNodeHeader) - + sizeof(NodeHeader); + SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1); + SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader); Pool->DeclaredSize = SizeHint; } unsigned Size = Pool->AllocSize; Pool->AllocSize <<= 1; Size = (Size+SizeHint-1) / SizeHint * SizeHint; - PoolSlab *PS = (PoolSlab*)malloc(Size+sizeof(PoolSlab) + sizeof(NodeHeader) + - sizeof(FreedNodeHeader)); + PoolSlab *PS = (PoolSlab*)malloc(Size+sizeof(PoolSlab) + + sizeof(NodeHeader) + + sizeof(FreedNodeHeader)); char *PoolBody = (char*)(PS+1); // If the Alignment is greater than the size of the FreedNodeHeader, skip over // some space so that the a "free pointer + sizeof(FreedNodeHeader)" is always // aligned. unsigned Alignment = Pool->Alignment; - if (Alignment > sizeof(FreedNodeHeader)) { - PoolBody += Alignment-sizeof(FreedNodeHeader); - Size -= Alignment-sizeof(FreedNodeHeader); + if (Alignment > sizeof(FreedNodeHeader)) { + PoolBody += Alignment-sizeof(FreedNodeHeader); + Size -= Alignment-sizeof(FreedNodeHeader); } // Add the body of the slab to the free list. - FreedNodeHeader *SlabBody = (FreedNodeHeader*)PoolBody; + FreedNodeHeader *SlabBody =(FreedNodeHeader*)PoolBody; SlabBody->Header.Size = Size; AddNodeToFreeList(Pool, SlabBody); // Make sure to add a marker at the end of the slab to prevent the coallescer // from trying to merge off the end of the page. - FreedNodeHeader *End = - (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader) + Size); + FreedNodeHeader *End = + (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader)+ + Size); End->Header.Size = ~0; // Looks like an allocated chunk // Add the slab to the list... @@ -223,7 +238,8 @@ } /// create_for_bp - This creates a slab for a bump-pointer pool. -void *PoolSlab::create_for_bp(PoolTy *Pool) { +template +void *PoolSlab::create_for_bp(PoolTy *Pool) { unsigned Size = Pool->AllocSize; Pool->AllocSize <<= 1; PoolSlab *PS = (PoolSlab*)malloc(Size+sizeof(PoolSlab)); @@ -232,7 +248,7 @@ PoolBody += 4; // No reason to start out unaligned. // Update the end pointer. - Pool->OtherFreeList = (FreedNodeHeader*)((char*)(PS+1)+Size); + Pool->OtherFreeList = (FreedNodeHeader*)((char*)(PS+1)+Size); // Add the slab to the list... PS->Next = Pool->Slabs; @@ -242,16 +258,20 @@ /// create_for_ptrcomp - Initialize a chunk of memory 'Mem' of size 'Size' for /// pointer compression. -void PoolSlab::create_for_ptrcomp(PoolTy *Pool, void *SMem, unsigned Size) { +template +void PoolSlab::create_for_ptrcomp(PoolTy *Pool, + void *SMem, unsigned Size) { if (Pool->DeclaredSize == 0) { unsigned Align = Pool->Alignment; - unsigned SizeHint = sizeof(FreedNodeHeader)-sizeof(NodeHeader); - SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1); - SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader); + unsigned SizeHint = sizeof(FreedNodeHeader) - + sizeof(NodeHeader); + SizeHint = SizeHint+sizeof(FreedNodeHeader)+(Align-1); + SizeHint = (SizeHint & ~(Align-1))-sizeof(FreedNodeHeader); Pool->DeclaredSize = SizeHint; } - Size -= sizeof(PoolSlab) + sizeof(NodeHeader) + sizeof(FreedNodeHeader); + Size -= sizeof(PoolSlab) + sizeof(NodeHeader) + + sizeof(FreedNodeHeader); PoolSlab *PS = (PoolSlab*)SMem; char *PoolBody = (char*)(PS+1); @@ -259,26 +279,28 @@ // some space so that the a "free pointer + sizeof(FreedNodeHeader)" is always // aligned. unsigned Alignment = Pool->Alignment; - if (Alignment > sizeof(FreedNodeHeader)) { - PoolBody += Alignment-sizeof(FreedNodeHeader); - Size -= Alignment-sizeof(FreedNodeHeader); + if (Alignment > sizeof(FreedNodeHeader)) { + PoolBody += Alignment-sizeof(FreedNodeHeader); + Size -= Alignment-sizeof(FreedNodeHeader); } // Add the body of the slab to the free list. - FreedNodeHeader *SlabBody = (FreedNodeHeader*)PoolBody; + FreedNodeHeader *SlabBody =(FreedNodeHeader*)PoolBody; SlabBody->Header.Size = Size; AddNodeToFreeList(Pool, SlabBody); // Make sure to add a marker at the end of the slab to prevent the coallescer // from trying to merge off the end of the page. - FreedNodeHeader *End = - (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader) + Size); + FreedNodeHeader *End = + (FreedNodeHeader*)(PoolBody + sizeof(NodeHeader) + + Size); End->Header.Size = ~0; // Looks like an allocated chunk PS->Next = 0; } -void PoolSlab::destroy() { +template +void PoolSlab::destroy() { free(this); } @@ -288,8 +310,8 @@ // //===----------------------------------------------------------------------===// -void poolinit_bp(PoolTy *Pool, unsigned ObjAlignment) { - DO_IF_PNP(memset(Pool, 0, sizeof(PoolTy))); +void poolinit_bp(PoolTy *Pool, unsigned ObjAlignment) { + DO_IF_PNP(memset(Pool, 0, sizeof(PoolTy))); Pool->Slabs = 0; if (ObjAlignment < 4) ObjAlignment = __alignof(double); Pool->AllocSize = INITIAL_SLAB_SIZE; @@ -301,10 +323,10 @@ DO_IF_TRACE(fprintf(stderr, "[%d] poolinit_bp(0x%X, %d)\n", addPoolNumber(Pool), Pool, ObjAlignment)); DO_IF_PNP(++PoolsInited); // Track # pools initialized - DO_IF_PNP(InitPrintNumPools()); + DO_IF_PNP(InitPrintNumPools()); } -void *poolalloc_bp(PoolTy *Pool, unsigned NumBytes) { +void *poolalloc_bp(PoolTy *Pool, unsigned NumBytes) { assert(Pool && "Bump pointer pool does not support null PD!"); DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc_bp(%d) -> ", getPoolNumber(Pool), NumBytes)); @@ -331,12 +353,12 @@ if (BumpPtr + NumBytes < EndPtr) { void *Result = BumpPtr; // Update bump ptr. - Pool->ObjFreeList = (FreedNodeHeader*)(BumpPtr+NumBytes); + Pool->ObjFreeList = (FreedNodeHeader*)(BumpPtr+NumBytes); DO_IF_TRACE(fprintf(stderr, "0x%X\n", Result)); return Result; } - BumpPtr = (char*)PoolSlab::create_for_bp(Pool); + BumpPtr = (char*)PoolSlab::create_for_bp(Pool); EndPtr = (char*)Pool->OtherFreeList; // Get our updated end pointer. goto TryAgain; @@ -352,16 +374,16 @@ return LAH+1; } -void pooldestroy_bp(PoolTy *Pool) { +void pooldestroy_bp(PoolTy *Pool) { assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy_bp", removePoolNumber(Pool))); DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // Free all allocated slabs. - PoolSlab *PS = Pool->Slabs; + PoolSlab *PS = Pool->Slabs; while (PS) { - PoolSlab *Next = PS->getNext(); + PoolSlab *Next = PS->getNext(); PS->destroy(); PS = Next; } @@ -385,9 +407,11 @@ // poolinit - Initialize a pool descriptor to empty // -void poolinit(PoolTy *Pool, unsigned DeclaredSize, unsigned ObjAlignment) { +template +static void poolinit_internal(PoolTy *Pool, + unsigned DeclaredSize, unsigned ObjAlignment) { assert(Pool && "Null pool pointer passed into poolinit!\n"); - memset(Pool, 0, sizeof(PoolTy)); + memset(Pool, 0, sizeof(PoolTy)); Pool->AllocSize = INITIAL_SLAB_SIZE; if (ObjAlignment < 4) ObjAlignment = __alignof(double); @@ -396,10 +420,14 @@ // Round the declared size up to an alignment boundary-header size, just like // we have to do for objects. if (DeclaredSize) { - if (DeclaredSize < sizeof(FreedNodeHeader)-sizeof(NodeHeader)) - DeclaredSize = sizeof(FreedNodeHeader)-sizeof(NodeHeader); - DeclaredSize = DeclaredSize+sizeof(FreedNodeHeader)+(ObjAlignment-1); - DeclaredSize = (DeclaredSize & ~(ObjAlignment-1))-sizeof(FreedNodeHeader); + if (DeclaredSize < sizeof(FreedNodeHeader) - + sizeof(NodeHeader)) + DeclaredSize = sizeof(FreedNodeHeader) - + sizeof(NodeHeader); + DeclaredSize = DeclaredSize+sizeof(FreedNodeHeader) + + (ObjAlignment-1); + DeclaredSize = (DeclaredSize & ~(ObjAlignment-1)) - + sizeof(FreedNodeHeader); } Pool->DeclaredSize = DeclaredSize; @@ -407,21 +435,26 @@ DO_IF_TRACE(fprintf(stderr, "[%d] poolinit(0x%X, %d, %d)\n", addPoolNumber(Pool), Pool, DeclaredSize, ObjAlignment)); DO_IF_PNP(++PoolsInited); // Track # pools initialized - DO_IF_PNP(InitPrintNumPools()); + DO_IF_PNP(InitPrintNumPools()); +} + +void poolinit(PoolTy *Pool, + unsigned DeclaredSize, unsigned ObjAlignment) { + poolinit_internal(Pool, DeclaredSize, ObjAlignment); } // pooldestroy - Release all memory allocated for a pool // -void pooldestroy(PoolTy *Pool) { +void pooldestroy(PoolTy *Pool) { assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy", removePoolNumber(Pool))); DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // Free all allocated slabs. - PoolSlab *PS = Pool->Slabs; + PoolSlab *PS = Pool->Slabs; while (PS) { - PoolSlab *Next = PS->getNext(); + PoolSlab *Next = PS->getNext(); PS->destroy(); PS = Next; } @@ -435,7 +468,8 @@ } } -void *poolalloc(PoolTy *Pool, unsigned NumBytes) { +template +static void *poolalloc_internal(PoolTy *Pool, unsigned NumBytes) { DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc(%d) -> ", getPoolNumber(Pool), NumBytes)); @@ -450,21 +484,25 @@ // Objects must be at least 8 bytes to hold the FreedNodeHeader object when // they are freed. This also handles allocations of 0 bytes. - if (NumBytes < (sizeof(FreedNodeHeader)-sizeof(NodeHeader))) - NumBytes = sizeof(FreedNodeHeader)-sizeof(NodeHeader); + if (NumBytes < (sizeof(FreedNodeHeader) - + sizeof(NodeHeader))) + NumBytes = sizeof(FreedNodeHeader) - + sizeof(NodeHeader); // Adjust the size so that memory allocated from the pool is always on the // proper alignment boundary. unsigned Alignment = Pool->Alignment; - NumBytes = NumBytes+sizeof(FreedNodeHeader)+(Alignment-1); // Round up - NumBytes = (NumBytes & ~(Alignment-1))-sizeof(FreedNodeHeader); // Truncate + NumBytes = NumBytes+sizeof(FreedNodeHeader) + + (Alignment-1); // Round up + NumBytes = (NumBytes & ~(Alignment-1)) - + sizeof(FreedNodeHeader); // Truncate DO_IF_PNP(++Pool->NumObjects); DO_IF_PNP(Pool->BytesAllocated += NumBytes); // Fast path - allocate objects off the object list. if (NumBytes == Pool->DeclaredSize && Pool->ObjFreeList != 0) { - FreedNodeHeader *Node = Pool->ObjFreeList; + FreedNodeHeader *Node = Pool->ObjFreeList; UnlinkFreeNode(Node); assert(NumBytes == Node->Header.Size); @@ -472,27 +510,30 @@ DO_IF_TRACE(fprintf(stderr, "0x%X\n", &Node->Header+1)); return &Node->Header+1; } - - if (NumBytes >= LARGE_SLAB_SIZE-sizeof(PoolSlab)-sizeof(NodeHeader) && - !Pool->isPtrCompPool) + + if (PoolTraits::UseLargeArrayObjects && + NumBytes >= LARGE_SLAB_SIZE-sizeof(PoolSlab) - + sizeof(NodeHeader)) goto LargeObject; // Fast path. In the common case, we can allocate a portion of the node at // the front of the free list. do { - FreedNodeHeader *FirstNode = Pool->OtherFreeList; + FreedNodeHeader *FirstNode = Pool->OtherFreeList; if (FirstNode) { unsigned FirstNodeSize = FirstNode->Header.Size; if (FirstNodeSize >= NumBytes) { - if (FirstNodeSize >= 2*NumBytes+sizeof(NodeHeader)) { + if (FirstNodeSize >= 2*NumBytes+sizeof(NodeHeader)) { // Put the remainder back on the list... - FreedNodeHeader *NextNodes = - (FreedNodeHeader*)((char*)FirstNode + sizeof(NodeHeader) +NumBytes); + FreedNodeHeader *NextNodes = + (FreedNodeHeader*)((char*)FirstNode + + sizeof(NodeHeader) +NumBytes); // Remove from list UnlinkFreeNode(FirstNode); - NextNodes->Header.Size = FirstNodeSize-NumBytes-sizeof(NodeHeader); + NextNodes->Header.Size = FirstNodeSize-NumBytes - + sizeof(NodeHeader); AddNodeToFreeList(Pool, NextNodes); } else { @@ -506,8 +547,8 @@ // Perform a search of the free list, taking the front of the first free // chunk that is big enough. - FreedNodeHeader **FN = &Pool->OtherFreeList; - FreedNodeHeader *FNN = FirstNode; + FreedNodeHeader **FN = &Pool->OtherFreeList; + FreedNodeHeader *FNN = FirstNode; // Search the list for the first-fit. while (FNN && FNN->Header.Size < NumBytes) @@ -517,13 +558,16 @@ // We found a slab big enough. If it's a perfect fit, just unlink // from the free list, otherwise, slice a little bit off and adjust // the free list. - if (FNN->Header.Size > 2*NumBytes+sizeof(NodeHeader)) { + if (FNN->Header.Size > 2*NumBytes+sizeof(NodeHeader)) { UnlinkFreeNode(FNN); // Put the remainder back on the list... - FreedNodeHeader *NextNodes = - (FreedNodeHeader*)((char*)FNN + sizeof(NodeHeader) + NumBytes); - NextNodes->Header.Size = FNN->Header.Size-NumBytes-sizeof(NodeHeader); + FreedNodeHeader *NextNodes = + (FreedNodeHeader*)((char*)FNN + + sizeof(NodeHeader) + + NumBytes); + NextNodes->Header.Size = FNN->Header.Size-NumBytes - + sizeof(NodeHeader); AddNodeToFreeList(Pool, NextNodes); } else { UnlinkFreeNode(FNN); @@ -537,7 +581,7 @@ // Oops, we didn't find anything on the free list big enough! Allocate // another slab and try again. - PoolSlab::create(Pool, NumBytes); + PoolSlab::create(Pool, NumBytes); } while (1); LargeObject: @@ -552,7 +596,8 @@ return LAH+1; } -void poolfree(PoolTy *Pool, void *Node) { +template +static void poolfree_internal(PoolTy *Pool, void *Node) { if (Node == 0) return; DO_IF_TRACE(fprintf(stderr, "[%d] poolfree(0x%X) ", getPoolNumber(Pool), Node)); @@ -566,7 +611,8 @@ } // Check to see how many elements were allocated to this node... - FreedNodeHeader *FNH = (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader)); + FreedNodeHeader *FNH = + (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader)); assert((FNH->Header.Size & 1) && "Node not allocated!"); unsigned Size = FNH->Header.Size & ~1; @@ -574,13 +620,13 @@ DO_IF_TRACE(fprintf(stderr, "%d bytes\n", Size)); // If the node immediately after this one is also free, merge it into node. - FreedNodeHeader *NextFNH; - NextFNH = (FreedNodeHeader*)((char*)Node+Size); + FreedNodeHeader *NextFNH; + NextFNH = (FreedNodeHeader*)((char*)Node+Size); while ((NextFNH->Header.Size & 1) == 0) { // Unlink NextFNH from the freelist that it is in. UnlinkFreeNode(NextFNH); - Size += sizeof(NodeHeader)+NextFNH->Header.Size; - NextFNH = (FreedNodeHeader*)((char*)Node+Size); + Size += sizeof(NodeHeader)+NextFNH->Header.Size; + NextFNH = (FreedNodeHeader*)((char*)Node+Size); } // If there are already nodes on the freelist, see if these blocks can be @@ -588,21 +634,23 @@ // a simple check that prevents many horrible forms of fragmentation, // particularly when freeing objects in allocation order. // - if (FreedNodeHeader *ObjFNH = Pool->ObjFreeList) - if ((char*)ObjFNH + sizeof(NodeHeader) + ObjFNH->Header.Size == (char*)FNH){ + if (FreedNodeHeader *ObjFNH = Pool->ObjFreeList) + if ((char*)ObjFNH + sizeof(NodeHeader) + + ObjFNH->Header.Size == (char*)FNH){ // Merge this with a node that is already on the object size free list. // Because the object is growing, we will never be able to find it if we // leave it on the object freelist. UnlinkFreeNode(ObjFNH); - ObjFNH->Header.Size += Size+sizeof(NodeHeader); + ObjFNH->Header.Size += Size+sizeof(NodeHeader); AddNodeToFreeList(Pool, ObjFNH); return; } - if (FreedNodeHeader *OFNH = Pool->OtherFreeList) - if ((char*)OFNH + sizeof(NodeHeader) + OFNH->Header.Size == (char*)FNH) { + if (FreedNodeHeader *OFNH = Pool->OtherFreeList) + if ((char*)OFNH + sizeof(NodeHeader) + + OFNH->Header.Size == (char*)FNH) { // Merge this with a node that is already on the object size free list. - OFNH->Header.Size += Size+sizeof(NodeHeader); + OFNH->Header.Size += Size+sizeof(NodeHeader); return; } @@ -619,7 +667,9 @@ free(LAH); } -void *poolrealloc(PoolTy *Pool, void *Node, unsigned NumBytes) { +template +static void *poolrealloc_internal(PoolTy *Pool, void *Node, + unsigned NumBytes) { DO_IF_TRACE(fprintf(stderr, "[%d] poolrealloc(0x%X, %d) -> ", getPoolNumber(Pool), Node, NumBytes)); @@ -637,7 +687,8 @@ return 0; } - FreedNodeHeader *FNH = (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader)); + FreedNodeHeader *FNH = + (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader)); assert((FNH->Header.Size & 1) && "Node not allocated!"); unsigned Size = FNH->Header.Size & ~1; if (Size != ~1U) { @@ -670,7 +721,7 @@ return NewLAH+1; } -unsigned poolobjsize(PoolTy *Pool, void *Node) { +unsigned poolobjsize(PoolTy *Pool, void *Node) { if (Node == 0) return 0; // If a null pool descriptor is passed in, this is not a pool allocated data @@ -682,7 +733,9 @@ } // Check to see how many bytes were allocated to this node. - FreedNodeHeader *FNH = (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader)); + FreedNodeHeader *FNH = + (FreedNodeHeader*)((char*)Node - + sizeof(NodeHeader)); assert((FNH->Header.Size & 1) && "Node not allocated!"); unsigned Size = FNH->Header.Size & ~1; if (Size != ~1U) return Size; @@ -692,6 +745,23 @@ return LAH->Size; } + +void *poolalloc(PoolTy *Pool, unsigned NumBytes) { + return poolalloc_internal(Pool, NumBytes); +} + + +void poolfree(PoolTy *Pool, void *Node) { + poolfree_internal(Pool, Node); +} + +void *poolrealloc(PoolTy *Pool, void *Node, + unsigned NumBytes) { + return poolrealloc_internal(Pool, Node, NumBytes); +} + + + //===----------------------------------------------------------------------===// // Pointer Compression runtime library. Most of these are just wrappers // around the normal pool routines. @@ -702,12 +772,12 @@ // Pools - When we are done with a pool, don't munmap it, keep it around for // next time. -static PoolSlab *Pools[4] = { 0, 0, 0, 0 }; +static PoolSlab *Pools[4] = { 0, 0, 0, 0 }; -void *poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment) { - poolinit(Pool, NodeSize, ObjAlignment); - Pool->isPtrCompPool = true; +void *poolinit_pc(PoolTy *Pool, + unsigned DeclaredSize, unsigned ObjAlignment) { + poolinit_internal(Pool, DeclaredSize, ObjAlignment); // Create the pool. We have to do this eagerly (instead of on the first // allocation), because code may want to eagerly copy the pool base into a @@ -723,16 +793,18 @@ if (Pool->Slabs == 0) { // Didn't find an existing pool, create one. - Pool->Slabs = (PoolSlab*)mmap(0, POOLSIZE, PROT_READ|PROT_WRITE, - MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0); + Pool->Slabs = (PoolSlab*) + mmap(0, POOLSIZE, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS, 0, 0); DO_IF_TRACE(fprintf(stderr, "RESERVED ADDR SPACE: %p -> %p\n", Pool->Slabs, (char*)Pool->Slabs+POOLSIZE)); } - PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, POOLSIZE); + PoolSlab::create_for_ptrcomp(Pool, Pool->Slabs, + POOLSIZE); return Pool->Slabs; } -void pooldestroy_pc(PoolTy *Pool) { +void pooldestroy_pc(PoolTy *Pool) { assert(Pool && "Null pool pointer passed in to pooldestroy!\n"); if (Pool->Slabs == 0) return; // no memory allocated from this pool. @@ -753,13 +825,14 @@ munmap(Pool->Slabs, POOLSIZE); } -unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes) { - void *Result = poolalloc(Pool, NumBytes); +unsigned long poolalloc_pc(PoolTy *Pool, + unsigned NumBytes) { + void *Result = poolalloc_internal(Pool, NumBytes); return (char*)Result-(char*)Pool->Slabs; } -void poolfree_pc(PoolTy *Pool, unsigned long Node) { - poolfree(Pool, (char*)Pool->Slabs+Node); +void poolfree_pc(PoolTy *Pool, unsigned long Node) { + poolfree_internal(Pool, (char*)Pool->Slabs+Node); } Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.18 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.19 --- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.18 Wed Mar 2 10:15:19 2005 +++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h Wed Mar 2 21:36:16 2005 @@ -10,26 +10,58 @@ // This file defines the interface which is implemented by the LLVM pool // allocator runtime library. // +// Note: Most of this runtime library is templated based on a PoolTraits +// instance. This allows the normal pool allocator to use standard pointers and +// long's to represent things, but allows the pointer compression runtime +// library use pool indexes which are smaller. Using smaller indexes reduces +// the minimum object size on a 64-bit system from 16 to 8 bytes, and reduces +// the object header size to 4 bytes (from 8). +// //===----------------------------------------------------------------------===// #ifndef POOLALLOCATOR_RUNTIME_H #define POOLALLOCATOR_RUNTIME_H +template struct PoolSlab; -struct FreedNodeHeader; + +// NormalPoolTraits - This describes normal pool allocation pools, which can +// address the entire heap, and are made out of multiple chunks of memory. The +// object header is a full machine word, and pointers into the heap are native +// pointers. +struct NormalPoolTraits { + typedef unsigned long NodeHeaderType; + enum { UseLargeArrayObjects = 1 }; +}; + + +// CompressedPoolTraits - This describes a statically pointer compressed pool, +// which is known to be <= 2^32 bytes in size (even on a 64-bit machine), and is +// made out of a single contiguous block. The meta-data to represent the pool +// uses 32-bit indexes from the start of the pool instead of full pointers to +// decrease the minimum object size. +struct CompressedPoolTraits { + typedef unsigned long NodeHeaderType; + + enum { UseLargeArrayObjects = 0 }; + +}; + // NodeHeader - Each block of memory is preceeded in the the pool by one of // these headers. +template struct NodeHeader { - unsigned long Size; + typename PoolTraits::NodeHeaderType Size; }; // When objects are on the free list, we pretend they have this header. +template struct FreedNodeHeader { // NormalHeader - This is the normal node header that is on allocated or free // blocks. - NodeHeader Header; + NodeHeader Header; // Next - The next object in the free list. FreedNodeHeader *Next; @@ -68,14 +100,15 @@ }; +template struct PoolTy { // Slabs - the list of slabs in this pool. NOTE: This must remain the first // memory of this structure for the pointer compression pass. - PoolSlab *Slabs; + PoolSlab *Slabs; // The free node lists for objects of various sizes. - FreedNodeHeader *ObjFreeList; - FreedNodeHeader *OtherFreeList; + FreedNodeHeader *ObjFreeList; + FreedNodeHeader *OtherFreeList; // Alignment - The required alignment of allocations the pool in bytes. unsigned Alignment; @@ -90,10 +123,6 @@ // The size to allocate for the next slab. unsigned AllocSize; - // isPtrCompPool - True if this pool must be kept consequtive for pointer - // compression. - bool isPtrCompPool; - // NumObjects - the number of poolallocs for this pool. unsigned NumObjects; @@ -103,36 +132,40 @@ }; extern "C" { - void poolinit(PoolTy *Pool, unsigned DeclaredSize, unsigned ObjAlignment); - void poolmakeunfreeable(PoolTy *Pool); - void pooldestroy(PoolTy *Pool); - void *poolalloc(PoolTy *Pool, unsigned NumBytes); - void *poolrealloc(PoolTy *Pool, void *Node, unsigned NumBytes); - void *poolmemalign(PoolTy *Pool, unsigned Alignment, unsigned NumBytes); - void poolfree(PoolTy *Pool, void *Node); + void poolinit(PoolTy *Pool, + unsigned DeclaredSize, unsigned ObjAlignment); + void poolmakeunfreeable(PoolTy *Pool); + void pooldestroy(PoolTy *Pool); + void *poolalloc(PoolTy *Pool, unsigned NumBytes); + void *poolrealloc(PoolTy *Pool, + void *Node, unsigned NumBytes); + void *poolmemalign(PoolTy *Pool, + unsigned Alignment, unsigned NumBytes); + void poolfree(PoolTy *Pool, void *Node); /// poolobjsize - Return the size of the object at the specified address, in /// the specified pool. Note that this cannot be used in normal cases, as it /// is completely broken if things land in the system heap. Perhaps in the /// future. :( /// - unsigned poolobjsize(PoolTy *Pool, void *Node); + unsigned poolobjsize(PoolTy *Pool, void *Node); // Bump pointer pool library. This is a pool implementation that does not // support frees or reallocs to the pool. As such, it can be much more // efficient and simpler than a general pool implementation. - void poolinit_bp(PoolTy *Pool, unsigned ObjAlignment); - void *poolalloc_bp(PoolTy *Pool, unsigned NumBytes); - void pooldestroy_bp(PoolTy *Pool); + void poolinit_bp(PoolTy *Pool, unsigned ObjAlignment); + void *poolalloc_bp(PoolTy *Pool, unsigned NumBytes); + void pooldestroy_bp(PoolTy *Pool); // Pointer Compression runtime library. Most of these are just wrappers // around the normal pool routines. - void *poolinit_pc(PoolTy *Pool, unsigned NodeSize, + void *poolinit_pc(PoolTy *Pool, unsigned NodeSize, unsigned ObjAlignment); - void pooldestroy_pc(PoolTy *Pool); - unsigned long poolalloc_pc(PoolTy *Pool, unsigned NumBytes); - void poolfree_pc(PoolTy *Pool, unsigned long Node); + void pooldestroy_pc(PoolTy *Pool); + unsigned long poolalloc_pc(PoolTy *Pool, + unsigned NumBytes); + void poolfree_pc(PoolTy *Pool, unsigned long Node); //void *poolmemalign_pc(PoolTy *Pool, unsigned Alignment, unsigned NumBytes); } From lattner at cs.uiuc.edu Wed Mar 2 22:49:48 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 2 Mar 2005 22:49:48 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h Message-ID: <200503030449.j234nmSv028273@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.36 -> 1.37 PoolAllocator.h updated: 1.19 -> 1.20 --- Log message: Now that we have templates, we can actually use them for something interesting. In particular, we make the following changes for pointer compressed pools (because we know they are contiguous and max 2^32 bytes): 1. The loop in poolalloc to allocate new chunks of memory is now no longer a loop. 2. NodeHeader is now a 4 byte object size instead of 8 bytes. 3. FreedNodeHeader now consists of two 4 byte indexes, instead of two pointers. On a 64-bit system, this shrinks the minimum object size from 16 bytes to 8 bytes. The code to manage the differences between normal pools (which use real pointers not indexes), and pointer compressed pools is all isolated to two small traits classes. --- Diffs of the changes: (+123 -32) FreeListAllocator.cpp | 95 +++++++++++++++++++++++++++++++++++++------------- PoolAllocator.h | 60 ++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 32 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.36 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.37 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.36 Wed Mar 2 21:36:16 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Wed Mar 2 22:49:32 2005 @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "PoolAllocator.h" -#include #include #include #include @@ -149,24 +148,47 @@ template static void AddNodeToFreeList(PoolTy *Pool, FreedNodeHeader *FreeNode) { - FreedNodeHeader **FreeList; + typename PoolTraits::FreeNodeHeaderPtrTy *FreeList; if (FreeNode->Header.Size == Pool->DeclaredSize) FreeList = &Pool->ObjFreeList; else FreeList = &Pool->OtherFreeList; - FreeNode->PrevP = FreeList; + void *PoolBase = Pool->Slabs; + + typename PoolTraits::FreeNodeHeaderPtrTy FreeNodeIdx = + PoolTraits::FNHPtrToIndex(FreeNode, PoolBase); + + FreeNode->Prev = 0; // First on the list. FreeNode->Next = *FreeList; - *FreeList = FreeNode; + *FreeList = FreeNodeIdx; if (FreeNode->Next) - FreeNode->Next->PrevP = &FreeNode->Next; + PoolTraits::IndexToFNHPtr(FreeNode->Next, PoolBase)->Prev = FreeNodeIdx; } template -static void UnlinkFreeNode(FreedNodeHeader *FNH) { - *FNH->PrevP = FNH->Next; +static void UnlinkFreeNode(PoolTy *Pool, + FreedNodeHeader *FNH) { + void *PoolBase = Pool->Slabs; + + // Make the predecessor point to our next node. + if (FNH->Prev) + PoolTraits::IndexToFNHPtr(FNH->Prev, PoolBase)->Next = FNH->Next; + else { + typename PoolTraits::FreeNodeHeaderPtrTy NodeIdx = + PoolTraits::FNHPtrToIndex(FNH, PoolBase); + + if (Pool->ObjFreeList == NodeIdx) + Pool->ObjFreeList = FNH->Next; + else { + assert(Pool->OtherFreeList == NodeIdx && + "Prev Ptr is null but not at head of free list?"); + Pool->OtherFreeList = FNH->Next; + } + } + if (FNH->Next) - FNH->Next->PrevP = FNH->PrevP; + PoolTraits::IndexToFNHPtr(FNH->Next, PoolBase)->Prev = FNH->Prev; } @@ -502,8 +524,11 @@ // Fast path - allocate objects off the object list. if (NumBytes == Pool->DeclaredSize && Pool->ObjFreeList != 0) { - FreedNodeHeader *Node = Pool->ObjFreeList; - UnlinkFreeNode(Node); + typename PoolTraits::FreeNodeHeaderPtrTy NodeIdx = Pool->ObjFreeList; + void *PoolBase = Pool->Slabs; + FreedNodeHeader *Node = + PoolTraits::IndexToFNHPtr(NodeIdx, PoolBase); + UnlinkFreeNode(Pool, Node); assert(NumBytes == Node->Header.Size); Node->Header.Size = NumBytes|1; // Mark as allocated @@ -519,7 +544,9 @@ // Fast path. In the common case, we can allocate a portion of the node at // the front of the free list. do { - FreedNodeHeader *FirstNode = Pool->OtherFreeList; + void *PoolBase = Pool->Slabs; + FreedNodeHeader *FirstNode = + PoolTraits::IndexToFNHPtr(Pool->OtherFreeList, PoolBase); if (FirstNode) { unsigned FirstNodeSize = FirstNode->Header.Size; if (FirstNodeSize >= NumBytes) { @@ -530,14 +557,14 @@ sizeof(NodeHeader) +NumBytes); // Remove from list - UnlinkFreeNode(FirstNode); + UnlinkFreeNode(Pool, FirstNode); NextNodes->Header.Size = FirstNodeSize-NumBytes - sizeof(NodeHeader); AddNodeToFreeList(Pool, NextNodes); } else { - UnlinkFreeNode(FirstNode); + UnlinkFreeNode(Pool, FirstNode); NumBytes = FirstNodeSize; } FirstNode->Header.Size = NumBytes|1; // Mark as allocated @@ -547,19 +574,25 @@ // Perform a search of the free list, taking the front of the first free // chunk that is big enough. - FreedNodeHeader **FN = &Pool->OtherFreeList; + typename PoolTraits::FreeNodeHeaderPtrTy *FN = &Pool->OtherFreeList; FreedNodeHeader *FNN = FirstNode; // Search the list for the first-fit. - while (FNN && FNN->Header.Size < NumBytes) - FN = &FNN->Next, FNN = *FN; + while (FNN && FNN->Header.Size < NumBytes) { + // Advance FN to point to the Next field of FNN. + FN = &FNN->Next; + + // Advance FNN to point to whatever the next node points to (null or the + // next node in the free list). + FNN = PoolTraits::IndexToFNHPtr(*FN, PoolBase); + } if (FNN) { // We found a slab big enough. If it's a perfect fit, just unlink // from the free list, otherwise, slice a little bit off and adjust // the free list. if (FNN->Header.Size > 2*NumBytes+sizeof(NodeHeader)) { - UnlinkFreeNode(FNN); + UnlinkFreeNode(Pool, FNN); // Put the remainder back on the list... FreedNodeHeader *NextNodes = @@ -570,7 +603,7 @@ sizeof(NodeHeader); AddNodeToFreeList(Pool, NextNodes); } else { - UnlinkFreeNode(FNN); + UnlinkFreeNode(Pool, FNN); NumBytes = FNN->Header.Size; } FNN->Header.Size = NumBytes|1; // Mark as allocated @@ -579,6 +612,12 @@ } } + // If we are not allowed to grow this pool, don't. + if (!PoolTraits::CanGrowPool) { + abort(); + return 0; + } + // Oops, we didn't find anything on the free list big enough! Allocate // another slab and try again. PoolSlab::create(Pool, NumBytes); @@ -624,7 +663,7 @@ NextFNH = (FreedNodeHeader*)((char*)Node+Size); while ((NextFNH->Header.Size & 1) == 0) { // Unlink NextFNH from the freelist that it is in. - UnlinkFreeNode(NextFNH); + UnlinkFreeNode(Pool, NextFNH); Size += sizeof(NodeHeader)+NextFNH->Header.Size; NextFNH = (FreedNodeHeader*)((char*)Node+Size); } @@ -634,25 +673,35 @@ // a simple check that prevents many horrible forms of fragmentation, // particularly when freeing objects in allocation order. // - if (FreedNodeHeader *ObjFNH = Pool->ObjFreeList) + if (Pool->ObjFreeList) { + void *PoolBase = Pool->Slabs; + FreedNodeHeader *ObjFNH = + PoolTraits::IndexToFNHPtr(Pool->ObjFreeList, PoolBase); + if ((char*)ObjFNH + sizeof(NodeHeader) + - ObjFNH->Header.Size == (char*)FNH){ + ObjFNH->Header.Size == (char*)FNH) { // Merge this with a node that is already on the object size free list. // Because the object is growing, we will never be able to find it if we // leave it on the object freelist. - UnlinkFreeNode(ObjFNH); + UnlinkFreeNode(Pool, ObjFNH); ObjFNH->Header.Size += Size+sizeof(NodeHeader); AddNodeToFreeList(Pool, ObjFNH); return; } + } + + if (Pool->OtherFreeList) { + void *PoolBase = Pool->Slabs; + FreedNodeHeader *OFNH = + PoolTraits::IndexToFNHPtr(Pool->OtherFreeList, PoolBase); - if (FreedNodeHeader *OFNH = Pool->OtherFreeList) if ((char*)OFNH + sizeof(NodeHeader) + OFNH->Header.Size == (char*)FNH) { // Merge this with a node that is already on the object size free list. OFNH->Header.Size += Size+sizeof(NodeHeader); return; } + } FNH->Header.Size = Size; AddNodeToFreeList(Pool, FNH); Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.19 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.20 --- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.19 Wed Mar 2 21:36:16 2005 +++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h Wed Mar 2 22:49:32 2005 @@ -22,8 +22,12 @@ #ifndef POOLALLOCATOR_RUNTIME_H #define POOLALLOCATOR_RUNTIME_H +#include + template struct PoolSlab; +template +struct FreedNodeHeader; // NormalPoolTraits - This describes normal pool allocation pools, which can // address the entire heap, and are made out of multiple chunks of memory. The @@ -31,7 +35,26 @@ // pointers. struct NormalPoolTraits { typedef unsigned long NodeHeaderType; - enum { UseLargeArrayObjects = 1 }; + enum { + UseLargeArrayObjects = 1, + CanGrowPool = 1, + }; + + // Pointers are just pointers. + typedef FreedNodeHeader* FreeNodeHeaderPtrTy; + + + /// DerefFNHPtr - Given an index into the pool, return a pointer to the + /// FreeNodeHeader object. + static FreedNodeHeader* + IndexToFNHPtr(FreeNodeHeaderPtrTy P, void *PoolBase) { + return P; + } + + static FreeNodeHeaderPtrTy + FNHPtrToIndex(FreedNodeHeader* FNHP, void *PoolBase) { + return FNHP; + } }; @@ -41,10 +64,28 @@ // uses 32-bit indexes from the start of the pool instead of full pointers to // decrease the minimum object size. struct CompressedPoolTraits { - typedef unsigned long NodeHeaderType; + typedef unsigned NodeHeaderType; - enum { UseLargeArrayObjects = 0 }; - + enum { + UseLargeArrayObjects = 0, + CanGrowPool = 0, + }; + + // Represent pointers with indexes from the pool base. + typedef unsigned FreeNodeHeaderPtrTy; + + /// DerefFNHPtr - Given an index into the pool, return a pointer to the + /// FreeNodeHeader object. + static FreedNodeHeader* + IndexToFNHPtr(FreeNodeHeaderPtrTy P, void *PoolBase) { + return (FreedNodeHeader*)((char*)PoolBase + P); + } + + static FreeNodeHeaderPtrTy + FNHPtrToIndex(FreedNodeHeader* FNHP, void *PoolBase) { + assert(FNHP && PoolBase && "Can't handle null FHNP!"); + return (char*)FNHP - (char*)PoolBase; + } }; @@ -64,10 +105,11 @@ NodeHeader Header; // Next - The next object in the free list. - FreedNodeHeader *Next; + typename PoolTraits::FreeNodeHeaderPtrTy Next; - // PrevP - The pointer that points to this node on the free list. - FreedNodeHeader **PrevP; + // Prev - The node that points to this node on the free list. This is null + // if it is the first node in one of the two free lists. + typename PoolTraits::FreeNodeHeaderPtrTy Prev; }; @@ -107,8 +149,8 @@ PoolSlab *Slabs; // The free node lists for objects of various sizes. - FreedNodeHeader *ObjFreeList; - FreedNodeHeader *OtherFreeList; + typename PoolTraits::FreeNodeHeaderPtrTy ObjFreeList; + typename PoolTraits::FreeNodeHeaderPtrTy OtherFreeList; // Alignment - The required alignment of allocations the pool in bytes. unsigned Alignment; From alenhar2 at cs.uiuc.edu Thu Mar 3 13:03:37 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 3 Mar 2005 13:03:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Message-ID: <200503031903.j23J3bPI032219@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaTargetMachine.cpp updated: 1.5 -> 1.6 --- Log message: LSR cleanup patch --- Diffs of the changes: (+3 -1) AlphaTargetMachine.cpp | 4 +++- 1 files changed, 3 insertions(+), 1 deletion(-) Index: llvm/lib/Target/Alpha/AlphaTargetMachine.cpp diff -u llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.5 llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.6 --- llvm/lib/Target/Alpha/AlphaTargetMachine.cpp:1.5 Wed Mar 2 11:21:38 2005 +++ llvm/lib/Target/Alpha/AlphaTargetMachine.cpp Thu Mar 3 13:03:21 2005 @@ -60,8 +60,10 @@ bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) { - if (EnableAlphaLSR) + if (EnableAlphaLSR) { PM.add(createLoopStrengthReducePass()); + PM.add(createCFGSimplificationPass()); + } // FIXME: Implement efficient support for garbage collection intrinsics. PM.add(createLowerGCPass()); From lattner at cs.uiuc.edu Thu Mar 3 15:12:20 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 3 Mar 2005 15:12:20 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200503032112.j23LCK4s001057@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.226 -> 1.227 --- Log message: Print -X like this: double test(double l1_X) { return (-l1_X); } instead of like this: double test(double l1_X) { return (-0x0p+0 - l1_X); } --- Diffs of the changes: (+30 -22) Writer.cpp | 52 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 30 insertions(+), 22 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.226 llvm/lib/Target/CBackend/Writer.cpp:1.227 --- llvm/lib/Target/CBackend/Writer.cpp:1.226 Wed Mar 2 19:04:50 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Thu Mar 3 15:12:04 2005 @@ -1358,30 +1358,38 @@ printType(Out, I.getType()); Out << ")("; } - - writeOperand(I.getOperand(0)); - switch (I.getOpcode()) { - case Instruction::Add: Out << " + "; break; - case Instruction::Sub: Out << " - "; break; - case Instruction::Mul: Out << '*'; break; - case Instruction::Div: Out << '/'; break; - case Instruction::Rem: Out << '%'; break; - case Instruction::And: Out << " & "; break; - case Instruction::Or: Out << " | "; break; - case Instruction::Xor: Out << " ^ "; break; - case Instruction::SetEQ: Out << " == "; break; - case Instruction::SetNE: Out << " != "; break; - case Instruction::SetLE: Out << " <= "; break; - case Instruction::SetGE: Out << " >= "; break; - case Instruction::SetLT: Out << " < "; break; - case Instruction::SetGT: Out << " > "; break; - case Instruction::Shl : Out << " << "; break; - case Instruction::Shr : Out << " >> "; break; - default: std::cerr << "Invalid operator type!" << I; abort(); - } + // If this is a negation operation, print it out as such. For FP, we don't + // want to print "-0.0 - X". + if (BinaryOperator::isNeg(&I)) { + Out << "-"; + writeOperand(BinaryOperator::getNegArgument(cast(&I))); + + } else { + writeOperand(I.getOperand(0)); - writeOperand(I.getOperand(1)); + switch (I.getOpcode()) { + case Instruction::Add: Out << " + "; break; + case Instruction::Sub: Out << " - "; break; + case Instruction::Mul: Out << '*'; break; + case Instruction::Div: Out << '/'; break; + case Instruction::Rem: Out << '%'; break; + case Instruction::And: Out << " & "; break; + case Instruction::Or: Out << " | "; break; + case Instruction::Xor: Out << " ^ "; break; + case Instruction::SetEQ: Out << " == "; break; + case Instruction::SetNE: Out << " != "; break; + case Instruction::SetLE: Out << " <= "; break; + case Instruction::SetGE: Out << " >= "; break; + case Instruction::SetLT: Out << " < "; break; + case Instruction::SetGT: Out << " > "; break; + case Instruction::Shl : Out << " << "; break; + case Instruction::Shr : Out << " >> "; break; + default: std::cerr << "Invalid operator type!" << I; abort(); + } + + writeOperand(I.getOperand(1)); + } if (needsCast) { Out << "))"; From alenhar2 at cs.uiuc.edu Thu Mar 3 15:48:06 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 3 Mar 2005 15:48:06 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp Message-ID: <200503032148.j23Lm6Nw001270@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.58 -> 1.59 --- Log message: beter Select on FP --- Diffs of the changes: (+67 -16) AlphaISelPattern.cpp | 83 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 67 insertions(+), 16 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.58 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.59 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.58 Wed Mar 2 11:23:03 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Thu Mar 3 15:47:53 2005 @@ -508,22 +508,73 @@ case ISD::SELECT: { - Tmp1 = SelectExpr(N.getOperand(0)); //Cond - Tmp2 = SelectExpr(N.getOperand(1)); //Use if TRUE - Tmp3 = SelectExpr(N.getOperand(2)); //Use if FALSE - - - // Spill the cond to memory and reload it from there. - unsigned Size = MVT::getSizeInBits(MVT::f64)/8; - MachineFunction *F = BB->getParent(); - int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); - unsigned Tmp4 = MakeReg(MVT::f64); - BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); - BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); - //now ideally, we don't have to do anything to the flag... - // Get the condition into the zero flag. - BuildMI(BB, Alpha::FCMOVEQ, 2, Result).addReg(Tmp2).addReg(Tmp3).addReg(Tmp4); - return Result; + //Tmp1 = SelectExpr(N.getOperand(0)); //Cond + unsigned TV = SelectExpr(N.getOperand(1)); //Use if TRUE + unsigned FV = SelectExpr(N.getOperand(2)); //Use if FALSE + + SDOperand CC = N.getOperand(0); + SetCCSDNode* SetCC = dyn_cast(CC.Val); + + if (CC.getOpcode() == ISD::SETCC && + !MVT::isInteger(SetCC->getOperand(0).getValueType())) + { //FP Setcc -> Select yay! + + + //for a cmp b: c = a - b; + //a = b: c = 0 + //a < b: c < 0 + //a > b: c > 0 + + bool invTest = false; + unsigned Tmp3; + + ConstantFPSDNode *CN; + if ((CN = dyn_cast(SetCC->getOperand(1))) + && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) + Tmp3 = SelectExpr(SetCC->getOperand(0)); + else if ((CN = dyn_cast(SetCC->getOperand(0))) + && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0))) + { + Tmp3 = SelectExpr(SetCC->getOperand(1)); + invTest = true; + } + else + { + unsigned Tmp1 = SelectExpr(SetCC->getOperand(0)); + unsigned Tmp2 = SelectExpr(SetCC->getOperand(1)); + bool isD = SetCC->getOperand(0).getValueType() == MVT::f64; + Tmp3 = MakeReg(isD ? MVT::f64 : MVT::f32); + BuildMI(BB, isD ? Alpha::SUBT : Alpha::SUBS, 2, Tmp3) + .addReg(Tmp1).addReg(Tmp2); + } + + switch (SetCC->getCondition()) { + default: CC.Val->dump(); assert(0 && "Unknown FP comparison!"); + case ISD::SETEQ: Opc = invTest ? Alpha::FCMOVNE : Alpha::FCMOVEQ; break; + case ISD::SETLT: Opc = invTest ? Alpha::FCMOVGT : Alpha::FCMOVLT; break; + case ISD::SETLE: Opc = invTest ? Alpha::FCMOVGE : Alpha::FCMOVLE; break; + case ISD::SETGT: Opc = invTest ? Alpha::FCMOVLT : Alpha::FCMOVGT; break; + case ISD::SETGE: Opc = invTest ? Alpha::FCMOVLE : Alpha::FCMOVGE; break; + case ISD::SETNE: Opc = invTest ? Alpha::FCMOVEQ : Alpha::FCMOVNE; break; + } + BuildMI(BB, Opc, 3, Result).addReg(TV).addReg(FV).addReg(Tmp3); + return Result; + } + else + { + Tmp1 = SelectExpr(N.getOperand(0)); //Cond + // Spill the cond to memory and reload it from there. + unsigned Size = MVT::getSizeInBits(MVT::f64)/8; + MachineFunction *F = BB->getParent(); + int FrameIdx = F->getFrameInfo()->CreateStackObject(Size, 8); + unsigned Tmp4 = MakeReg(MVT::f64); + BuildMI(BB, Alpha::STQ, 3).addReg(Tmp1).addFrameIndex(FrameIdx).addReg(Alpha::F31); + BuildMI(BB, Alpha::LDT, 2, Tmp4).addFrameIndex(FrameIdx).addReg(Alpha::F31); + //now ideally, we don't have to do anything to the flag... + // Get the condition into the zero flag. + BuildMI(BB, Alpha::FCMOVEQ, 3, Result).addReg(TV).addReg(FV).addReg(Tmp4); + return Result; + } } case ISD::FP_ROUND: From alenhar2 at cs.uiuc.edu Thu Mar 3 16:12:24 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Thu, 3 Mar 2005 16:12:24 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaInstrInfo.td Message-ID: <200503032212.j23MCOrG001462@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaInstrInfo.td updated: 1.27 -> 1.28 --- Log message: turn on IEEE for compares --- Diffs of the changes: (+4 -4) AlphaInstrInfo.td | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.27 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.28 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.27 Mon Feb 28 11:22:18 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Thu Mar 3 16:12:11 2005 @@ -247,10 +247,10 @@ def CMPULTi : OFormL<0x10, 0x1D, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "CMPULT $RA,$L,$RC">; //Compare unsigned quadword less than //Comparison, FP -def CMPTEQ : FPForm<0x16, 0x0A5, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmpteq $RA,$RB,$RC">; //Compare T_floating equal -def CMPTLE : FPForm<0x16, 0x0A7, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptle $RA,$RB,$RC">; //Compare T_floating less than or equal -def CMPTLT : FPForm<0x16, 0x0A6, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptlt $RA,$RB,$RC">; //Compare T_floating less than -def CMPTUN : FPForm<0x16, 0x0A4, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptun $RA,$RB,$RC">; //Compare T_floating unordered +def CMPTEQ : FPForm<0x16, 0x0A5, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmpteq/su $RA,$RB,$RC">; //Compare T_floating equal +def CMPTLE : FPForm<0x16, 0x0A7, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptle/su $RA,$RB,$RC">; //Compare T_floating less than or equal +def CMPTLT : FPForm<0x16, 0x0A6, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptlt/su $RA,$RB,$RC">; //Compare T_floating less than +def CMPTUN : FPForm<0x16, 0x0A4, (ops FPRC:$RC, FPRC:$RA, FPRC:$RB), "cmptun/su $RA,$RB,$RC">; //Compare T_floating unordered //There are in the Multimedia extentions, so let's not use them yet def MAXSB8 : OForm<0x1C, 0x3E, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "MAXSB8 $RA,$RB,$RC">; //Vector signed byte maximum From lattner at cs.uiuc.edu Thu Mar 3 21:35:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 3 Mar 2005 21:35:27 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/test/TEST.ptrcomp.Makefile TEST.ptrcomp.report Makefile Message-ID: <200503040335.j243ZRFb003227@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/test: TEST.ptrcomp.Makefile added (r1.1) TEST.ptrcomp.report added (r1.1) Makefile updated: 1.28 -> 1.29 --- Log message: Add a new pointer compression test and report --- Diffs of the changes: (+229 -0) Makefile | 6 ++ TEST.ptrcomp.Makefile | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ TEST.ptrcomp.report | 79 +++++++++++++++++++++++++++ 3 files changed, 229 insertions(+) Index: llvm-poolalloc/test/TEST.ptrcomp.Makefile diff -c /dev/null llvm-poolalloc/test/TEST.ptrcomp.Makefile:1.1 *** /dev/null Thu Mar 3 21:35:22 2005 --- llvm-poolalloc/test/TEST.ptrcomp.Makefile Thu Mar 3 21:35:11 2005 *************** *** 0 **** --- 1,144 ---- + ##===- poolalloc/test/TEST.ptrcomp.Makefile ----------------*- Makefile -*-===## + # + # This test runs the pool allocator and pointer compressor on all of the + # programs, producing some performance numbers and statistics. + # + ##===----------------------------------------------------------------------===## + + CFLAGS = -O2 -fno-strict-aliasing + + EXTRA_PA_FLAGS := + + CURDIR := $(shell cd .; pwd) + PROGDIR := $(shell cd $(LLVM_SRC_ROOT)/projects/llvm-test; pwd)/ + RELDIR := $(subst $(PROGDIR),,$(CURDIR)) + + # Pool allocator pass shared object + PA_SO := $(PROJECT_DIR)/Debug/lib/libpoolalloc$(SHLIBEXT) + + # Pool allocator runtime library + #PA_RT := $(PROJECT_DIR)/lib/Bytecode/libpoolalloc_fl_rt.bc + #PA_RT_O := $(PROJECT_DIR)/lib/$(CONFIGURATION)/poolalloc_rt.o + PA_RT_O := $(PROJECT_DIR)/Release/lib/poolalloc_rt.o + #PA_RT_O := $(PROJECT_DIR)/lib/Release/poolalloc_fl_rt.o + + # Command to run opt with the pool allocator pass loaded + OPT_PA := $(LOPT) -load $(PA_SO) + + # OPT_PA_STATS - Run opt with the -stats and -time-passes options, capturing the + # output to a file. + OPT_PA_STATS = $(OPT_PA) -info-output-file=$(CURDIR)/$@.info -stats -time-passes + + OPTZN_PASSES := -globaldce -ipsccp -deadargelim -adce -instcombine -simplifycfg + + + # This rule runs the pool allocator on the .llvm.bc file to produce a new .bc + # file + $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).poolalloc.bc): \ + Output/%.$(TEST).poolalloc.bc: Output/%.llvm.bc $(PA_SO) $(LOPT) + - at rm -f $(CURDIR)/$@.info + -$(OPT_PA_STATS) -poolalloc $(EXTRA_PA_FLAGS) $(OPTZN_PASSES) $< -o $@ -f 2>&1 > $@.out + + $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).ptrcomp64.bc): \ + Output/%.$(TEST).ptrcomp64.bc: Output/%.llvm.bc $(PA_SO) $(LOPT) + - at rm -f $(CURDIR)/$@.info + -$(OPT_PA_STATS) -pointercompress $(OPTZN_PASSES) $< -o $@ -f 2>&1 > $@.out + + # This rule compiles the new .bc file into a .c file using CBE + $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.cbe.c): \ + Output/%.poolalloc.cbe.c: Output/%.$(TEST).poolalloc.bc $(LLC) + -$(LLC) -march=c -f $< -o $@ + + $(PROGRAMS_TO_TEST:%=Output/%.ptrcomp64.cbe.c): \ + Output/%.ptrcomp64.cbe.c: Output/%.$(TEST).ptrcomp64.bc $(LLC) + -$(LLC) -march=c -f $< -o $@ + + + + $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.cbe): \ + Output/%.poolalloc.cbe: Output/%.poolalloc.cbe.c $(PA_RT_O) + -$(CC) $(CFLAGS) $< $(PA_RT_O) $(LLCLIBS) $(LDFLAGS) -o $@ + + $(PROGRAMS_TO_TEST:%=Output/%.ptrcomp64.cbe): \ + Output/%.ptrcomp64.cbe: Output/%.ptrcomp64.cbe.c $(PA_RT_O) + -$(CC) $(CFLAGS) $< $(PA_RT_O) $(LLCLIBS) $(LDFLAGS) -o $@ + + + ifndef PROGRAMS_HAVE_CUSTOM_RUN_RULES + + # This rule runs the generated executable, generating timing information, for + # normal test programs + $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.out-cbe): \ + Output/%.poolalloc.out-cbe: Output/%.poolalloc.cbe + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) + + $(PROGRAMS_TO_TEST:%=Output/%.ptrcomp64.out-cbe): \ + Output/%.ptrcomp64.out-cbe: Output/%.ptrcomp64.cbe + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) + + else + + # This rule runs the generated executable, generating timing information, for + # SPEC + $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.out-cbe): \ + Output/%.poolalloc.out-cbe: Output/%.poolalloc.cbe + -$(SPEC_SANDBOX) poolalloccbe-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/poolalloccbe-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/poolalloccbe-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + $(PROGRAMS_TO_TEST:%=Output/%.ptrcomp64.out-cbe): \ + Output/%.ptrcomp64.out-cbe: Output/%.ptrcomp64.cbe + -$(SPEC_SANDBOX) ptrcomp64cbe-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/ptrcomp64cbe-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/ptrcomp64cbe-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + + endif + + + # This rule diffs the post-poolallocated version to make sure we didn't break + # the program! + $(PROGRAMS_TO_TEST:%=Output/%.poolalloc.diff-cbe): \ + Output/%.poolalloc.diff-cbe: Output/%.out-nat Output/%.poolalloc.out-cbe + @cp Output/$*.out-nat Output/$*.poolalloc.out-nat + -$(DIFFPROG) cbe $*.poolalloc $(HIDEDIFF) + + $(PROGRAMS_TO_TEST:%=Output/%.ptrcomp64.diff-cbe): \ + Output/%.ptrcomp64.diff-cbe: Output/%.out-nat Output/%.ptrcomp64.out-cbe + @cp Output/$*.out-nat Output/$*.ptrcomp64.out-nat + -$(DIFFPROG) cbe $*.ptrcomp64 $(HIDEDIFF) + + + # This rule wraps everything together to build the actual output the report is + # generated from. + $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).report.txt): \ + Output/%.$(TEST).report.txt: Output/%.out-nat \ + Output/%.poolalloc.diff-cbe \ + Output/%.ptrcomp64.diff-cbe \ + Output/%.LOC.txt + @echo > $@ + @-if test -f Output/$*.ptrcomp64.diff-cbe; then \ + printf "CBE-RUN-TIME-PTRCOMP64: " >> $@;\ + grep "^program" Output/$*.ptrcomp64.out-cbe.time >> $@;\ + fi + @-if test -f Output/$*.poolalloc.diff-cbe; then \ + printf "CBE-RUN-TIME-POOLALLOC: " >> $@;\ + grep "^program" Output/$*.poolalloc.out-cbe.time >> $@;\ + fi + printf "LOC: " >> $@ + cat Output/$*.LOC.txt >> $@ + @cat Output/$*.$(TEST).ptrcomp64.bc.info >> $@ + @#cat Output/$*.$(TEST).ptrcomp64.bc.out >> $@ + + + $(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ + test.$(TEST).%: Output/%.$(TEST).report.txt + @echo "---------------------------------------------------------------" + @echo ">>> ========= '$(RELDIR)/$*' Program" + @echo "---------------------------------------------------------------" + @cat $< + + REPORT_DEPENDENCIES := $(PA_RT_O) $(PA_SO) $(PROGRAMS_TO_TEST:%=Output/%.llvm.bc) $(LLC) $(LOPT) Index: llvm-poolalloc/test/TEST.ptrcomp.report diff -c /dev/null llvm-poolalloc/test/TEST.ptrcomp.report:1.1 *** /dev/null Thu Mar 3 21:35:27 2005 --- llvm-poolalloc/test/TEST.ptrcomp.report Thu Mar 3 21:35:12 2005 *************** *** 0 **** --- 1,79 ---- + ##=== TEST.ptrcomp.report - Report description for ptrcomp -----*- perl -*-===## + # + # This file defines a report to be generated for the pointer compression tests. + # + ##===----------------------------------------------------------------------===## + + # Sort by program name + $SortCol = 0; + $TrimRepeatedPrefix = 1; + + # FormatTime - Convert a time from 1m23.45 into 83.45 + sub FormatTime { + my $Time = shift; + if ($Time =~ m/([0-9]+)[m:]([0-9.]+)/) { + return sprintf("%7.3f", $1*60.0+$2); + } + + return sprintf("%6.2f", $Time); + } + + + sub RuntimePercent { + my ($Cols, $Col) = @_; + if ($Cols->[$Col-1] ne "*" and $Cols->[3] ne "*" and + $Cols->[3] != "0") { + return sprintf "%7.2f", 100*$Cols->[$Col-1]/$Cols->[3]; + } else { + return "n/a"; + } + } + + @LatexColumns = (1, 5, 8, 12, 9, 13, 14, 15, 2, 16); + + my $FREEBENCH = 'MultiSource/Benchmarks/FreeBench'; + my $PTRDIST = 'MultiSource/Benchmarks/Ptrdist'; + + @LatexRowMapOrder = ( + "anagram/anagram" => 'anagram', + "bc/bc" => 'bc', + "ft/ft" => 'ft', + "ks/ks" => 'ks', + "yacr2/yacr2" => 'yacr2', + '-' => '-', + '164.gzip/164.gzip' => '164.gzip', + '175.vpr/175.vpr' => '175.vpr', + '181.mcf/181.mcf' => '181.mcf', + '186.crafty/186.crafty' => '186.crafty', + '197.parser/197.parser' => '197.parser', + '197.parser.hacked/197.parser.hacked' => '197.parser(b)', + '255.vortex/255.vortex' => '255.vortex', + '256.bzip2/256.bzip2' => '256.bzip2', + '300.twolf/300.twolf' => '300.twolf', + '-' => '-', + "analyzer" => 'analyzer', + "llu" => 'llu-bench', + ); + + + # These are the columns for the report. The first entry is the header for the + # column, the second is the regex to use to match the value. Empty list create + # seperators, and closures may be put in for custom processing. + ( + # Name + ["Name:" , '\'([^\']+)\' Program'], + ["LOC" , 'LOC:\s*([0-9]+)'], + [], + # Times + ["PA Time", 'CBE-RUN-TIME-POOLALLOC: program\s*([.0-9m:]+)', \&FormatTime], + ["PC Time", 'CBE-RUN-TIME-PTRCOMP64: program\s*([.0-9m:]+)', \&FormatTime], + ["AN run%", \&RuntimePercent], + [], + ["NumPools", '([0-9]+).*Number of pools allocated'], + ["Typesafe", '([0-9]+).*Number of typesafe pools'], + ["BumpPtr", '([0-9]+).*Number of bump pointer pools'], + ["NumArgs", '([0-9]+).*Number of function arguments added'], + #["Nonprofit", '([0-9]+).*Number of DSNodes not profitable'], + [] + ); + Index: llvm-poolalloc/test/Makefile diff -u llvm-poolalloc/test/Makefile:1.28 llvm-poolalloc/test/Makefile:1.29 --- llvm-poolalloc/test/Makefile:1.28 Fri Feb 4 14:21:27 2005 +++ llvm-poolalloc/test/Makefile Thu Mar 3 21:35:11 2005 @@ -146,6 +146,12 @@ GET_STABLE_NUMBERS=1 report report.html) @printf "\a"; sleep 1; printf "\a"; sleep 1; printf "\a" +ptrcomp:: + (cd $(LLVM_OBJ_ROOT)/projects/llvm-test/$(SUBDIR); \ + PROJECT_DIR=$(PROJ_OBJ_ROOT) $(MAKE) -j1 TEST=ptrcomp \ + GET_STABLE_NUMBERS=1 report report.html) + @printf "\a"; sleep 1; printf "\a"; sleep 1; printf "\a" + vtl:: (cd $(LLVM_OBJ_ROOT)/projects/llvm-test/$(SUBDIR); \ PROJECT_DIR=$(PROJ_OBJ_ROOT) $(MAKE) -j1 TEST=pavtl \ From jeffc at jolt-lang.org Thu Mar 3 22:04:37 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Thu, 3 Mar 2005 22:04:37 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Scalar.h Message-ID: <200503040404.WAA03497@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: Scalar.h updated: 1.52 -> 1.53 --- Log message: Add support for not strength reducing GEPs where the element size is a small power of two. This emphatically includes the zeroeth power of two. --- Diffs of the changes: (+5 -2) Scalar.h | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm/include/llvm/Transforms/Scalar.h diff -u llvm/include/llvm/Transforms/Scalar.h:1.52 llvm/include/llvm/Transforms/Scalar.h:1.53 --- llvm/include/llvm/Transforms/Scalar.h:1.52 Wed Mar 2 19:03:10 2005 +++ llvm/include/llvm/Transforms/Scalar.h Thu Mar 3 22:04:26 2005 @@ -129,9 +129,12 @@ //===----------------------------------------------------------------------===// // // LoopStrengthReduce - This pass is strength reduces GEP instructions that use -// a loop's canonical induction variable as one of their indices. +// a loop's canonical induction variable as one of their indices. The +// MaxTargetAMSize is the largest element size that the target architecture +// can handle in its addressing modes. Power of two multipliers less than or +// equal to this value are not reduced. // -FunctionPass *createLoopStrengthReducePass(); +FunctionPass *createLoopStrengthReducePass(unsigned MaxTargetAMSize = 1); //===----------------------------------------------------------------------===// // From jeffc at jolt-lang.org Thu Mar 3 22:04:37 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Thu, 3 Mar 2005 22:04:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503040404.WAA03493@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.5 -> 1.6 --- Log message: Add support for not strength reducing GEPs where the element size is a small power of two. This emphatically includes the zeroeth power of two. --- Diffs of the changes: (+25 -2) LoopStrengthReduce.cpp | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.5 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.6 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.5 Mon Feb 28 21:46:11 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Thu Mar 3 22:04:26 2005 @@ -22,10 +22,12 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Type.h" +#include "llvm/DerivedTypes.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Target/TargetData.h" #include "llvm/ADT/Statistic.h" #include using namespace llvm; @@ -37,7 +39,12 @@ LoopInfo *LI; DominatorSet *DS; bool Changed; + unsigned MaxTargetAMSize; public: + LoopStrengthReduce(unsigned MTAMS = 1) + : MaxTargetAMSize(MTAMS) { + } + virtual bool runOnFunction(Function &) { LI = &getAnalysis(); DS = &getAnalysis(); @@ -53,6 +60,7 @@ AU.addRequiredID(LoopSimplifyID); AU.addRequired(); AU.addRequired(); + AU.addRequired(); } private: void runOnLoop(Loop *L); @@ -65,8 +73,8 @@ "Strength Reduce GEP Uses of Ind. Vars"); } -FunctionPass *llvm::createLoopStrengthReducePass() { - return new LoopStrengthReduce(); +FunctionPass *llvm::createLoopStrengthReducePass(unsigned MaxTargetAMSize) { + return new LoopStrengthReduce(MaxTargetAMSize); } /// DeleteTriviallyDeadInstructions - If any of the instructions is the @@ -104,6 +112,7 @@ unsigned indvar = 0; std::vector pre_op_vector; std::vector inc_op_vector; + const Type *ty = GEPI->getOperand(0)->getType(); Value *CanonicalIndVar = L->getCanonicalInductionVariable(); BasicBlock *Header = L->getHeader(); BasicBlock *Preheader = L->getLoopPreheader(); @@ -111,6 +120,14 @@ for (unsigned op = 1, e = GEPI->getNumOperands(); op != e; ++op) { Value *operand = GEPI->getOperand(op); + if (ty->getTypeID() == Type::StructTyID) { + assert(isa(operand)); + ConstantUInt *c = dyn_cast(operand); + ty = ty->getContainedType(unsigned(c->getValue())); + } else { + ty = ty->getContainedType(0); + } + if (operand == CanonicalIndVar) { // FIXME: use getCanonicalInductionVariableIncrement to choose between // one and neg one maybe? We need to support int *foo = GEP base, -1 @@ -139,6 +156,12 @@ if (Instruction *GepPtrOp = dyn_cast(GEPI->getOperand(0))) if (!DS->dominates(GepPtrOp, Preheader->getTerminator())) return; + + // Don't reduced multiplies that the target can handle via addressing modes. + uint64_t sz = getAnalysis().getTypeSize(ty); + for (unsigned i = 1; i <= MaxTargetAMSize; i *= 2) + if (i == sz) + return; // If all operands of the GEP we are going to insert into the preheader // are constants, generate a GEP ConstantExpr instead. From lattner at cs.uiuc.edu Thu Mar 3 22:32:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 3 Mar 2005 22:32:46 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503040432.j244Wkfh005920@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.39 -> 1.40 --- Log message: We went through all the trouble to figure out the proper place to insert this instruction, why not use it? --- Diffs of the changes: (+2 -2) PointerCompress.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.39 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.40 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.39 Thu Mar 3 21:44:47 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Thu Mar 3 22:32:30 2005 @@ -255,8 +255,8 @@ while (isa(IP)) ++IP; Constant *Zero = Constant::getNullValue(Type::UIntTy); Value *BasePtrPtr = new GetElementPtrInst(getPoolDesc(), Zero, Zero, - "poolbaseptrptr", &I); - PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", &I); + "poolbaseptrptr", IP); + PoolBase = new LoadInst(BasePtrPtr, "poolbaseptr", IP); } assert(PoolBase && "Mixing and matching optimized vs not!"); From alenhar2 at cs.uiuc.edu Fri Mar 4 14:09:39 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 4 Mar 2005 14:09:39 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaISelPattern.cpp AlphaInstrInfo.td Message-ID: <200503042009.j24K9dKb014413@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaISelPattern.cpp updated: 1.59 -> 1.60 AlphaInstrInfo.td updated: 1.28 -> 1.29 --- Log message: fix FCMOVxx typo, set rem and div to hardcode target reg to be the same as the one the assembler uese, update ISel to put values in regs used by assembler for rem and div --- Diffs of the changes: (+65 -35) AlphaISelPattern.cpp | 20 ++++++++---- AlphaInstrInfo.td | 80 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 35 deletions(-) Index: llvm/lib/Target/Alpha/AlphaISelPattern.cpp diff -u llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.59 llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.60 --- llvm/lib/Target/Alpha/AlphaISelPattern.cpp:1.59 Thu Mar 3 15:47:53 2005 +++ llvm/lib/Target/Alpha/AlphaISelPattern.cpp Fri Mar 4 14:09:23 2005 @@ -49,6 +49,7 @@ addRegisterClass(MVT::f32, Alpha::FPRCRegisterClass); setOperationAction(ISD::EXTLOAD , MVT::i1 , Promote); + setOperationAction(ISD::EXTLOAD , MVT::f32 , Promote); setOperationAction(ISD::ZEXTLOAD , MVT::i1 , Expand); setOperationAction(ISD::ZEXTLOAD , MVT::i32 , Expand); @@ -64,6 +65,7 @@ setOperationAction(ISD::MEMSET , MVT::Other, Expand); setOperationAction(ISD::MEMCPY , MVT::Other, Expand); + //Doesn't work yet setOperationAction(ISD::SETCC , MVT::f32, Promote); computeRegisterProperties(); @@ -557,7 +559,7 @@ case ISD::SETGE: Opc = invTest ? Alpha::FCMOVLE : Alpha::FCMOVGE; break; case ISD::SETNE: Opc = invTest ? Alpha::FCMOVEQ : Alpha::FCMOVNE; break; } - BuildMI(BB, Opc, 3, Result).addReg(TV).addReg(FV).addReg(Tmp3); + BuildMI(BB, Opc, 3, Result).addReg(FV).addReg(TV).addReg(Tmp3); return Result; } else @@ -843,11 +845,11 @@ BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R30).addReg(Alpha::R30); return Result; - case ISD::ConstantPool: - Tmp1 = cast(N)->getIndex(); - AlphaLowering.restoreGP(BB); - BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(Tmp1); - return Result; +// case ISD::ConstantPool: +// Tmp1 = cast(N)->getIndex(); +// AlphaLowering.restoreGP(BB); +// BuildMI(BB, Alpha::LDQ_SYM, 1, Result).addConstantPoolIndex(Tmp1); +// return Result; case ISD::FrameIndex: BuildMI(BB, Alpha::LDA, 2, Result) @@ -1393,8 +1395,12 @@ } Tmp1 = SelectExpr(N.getOperand(0)); Tmp2 = SelectExpr(N.getOperand(1)); + //set up regs explicitly (helps Reg alloc) + BuildMI(BB, Alpha::BIS, 2, Alpha::R24).addReg(Tmp1).addReg(Tmp1); + BuildMI(BB, Alpha::BIS, 2, Alpha::R25).addReg(Tmp2).addReg(Tmp2); AlphaLowering.restoreGP(BB); - BuildMI(BB, Opc, 2, Result).addReg(Tmp1).addReg(Tmp2); + BuildMI(BB, Opc, 2).addReg(Alpha::R24).addReg(Alpha::R25); + BuildMI(BB, Alpha::BIS, 2, Result).addReg(Alpha::R27).addReg(Alpha::R27); return Result; case ISD::FP_TO_UINT: Index: llvm/lib/Target/Alpha/AlphaInstrInfo.td diff -u llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.28 llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.29 --- llvm/lib/Target/Alpha/AlphaInstrInfo.td:1.28 Thu Mar 3 16:12:11 2005 +++ llvm/lib/Target/Alpha/AlphaInstrInfo.td Fri Mar 4 14:09:23 2005 @@ -79,13 +79,15 @@ def STT_SYM : PseudoInstAlpha<(ops GPRC:$RA, s64imm:$DISP), "stt $RA,$DISP">; //store double } + +//RESULTS of these go to R27 let Uses = [R29], - Defs = [R28, R29, R23, R24, R25, R27] in + Defs = [R28, R23, R24, R25, R27] in { - def REMQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remqu $RA,$RB,$RC">; //unsigned remander - def REMQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$RC">; //signed remander - def DIVQU : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divqu $RA,$RB,$RC">; //unsigned division - def DIVQ : PseudoInstAlpha<(ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "divq $RA,$RB,$RC">; //signed division + def REMQU : PseudoInstAlpha<(ops GPRC:$RA, GPRC:$RB), "remqu $RA,$RB,$$27">; //unsigned remander + def REMQ : PseudoInstAlpha<(ops GPRC:$RA, GPRC:$RB), "remq $RA,$RB,$$27">; //signed remander + def DIVQU : PseudoInstAlpha<(ops GPRC:$RA, GPRC:$RB), "divqu $RA,$RB,$$27">; //unsigned division + def DIVQ : PseudoInstAlpha<(ops GPRC:$RA, GPRC:$RB), "divq $RA,$RB,$$27">; //signed division } //*********************** @@ -96,31 +98,52 @@ let isTwoAddress = 1 in { //conditional moves, int - def CMOVEQ : OForm< 0x11, 0x24, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "cmoveq $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND = zero - def CMOVEQi : OFormL< 0x11, 0x24, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "cmoveq $RCOND,$L,$RDEST">; //CMOVE if RCOND = zero - def CMOVGE : OForm< 0x11, 0x46, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVGE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND >= zero - def CMOVGEi : OFormL< 0x11, 0x46, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVGE $RCOND,$L,$RDEST">; //CMOVE if RCOND >= zero - def CMOVGT : OForm< 0x11, 0x66, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVGT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND > zero - def CMOVGTi : OFormL< 0x11, 0x66, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVGT $RCOND,$L,$RDEST">; //CMOVE if RCOND > zero - def CMOVLBC : OForm< 0x11, 0x16, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVLBC $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit clear - def CMOVLBCi : OFormL< 0x11, 0x16, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVLBC $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit clear - def CMOVLBS : OForm< 0x11, 0x14, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVLBS $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit set - def CMOVLBSi : OFormL< 0x11, 0x14, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVLBS $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit set - def CMOVLE : OForm< 0x11, 0x64, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVLE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND <= zero - def CMOVLEi : OFormL< 0x11, 0x64, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVLE $RCOND,$L,$RDEST">; //CMOVE if RCOND <= zero - def CMOVLT : OForm< 0x11, 0x44, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "CMOVLT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND < zero - def CMOVLTi : OFormL< 0x11, 0x44, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "CMOVLT $RCOND,$L,$RDEST">; //CMOVE if RCOND < zero - def CMOVNE : OForm< 0x11, 0x26, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), "cmovne $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND != zero - def CMOVNEi : OFormL< 0x11, 0x26, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), "cmovne $RCOND,$L,$RDEST">; //CMOVE if RCOND != zero + def CMOVEQ : OForm< 0x11, 0x24, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "cmoveq $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND = zero + def CMOVEQi : OFormL< 0x11, 0x24, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "cmoveq $RCOND,$L,$RDEST">; //CMOVE if RCOND = zero + def CMOVGE : OForm< 0x11, 0x46, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVGE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND >= zero + def CMOVGEi : OFormL< 0x11, 0x46, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVGE $RCOND,$L,$RDEST">; //CMOVE if RCOND >= zero + def CMOVGT : OForm< 0x11, 0x66, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVGT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND > zero + def CMOVGTi : OFormL< 0x11, 0x66, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVGT $RCOND,$L,$RDEST">; //CMOVE if RCOND > zero + def CMOVLBC : OForm< 0x11, 0x16, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVLBC $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit clear + def CMOVLBCi : OFormL< 0x11, 0x16, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVLBC $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit clear + def CMOVLBS : OForm< 0x11, 0x14, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVLBS $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND low bit set + def CMOVLBSi : OFormL< 0x11, 0x14, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVLBS $RCOND,$L,$RDEST">; //CMOVE if RCOND low bit set + def CMOVLE : OForm< 0x11, 0x64, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVLE $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND <= zero + def CMOVLEi : OFormL< 0x11, 0x64, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVLE $RCOND,$L,$RDEST">; //CMOVE if RCOND <= zero + def CMOVLT : OForm< 0x11, 0x44, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "CMOVLT $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND < zero + def CMOVLTi : OFormL< 0x11, 0x44, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "CMOVLT $RCOND,$L,$RDEST">; //CMOVE if RCOND < zero + def CMOVNE : OForm< 0x11, 0x26, (ops GPRC:$RDEST, GPRC:$RSRC2, GPRC:$RSRC, GPRC:$RCOND), + "cmovne $RCOND,$RSRC,$RDEST">; //CMOVE if RCOND != zero + def CMOVNEi : OFormL< 0x11, 0x26, (ops GPRC:$RDEST, GPRC:$RSRC2, u8imm:$L, GPRC:$RCOND), + "cmovne $RCOND,$L,$RDEST">; //CMOVE if RCOND != zero //conditional moves, fp - def FCMOVEQ : FPForm<0x17, 0x02A, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmoveq $RCOND,$RSRC,$RDEST">; //FCMOVE if = zero - def FCMOVGE : FPForm<0x17, 0x02D, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmovge $RCOND,$RSRC,$RDEST">; //FCMOVE if >= zero - def FCMOVGT : FPForm<0x17, 0x02F, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmovge $RCOND,$RSRC,$RDEST">; //FCMOVE if > zero - def FCMOVLE : FPForm<0x17, 0x02E, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmovle $RCOND,$RSRC,$RDEST">; //FCMOVE if <= zero - def FCMOVLT : FPForm<0x17, 0x02, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmovlt $RCOND,$RSRC,$RDEST">; // FCMOVE if < zero - def FCMOVNE : FPForm<0x17, 0x02B, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), "fcmovne $RCOND,$RSRC,$RDEST">; //FCMOVE if != zero - + def FCMOVEQ : FPForm<0x17, 0x02A, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmoveq $RCOND,$RSRC,$RDEST">; //FCMOVE if = zero + def FCMOVGE : FPForm<0x17, 0x02D, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmovge $RCOND,$RSRC,$RDEST">; //FCMOVE if >= zero + def FCMOVGT : FPForm<0x17, 0x02F, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmovgt $RCOND,$RSRC,$RDEST">; //FCMOVE if > zero + def FCMOVLE : FPForm<0x17, 0x02E, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmovle $RCOND,$RSRC,$RDEST">; //FCMOVE if <= zero + def FCMOVLT : FPForm<0x17, 0x02, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmovlt $RCOND,$RSRC,$RDEST">; // FCMOVE if < zero + def FCMOVNE : FPForm<0x17, 0x02B, (ops FPRC:$RDEST, FPRC:$RSRC2, FPRC:$RSRC, FPRC:$RCOND), + "fcmovne $RCOND,$RSRC,$RDEST">; //FCMOVE if != zero } def ADDL : OForm< 0x10, 0x00, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "addl $RA,$RB,$RC">; //Add longword @@ -218,6 +241,7 @@ def SRA : OForm< 0x12, 0x3C, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRA $RA,$RB,$RC">; //Shift right arithmetic def SRAi : OFormL<0x12, 0x3C, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SRA $RA,$L,$RC">; //Shift right arithmetic def SRL : OForm< 0x12, 0x34, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SRL $RA,$RB,$RC">; //Shift right logical + def SRLi : OFormL<0x12, 0x34, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SRL $RA,$L,$RC">; //Shift right logical def SUBL : OForm< 0x10, 0x09, (ops GPRC:$RC, GPRC:$RA, GPRC:$RB), "SUBL $RA,$RB,$RC">; //Subtract longword def SUBLi : OFormL<0x10, 0x09, (ops GPRC:$RC, GPRC:$RA, u8imm:$L), "SUBL $RA,$L,$RC">; //Subtract longword From lattner at cs.uiuc.edu Fri Mar 4 14:19:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 14:19:18 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503042019.j24KJIHY014830@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.41 -> 1.42 --- Log message: Move some code around, first attempt to handle compressing pools pointed to by globals. --- Diffs of the changes: (+159 -79) PointerCompress.cpp | 238 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 159 insertions(+), 79 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.41 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.42 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.41 Fri Mar 4 10:45:34 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 14:19:05 2005 @@ -102,12 +102,20 @@ /// a clone came from. std::map ClonedFunctionInfoMap; + /// CompressedGlobalPools - Keep track of which DSNodes in the globals graph + /// are both pool allocated and should be compressed, and which GlobalValue + /// their pool descriptor is. + std::map CompressedGlobalPools; + public: Function *PoolInitPC, *PoolDestroyPC, *PoolAllocPC; typedef std::map PoolInfoMap; bool runOnModule(Module &M); + void HandleGlobalPools(Module &M); + + void getAnalysisUsage(AnalysisUsage &AU) const; PoolAllocate *getPoolAlloc() const { return PoolAlloc; } @@ -276,83 +284,9 @@ //===----------------------------------------------------------------------===// -// PointerCompress Implementation +// InstructionRewriter Implementation //===----------------------------------------------------------------------===// -void PointerCompress::getAnalysisUsage(AnalysisUsage &AU) const { - // Need information about how pool allocation happened. - AU.addRequired(); - - // Need information from DSA. - AU.addRequired(); -} - -/// PoolIsCompressible - Return true if we can pointer compress this node. -/// If not, we should DEBUG print out why. -static bool PoolIsCompressible(const DSNode *N, Function &F) { - assert(!N->isForwarding() && "Should not be dealing with merged nodes!"); - if (N->isNodeCompletelyFolded()) { - DEBUG(std::cerr << "Node is not type-safe:\n"); - return false; - } - - // FIXME: If any non-type-safe nodes point to this one, we cannot compress it. -#if 0 - bool HasFields = false; - for (DSNode::const_edge_iterator I = N->edge_begin(), E = N->edge_end(); - I != E; ++I) - if (!I->isNull()) { - HasFields = true; - if (I->getNode() != N) { - // We currently only handle trivially self cyclic DS's right now. - DEBUG(std::cerr << "Node points to nodes other than itself:\n"); - return false; - } - } - - if (!HasFields) { - DEBUG(std::cerr << "Node does not contain any pointers to compress:\n"); - return false; - } -#endif - - if (N->isArray()) { - DEBUG(std::cerr << "Node is an array (not yet handled!):\n"); - return false; - } - - if ((N->getNodeFlags() & DSNode::Composition) != DSNode::HeapNode) { - DEBUG(std::cerr << "Node contains non-heap values:\n"); - return false; - } - - return true; -} - -/// FindPoolsToCompress - Inspect the specified function and find pools that are -/// compressible that are homed in that function. Return those pools in the -/// Pools set. -void PointerCompress::FindPoolsToCompress(std::set &Pools, - Function &F, DSGraph &DSG, - PA::FuncInfo *FI) { - DEBUG(std::cerr << "In function '" << F.getName() << "':\n"); - for (unsigned i = 0, e = FI->NodesToPA.size(); i != e; ++i) { - const DSNode *N = FI->NodesToPA[i]; - - // Ignore potential pools that the pool allocation heuristic decided not to - // pool allocated. - if (!isa(FI->PoolDescriptors[N])) - if (PoolIsCompressible(N, F)) { - Pools.insert(N); - ++NumCompressed; - } else { - DEBUG(std::cerr << "PCF: "; N->dump()); - ++NumNotCompressed; - } - } -} - - namespace { /// InstructionRewriter - This class implements the rewriting neccesary to /// transform a function body from normal pool allocation to pointer @@ -674,6 +608,20 @@ // Get the base index. Value *Val = getTransformedValue(GEPI.getOperand(0)); + bool AllZeros = true; + for (unsigned i = 1, e = GEPI.getNumOperands(); i != e; ++i) + if (!isa(GEPI.getOperand(i)) || + !cast(GEPI.getOperand(i))->isNullValue()) { + AllZeros = false; + break; + } + if (AllZeros) { + // We occasionally get non-type-matching GEP instructions with zeros. These + // are effectively pointer casts, so treat them as such. + setTransformedValue(GEPI, Val); + return; + } + // The compressed type for the pool. FIXME: NOTE: This only works if 'Val' // pointed to the start of a node! const Type *NTy = PointerType::get(PI->getNewType()); @@ -1027,6 +975,112 @@ } + +//===----------------------------------------------------------------------===// +// PointerCompress Implementation +//===----------------------------------------------------------------------===// + +void PointerCompress::getAnalysisUsage(AnalysisUsage &AU) const { + // Need information about how pool allocation happened. + AU.addRequired(); + + // Need information from DSA. + AU.addRequired(); +} + +/// PoolIsCompressible - Return true if we can pointer compress this node. +/// If not, we should DEBUG print out why. +static bool PoolIsCompressible(const DSNode *N) { + assert(!N->isForwarding() && "Should not be dealing with merged nodes!"); + if (N->isNodeCompletelyFolded()) { + DEBUG(std::cerr << "Node is not type-safe:\n"); + return false; + } + + // FIXME: If any non-type-safe nodes point to this one, we cannot compress it. +#if 0 + bool HasFields = false; + for (DSNode::const_edge_iterator I = N->edge_begin(), E = N->edge_end(); + I != E; ++I) + if (!I->isNull()) { + HasFields = true; + if (I->getNode() != N) { + // We currently only handle trivially self cyclic DS's right now. + DEBUG(std::cerr << "Node points to nodes other than itself:\n"); + return false; + } + } + + if (!HasFields) { + DEBUG(std::cerr << "Node does not contain any pointers to compress:\n"); + return false; + } +#endif + + if (N->isArray()) { + DEBUG(std::cerr << "Node is an array (not yet handled!):\n"); + return false; + } + + if ((N->getNodeFlags() & DSNode::Composition) != DSNode::HeapNode) { + DEBUG(std::cerr << "Node contains non-heap values:\n"); + return false; + } + + return true; +} + +/// FindPoolsToCompress - Inspect the specified function and find pools that are +/// compressible that are homed in that function. Return those pools in the +/// Pools set. +void PointerCompress::FindPoolsToCompress(std::set &Pools, + Function &F, DSGraph &DSG, + PA::FuncInfo *FI) { + DEBUG(std::cerr << "In function '" << F.getName() << "':\n"); + for (unsigned i = 0, e = FI->NodesToPA.size(); i != e; ++i) { + const DSNode *N = FI->NodesToPA[i]; + + // Ignore potential pools that the pool allocation heuristic decided not to + // pool allocated. + if (!isa(FI->PoolDescriptors[N])) + if (PoolIsCompressible(N)) { + Pools.insert(N); + ++NumCompressed; + } else { + DEBUG(std::cerr << "PCF: "; N->dump()); + ++NumNotCompressed; + } + } + + // If there are no compressed global pools, don't bother to look for them. + if (CompressedGlobalPools.empty()) return; + + // Calculate which DSNodes are reachable from globals. If a node is reachable + // from a global, we check to see if the global pool is compressed. + DSGraph &GG = ECG->getGlobalsGraph(); + + DSGraph::NodeMapTy GlobalsGraphNodeMapping; + for (DSScalarMap::global_iterator I = DSG.getScalarMap().global_begin(), + E = DSG.getScalarMap().global_end(); I != E; ++I) { + // Map all node reachable from this global to the corresponding nodes in + // the globals graph. + DSGraph::computeNodeMapping(DSG.getNodeForValue(*I), GG.getNodeForValue(*I), + GlobalsGraphNodeMapping); + } + + // See if there are nodes in this graph that correspond to nodes in the + // globals graph, and if so, if it is compressed. + for (DSGraph::node_iterator I = DSG.node_begin(), E = DSG.node_end(); + I != E;++I) + if (GlobalsGraphNodeMapping.count(*I)) { + // If it is a global pool, set up the pool descriptor appropriately. + DSNode *GGN = GlobalsGraphNodeMapping[*I].getNode(); + if (CompressedGlobalPools.count(GGN)) + Pools.insert(*I); + } +} + + /// CompressPoolsInFunction - Find all pools that are compressible in this /// function and compress them. bool PointerCompress:: @@ -1059,10 +1113,6 @@ if (FI->Clone && &FI->F == &F) return false; - // If there are no pools in this function, exit early. - if (FI->NodesToPA.empty() && CloneSource == 0) - return false; - // Get the DSGraph for this function. DSGraph &DSG = ECG->getDSGraph(FI->F); @@ -1261,6 +1311,33 @@ } +// Handle all pools pointed to by global variables. +void PointerCompress::HandleGlobalPools(Module &M) { + if (PoolAlloc->GlobalNodes.empty()) return; + + DEBUG(std::cerr << "Inspecting global nodes:\n"); + + // Loop over all of the global nodes identified by the pool allocator. + for (std::map::iterator I = + PoolAlloc->GlobalNodes.begin(), E = PoolAlloc->GlobalNodes.end(); + I != E; ++I) { + const DSNode *N = I->first; + + // Ignore potential pools that the pool allocation heuristic decided not to + // pool allocated. + if (!isa(I->second)) + if (PoolIsCompressible(N)) { + CompressedGlobalPools.insert(std::make_pair(N, + cast(I->second))); + ++NumCompressed; + } else { + DEBUG(std::cerr << "PCF: "; N->dump()); + ++NumNotCompressed; + } + } +} + + /// InitializePoolLibraryFunctions - Create the function prototypes for pointer /// compress runtime library functions. void PointerCompress::InitializePoolLibraryFunctions(Module &M) { @@ -1292,6 +1369,9 @@ // functions. InitializePoolLibraryFunctions(M); + // Handle all pools pointed to by global variables. + HandleGlobalPools(M); + // Iterate over all functions in the module, looking for compressible data // structures. bool Changed = false; From lattner at cs.uiuc.edu Fri Mar 4 14:27:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 14:27:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200503042027.j24KRxEE015763@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.123 -> 1.124 --- Log message: Trivial cleanup patch --- Diffs of the changes: (+2 -2) Local.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.123 llvm/lib/Analysis/DataStructure/Local.cpp:1.124 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.123 Thu Feb 24 19:27:48 2005 +++ llvm/lib/Analysis/DataStructure/Local.cpp Fri Mar 4 14:27:46 2005 @@ -1061,10 +1061,10 @@ bool LocalDataStructures::runOnModule(Module &M) { - GlobalsGraph = new DSGraph(getAnalysis()); - const TargetData &TD = getAnalysis(); + GlobalsGraph = new DSGraph(TD); + { GraphBuilder GGB(*GlobalsGraph); From lattner at cs.uiuc.edu Fri Mar 4 14:32:17 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 14:32:17 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503042032.j24KWHKd015791@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.42 -> 1.43 --- Log message: Print debug output that shows how much we are helping. --- Diffs of the changes: (+3 -0) PointerCompress.cpp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.42 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.43 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.42 Fri Mar 4 14:19:05 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 14:32:01 2005 @@ -278,6 +278,9 @@ /// dump - Emit a debugging dump for this pool info. /// void CompressedPoolInfo::dump() const { + const TargetData &TD = getNode()->getParentGraph()->getTargetData(); + std::cerr << " From size: " << TD.getTypeSize(getNode()->getType()) + << " To size: " << TD.getTypeSize(NewTy) << "\n"; std::cerr << "Node: "; getNode()->dump(); std::cerr << "New Type: " << *NewTy << "\n"; } From lattner at cs.uiuc.edu Fri Mar 4 14:42:57 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 14:42:57 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503042042.j24Kgv68016594@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.43 -> 1.44 --- Log message: don't crash on a corner case --- Diffs of the changes: (+5 -2) PointerCompress.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.43 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.44 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.43 Fri Mar 4 14:32:01 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 14:42:42 2005 @@ -279,8 +279,11 @@ /// void CompressedPoolInfo::dump() const { const TargetData &TD = getNode()->getParentGraph()->getTargetData(); - std::cerr << " From size: " << TD.getTypeSize(getNode()->getType()) - << " To size: " << TD.getTypeSize(NewTy) << "\n"; + std::cerr << " From size: " + << (getNode()->getType()->isSized() ? + TD.getTypeSize(getNode()->getType()) : 0) + << " To size: " + << (NewTy->isSized() ? TD.getTypeSize(NewTy) : 0) << "\n"; std::cerr << "Node: "; getNode()->dump(); std::cerr << "New Type: " << *NewTy << "\n"; } From lattner at cs.uiuc.edu Fri Mar 4 14:53:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 14:53:51 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503042053.j24KrpFR017318@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.44 -> 1.45 --- Log message: Second part of global pointer to node patch. --- Diffs of the changes: (+14 -6) PointerCompress.cpp | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.44 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.45 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.44 Fri Mar 4 14:42:42 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 14:53:36 2005 @@ -145,8 +145,9 @@ std::vector > *PremappedVals = 0, std::set *ExternalPoolsToCompress = 0); - void FindPoolsToCompress(std::set &Pools, Function &F, - DSGraph &DSG, PA::FuncInfo *FI); + void FindPoolsToCompress(std::set &Pools, + std::map &PreassignedPools, + Function &F, DSGraph &DSG, PA::FuncInfo *FI); }; RegisterOpt @@ -1040,6 +1041,8 @@ /// compressible that are homed in that function. Return those pools in the /// Pools set. void PointerCompress::FindPoolsToCompress(std::set &Pools, + std::map &PreassignedPools, Function &F, DSGraph &DSG, PA::FuncInfo *FI) { DEBUG(std::cerr << "In function '" << F.getName() << "':\n"); @@ -1081,8 +1084,10 @@ if (GlobalsGraphNodeMapping.count(*I)) { // If it is a global pool, set up the pool descriptor appropriately. DSNode *GGN = GlobalsGraphNodeMapping[*I].getNode(); - if (CompressedGlobalPools.count(GGN)) + if (CompressedGlobalPools.count(GGN)) { Pools.insert(*I); + PreassignedPools[*I] = CompressedGlobalPools[GGN]; + } } } @@ -1126,7 +1131,8 @@ // Compute the set of compressible pools in this function that are hosted // here. - FindPoolsToCompress(PoolsToCompressSet, F, DSG, FI); + std::map PreassignedPools; + FindPoolsToCompress(PoolsToCompressSet, PreassignedPools, F, DSG, FI); // Handle pools that are passed into the function through arguments or // returned by the function. If this occurs, we must be dealing with a ptr @@ -1144,12 +1150,14 @@ for (std::set::iterator I = PoolsToCompressSet.begin(), E = PoolsToCompressSet.end(); I != E; ++I) { Value *PD; - if (FCR) + if (Value *PAPD = PreassignedPools[*I]) + PD = PAPD; // Must be a global pool. + else if (FCR) PD = FCR->PoolDescriptors.find(*I)->second; else PD = FI->PoolDescriptors[*I]; assert(PD && "No pool descriptor available for this pool???"); - + PoolsToCompress.insert(std::make_pair(*I, CompressedPoolInfo(*I, PD))); } From lattner at cs.uiuc.edu Fri Mar 4 15:24:11 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 15:24:11 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp PoolAllocator.h Message-ID: <200503042124.j24LOBAE019538@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.39 -> 1.40 PoolAllocator.h updated: 1.21 -> 1.22 --- Log message: Print out _pc after calls so that we can tell which runtime library calls are which. --- Diffs of the changes: (+14 -9) FreeListAllocator.cpp | 20 +++++++++++--------- PoolAllocator.h | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.39 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.40 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.39 Fri Mar 4 10:03:14 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Fri Mar 4 15:23:55 2005 @@ -454,8 +454,9 @@ Pool->DeclaredSize = DeclaredSize; - DO_IF_TRACE(fprintf(stderr, "[%d] poolinit(0x%X, %d, %d)\n", - addPoolNumber(Pool), Pool, DeclaredSize, ObjAlignment)); + DO_IF_TRACE(fprintf(stderr, "[%d] poolinit%s(0x%X, %d, %d)\n", + addPoolNumber(Pool), PoolTraits::getSuffix(), + Pool, DeclaredSize, ObjAlignment)); DO_IF_PNP(++PoolsInited); // Track # pools initialized DO_IF_PNP(InitPrintNumPools()); } @@ -492,8 +493,8 @@ template static void *poolalloc_internal(PoolTy *Pool, unsigned NumBytes) { - DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc(%d) -> ", - getPoolNumber(Pool), NumBytes)); + DO_IF_TRACE(fprintf(stderr, "[%d] poolalloc%s(%d) -> ", + getPoolNumber(Pool), PoolTraits::getSuffix(), NumBytes)); // If a null pool descriptor is passed in, this is not a pool allocated data // structure. Hand off to the system malloc. @@ -638,8 +639,8 @@ template static void poolfree_internal(PoolTy *Pool, void *Node) { if (Node == 0) return; - DO_IF_TRACE(fprintf(stderr, "[%d] poolfree(0x%X) ", - getPoolNumber(Pool), Node)); + DO_IF_TRACE(fprintf(stderr, "[%d] poolfree%s(0x%X) ", + getPoolNumber(Pool), PoolTraits::getSuffix(), Node)); // If a null pool descriptor is passed in, this is not a pool allocated data // structure. Hand off to the system free. @@ -719,8 +720,9 @@ template static void *poolrealloc_internal(PoolTy *Pool, void *Node, unsigned NumBytes) { - DO_IF_TRACE(fprintf(stderr, "[%d] poolrealloc(0x%X, %d) -> ", - getPoolNumber(Pool), Node, NumBytes)); + DO_IF_TRACE(fprintf(stderr, "[%d] poolrealloc%s(0x%X, %d) -> ", + getPoolNumber(Pool), PoolTraits::getSuffix(), + Node, NumBytes)); // If a null pool descriptor is passed in, this is not a pool allocated data // structure. Hand off to the system realloc. @@ -860,7 +862,7 @@ if (Pool->Slabs == 0) return; // no memory allocated from this pool. - DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy", removePoolNumber(Pool))); + DO_IF_TRACE(fprintf(stderr, "[%d] pooldestroy_pc", removePoolNumber(Pool))); DO_IF_POOLDESTROY_STATS(PrintPoolStats(Pool)); // If there is space to remember this pool, do so. Index: llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h diff -u llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.21 llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.22 --- llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h:1.21 Thu Mar 3 22:03:30 2005 +++ llvm-poolalloc/runtime/FL2Allocator/PoolAllocator.h Fri Mar 4 15:23:55 2005 @@ -43,6 +43,7 @@ // Pointers are just pointers. typedef FreedNodeHeader* FreeNodeHeaderPtrTy; + static const char *getSuffix() { return ""; } /// DerefFNHPtr - Given an index into the pool, return a pointer to the /// FreeNodeHeader object. @@ -74,6 +75,8 @@ // Represent pointers with indexes from the pool base. typedef unsigned FreeNodeHeaderPtrTy; + static const char *getSuffix() { return "_pc"; } + /// DerefFNHPtr - Given an index into the pool, return a pointer to the /// FreeNodeHeader object. static FreedNodeHeader* From alenhar2 at cs.uiuc.edu Fri Mar 4 15:40:15 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Fri, 4 Mar 2005 15:40:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200503042140.j24LeFlQ019735@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.13 -> 1.14 --- Log message: fix up stack pointer adjustments --- Diffs of the changes: (+22 -18) AlphaRegisterInfo.cpp | 40 ++++++++++++++++++++++------------------ 1 files changed, 22 insertions(+), 18 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.13 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.14 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.13 Thu Feb 24 12:36:32 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Fri Mar 4 15:40:02 2005 @@ -30,22 +30,25 @@ #include using namespace llvm; -static long getLower16(long l) -{ - long y = l / 65536; - if (l % 65536 > 32767) - ++y; - return l - y * 65536; -} +//These describe LDAx +static const long IMM_LOW = 0xffffffffffff8000; +static const long IMM_HIGH = 0x0000000000007fff; +static const long IMM_MULT = 65536; static long getUpper16(long l) { - long y = l / 65536; - if (l % 65536 > 32767) + long y = l / IMM_MULT; + if (l % IMM_MULT > IMM_HIGH) ++y; return y; } +static long getLower16(long l) +{ + long h = getUpper16(l); + return l - h * IMM_MULT; +} + AlphaRegisterInfo::AlphaRegisterInfo() : AlphaGenRegisterInfo(Alpha::ADJUSTSTACKDOWN, Alpha::ADJUSTSTACKUP) { @@ -183,7 +186,7 @@ DEBUG(std::cerr << "Corrected Offset " << Offset << " for stack size: " << MF.getFrameInfo()->getStackSize() << "\n"); - if (Offset > 32767 || Offset < -32768) { + if (Offset > IMM_HIGH || Offset < IMM_LOW) { //so in this case, we need to use a temporary register, and move the original //inst off the SP/FP //fix up the old: @@ -212,7 +215,7 @@ MBB.insert(MBBI, MI); // Get the number of bytes to allocate from the FrameInfo - unsigned NumBytes = MFI->getStackSize(); + long NumBytes = MFI->getStackSize(); if (MFI->hasCalls() && !FP) { // We reserve argument space for call sites in the function immediately on @@ -234,13 +237,14 @@ MFI->setStackSize(NumBytes); // adjust stack pointer: r30 -= numbytes - if (NumBytes <= 32767) { - MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(-NumBytes).addReg(Alpha::R30); + NumBytes = -NumBytes; + if (NumBytes >= IMM_LOW) { + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(NumBytes).addReg(Alpha::R30); MBB.insert(MBBI, MI); - } else if ((unsigned long)NumBytes <= (unsigned long)32767 * (unsigned long)65536) { - MI=BuildMI(Alpha::LDAH, 2, Alpha::R30).addImm(getUpper16(-NumBytes)).addReg(Alpha::R30); + } else if (getUpper16(NumBytes) >= IMM_LOW) { + MI=BuildMI(Alpha::LDAH, 2, Alpha::R30).addImm(getUpper16(NumBytes)).addReg(Alpha::R30); MBB.insert(MBBI, MI); - MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(getLower16(-NumBytes)).addReg(Alpha::R30); + MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(getLower16(NumBytes)).addReg(Alpha::R30); MBB.insert(MBBI, MI); } else { std::cerr << "Too big a stack frame at " << NumBytes << "\n"; @@ -285,10 +289,10 @@ if (NumBytes != 0) { - if (NumBytes <= 32767) { + if (NumBytes <= IMM_HIGH) { MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(NumBytes).addReg(Alpha::R30); MBB.insert(MBBI, MI); - } else if ((unsigned long)NumBytes <= (unsigned long)32767 * (unsigned long)65536) { + } else if (getUpper16(NumBytes) <= IMM_HIGH) { MI=BuildMI(Alpha::LDAH, 2, Alpha::R30).addImm(getUpper16(NumBytes)).addReg(Alpha::R30); MBB.insert(MBBI, MI); MI=BuildMI(Alpha::LDA, 2, Alpha::R30).addImm(getLower16(NumBytes)).addReg(Alpha::R30); From lattner at cs.uiuc.edu Fri Mar 4 16:46:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 16:46:51 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503042246.j24MkpP6021623@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.45 -> 1.46 --- Log message: Two fixes: only print info about compressed pools in the function they are homed in Second, don't match up args-to-args exactly. If a parameter passed isn't being compressed, but something it points to is, we used to miscompile stuff. --- Diffs of the changes: (+14 -12) PointerCompress.cpp | 26 ++++++++++++++------------ 1 files changed, 14 insertions(+), 12 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.45 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.46 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.45 Fri Mar 4 14:53:36 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 16:46:35 2005 @@ -913,29 +913,21 @@ DSGraph::NodeMapTy CalleeCallerMap; // Do we need to compress the return value? - if (isa(CI.getType()) && getNodeIfCompressed(&CI)) { + if (isa(CI.getType())) DSGraph::computeNodeMapping(CG->getReturnNodeFor(FI->F), getMappedNodeHandle(&CI), CalleeCallerMap); - PoolsToCompress.insert(CG->getReturnNodeFor(FI->F).getNode()); - } // Find the arguments we need to compress. unsigned NumPoolArgs = FI ? FI->ArgNodes.size() : 0; for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i) - if (isa(CI.getOperand(i)->getType()) && - getNodeIfCompressed(CI.getOperand(i))) { + if (isa(CI.getOperand(i)->getType()) && i > NumPoolArgs) { Argument *FormalArg = next(FI->F.abegin(), i-1-NumPoolArgs); DSGraph::computeNodeMapping(CG->getNodeForValue(FormalArg), getMappedNodeHandle(CI.getOperand(i)), CalleeCallerMap); - - PoolsToCompress.insert(CG->getNodeForValue(FormalArg).getNode()); } - // If this function doesn't require compression, there is nothing to do! - if (PoolsToCompress.empty()) return; - // Now that we know the basic pools passed/returned through the // argument/retval of the call, add the compressed pools that are reachable // from them. The CalleeCallerMap contains a mapping from callee nodes to the @@ -946,6 +938,9 @@ if (PoolInfo.count(I->second.getNode())) PoolsToCompress.insert(I->first); } + + // If this function doesn't require compression, there is nothing to do! + if (PoolsToCompress.empty()) return; // Get the clone of this function that uses compressed pointers instead of // normal pointers. @@ -1168,9 +1163,16 @@ std::cerr << "In function '" << F.getName() << "':\n"; for (std::map::iterator I = PoolsToCompress.begin(), E = PoolsToCompress.end(); I != E; ++I) { + I->second.Initialize(PoolsToCompress, TD); - std::cerr << " COMPRESSING POOL:\nPCS:"; - I->second.dump(); + + // Only dump info about a compressed pool if this is the home for it. + if (isa(I->second.getPoolDesc()) || + (isa(I->second.getPoolDesc()) && + F.hasExternalLinkage() && F.getName() == "main")) { + std::cerr << " COMPRESSING POOL:\nPCS:"; + I->second.dump(); + } } // Finally, rewrite the function body to use compressed pointers! From lattner at cs.uiuc.edu Fri Mar 4 17:20:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 17:20:59 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll Message-ID: <200503042320.j24NKxE1022385@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: 2005-03-04-ShiftOverflow.ll added (r1.1) --- Log message: Testcase for a bug that caused us to miscompile ptrdist/ks on sparc. --- Diffs of the changes: (+7 -0) 2005-03-04-ShiftOverflow.ll | 7 +++++++ 1 files changed, 7 insertions(+) Index: llvm/test/Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll diff -c /dev/null llvm/test/Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll:1.1 *** /dev/null Fri Mar 4 17:20:56 2005 --- llvm/test/Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll Fri Mar 4 17:20:46 2005 *************** *** 0 **** --- 1,7 ---- + ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep 'ret bool false' + bool %test(ulong %tmp.169) { + %tmp.1710 = shr ulong %tmp.169, ubyte 1 + %tmp.1912 = setgt ulong %tmp.1710, 0 + ret bool %tmp.1912 + } + From lattner at cs.uiuc.edu Fri Mar 4 17:21:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 17:21:46 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200503042321.j24NLksw022397@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.315 -> 1.316 --- Log message: Do not compute 1ULL << 64, which is undefined. This fixes Ptrdist/ks on the sparc, and testcase Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll --- Diffs of the changes: (+2 -1) InstructionCombining.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.315 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.316 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.315 Sun Jan 30 23:51:45 2005 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri Mar 4 17:21:33 2005 @@ -2563,7 +2563,8 @@ Constant *Mask; if (CI->getType()->isUnsigned()) { unsigned TypeBits = CI->getType()->getPrimitiveSize()*8; - Val &= (1ULL << TypeBits)-1; + if (TypeBits != 64) + Val &= (1ULL << TypeBits)-1; Mask = ConstantUInt::get(CI->getType(), Val); } else { Mask = ConstantSInt::get(CI->getType(), Val); From lattner at cs.uiuc.edu Fri Mar 4 19:04:19 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 19:04:19 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503050104.j2514JDu024392@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.46 -> 1.47 --- Log message: Handle programs that have 1 element arrays and 1 element structs like Olden/mst --- Diffs of the changes: (+19 -8) PointerCompress.cpp | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.46 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.47 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.46 Fri Mar 4 16:46:35 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 19:04:04 2005 @@ -638,18 +638,25 @@ Value *Idx = GEPI.getOperand(i); if (const StructType *STy = dyn_cast(*GTI)) { unsigned Field = (unsigned)cast(Idx)->getValue(); + if (Field) { + uint64_t FieldOffs = TD.getStructLayout(cast(NTy)) + ->MemberOffsets[Field]; + Constant *FieldOffsCst = ConstantUInt::get(SCALARUINTTYPE, FieldOffs); + Val = BinaryOperator::createAdd(Val, FieldOffsCst, + GEPI.getName(), &GEPI); + } - uint64_t FieldOffs = TD.getStructLayout(cast(NTy)) - ->MemberOffsets[Field]; - Constant *FieldOffsCst = ConstantUInt::get(SCALARUINTTYPE, FieldOffs); - Val = BinaryOperator::createAdd(Val, FieldOffsCst, GEPI.getName(), &GEPI); - - NTy = cast(NTy)->getElementType(Field); + // If this is a one element struct, NTy may not have the structure type. + if (STy->getNumElements() > 1 || + (isa(NTy) && + cast(NTy)->getNumElements() == 1)) + NTy = cast(NTy)->getElementType(Field); } else { assert(isa(*GTI) && "Not struct or sequential?"); + const SequentialType *STy = cast(*GTI); if (!isa(Idx) || !cast(Idx)->isNullValue()) { // Add Idx*sizeof(NewElementType) to the index. - const Type *ElTy = cast(NTy)->getElementType(); + const Type *ElTy = STy->getElementType(); if (Idx->getType() != SCALARUINTTYPE) Idx = new CastInst(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI); @@ -658,7 +665,11 @@ Idx = BinaryOperator::createMul(Idx, Scale, "fieldidx", &GEPI); Val = BinaryOperator::createAdd(Val, Idx, GEPI.getName(), &GEPI); } - NTy = cast(NTy)->getElementType(); + + // If this is a one element array type, NTy may not reflect the array. + if (!isa(STy) || cast(STy)->getNumElements() != 1 || + (isa(NTy) && cast(NTy)->getNumElements() == 1)) + NTy = cast(NTy)->getElementType(); } } From lattner at cs.uiuc.edu Fri Mar 4 20:47:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 20:47:51 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Message-ID: <200503050247.j252lpOO024887@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/runtime/FL2Allocator: FreeListAllocator.cpp updated: 1.40 -> 1.41 --- Log message: print pointers as pointers. --- Diffs of the changes: (+3 -3) FreeListAllocator.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp diff -u llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.40 llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.41 --- llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.40 Fri Mar 4 15:23:55 2005 +++ llvm-poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp Fri Mar 4 20:47:35 2005 @@ -376,7 +376,7 @@ void *Result = BumpPtr; // Update bump ptr. Pool->ObjFreeList = (FreedNodeHeader*)(BumpPtr+NumBytes); - DO_IF_TRACE(fprintf(stderr, "0x%X\n", Result)); + DO_IF_TRACE(fprintf(stderr, "%p\n", Result)); return Result; } @@ -392,7 +392,7 @@ LAH->Size = NumBytes; LAH->Marker = ~0U; LAH->LinkIntoList(&Pool->LargeArrays); - DO_IF_TRACE(fprintf(stderr, "0x%X [large]\n", LAH+1)); + DO_IF_TRACE(fprintf(stderr, "%p [large]\n", LAH+1)); return LAH+1; } @@ -639,7 +639,7 @@ template static void poolfree_internal(PoolTy *Pool, void *Node) { if (Node == 0) return; - DO_IF_TRACE(fprintf(stderr, "[%d] poolfree%s(0x%X) ", + DO_IF_TRACE(fprintf(stderr, "[%d] poolfree%s(%p) ", getPoolNumber(Pool), PoolTraits::getSuffix(), Node)); // If a null pool descriptor is passed in, this is not a pool allocated data From lattner at cs.uiuc.edu Fri Mar 4 20:48:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 4 Mar 2005 20:48:18 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503050248.j252mIYF024901@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.48 -> 1.49 --- Log message: traverse the call graph from bottom up. --- Diffs of the changes: (+23 -6) PointerCompress.cpp | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.48 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.49 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.48 Fri Mar 4 20:11:16 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Fri Mar 4 20:48:05 2005 @@ -111,6 +111,11 @@ Function *PoolInitPC, *PoolDestroyPC, *PoolAllocPC; typedef std::map PoolInfoMap; + /// NoArgFunctionsCalled - When we are walking the call graph, keep track of + /// which functions are called that don't need their prototype to be + /// changed. + std::vector NoArgFunctionsCalled; + bool runOnModule(Module &M); void HandleGlobalPools(Module &M); @@ -904,8 +909,10 @@ Operands.push_back(CI.getOperand(i)); } - if (CompressedArgs.empty()) + if (CompressedArgs.empty()) { + PtrComp.NoArgFunctionsCalled.push_back(Callee); return; // Nothing to compress! + } Function *Clone = PtrComp.GetExtFunctionClone(Callee, CompressedArgs); Value *NC = new CallInst(Clone, Operands, CI.getName(), &CI); @@ -1394,16 +1401,26 @@ // Handle all pools pointed to by global variables. HandleGlobalPools(M); + std::set TransformedFns; + // Iterate over all functions in the module, looking for compressible data // structures. bool Changed = false; - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { - // If this function is not a pointer-compressed clone, compress any pools in - // it now. - if (!ClonedFunctionInfoMap.count(I)) + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + // If this function is not a pointer-compressed or pool allocated clone, + // compress any pools in it now. + if (I->hasExternalLinkage()) { Changed |= CompressPoolsInFunction(*I); - } + TransformedFns.insert(I); + } + + // If compressing external functions (e.g. main), required other function + // bodies to be compressed that do not take pool arguments, handle them now. + for (unsigned i = 0; i != NoArgFunctionsCalled.size(); ++i) + if (TransformedFns.insert(NoArgFunctionsCalled[i]).second) + Changed |= CompressPoolsInFunction(*NoArgFunctionsCalled[i]); + NoArgFunctionsCalled.clear(); ClonedFunctionMap.clear(); return Changed; } From lattner at cs.uiuc.edu Sat Mar 5 00:35:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 00:35:45 -0600 Subject: [llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Message-ID: <200503050635.j256ZjYg028076@apoc.cs.uiuc.edu> Changes in directory llvm-poolalloc/lib/PoolAllocate: PointerCompress.cpp updated: 1.50 -> 1.51 --- Log message: handle memset, printf, and use the *COMPRESSED* type when transforming subscripts, not the ORIGINAL type. Bork. This fixes Olden/power and several others. --- Diffs of the changes: (+23 -1) PointerCompress.cpp | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletion(-) Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.50 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.51 --- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.50 Fri Mar 4 21:46:19 2005 +++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp Sat Mar 5 00:35:30 2005 @@ -673,7 +673,7 @@ const SequentialType *STy = cast(*GTI); if (!isa(Idx) || !cast(Idx)->isNullValue()) { // Add Idx*sizeof(NewElementType) to the index. - const Type *ElTy = STy->getElementType(); + const Type *ElTy = cast(NTy)->getElementType(); if (Idx->getType() != SCALARUINTTYPE) Idx = new CastInst(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI); @@ -908,6 +908,28 @@ std::vector Operands; Operands.reserve(CI.getNumOperands()-1); + // If this is one of the functions we know about, just materialize the + // compressed pointer as a real pointer, and pass it. + if (Callee->getName() == "printf") { + for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i) + if (isa(CI.getOperand(i)->getType()) && + getPoolInfo(CI.getOperand(i))) + CI.setOperand(i, getTransformedValue(CI.getOperand(i))); + return; + } else if (Callee->getName() == "llvm.memset") { + if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) { + std::vector Ops; + Ops.push_back(getTransformedValue(CI.getOperand(1))); + Value *BasePtr = DestPI->EmitPoolBaseLoad(CI); + Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops, + CI.getOperand(1)->getName()+".pp", &CI); + SrcPtr = new CastInst(SrcPtr, CI.getOperand(1)->getType(), "", &CI); + CI.setOperand(1, SrcPtr); + return; + } + } + + std::vector CompressedArgs; if (isa(CI.getType()) && getPoolInfo(&CI)) CompressedArgs.push_back(0); // Compress retval. From alenhar2 at cs.uiuc.edu Sat Mar 5 09:30:49 2005 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Sat, 5 Mar 2005 09:30:49 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200503051530.JAA05828@niobe.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.14 -> 1.15 --- Log message: fix data size stuff for architectures with bit challenged data types --- Diffs of the changes: (+4 -4) AlphaRegisterInfo.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.14 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.15 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.14 Fri Mar 4 15:40:02 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sat Mar 5 09:30:33 2005 @@ -31,9 +31,9 @@ using namespace llvm; //These describe LDAx -static const long IMM_LOW = 0xffffffffffff8000; -static const long IMM_HIGH = 0x0000000000007fff; -static const long IMM_MULT = 65536; +static const int64_t IMM_LOW = 0xffffffffffff8000; +static const int IMM_HIGH = 0x0000000000007fff; +static const int IMM_MULT = 65536; static long getUpper16(long l) { @@ -274,7 +274,7 @@ bool FP = hasFP(MF); // Get the number of bytes allocated from the FrameInfo... - unsigned NumBytes = MFI->getStackSize(); + long NumBytes = MFI->getStackSize(); //now if we need to, restore the old FP if (FP) From lattner at cs.uiuc.edu Sat Mar 5 11:28:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 11:28:54 -0600 Subject: [llvm-commits] CVS: llvm/test/Feature/constexprbad.ll Message-ID: <200503051728.j25HSs2H007734@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: constexprbad.ll (r1.3) removed --- Log message: This file is all commented out. --- Diffs of the changes: (+0 -0) 0 files changed From lattner at cs.uiuc.edu Sat Mar 5 11:47:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 11:47:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Message-ID: <200503051747.j25HluLk030530@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Alpha: AlphaRegisterInfo.cpp updated: 1.15 -> 1.16 --- Log message: don't break the build on 32-bit hosts. --- Diffs of the changes: (+2 -2) AlphaRegisterInfo.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp diff -u llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.15 llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.16 --- llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp:1.15 Sat Mar 5 09:30:33 2005 +++ llvm/lib/Target/Alpha/AlphaRegisterInfo.cpp Sat Mar 5 11:47:38 2005 @@ -31,8 +31,8 @@ using namespace llvm; //These describe LDAx -static const int64_t IMM_LOW = 0xffffffffffff8000; -static const int IMM_HIGH = 0x0000000000007fff; +static const int64_t IMM_LOW = 0xffffffffffff8000LL; +static const int IMM_HIGH = 0x0000000000007fffLL; static const int IMM_MULT = 65536; static long getUpper16(long l) From lattner at cs.uiuc.edu Sat Mar 5 12:47:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:47:45 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2005-03-05-OffsetOfHack.c Message-ID: <200503051847.j25Iljx1012476@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2005-03-05-OffsetOfHack.c added (r1.1) --- Log message: New testcase for PR533: http://llvm.cs.uiuc.edu/PR533 --- Diffs of the changes: (+12 -0) 2005-03-05-OffsetOfHack.c | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: llvm/test/Regression/CFrontend/2005-03-05-OffsetOfHack.c diff -c /dev/null llvm/test/Regression/CFrontend/2005-03-05-OffsetOfHack.c:1.1 *** /dev/null Sat Mar 5 12:47:39 2005 --- llvm/test/Regression/CFrontend/2005-03-05-OffsetOfHack.c Sat Mar 5 12:47:28 2005 *************** *** 0 **** --- 1,12 ---- + // RUN: %llvmgcc %s -S -o - + + struct s { + unsigned long int field[0]; + }; + + #define OFFS \ + (((char *) &((struct s *) 0)->field[0]) - (char *) 0) + + int foo[OFFS]; + + From lattner at cs.uiuc.edu Sat Mar 5 12:49:06 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:49:06 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/tree.h Message-ID: <200503051849.j25In6sl012500@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: tree.h updated: 1.4 -> 1.5 --- Log message: expose some prototypes. --- Diffs of the changes: (+3 -0) tree.h | 3 +++ 1 files changed, 3 insertions(+) Index: llvm-gcc/gcc/tree.h diff -u llvm-gcc/gcc/tree.h:1.4 llvm-gcc/gcc/tree.h:1.5 --- llvm-gcc/gcc/tree.h:1.4 Mon Feb 14 15:23:54 2005 +++ llvm-gcc/gcc/tree.h Sat Mar 5 12:48:48 2005 @@ -2801,9 +2801,12 @@ subexpressions are not changed. */ extern tree fold (tree); +extern tree fold_convert (tree, tree); extern tree fold_initializer (tree); extern tree fold_single_bit_test (enum tree_code, tree, tree, tree); +extern tree get_base_address (tree t); + extern int force_fit_type (tree, int); extern int add_double (unsigned HOST_WIDE_INT, HOST_WIDE_INT, unsigned HOST_WIDE_INT, HOST_WIDE_INT, From lattner at cs.uiuc.edu Sat Mar 5 12:49:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:49:37 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/c-common.h c-common.c Message-ID: <200503051849.j25InbLX012516@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: c-common.h updated: 1.4 -> 1.5 c-common.c updated: 1.8 -> 1.9 --- Log message: implement new fold-offsetof and getbaseaddress functions. --- Diffs of the changes: (+95 -0) c-common.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ c-common.h | 2 + 2 files changed, 95 insertions(+) Index: llvm-gcc/gcc/c-common.h diff -u llvm-gcc/gcc/c-common.h:1.4 llvm-gcc/gcc/c-common.h:1.5 --- llvm-gcc/gcc/c-common.h:1.4 Mon Feb 14 15:24:32 2005 +++ llvm-gcc/gcc/c-common.h Sat Mar 5 12:49:20 2005 @@ -1306,6 +1306,8 @@ extern bool c_dump_tree (void *, tree); +extern tree fold_offsetof (tree); + extern void pch_init (void); extern int c_common_valid_pch (cpp_reader *pfile, const char *name, int fd); extern void c_common_read_pch (cpp_reader *pfile, const char *name, int fd, Index: llvm-gcc/gcc/c-common.c diff -u llvm-gcc/gcc/c-common.c:1.8 llvm-gcc/gcc/c-common.c:1.9 --- llvm-gcc/gcc/c-common.c:1.8 Mon Feb 14 15:24:32 2005 +++ llvm-gcc/gcc/c-common.c Sat Mar 5 12:49:21 2005 @@ -5566,6 +5566,99 @@ return NULL_TREE; } + + + +/* Given a memory reference expression T, return its base address. + The base address of a memory reference expression is the main + object being referenced. For instance, the base address for + 'array[i].fld[j]' is 'array'. You can think of this as stripping + away the offset part from a memory address. + + This function calls handled_component_p to strip away all the inner + parts of the memory reference until it reaches the base object. */ + +tree +get_base_address (tree t) +{ + while (handled_component_p (t)) + t = TREE_OPERAND (t, 0); + + if (TREE_CODE (t) == STRING_CST + || TREE_CODE (t) == CONSTRUCTOR + || TREE_CODE (t) == INDIRECT_REF) + return t; + else + return NULL_TREE; +} + + +/* Build the result of __builtin_offsetof. EXPR is a nested sequence of + component references, with an INDIRECT_REF at the bottom; much like + the traditional rendering of offsetof as a macro. Returns the folded + and properly cast result. */ + +static tree +fold_offsetof_1 (tree expr) +{ + enum tree_code code = PLUS_EXPR; + tree base, off, t; + + switch (TREE_CODE (expr)) + { + case ERROR_MARK: + return expr; + + case INDIRECT_REF: + return size_zero_node; + + case COMPONENT_REF: + base = fold_offsetof_1 (TREE_OPERAND (expr, 0)); + if (base == error_mark_node) + return base; + + t = TREE_OPERAND (expr, 1); + if (DECL_C_BIT_FIELD (t)) + { + error ("attempt to take address of bit-field structure " + "member %qs", IDENTIFIER_POINTER (DECL_NAME (t))); + return error_mark_node; + } + off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t), + size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), 1) + / BITS_PER_UNIT)); + break; + + case ARRAY_REF: + base = fold_offsetof_1 (TREE_OPERAND (expr, 0)); + if (base == error_mark_node) + return base; + + t = TREE_OPERAND (expr, 1); + if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) < 0) + { + code = MINUS_EXPR; + t = fold (build1 (NEGATE_EXPR, TREE_TYPE (t), t)); + } + t = convert (sizetype, t); + off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t); + break; + + default: + abort (); + } + + return size_binop (code, base, off); +} + +tree +fold_offsetof (tree expr) +{ + /* Convert back from the internal sizetype to size_t. */ + return convert (size_type_node, fold_offsetof_1 (expr)); +} + + /* Check for valid arguments being passed to a function. */ void From lattner at cs.uiuc.edu Sat Mar 5 12:50:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:50:15 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/c-typeck.c Message-ID: <200503051850.j25IoF8u012533@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: c-typeck.c updated: 1.7 -> 1.8 --- Log message: Support hand-written 'offsetof' macros, fixing PR533: http://llvm.cs.uiuc.edu/PR533 and Regression/CFrontend/2005-03-05-OffsetOfHack.c --- Diffs of the changes: (+10 -0) c-typeck.c | 10 ++++++++++ 1 files changed, 10 insertions(+) Index: llvm-gcc/gcc/c-typeck.c diff -u llvm-gcc/gcc/c-typeck.c:1.7 llvm-gcc/gcc/c-typeck.c:1.8 --- llvm-gcc/gcc/c-typeck.c:1.7 Mon Feb 14 15:24:42 2005 +++ llvm-gcc/gcc/c-typeck.c Sat Mar 5 12:49:59 2005 @@ -2447,6 +2447,16 @@ argtype = build_pointer_type (argtype); + + /* ??? Cope with user tricks that amount to offsetof. Delete this + when we have proper support for integer constant expressions. */ + val = get_base_address (arg); + if (val && TREE_CODE (val) == INDIRECT_REF + && integer_zerop (TREE_OPERAND (val, 0))) + return fold_convert (argtype, fold_offsetof (arg)); + + + if (!c_mark_addressable (arg)) return error_mark_node; From lattner at cs.uiuc.edu Sat Mar 5 12:50:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:50:21 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/fold-const.c Message-ID: <200503051850.j25IoLan012559@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: fold-const.c updated: 1.4 -> 1.5 --- Log message: make this public --- Diffs of the changes: (+1 -2) fold-const.c | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm-gcc/gcc/fold-const.c diff -u llvm-gcc/gcc/fold-const.c:1.4 llvm-gcc/gcc/fold-const.c:1.5 --- llvm-gcc/gcc/fold-const.c:1.4 Sun Mar 7 22:04:31 2004 +++ llvm-gcc/gcc/fold-const.c Sat Mar 5 12:48:35 2005 @@ -70,7 +70,6 @@ static tree const_binop (enum tree_code, tree, tree, int); static hashval_t size_htab_hash (const void *); static int size_htab_eq (const void *, const void *); -static tree fold_convert (tree, tree); static enum tree_code invert_tree_comparison (enum tree_code); static enum tree_code swap_tree_comparison (enum tree_code); static int comparison_to_compcode (enum tree_code); @@ -1557,7 +1556,7 @@ /* Given T, a tree representing type conversion of ARG1, a constant, return a constant tree representing the result of conversion. */ -static tree +tree fold_convert (tree t, tree arg1) { tree type = TREE_TYPE (t); From lattner at cs.uiuc.edu Sat Mar 5 12:59:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 12:59:52 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Argument.h BasicBlock.h Constant.h Function.h GlobalVariable.h Instruction.h Value.h Message-ID: <200503051859.j25Ixqxm012780@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Argument.h updated: 1.8 -> 1.9 BasicBlock.h updated: 1.48 -> 1.49 Constant.h updated: 1.20 -> 1.21 Function.h updated: 1.59 -> 1.60 GlobalVariable.h updated: 1.30 -> 1.31 Instruction.h updated: 1.63 -> 1.64 Value.h updated: 1.71 -> 1.72 --- Log message: Remove the second argument to Value::setName, it is never needed. --- Diffs of the changes: (+12 -12) Argument.h | 4 ++-- BasicBlock.h | 2 +- Constant.h | 4 ++-- Function.h | 4 ++-- GlobalVariable.h | 4 ++-- Instruction.h | 4 ++-- Value.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) Index: llvm/include/llvm/Argument.h diff -u llvm/include/llvm/Argument.h:1.8 llvm/include/llvm/Argument.h:1.9 --- llvm/include/llvm/Argument.h:1.8 Thu Mar 11 17:42:24 2004 +++ llvm/include/llvm/Argument.h Sat Mar 5 12:59:35 2005 @@ -39,8 +39,8 @@ /// Argument(const Type *Ty, const std::string &Name = "", Function *F = 0); - /// setName - Specialize setName to handle symbol table majik... - virtual void setName(const std::string &name, SymbolTable *ST = 0); + /// setName - Specialize setName to handle symbol table majik. + virtual void setName(const std::string &name); inline const Function *getParent() const { return Parent; } inline Function *getParent() { return Parent; } Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.48 llvm/include/llvm/BasicBlock.h:1.49 --- llvm/include/llvm/BasicBlock.h:1.48 Wed Feb 23 20:37:17 2005 +++ llvm/include/llvm/BasicBlock.h Sat Mar 5 12:59:35 2005 @@ -77,7 +77,7 @@ ~BasicBlock(); // Specialize setName to take care of symbol table majik - virtual void setName(const std::string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name); /// getParent - Return the enclosing method, or null if none /// Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.20 llvm/include/llvm/Constant.h:1.21 --- llvm/include/llvm/Constant.h:1.20 Fri Jan 28 18:32:00 2005 +++ llvm/include/llvm/Constant.h Sat Mar 5 12:59:36 2005 @@ -26,8 +26,8 @@ void destroyConstantImpl(); public: - // setName - Specialize setName to handle symbol table majik... - virtual void setName(const std::string &name, SymbolTable *ST = 0); + // setName - Specialize setName to handle symbol table majik. + virtual void setName(const std::string &name); /// Static constructor to get a '0' constant of arbitrary type... /// Index: llvm/include/llvm/Function.h diff -u llvm/include/llvm/Function.h:1.59 llvm/include/llvm/Function.h:1.60 --- llvm/include/llvm/Function.h:1.59 Sat Jan 29 18:08:26 2005 +++ llvm/include/llvm/Function.h Sat Mar 5 12:59:36 2005 @@ -85,8 +85,8 @@ const std::string &N = "", Module *M = 0); ~Function(); - // Specialize setName to handle symbol table majik... - virtual void setName(const std::string &name, SymbolTable *ST = 0); + // Specialize setName to handle symbol table majik. + virtual void setName(const std::string &name); const Type *getReturnType() const; // Return the type of the ret val const FunctionType *getFunctionType() const; // Return the FunctionType for me Index: llvm/include/llvm/GlobalVariable.h diff -u llvm/include/llvm/GlobalVariable.h:1.30 llvm/include/llvm/GlobalVariable.h:1.31 --- llvm/include/llvm/GlobalVariable.h:1.30 Fri Jan 28 18:32:30 2005 +++ llvm/include/llvm/GlobalVariable.h Sat Mar 5 12:59:36 2005 @@ -51,8 +51,8 @@ Constant *Initializer = 0, const std::string &Name = "", Module *Parent = 0); - // Specialize setName to handle symbol table majik... - virtual void setName(const std::string &name, SymbolTable *ST = 0); + // Specialize setName to handle symbol table majik. + virtual void setName(const std::string &name); /// isExternal - Is this global variable lacking an initializer? If so, the /// global variable is defined in some other translation unit, and is thus Index: llvm/include/llvm/Instruction.h diff -u llvm/include/llvm/Instruction.h:1.63 llvm/include/llvm/Instruction.h:1.64 --- llvm/include/llvm/Instruction.h:1.63 Fri Jan 28 18:33:00 2005 +++ llvm/include/llvm/Instruction.h Sat Mar 5 12:59:36 2005 @@ -54,8 +54,8 @@ assert(Parent == 0 && "Instruction still linked in the program!"); } - // Specialize setName to handle symbol table majik... - virtual void setName(const std::string &name, SymbolTable *ST = 0); + // Specialize setName to handle symbol table majik. + virtual void setName(const std::string &name); /// mayWriteToMemory - Return true if this instruction may modify memory. /// Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.71 llvm/include/llvm/Value.h:1.72 --- llvm/include/llvm/Value.h:1.71 Wed Feb 23 10:50:59 2005 +++ llvm/include/llvm/Value.h Sat Mar 5 12:59:36 2005 @@ -75,7 +75,7 @@ inline bool hasName() const { return !Name.empty(); } inline const std::string &getName() const { return Name; } - virtual void setName(const std::string &name, SymbolTable * = 0) { + virtual void setName(const std::string &name) { Name = name; } From lattner at cs.uiuc.edu Sat Mar 5 13:02:05 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:02:05 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Globals.cpp BasicBlock.cpp Function.cpp Message-ID: <200503051902.j25J25aP013019@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Instruction.cpp updated: 1.42 -> 1.43 Globals.cpp updated: 1.8 -> 1.9 BasicBlock.cpp updated: 1.57 -> 1.58 Function.cpp updated: 1.88 -> 1.89 --- Log message: Remove the 2nd argument to Value::setName --- Diffs of the changes: (+6 -17) BasicBlock.cpp | 4 +--- Function.cpp | 10 +++------- Globals.cpp | 4 +--- Instruction.cpp | 5 +---- 4 files changed, 6 insertions(+), 17 deletions(-) Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.42 llvm/lib/VMCore/Instruction.cpp:1.43 --- llvm/lib/VMCore/Instruction.cpp:1.42 Fri Jan 28 18:35:33 2005 +++ llvm/lib/VMCore/Instruction.cpp Sat Mar 5 13:01:49 2005 @@ -58,11 +58,8 @@ } // Specialize setName to take care of symbol table majik -void Instruction::setName(const std::string &name, SymbolTable *ST) { +void Instruction::setName(const std::string &name) { BasicBlock *P = 0; Function *PP = 0; - assert((ST == 0 || !getParent() || !getParent()->getParent() || - ST == &getParent()->getParent()->getSymbolTable()) && - "Invalid symtab argument!"); if ((P = getParent()) && (PP = P->getParent()) && hasName()) PP->getSymbolTable().remove(this); Value::setName(name); Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.8 llvm/lib/VMCore/Globals.cpp:1.9 --- llvm/lib/VMCore/Globals.cpp:1.8 Fri Jan 28 18:35:33 2005 +++ llvm/lib/VMCore/Globals.cpp Sat Mar 5 13:01:49 2005 @@ -100,10 +100,8 @@ } // Specialize setName to take care of symbol table majik -void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { +void GlobalVariable::setName(const std::string &name) { Module *P; - assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.57 llvm/lib/VMCore/BasicBlock.cpp:1.58 --- llvm/lib/VMCore/BasicBlock.cpp:1.57 Wed Feb 23 20:37:26 2005 +++ llvm/lib/VMCore/BasicBlock.cpp Sat Mar 5 13:01:49 2005 @@ -96,10 +96,8 @@ } // Specialize setName to take care of symbol table majik -void BasicBlock::setName(const std::string &name, SymbolTable *ST) { +void BasicBlock::setName(const std::string &name) { Function *P; - assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.88 llvm/lib/VMCore/Function.cpp:1.89 --- llvm/lib/VMCore/Function.cpp:1.88 Mon Feb 28 13:28:00 2005 +++ llvm/lib/VMCore/Function.cpp Sat Mar 5 13:01:49 2005 @@ -64,10 +64,8 @@ // Specialize setName to take care of symbol table majik -void Argument::setName(const std::string &name, SymbolTable *ST) { +void Argument::setName(const std::string &name) { Function *P; - assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); @@ -121,10 +119,8 @@ } // Specialize setName to take care of symbol table majik -void Function::setName(const std::string &name, SymbolTable *ST) { +void Function::setName(const std::string &name) { Module *P; - assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); @@ -170,7 +166,7 @@ for (SymbolTable::plane_iterator LPI = LST.plane_begin(), E = LST.plane_end(); LPI != E; ++LPI) // All global symbols are of pointer type, ignore any non-pointer planes. - if (isa(LPI->first)) { + if (const PointerType *CurTy = dyn_cast(LPI->first)) { // Only check if the global plane has any symbols of this type. SymbolTable::plane_iterator GPI = GST.find(LPI->first); if (GPI != GST.plane_end()) { From lattner at cs.uiuc.edu Sat Mar 5 13:02:14 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:02:14 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200503051902.j25J2Eo8013056@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.121 -> 1.122 --- Log message: Constants never get names. --- Diffs of the changes: (+2 -5) Constants.cpp | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.121 llvm/lib/VMCore/Constants.cpp:1.122 --- llvm/lib/VMCore/Constants.cpp:1.121 Fri Jan 28 18:34:39 2005 +++ llvm/lib/VMCore/Constants.cpp Sat Mar 5 13:01:59 2005 @@ -31,11 +31,8 @@ // Constant Class //===----------------------------------------------------------------------===// -// Specialize setName to take care of symbol table majik -void Constant::setName(const std::string &Name, SymbolTable *ST) { - assert(ST && "Type::setName - Must provide symbol table argument!"); - - if (Name.size()) ST->insert(Name, this); +void Constant::setName(const std::string &Name) { + // Constants can't take names. } void Constant::destroyConstantImpl() { From lattner at cs.uiuc.edu Sat Mar 5 13:02:31 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:02:31 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503051902.j25J2VkQ013068@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.50 -> 1.51 --- Log message: 2nd arg to setName goes away. --- Diffs of the changes: (+5 -8) SymbolTable.cpp | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.50 llvm/lib/VMCore/SymbolTable.cpp:1.51 --- llvm/lib/VMCore/SymbolTable.cpp:1.50 Sun Feb 13 11:54:21 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 13:02:15 2005 @@ -217,7 +217,7 @@ assert(InternallyInconsistent == false && "Infinite loop inserting value!"); InternallyInconsistent = true; - V->setName(UniqueName, this); + V->setName(UniqueName); InternallyInconsistent = false; return; } @@ -281,7 +281,7 @@ // Get the name of a type -std::string SymbolTable::get_name( const Type* T ) const { +std::string SymbolTable::get_name(const Type* T) const { if (tmap.empty()) return ""; // No types at all. type_const_iterator TI = tmap.begin(); @@ -298,7 +298,7 @@ // Strip the symbol table of its names. -bool SymbolTable::strip( void ) { +bool SymbolTable::strip() { bool RemovedSymbol = false; for (plane_iterator I = pmap.begin(); I != pmap.end();) { // Removing items from the plane can cause the plane itself to get deleted. @@ -307,12 +307,9 @@ value_iterator B = Plane.begin(), Bend = Plane.end(); while (B != Bend) { // Found nonempty type plane! Value *V = B->second; - if (!isa(V) || cast(V)->hasInternalLinkage()){ + if (!isa(V) || cast(V)->hasInternalLinkage()) { // Set name to "", removing from symbol table! - V->setName("", this); - RemovedSymbol = true; - } else if (isa(V) ) { - remove(V); + V->setName(""); RemovedSymbol = true; } ++B; From lattner at cs.uiuc.edu Sat Mar 5 13:04:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:04:21 -0600 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200503051904.j25J4L74013362@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.214 -> 1.215 --- Log message: zap --- Diffs of the changes: (+1 -1) llvmAsmParser.y | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.214 llvm/lib/AsmParser/llvmAsmParser.y:1.215 --- llvm/lib/AsmParser/llvmAsmParser.y:1.214 Wed Feb 23 23:25:17 2005 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Mar 5 13:04:07 2005 @@ -523,7 +523,7 @@ V->getType()->getDescription() + "' type plane!"); // Set the name. - V->setName(Name, &ST); + V->setName(Name); } } From lattner at cs.uiuc.edu Sat Mar 5 13:04:44 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:04:44 -0600 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/Local.cpp Message-ID: <200503051904.j25J4iOU013379@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: Local.cpp updated: 1.124 -> 1.125 --- Log message: Make sure the two arguments of a setcc instruction point to the same node. --- Diffs of the changes: (+8 -1) Local.cpp | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletion(-) Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.124 llvm/lib/Analysis/DataStructure/Local.cpp:1.125 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.124 Fri Mar 4 14:27:46 2005 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sat Mar 5 13:04:31 2005 @@ -112,7 +112,7 @@ void visitStoreInst(StoreInst &SI); void visitCallInst(CallInst &CI); void visitInvokeInst(InvokeInst &II); - void visitSetCondInst(SetCondInst &SCI) {} // SetEQ & friends are ignored + void visitSetCondInst(SetCondInst &SCI); void visitFreeInst(FreeInst &FI); void visitCastInst(CastInst &CI); void visitInstruction(Instruction &I); @@ -325,6 +325,13 @@ Dest.mergeWith(getValueDest(*SI.getOperand(2))); } +void GraphBuilder::visitSetCondInst(SetCondInst &SCI) { + if (!isPointerType(SCI.getOperand(0)->getType()) || + isa(SCI.getOperand(1))) return; // Only pointers + ScalarMap[SCI.getOperand(0)].mergeWith(getValueDest(*SCI.getOperand(1))); +} + + void GraphBuilder::visitGetElementPtrInst(User &GEP) { DSNodeHandle Value = getValueDest(*GEP.getOperand(0)); if (Value.isNull()) From lattner at cs.uiuc.edu Sat Mar 5 13:05:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:05:15 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200503051905.j25J5FG2013520@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.154 -> 1.155 --- Log message: second argument to Value::setName is now gone. --- Diffs of the changes: (+1 -1) Reader.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.154 llvm/lib/Bytecode/Reader/Reader.cpp:1.155 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.154 Wed Feb 23 23:26:04 2005 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sat Mar 5 13:05:00 2005 @@ -1063,7 +1063,7 @@ } if (V == 0) error("Failed value look-up for name '" + Name + "'"); - V->setName(Name, ST); + V->setName(Name); } } } From lattner at cs.uiuc.edu Sat Mar 5 13:05:34 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:05:34 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200503051905.j25J5Yg1013540@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.104 -> 1.105 --- Log message: second argument to Value::setName is now gone. --- Diffs of the changes: (+1 -1) LevelRaise.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.104 llvm/lib/Transforms/LevelRaise.cpp:1.105 --- llvm/lib/Transforms/LevelRaise.cpp:1.104 Wed Jan 19 10:16:35 2005 +++ llvm/lib/Transforms/LevelRaise.cpp Sat Mar 5 13:05:18 2005 @@ -253,7 +253,7 @@ if (!Src->hasName() && CI->hasName()) { std::string Name = CI->getName(); CI->setName(""); - Src->setName(Name, &BB->getParent()->getSymbolTable()); + Src->setName(Name); } // DCE the instruction now, to avoid having the iterative version of DCE From lattner at cs.uiuc.edu Sat Mar 5 13:05:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:05:37 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp Message-ID: <200503051905.j25J5bXr013546@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: BasicBlockUtils.cpp updated: 1.11 -> 1.12 --- Log message: second argument to Value::setName is now gone. --- Diffs of the changes: (+3 -3) BasicBlockUtils.cpp | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp diff -u llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.11 llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.12 --- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp:1.11 Thu Jul 29 12:21:57 2004 +++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp Sat Mar 5 13:05:20 2005 @@ -34,9 +34,9 @@ // Delete the unnecessary instruction now... BI = BIL.erase(BI); - // Make sure to propagate a name if there is one already... - if (OldName.size() && !V->hasName()) - V->setName(OldName, &BIL.getParent()->getSymbolTable()); + // Make sure to propagate a name if there is one already. + if (!OldName.empty() && !V->hasName()) + V->setName(OldName); } From lattner at cs.uiuc.edu Sat Mar 5 13:51:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:51:37 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Argument.h BasicBlock.h Constant.h Function.h GlobalVariable.h Instruction.h Value.h Message-ID: <200503051951.j25JpbQM027997@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Argument.h updated: 1.9 -> 1.10 BasicBlock.h updated: 1.49 -> 1.50 Constant.h updated: 1.21 -> 1.22 Function.h updated: 1.60 -> 1.61 GlobalVariable.h updated: 1.31 -> 1.32 Instruction.h updated: 1.64 -> 1.65 Value.h updated: 1.72 -> 1.73 --- Log message: remove all of the various setName implementations, consolidating them into Value::setName, which is no longer virtual. --- Diffs of the changes: (+1 -21) Argument.h | 3 --- BasicBlock.h | 3 --- Constant.h | 3 --- Function.h | 3 --- GlobalVariable.h | 3 --- Instruction.h | 3 --- Value.h | 4 +--- 7 files changed, 1 insertion(+), 21 deletions(-) Index: llvm/include/llvm/Argument.h diff -u llvm/include/llvm/Argument.h:1.9 llvm/include/llvm/Argument.h:1.10 --- llvm/include/llvm/Argument.h:1.9 Sat Mar 5 12:59:35 2005 +++ llvm/include/llvm/Argument.h Sat Mar 5 13:51:20 2005 @@ -39,9 +39,6 @@ /// Argument(const Type *Ty, const std::string &Name = "", Function *F = 0); - /// setName - Specialize setName to handle symbol table majik. - virtual void setName(const std::string &name); - inline const Function *getParent() const { return Parent; } inline Function *getParent() { return Parent; } Index: llvm/include/llvm/BasicBlock.h diff -u llvm/include/llvm/BasicBlock.h:1.49 llvm/include/llvm/BasicBlock.h:1.50 --- llvm/include/llvm/BasicBlock.h:1.49 Sat Mar 5 12:59:35 2005 +++ llvm/include/llvm/BasicBlock.h Sat Mar 5 13:51:20 2005 @@ -76,9 +76,6 @@ BasicBlock *InsertBefore = 0); ~BasicBlock(); - // Specialize setName to take care of symbol table majik - virtual void setName(const std::string &name); - /// getParent - Return the enclosing method, or null if none /// const Function *getParent() const { return InstList.getParent(); } Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.21 llvm/include/llvm/Constant.h:1.22 --- llvm/include/llvm/Constant.h:1.21 Sat Mar 5 12:59:36 2005 +++ llvm/include/llvm/Constant.h Sat Mar 5 13:51:20 2005 @@ -26,9 +26,6 @@ void destroyConstantImpl(); public: - // setName - Specialize setName to handle symbol table majik. - virtual void setName(const std::string &name); - /// Static constructor to get a '0' constant of arbitrary type... /// static Constant *getNullValue(const Type *Ty); Index: llvm/include/llvm/Function.h diff -u llvm/include/llvm/Function.h:1.60 llvm/include/llvm/Function.h:1.61 --- llvm/include/llvm/Function.h:1.60 Sat Mar 5 12:59:36 2005 +++ llvm/include/llvm/Function.h Sat Mar 5 13:51:20 2005 @@ -85,9 +85,6 @@ const std::string &N = "", Module *M = 0); ~Function(); - // Specialize setName to handle symbol table majik. - virtual void setName(const std::string &name); - const Type *getReturnType() const; // Return the type of the ret val const FunctionType *getFunctionType() const; // Return the FunctionType for me Index: llvm/include/llvm/GlobalVariable.h diff -u llvm/include/llvm/GlobalVariable.h:1.31 llvm/include/llvm/GlobalVariable.h:1.32 --- llvm/include/llvm/GlobalVariable.h:1.31 Sat Mar 5 12:59:36 2005 +++ llvm/include/llvm/GlobalVariable.h Sat Mar 5 13:51:20 2005 @@ -51,9 +51,6 @@ Constant *Initializer = 0, const std::string &Name = "", Module *Parent = 0); - // Specialize setName to handle symbol table majik. - virtual void setName(const std::string &name); - /// isExternal - Is this global variable lacking an initializer? If so, the /// global variable is defined in some other translation unit, and is thus /// externally defined here. Index: llvm/include/llvm/Instruction.h diff -u llvm/include/llvm/Instruction.h:1.64 llvm/include/llvm/Instruction.h:1.65 --- llvm/include/llvm/Instruction.h:1.64 Sat Mar 5 12:59:36 2005 +++ llvm/include/llvm/Instruction.h Sat Mar 5 13:51:20 2005 @@ -54,9 +54,6 @@ assert(Parent == 0 && "Instruction still linked in the program!"); } - // Specialize setName to handle symbol table majik. - virtual void setName(const std::string &name); - /// mayWriteToMemory - Return true if this instruction may modify memory. /// virtual bool mayWriteToMemory() const { return false; } Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.72 llvm/include/llvm/Value.h:1.73 --- llvm/include/llvm/Value.h:1.72 Sat Mar 5 12:59:36 2005 +++ llvm/include/llvm/Value.h Sat Mar 5 13:51:20 2005 @@ -75,9 +75,7 @@ inline bool hasName() const { return !Name.empty(); } inline const std::string &getName() const { return Name; } - virtual void setName(const std::string &name) { - Name = name; - } + void setName(const std::string &name); /// replaceAllUsesWith - Go through the uses list for this definition and make /// each use point to "V" instead of "this". After this completes, 'this's From lattner at cs.uiuc.edu Sat Mar 5 13:52:03 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:52:03 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Constants.cpp Function.cpp Globals.cpp Instruction.cpp Value.cpp Message-ID: <200503051952.j25Jq3ti028019@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.58 -> 1.59 Constants.cpp updated: 1.122 -> 1.123 Function.cpp updated: 1.89 -> 1.90 Globals.cpp updated: 1.9 -> 1.10 Instruction.cpp updated: 1.43 -> 1.44 Value.cpp updated: 1.54 -> 1.55 --- Log message: remove all of the various setName implementations, consolidating them into Value::setName, which is no longer virtual. --- Diffs of the changes: (+28 -50) BasicBlock.cpp | 9 --------- Constants.cpp | 4 ---- Function.cpp | 17 ----------------- Globals.cpp | 8 -------- Instruction.cpp | 9 --------- Value.cpp | 31 ++++++++++++++++++++++++++++--- 6 files changed, 28 insertions(+), 50 deletions(-) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.58 llvm/lib/VMCore/BasicBlock.cpp:1.59 --- llvm/lib/VMCore/BasicBlock.cpp:1.58 Sat Mar 5 13:01:49 2005 +++ llvm/lib/VMCore/BasicBlock.cpp Sat Mar 5 13:51:49 2005 @@ -16,7 +16,6 @@ #include "llvm/Instructions.h" #include "llvm/Type.h" #include "llvm/Support/CFG.h" -#include "llvm/SymbolTable.h" #include "llvm/Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" #include @@ -95,14 +94,6 @@ LeakDetector::removeGarbageObject(this); } -// Specialize setName to take care of symbol table majik -void BasicBlock::setName(const std::string &name) { - Function *P; - if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); - Value::setName(name); - if (P && hasName()) P->getSymbolTable().insert(this); -} - void BasicBlock::removeFromParent() { getParent()->getBasicBlockList().remove(this); } Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.122 llvm/lib/VMCore/Constants.cpp:1.123 --- llvm/lib/VMCore/Constants.cpp:1.122 Sat Mar 5 13:01:59 2005 +++ llvm/lib/VMCore/Constants.cpp Sat Mar 5 13:51:50 2005 @@ -31,10 +31,6 @@ // Constant Class //===----------------------------------------------------------------------===// -void Constant::setName(const std::string &Name) { - // Constants can't take names. -} - void Constant::destroyConstantImpl() { // When a Constant is destroyed, there may be lingering // references to the constant by other constants in the constant pool. These Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.89 llvm/lib/VMCore/Function.cpp:1.90 --- llvm/lib/VMCore/Function.cpp:1.89 Sat Mar 5 13:01:49 2005 +++ llvm/lib/VMCore/Function.cpp Sat Mar 5 13:51:50 2005 @@ -62,15 +62,6 @@ Par->getArgumentList().push_back(this); } - -// Specialize setName to take care of symbol table majik -void Argument::setName(const std::string &name) { - Function *P; - if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); - Value::setName(name); - if (P && hasName()) P->getSymbolTable().insert(this); -} - void Argument::setParent(Function *parent) { if (getParent()) LeakDetector::addGarbageObject(this); @@ -118,14 +109,6 @@ delete SymTab; } -// Specialize setName to take care of symbol table majik -void Function::setName(const std::string &name) { - Module *P; - if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); - Value::setName(name); - if (P && hasName()) P->getSymbolTable().insert(this); -} - void Function::setParent(Module *parent) { if (getParent()) LeakDetector::addGarbageObject(this); Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.9 llvm/lib/VMCore/Globals.cpp:1.10 --- llvm/lib/VMCore/Globals.cpp:1.9 Sat Mar 5 13:01:49 2005 +++ llvm/lib/VMCore/Globals.cpp Sat Mar 5 13:51:50 2005 @@ -99,14 +99,6 @@ LeakDetector::removeGarbageObject(this); } -// Specialize setName to take care of symbol table majik -void GlobalVariable::setName(const std::string &name) { - Module *P; - if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); - Value::setName(name); - if (P && hasName()) P->getSymbolTable().insert(this); -} - void GlobalVariable::removeFromParent() { getParent()->getGlobalList().remove(this); } Index: llvm/lib/VMCore/Instruction.cpp diff -u llvm/lib/VMCore/Instruction.cpp:1.43 llvm/lib/VMCore/Instruction.cpp:1.44 --- llvm/lib/VMCore/Instruction.cpp:1.43 Sat Mar 5 13:01:49 2005 +++ llvm/lib/VMCore/Instruction.cpp Sat Mar 5 13:51:50 2005 @@ -57,15 +57,6 @@ Parent = P; } -// Specialize setName to take care of symbol table majik -void Instruction::setName(const std::string &name) { - BasicBlock *P = 0; Function *PP = 0; - if ((P = getParent()) && (PP = P->getParent()) && hasName()) - PP->getSymbolTable().remove(this); - Value::setName(name); - if (PP && hasName()) PP->getSymbolTable().insert(this); -} - void Instruction::removeFromParent() { getParent()->getInstList().remove(this); } Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.54 llvm/lib/VMCore/Value.cpp:1.55 --- llvm/lib/VMCore/Value.cpp:1.54 Wed Feb 23 10:51:11 2005 +++ llvm/lib/VMCore/Value.cpp Sat Mar 5 13:51:50 2005 @@ -11,11 +11,11 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Constant.h" +#include "llvm/DerivedTypes.h" #include "llvm/InstrTypes.h" +#include "llvm/Module.h" #include "llvm/SymbolTable.h" -#include "llvm/DerivedTypes.h" -#include "llvm/Constant.h" -#include "llvm/GlobalValue.h" #include "llvm/Support/LeakDetector.h" #include #include @@ -93,6 +93,31 @@ } +void Value::setName(const std::string &name) { + if (Name == name) return; // Name is already set. + + SymbolTable *ST = 0; + + if (Instruction *I = dyn_cast(this)) { + if (BasicBlock *P = I->getParent()) + if (Function *PP = P->getParent()) + ST = &PP->getSymbolTable(); + } else if (BasicBlock *BB = dyn_cast(this)) { + if (Function *P = BB->getParent()) ST = &P->getSymbolTable(); + } else if (GlobalValue *GV = dyn_cast(this)) { + if (Module *P = GV->getParent()) ST = &P->getSymbolTable(); + } else if (Argument *A = dyn_cast(this)) { + if (Function *P = A->getParent()) ST = &P->getSymbolTable(); + } else { + assert(isa(this) && "Unknown value type!"); + return; // no name is setable for this. + } + + if (ST && hasName()) ST->remove(this); + Name = name; + if (ST && hasName()) ST->insert(this); +} + // uncheckedReplaceAllUsesWith - This is exactly the same as replaceAllUsesWith, // except that it doesn't have all of the asserts. The asserts fail because we // are half-way done resolving types, which causes some types to exist as two From lattner at cs.uiuc.edu Sat Mar 5 13:58:53 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 13:58:53 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503051958.j25JwrqH028036@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.39 -> 1.40 --- Log message: remove extraneous spaces from argument lists. --- Diffs of the changes: (+11 -11) SymbolTable.h | 22 +++++++++++----------- 1 files changed, 11 insertions(+), 11 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.39 llvm/include/llvm/SymbolTable.h:1.40 --- llvm/include/llvm/SymbolTable.h:1.39 Sun Dec 5 00:33:15 2004 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 13:58:40 2005 @@ -101,7 +101,7 @@ /// @returns null if the name is not found, otherwise the Type /// associated with the \p name. /// @brief Lookup a type by name. - Type* lookupType( const std::string& name ) const; + Type* lookupType(const std::string& name) const; /// @returns true iff the type map is not empty. /// @brief Determine if there are types in the symbol table @@ -125,11 +125,11 @@ /// name. Only the type plane associated with the type of \p val /// is searched. /// @brief Return the name of a value - std::string get_name( const Value* Val ) const; + std::string get_name(const Value* Val) const; /// Finds the type \p Ty in the symbol table and returns its name. /// @brief Return the name of a type - std::string get_name( const Type* Ty ) const; + std::string get_name(const Type* Ty) const; /// Given a base name, return a string that is either equal to it or /// derived from it that does not already occur in the symbol table @@ -176,7 +176,7 @@ /// @brief Insert a type under a new name. inline void insert(const std::string &Name, const Type *Typ) { assert(Typ && "Can't insert null type into symbol table!"); - insertEntry(Name, Typ ); + insertEntry(Name, Typ); } /// This method removes a named value from the symbol table. The @@ -192,7 +192,7 @@ /// the Type in the type map. If the Type is not in the symbol /// table, this method silently ignores the request. /// @brief Remove a named type from the symbol table. - void remove(const Type* Typ ); + void remove(const Type* Typ); /// Remove a constant or type with the specified name from the /// symbol table. @@ -297,15 +297,15 @@ /// This method returns a plane_const_iterator for iteration over /// the type planes starting at a specific plane, given by \p Ty. /// @brief Find a type plane. - inline plane_const_iterator find(const Type* Typ ) const { + inline plane_const_iterator find(const Type* Typ) const { assert(Typ && "Can't find type plane with null type!"); - return pmap.find( Typ ); + return pmap.find(Typ); } /// This method returns a plane_iterator for iteration over the /// type planes starting at a specific plane, given by \p Ty. /// @brief Find a type plane. - inline plane_iterator find( const Type* Typ ) { + inline plane_iterator find(const Type* Typ) { assert(Typ && "Can't find type plane with null type!"); return pmap.find(Typ); } @@ -314,10 +314,10 @@ /// interface is deprecated and may go away in the future. /// @deprecated /// @brief Find a type plane - inline const ValueMap* findPlane( const Type* Typ ) const { + inline const ValueMap* findPlane(const Type* Typ) const { assert(Typ && "Can't find type plane with null type!"); - plane_const_iterator I = pmap.find( Typ ); - if ( I == pmap.end() ) return 0; + plane_const_iterator I = pmap.find(Typ); + if (I == pmap.end()) return 0; return &I->second; } From jeffc at jolt-lang.org Sat Mar 5 16:40:45 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Sat, 5 Mar 2005 16:40:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503052240.QAA06071@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.6 -> 1.7 --- Log message: Reuse induction variables created for strength-reduced GEPs by other similar GEPs. --- Diffs of the changes: (+61 -32) LoopStrengthReduce.cpp | 93 ++++++++++++++++++++++++++++++++----------------- 1 files changed, 61 insertions(+), 32 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.6 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.7 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.6 Thu Mar 3 22:04:26 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sat Mar 5 16:40:34 2005 @@ -35,6 +35,22 @@ namespace { Statistic<> NumReduced ("loop-reduce", "Number of GEPs strength reduced"); + class GEPCache + { + public: + GEPCache() : CachedPHINode(0), Map() {} + + GEPCache* operator[](Value *v) { + std::map::iterator I = Map.find(v); + if (I == Map.end()) + I = Map.insert(std::pair(v, GEPCache())).first; + return &(I->second); + } + + PHINode *CachedPHINode; + std::map Map; + }; + class LoopStrengthReduce : public FunctionPass { LoopInfo *LI; DominatorSet *DS; @@ -65,6 +81,7 @@ private: void runOnLoop(Loop *L); void strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, + GEPCache* GEPCache, Instruction *InsertBefore, std::set &DeadInsts); void DeleteTriviallyDeadInstructions(std::set &Insts); @@ -96,6 +113,7 @@ } void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, + GEPCache *Cache, Instruction *InsertBefore, std::set &DeadInsts) { // We will strength reduce the GEP by splitting it into two parts. The first @@ -117,6 +135,7 @@ BasicBlock *Header = L->getHeader(); BasicBlock *Preheader = L->getLoopPreheader(); bool AllConstantOperands = true; + Cache = (*Cache)[GEPI->getOperand(0)]; for (unsigned op = 1, e = GEPI->getNumOperands(); op != e; ++op) { Value *operand = GEPI->getOperand(op); @@ -145,6 +164,7 @@ AllConstantOperands = false; } else return; + Cache = (*Cache)[operand]; } assert(indvar > 0 && "Indvar used by GEP not found in operand list"); @@ -157,7 +177,7 @@ if (!DS->dominates(GepPtrOp, Preheader->getTerminator())) return; - // Don't reduced multiplies that the target can handle via addressing modes. + // Don't reduce multiplies that the target can handle via addressing modes. uint64_t sz = getAnalysis().getTypeSize(ty); for (unsigned i = 1; i <= MaxTargetAMSize; i *= 2) if (i == sz) @@ -169,38 +189,46 @@ // If there is only one operand after the initial non-constant one, we know // that it was the induction variable, and has been replaced by a constant // null value. In this case, replace the GEP with a use of pointer directly. - Value *PreGEP; - if (AllConstantOperands && isa(GEPI->getOperand(0))) { - Constant *C = dyn_cast(GEPI->getOperand(0)); - PreGEP = ConstantExpr::getGetElementPtr(C, pre_op_vector); - } else if (pre_op_vector.size() == 1) { - PreGEP = GEPI->getOperand(0); + PHINode *NewPHI; + if (1) { + Value *PreGEP; + if (AllConstantOperands && isa(GEPI->getOperand(0))) { + Constant *C = dyn_cast(GEPI->getOperand(0)); + PreGEP = ConstantExpr::getGetElementPtr(C, pre_op_vector); + } else if (pre_op_vector.size() == 1) { + PreGEP = GEPI->getOperand(0); + } else { + PreGEP = new GetElementPtrInst(GEPI->getOperand(0), + pre_op_vector, GEPI->getName()+".pre", + Preheader->getTerminator()); + } + + // The next step of the strength reduction is to create a PHI that will choose + // between the initial GEP we created and inserted into the preheader, and + // the incremented GEP that we will create below and insert into the loop body + NewPHI = new PHINode(PreGEP->getType(), + GEPI->getName()+".str", InsertBefore); + NewPHI->addIncoming(PreGEP, Preheader); + + // Now, create the GEP instruction to increment by one the value selected by + // the PHI instruction we just created above, and add it as the second + // incoming Value/BasicBlock pair to the PHINode. It is inserted before the + // increment of the canonical induction variable. + Instruction *IncrInst = + const_cast(L->getCanonicalInductionVariableIncrement()); + GetElementPtrInst *StrGEP = new GetElementPtrInst(NewPHI, inc_op_vector, + GEPI->getName()+".inc", + IncrInst); + pred_iterator PI = pred_begin(Header); + if (*PI == Preheader) + ++PI; + NewPHI->addIncoming(StrGEP, *PI); + Cache->CachedPHINode = NewPHI; } else { - PreGEP = new GetElementPtrInst(GEPI->getOperand(0), - pre_op_vector, GEPI->getName()+".pre", - Preheader->getTerminator()); + // Reuse previously created pointer, as it is identical to the one we were + // about to create. + NewPHI = Cache->CachedPHINode; } - - // The next step of the strength reduction is to create a PHI that will choose - // between the initial GEP we created and inserted into the preheader, and - // the incremented GEP that we will create below and insert into the loop body - PHINode *NewPHI = new PHINode(PreGEP->getType(), - GEPI->getName()+".str", InsertBefore); - NewPHI->addIncoming(PreGEP, Preheader); - - // Now, create the GEP instruction to increment by one the value selected by - // the PHI instruction we just created above, and add it as the second - // incoming Value/BasicBlock pair to the PHINode. It is inserted before the - // increment of the canonical induction variable. - Instruction *IncrInst = - const_cast(L->getCanonicalInductionVariableIncrement()); - GetElementPtrInst *StrGEP = new GetElementPtrInst(NewPHI, inc_op_vector, - GEPI->getName()+".inc", - IncrInst); - pred_iterator PI = pred_begin(Header); - if (*PI == Preheader) - ++PI; - NewPHI->addIncoming(StrGEP, *PI); if (GEPI->getNumOperands() - 1 == indvar) { // If there were no operands following the induction variable, replace all @@ -246,10 +274,11 @@ // strength reduced pointers we'll be creating after the canonical induction // variable's PHI. std::set DeadInsts; + GEPCache Cache; for (Value::use_iterator UI = PN->use_begin(), UE = PN->use_end(); UI != UE; ++UI) if (GetElementPtrInst *GEPI = dyn_cast(*UI)) - strengthReduceGEP(GEPI, L, PN->getNext(), DeadInsts); + strengthReduceGEP(GEPI, L, &Cache, PN->getNext(), DeadInsts); // Clean up after ourselves if (!DeadInsts.empty()) { From jeffc at jolt-lang.org Sat Mar 5 16:45:51 2005 From: jeffc at jolt-lang.org (Jeff Cohen) Date: Sat, 5 Mar 2005 16:45:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503052245.QAA06103@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.7 -> 1.8 --- Log message: Reformat comments to fix 80 columns. --- Diffs of the changes: (+8 -7) LoopStrengthReduce.cpp | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.7 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.8 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.7 Sat Mar 5 16:40:34 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sat Mar 5 16:45:40 2005 @@ -203,17 +203,18 @@ Preheader->getTerminator()); } - // The next step of the strength reduction is to create a PHI that will choose - // between the initial GEP we created and inserted into the preheader, and - // the incremented GEP that we will create below and insert into the loop body + // The next step of the strength reduction is to create a PHI that will + // choose between the initial GEP we created and inserted into the + // preheader, and the incremented GEP that we will create below and insert + // into the loop body. NewPHI = new PHINode(PreGEP->getType(), GEPI->getName()+".str", InsertBefore); NewPHI->addIncoming(PreGEP, Preheader); - // Now, create the GEP instruction to increment by one the value selected by - // the PHI instruction we just created above, and add it as the second - // incoming Value/BasicBlock pair to the PHINode. It is inserted before the - // increment of the canonical induction variable. + // Now, create the GEP instruction to increment by one the value selected + // by the PHI instruction we just created above, and add it as the second + // incoming Value/BasicBlock pair to the PHINode. It is inserted before + // the increment of the canonical induction variable. Instruction *IncrInst = const_cast(L->getCanonicalInductionVariableIncrement()); GetElementPtrInst *StrGEP = new GetElementPtrInst(NewPHI, inc_op_vector, From lattner at cs.uiuc.edu Sat Mar 5 20:11:10 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:11:10 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Value.h Message-ID: <200503060211.j262B9in006949@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.40 -> 1.41 Value.h updated: 1.73 -> 1.74 --- Log message: Add a new method, allow symtab to poke name. --- Diffs of the changes: (+10 -0) SymbolTable.h | 8 ++++++++ Value.h | 2 ++ 2 files changed, 10 insertions(+) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.40 llvm/include/llvm/SymbolTable.h:1.41 --- llvm/include/llvm/SymbolTable.h:1.40 Sat Mar 5 13:58:40 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 20:10:40 2005 @@ -217,6 +217,14 @@ return this->removeEntry(pmap.find(It->second->getType()), It); } + /// changeName - Given a value with a non-empty name, remove its existing + /// entry from the symbol table and insert a new one for Name. This is + /// equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster, + /// and will not temporarily remove the symbol table plane if V is the last + /// value in the symtab with that name (which could invalidate iterators to + /// that plane). + void changeName(Value *V, const std::string &Name); + /// This method will strip the symbol table of its names leaving /// the type and values. /// @brief Strip the symbol table. Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.73 llvm/include/llvm/Value.h:1.74 --- llvm/include/llvm/Value.h:1.73 Sat Mar 5 13:51:20 2005 +++ llvm/include/llvm/Value.h Sat Mar 5 20:10:40 2005 @@ -50,6 +50,8 @@ private: PATypeHolder Ty; Use *UseList; + + friend class SymbolTable; // Allow SymbolTable to directly poke Name. std::string Name; void operator=(const Value &); // Do not implement From lattner at cs.uiuc.edu Sat Mar 5 20:14:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:14:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Value.cpp Message-ID: <200503060214.j262EpLj006970@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.51 -> 1.52 Value.cpp updated: 1.55 -> 1.56 --- Log message: This fixes PR531: http://llvm.cs.uiuc.edu/PR531 , a crash when running the CBE on a bytecode file. The problem is that Function::renameLocalSymbols is iterating through the symbol table planes, occasionally calling setName to rename a value (which used to do a symbol table remove/insert pair). The problem is that if there is only a single value in a particular type plane that the remove will nuke the symbol table plane, and the insert will create and insert a new one. This hoses Function::renameLocalSymbols because it has an iterator to the old plane, under the (very reasonable) assumption that simply renaming a value won't cause the type plane to disappear. This patch fixes the bug by making the rename operation a single atomic operation, which has a side effect of making the whole thing faster too. :) --- Diffs of the changes: (+50 -4) SymbolTable.cpp | 36 ++++++++++++++++++++++++++++++++++++ Value.cpp | 18 ++++++++++++++---- 2 files changed, 50 insertions(+), 4 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.51 llvm/lib/VMCore/SymbolTable.cpp:1.52 --- llvm/lib/VMCore/SymbolTable.cpp:1.51 Sat Mar 5 13:02:15 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 20:14:28 2005 @@ -102,6 +102,42 @@ removeEntry(PI, PI->second.find(N->getName())); } +/// changeName - Given a value with a non-empty name, remove its existing entry +/// from the symbol table and insert a new one for Name. This is equivalent to +/// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not +/// temporarily remove the symbol table plane if V is the last value in the +/// symtab with that name (which could invalidate iterators to that plane). +void SymbolTable::changeName(Value *V, const std::string &name) { + assert(!V->getName().empty() && !name.empty() && V->getName() != name && + "Illegal use of this method!"); + + plane_iterator PI = pmap.find(V->getType()); + assert(PI != pmap.end() && "Value doesn't have an entry in this table?"); + ValueMap &VM = PI->second; + + value_iterator VI; + + if (!InternallyInconsistent) { + VI = VM.find(V->getName()); + assert(VI != VM.end() && "Value does have an entry in this table?"); + + // Remove the old entry. + VM.erase(VI); + } + + // See if we can insert the new name. + VI = VM.lower_bound(name); + + // Is there a naming conflict? + if (VI != VM.end() && VI->first == name) { + V->Name = getUniqueName(V->getType(), name); + VM.insert(make_pair(V->Name, V)); + } else { + V->Name = name; + VM.insert(VI, make_pair(name, V)); + } +} + // removeEntry - Remove a value from the symbol table... Value *SymbolTable::removeEntry(plane_iterator Plane, value_iterator Entry) { Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.55 llvm/lib/VMCore/Value.cpp:1.56 --- llvm/lib/VMCore/Value.cpp:1.55 Sat Mar 5 13:51:50 2005 +++ llvm/lib/VMCore/Value.cpp Sat Mar 5 20:14:28 2005 @@ -96,8 +96,8 @@ void Value::setName(const std::string &name) { if (Name == name) return; // Name is already set. + // Get the symbol table to update for this object. SymbolTable *ST = 0; - if (Instruction *I = dyn_cast(this)) { if (BasicBlock *P = I->getParent()) if (Function *PP = P->getParent()) @@ -113,9 +113,19 @@ return; // no name is setable for this. } - if (ST && hasName()) ST->remove(this); - Name = name; - if (ST && hasName()) ST->insert(this); + if (!ST) // No symbol table to update? Just do the change. + Name = name; + else if (hasName()) { + if (!name.empty()) { // Replacing name. + ST->changeName(this, name); + } else { // Transitioning from hasName -> noname. + ST->remove(this); + Name.clear(); + } + } else { // Transitioning from noname -> hasName. + Name = name; + ST->insert(this); + } } // uncheckedReplaceAllUsesWith - This is exactly the same as replaceAllUsesWith, From lattner at cs.uiuc.edu Sat Mar 5 20:25:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:25:43 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060225.j262PcFF008657@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.41 -> 1.42 --- Log message: nuke some dead methods. --- Diffs of the changes: (+0 -20) SymbolTable.h | 20 -------------------- 1 files changed, 20 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.41 llvm/include/llvm/SymbolTable.h:1.42 --- llvm/include/llvm/SymbolTable.h:1.41 Sat Mar 5 20:10:40 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 20:25:02 2005 @@ -159,16 +159,6 @@ insertEntry(Val->getName(), Val->getType(), Val); } - /// Inserts a constant into the symbol table with the specified - /// name. There can be a many to one mapping between names and constants. - /// @brief Insert a constant or type. - inline void insert(const std::string &Name, Value *Val) { - assert(Val && "Can't insert null type into symbol table!"); - assert(isa(Val) && - "Can only insert constants into a symbol table!"); - insertEntry(Name, Val->getType(), Val); - } - /// Inserts a type into the symbol table with the specified name. There /// can be a many-to-one mapping between names and types. This method /// allows a type with an existing entry in the symbol table to get @@ -194,16 +184,6 @@ /// @brief Remove a named type from the symbol table. void remove(const Type* Typ); - /// Remove a constant or type with the specified name from the - /// symbol table. - /// @returns the removed Value. - /// @brief Remove a constant or type from the symbol table. - inline Value* remove(const std::string &Name, Value *Val) { - assert(Val && "Can't remove null value from symbol table!"); - plane_iterator PI = pmap.find(Val->getType()); - return removeEntry(PI, PI->second.find(Name)); - } - /// Remove a type at the specified position in the symbol table. /// @returns the removed Type. inline Type* remove(type_iterator TI) { From lattner at cs.uiuc.edu Sat Mar 5 20:28:42 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:28:42 -0600 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200503060228.j262Sgh0010977@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.227 -> 1.228 --- Log message: simplify some code. --- Diffs of the changes: (+4 -5) Writer.cpp | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.227 llvm/lib/Target/CBackend/Writer.cpp:1.228 --- llvm/lib/Target/CBackend/Writer.cpp:1.227 Thu Mar 3 15:12:04 2005 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Mar 5 20:28:23 2005 @@ -990,13 +990,12 @@ /// type name is found, emit it's declaration... /// void CWriter::printModuleTypes(const SymbolTable &ST) { - // If there are no type names, exit early. - if ( ! ST.hasTypes() ) - return; - - // We are only interested in the type plane of the symbol table... + // We are only interested in the type plane of the symbol table. SymbolTable::type_const_iterator I = ST.type_begin(); SymbolTable::type_const_iterator End = ST.type_end(); + + // If there are no type names, exit early. + if (I == End) return; // Print out forward declarations for structure types before anything else! Out << "/* Structure forward decls */\n"; From lattner at cs.uiuc.edu Sat Mar 5 20:32:23 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:32:23 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotTable.h Writer.cpp Message-ID: <200503060232.j262WNaN015259@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: SlotTable.h updated: 1.3 -> 1.4 Writer.cpp updated: 1.93 -> 1.94 --- Log message: simplify and speed up some code --- Diffs of the changes: (+1 -4) SlotTable.h | 3 --- Writer.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotTable.h diff -u llvm/lib/Bytecode/Writer/SlotTable.h:1.3 llvm/lib/Bytecode/Writer/SlotTable.h:1.4 --- llvm/lib/Bytecode/Writer/SlotTable.h:1.3 Thu Jun 17 13:17:59 2004 +++ llvm/lib/Bytecode/Writer/SlotTable.h Sat Mar 5 20:32:00 2005 @@ -91,9 +91,6 @@ /// @brief Get the number of planes of values. size_t value_size() const { return vTable.size(); } - /// @brief Get the number of types. - size_t type_size() const { return tPlane.size(); } - /// @brief Determine if a specific type plane in the value table exists bool plane_exists(PlaneNum plane) const { return vTable.size() > plane; Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.93 llvm/lib/Bytecode/Writer/Writer.cpp:1.94 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.93 Sun Feb 27 00:16:15 2005 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sat Mar 5 20:32:00 2005 @@ -1071,7 +1071,7 @@ if (I == End) continue; // Don't mess with an absent type... // Write the number of values in this plane - output_vbr(MST.type_size(PI->first)); + output_vbr(PI->second.size()); // Write the slot number of the type for this plane Slot = Table.getSlot(PI->first); From lattner at cs.uiuc.edu Sat Mar 5 20:38:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:38:18 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060238.j262cGeO022449@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.52 -> 1.53 --- Log message: remove these methods. --- Diffs of the changes: (+0 -42) SymbolTable.cpp | 42 ------------------------------------------ 1 files changed, 42 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.52 llvm/lib/VMCore/SymbolTable.cpp:1.53 --- llvm/lib/VMCore/SymbolTable.cpp:1.52 Sat Mar 5 20:14:28 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 20:37:47 2005 @@ -291,48 +291,6 @@ } } - -// Determine how many entries for a given type. -unsigned SymbolTable::type_size(const Type *Ty) const { - plane_const_iterator PI = pmap.find(Ty); - if ( PI == pmap.end() ) return 0; - return PI->second.size(); -} - - -// Get the name of a value -std::string SymbolTable::get_name( const Value* V ) const { - value_const_iterator VI = this->value_begin( V->getType() ); - value_const_iterator VE = this->value_end( V->getType() ); - - // Search for the entry - while ( VI != VE && VI->second != V ) - ++VI; - - if ( VI != VE ) - return VI->first; - - return ""; -} - - -// Get the name of a type -std::string SymbolTable::get_name(const Type* T) const { - if (tmap.empty()) return ""; // No types at all. - - type_const_iterator TI = tmap.begin(); - type_const_iterator TE = tmap.end(); - - // Search for the entry - while (TI != TE && TI->second != T ) - ++TI; - - if (TI != TE) // Must have found an entry! - return TI->first; - return ""; // Must not have found anything... -} - - // Strip the symbol table of its names. bool SymbolTable::strip() { bool RemovedSymbol = false; From lattner at cs.uiuc.edu Sat Mar 5 20:38:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:38:18 -0600 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200503060238.j262cGFE022440@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.75 -> 1.76 --- Log message: These methods are removed. --- Diffs of the changes: (+1 -9) ProgrammersManual.html | 10 +--------- 1 files changed, 1 insertion(+), 9 deletions(-) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.75 llvm/docs/ProgrammersManual.html:1.76 --- llvm/docs/ProgrammersManual.html:1.75 Sun Jan 16 18:12:04 2005 +++ llvm/docs/ProgrammersManual.html Sat Mar 5 20:37:21 2005 @@ -1878,14 +1878,6 @@
    bool isEmpty() const:
    This function returns true if both the value and types maps are empty
    - -
    std::string get_name(const Value*) const:
    -
    This function returns the name of the Value provided or the empty - string if the Value is not in the symbol table.
    - -
    std::string get_name(const Type*) const:
    -
    This function returns the name of the Type provided or the empty - string if the Type is not in the symbol table.

    Mutators

    @@ -2060,7 +2052,7 @@ Dinakar Dhurjati and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/01/17 00:12:04 $ + Last modified: $Date: 2005/03/06 02:37:21 $ From lattner at cs.uiuc.edu Sat Mar 5 20:38:37 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 20:38:37 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060238.j262cbMS022849@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.42 -> 1.43 --- Log message: remove these dead methods. --- Diffs of the changes: (+0 -30) SymbolTable.h | 30 ------------------------------ 1 files changed, 30 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.42 llvm/include/llvm/SymbolTable.h:1.43 --- llvm/include/llvm/SymbolTable.h:1.42 Sat Mar 5 20:25:02 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 20:38:24 2005 @@ -103,34 +103,14 @@ /// @brief Lookup a type by name. Type* lookupType(const std::string& name) const; - /// @returns true iff the type map is not empty. - /// @brief Determine if there are types in the symbol table - inline bool hasTypes() const { return ! tmap.empty(); } - /// @returns true iff the type map and the type plane are both not /// empty. /// @brief Determine if the symbol table is empty inline bool isEmpty() const { return pmap.empty() && tmap.empty(); } - /// The plane associated with the \p TypeID parameter is found - /// and the number of entries in the plane is returned. - /// @returns Number of entries in the specified type plane or 0. - /// @brief Get the size of a type plane. - unsigned type_size(const Type *TypeID) const; - /// @brief The number of name/type pairs is returned. inline unsigned num_types() const { return (unsigned)tmap.size(); } - /// Finds the value \p val in the symbol table and returns its - /// name. Only the type plane associated with the type of \p val - /// is searched. - /// @brief Return the name of a value - std::string get_name(const Value* Val) const; - - /// Finds the type \p Ty in the symbol table and returns its name. - /// @brief Return the name of a type - std::string get_name(const Type* Ty) const; - /// Given a base name, return a string that is either equal to it or /// derived from it that does not already occur in the symbol table /// for the specified type. @@ -190,13 +170,6 @@ return removeEntry(TI); } - /// Removes a specific value from the symbol table. - /// @returns the removed value. - /// @brief Remove a specific value given by an iterator - inline Value *value_remove(const value_iterator &It) { - return this->removeEntry(pmap.find(It->second->getType()), It); - } - /// changeName - Given a value with a non-empty name, remove its existing /// entry from the symbol table and insert a new one for Name. This is /// equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster, @@ -210,9 +183,6 @@ /// @brief Strip the symbol table. bool strip(); - /// @brief Empty the symbol table completely. - inline void clear() { pmap.clear(); tmap.clear(); } - /// @} /// @name Iteration /// @{ From lattner at cs.uiuc.edu Sat Mar 5 23:13:59 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:13:59 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060513.j265Dw5f000623@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.53 -> 1.54 --- Log message: Simplify some code. --- Diffs of the changes: (+5 -7) SymbolTable.cpp | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.53 llvm/lib/VMCore/SymbolTable.cpp:1.54 --- llvm/lib/VMCore/SymbolTable.cpp:1.53 Sat Mar 5 20:37:47 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 23:13:42 2005 @@ -252,9 +252,8 @@ std::string UniqueName = getUniqueName(VTy, Name); assert(InternallyInconsistent == false && "Infinite loop inserting value!"); - InternallyInconsistent = true; - V->setName(UniqueName); - InternallyInconsistent = false; + V->Name = UniqueName; + VM->insert(VI, make_pair(UniqueName, V)); return; } } @@ -382,11 +381,10 @@ // assert(InternallyInconsistent == false && "Symbol table already inconsistent!"); - InternallyInconsistent = true; - // Remove newM from the symtab - NewGV->setName(""); - InternallyInconsistent = false; + // Update NewGV's name, we're about the remove it from the symbol + // table. + NewGV->Name = ""; // Now we can remove this global from the module entirely... Module *M = NewGV->getParent(); From lattner at cs.uiuc.edu Sat Mar 5 23:21:57 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:21:57 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060521.j265Lv63005987@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.54 -> 1.55 --- Log message: Remove some really gross and hard to understand code now that InternallyInconsistent is always false. --- Diffs of the changes: (+6 -27) SymbolTable.cpp | 33 ++++++--------------------------- 1 files changed, 6 insertions(+), 27 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.54 llvm/lib/VMCore/SymbolTable.cpp:1.55 --- llvm/lib/VMCore/SymbolTable.cpp:1.54 Sat Mar 5 23:13:42 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 23:21:40 2005 @@ -94,7 +94,6 @@ // Remove a value void SymbolTable::remove(Value *N) { assert(N->hasName() && "Value doesn't have name!"); - if (InternallyInconsistent) return; plane_iterator PI = pmap.find(N->getType()); assert(PI != pmap.end() && @@ -115,15 +114,11 @@ assert(PI != pmap.end() && "Value doesn't have an entry in this table?"); ValueMap &VM = PI->second; - value_iterator VI; + value_iterator VI = VM.find(V->getName()); + assert(VI != VM.end() && "Value does have an entry in this table?"); - if (!InternallyInconsistent) { - VI = VM.find(V->getName()); - assert(VI != VM.end() && "Value does have an entry in this table?"); - - // Remove the old entry. - VM.erase(VI); - } + // Remove the old entry. + VM.erase(VI); // See if we can insert the new name. VI = VM.lower_bound(name); @@ -141,7 +136,6 @@ // removeEntry - Remove a value from the symbol table... Value *SymbolTable::removeEntry(plane_iterator Plane, value_iterator Entry) { - if (InternallyInconsistent) return 0; assert(Plane != pmap.end() && Entry != Plane->second.end() && "Invalid entry to remove!"); @@ -189,7 +183,6 @@ // removeEntry - Remove a type from the symbol table... Type* SymbolTable::removeEntry(type_iterator Entry) { - if (InternallyInconsistent) return 0; assert( Entry != tmap.end() && "Invalid entry to remove!"); const Type* Result = Entry->second; @@ -249,11 +242,8 @@ VM = &PI->second; VI = VM->lower_bound(Name); if (VI != VM->end() && VI->first == Name) { - std::string UniqueName = getUniqueName(VTy, Name); - assert(InternallyInconsistent == false && - "Infinite loop inserting value!"); - V->Name = UniqueName; - VM->insert(VI, make_pair(UniqueName, V)); + V->Name = getUniqueName(VTy, Name); + VM->insert(make_pair(V->Name, V)); return; } } @@ -371,17 +361,6 @@ // one use the old one... NewGV->uncheckedReplaceAllUsesWith(ExistGV); - // Now we just convert it to an unnamed method... which won't get - // added to our symbol table. The problem is that if we call - // setName on the method that it will try to remove itself from - // the symbol table and die... because it's not in the symtab - // right now. To fix this, we have an internally consistent flag - // that turns remove into a noop. Thus the name will get null'd - // out, but the symbol table won't get upset. - // - assert(InternallyInconsistent == false && - "Symbol table already inconsistent!"); - // Update NewGV's name, we're about the remove it from the symbol // table. NewGV->Name = ""; From lattner at cs.uiuc.edu Sat Mar 5 23:22:18 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:22:18 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060522.j265MI2M006000@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.43 -> 1.44 --- Log message: InternallyInconsistent is dead! --- Diffs of the changes: (+1 -11) SymbolTable.h | 12 +----------- 1 files changed, 1 insertion(+), 11 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.43 llvm/include/llvm/SymbolTable.h:1.44 --- llvm/include/llvm/SymbolTable.h:1.43 Sat Mar 5 20:38:24 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 23:22:05 2005 @@ -79,8 +79,7 @@ /// @{ public: - inline SymbolTable() - : pmap(), tmap(), InternallyInconsistent(false), LastUnique(0) {} + SymbolTable() : LastUnique(0) {} ~SymbolTable(); /// @} @@ -322,15 +321,6 @@ /// name/Value pairs and Type is not a Value. TypeMap tmap; - /// There are times when the symbol table is internally inconsistent with - /// the rest of the program. In this one case, a value exists with a Name, - /// and it's not in the symbol table. When we call V->setName(""), it - /// tries to remove itself from the symbol table and dies. We know this - /// is happening, and so if the flag InternallyInconsistent is set, - /// removal from the symbol table is a noop. - /// @brief Indicator of symbol table internal inconsistency. - bool InternallyInconsistent; - /// This value is used to retain the last unique value used /// by getUniqueName to generate unique names. mutable unsigned long LastUnique; From lattner at cs.uiuc.edu Sat Mar 5 23:42:51 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:42:51 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp Message-ID: <200503060542.j265gpcT013032@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: DeadTypeElimination.cpp updated: 1.53 -> 1.54 --- Log message: Make this MUCH faster by avoiding a linear search in the symbol table code. --- Diffs of the changes: (+1 -2) DeadTypeElimination.cpp | 3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: llvm/lib/Transforms/IPO/DeadTypeElimination.cpp diff -u llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.53 llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.54 --- llvm/lib/Transforms/IPO/DeadTypeElimination.cpp:1.53 Sun Sep 19 23:43:34 2004 +++ llvm/lib/Transforms/IPO/DeadTypeElimination.cpp Sat Mar 5 23:42:36 2005 @@ -80,8 +80,7 @@ // the type is not used, remove it. const Type *RHS = TI->second; if (ShouldNukeSymtabEntry(RHS) || !UsedTypes.count(RHS)) { - SymbolTable::type_iterator ToRemove = TI++; - ST.remove(ToRemove->second); + ST.remove(TI++); ++NumKilled; Changed = true; } else { From lattner at cs.uiuc.edu Sat Mar 5 23:46:16 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:46:16 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060546.j265kG55017188@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.44 -> 1.45 --- Log message: Delete the really inefficient method: void remove(const Type* Typ); Get rid of removeEntry(type_iterator), since 'remove' is exactly the same operation. --- Diffs of the changes: (+1 -14) SymbolTable.h | 15 +-------------- 1 files changed, 1 insertion(+), 14 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.44 llvm/include/llvm/SymbolTable.h:1.45 --- llvm/include/llvm/SymbolTable.h:1.44 Sat Mar 5 23:22:05 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 23:46:00 2005 @@ -156,18 +156,9 @@ /// @brief Remove a named value from the symbol table. void remove(Value* Val); - /// This method removes a named type from the symbol table. The - /// name of the type is extracted from \p T and used to look up - /// the Type in the type map. If the Type is not in the symbol - /// table, this method silently ignores the request. - /// @brief Remove a named type from the symbol table. - void remove(const Type* Typ); - /// Remove a type at the specified position in the symbol table. /// @returns the removed Type. - inline Type* remove(type_iterator TI) { - return removeEntry(TI); - } + Type* remove(type_iterator TI); /// changeName - Given a value with a non-empty name, remove its existing /// entry from the symbol table and insert a new one for Name. This is @@ -292,10 +283,6 @@ /// @returns the removed Value. Value* removeEntry(plane_iterator Plane, value_iterator Entry); - /// Remove a specific type from the SymbolTable. - /// @returns the removed Type. - Type* removeEntry(type_iterator Entry); - /// This function is called when one of the types in the type plane /// is refined. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); From lattner at cs.uiuc.edu Sat Mar 5 23:46:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:46:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060546.j265ksgb017944@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.55 -> 1.56 --- Log message: Delete the really inefficient method: void remove(const Type* Typ); Speed up the symbol stripping code by avoiding a linear search of the type table. Get rid of removeEntry(type_iterator), since 'remove' is exactly the same operation. --- Diffs of the changes: (+2 -18) SymbolTable.cpp | 20 ++------------------ 1 files changed, 2 insertions(+), 18 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.55 llvm/lib/VMCore/SymbolTable.cpp:1.56 --- llvm/lib/VMCore/SymbolTable.cpp:1.55 Sat Mar 5 23:21:40 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 23:46:41 2005 @@ -166,23 +166,8 @@ return Result; } - -// remove - Remove a type -void SymbolTable::remove(const Type* Ty ) { - type_iterator TI = this->type_begin(); - type_iterator TE = this->type_end(); - - // Search for the entry - while ( TI != TE && TI->second != Ty ) - ++TI; - - if ( TI != TE ) - this->removeEntry( TI ); -} - - // removeEntry - Remove a type from the symbol table... -Type* SymbolTable::removeEntry(type_iterator Entry) { +Type* SymbolTable::remove(type_iterator Entry) { assert( Entry != tmap.end() && "Invalid entry to remove!"); const Type* Result = Entry->second; @@ -300,8 +285,7 @@ } for (type_iterator TI = tmap.begin(); TI != tmap.end(); ) { - const Type* T = (TI++)->second; - remove(T); + remove(TI++); RemovedSymbol = true; } From lattner at cs.uiuc.edu Sat Mar 5 23:51:05 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:51:05 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060551.j265p5Xl018145@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.45 -> 1.46 --- Log message: remove this method. --- Diffs of the changes: (+0 -4) SymbolTable.h | 4 ---- 1 files changed, 4 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.45 llvm/include/llvm/SymbolTable.h:1.46 --- llvm/include/llvm/SymbolTable.h:1.45 Sat Mar 5 23:46:00 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 23:50:49 2005 @@ -279,10 +279,6 @@ /// @brief Insert a type into the symbol table with the specified name. void insertEntry(const std::string &Name, const Type *T); - /// Remove a specific value from a specific plane in the SymbolTable. - /// @returns the removed Value. - Value* removeEntry(plane_iterator Plane, value_iterator Entry); - /// This function is called when one of the types in the type plane /// is refined. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); From lattner at cs.uiuc.edu Sat Mar 5 23:51:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:51:22 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060551.j265pMxK018157@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.56 -> 1.57 --- Log message: Merge SymbolTable::removeEntry into SymbolTable::remove, its only caller --- Diffs of the changes: (+21 -28) SymbolTable.cpp | 49 +++++++++++++++++++++---------------------------- 1 files changed, 21 insertions(+), 28 deletions(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.56 llvm/lib/VMCore/SymbolTable.cpp:1.57 --- llvm/lib/VMCore/SymbolTable.cpp:1.56 Sat Mar 5 23:46:41 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 23:51:09 2005 @@ -84,23 +84,13 @@ // lookup a type by name - returns null on failure -Type* SymbolTable::lookupType( const std::string& Name ) const { - type_const_iterator TI = tmap.find( Name ); - if ( TI != tmap.end() ) +Type* SymbolTable::lookupType(const std::string& Name) const { + type_const_iterator TI = tmap.find(Name); + if (TI != tmap.end()) return const_cast(TI->second); return 0; } -// Remove a value -void SymbolTable::remove(Value *N) { - assert(N->hasName() && "Value doesn't have name!"); - - plane_iterator PI = pmap.find(N->getType()); - assert(PI != pmap.end() && - "Trying to remove a value that doesn't have a type plane yet!"); - removeEntry(PI, PI->second.find(N->getName())); -} - /// changeName - Given a value with a non-empty name, remove its existing entry /// from the symbol table and insert a new one for Name. This is equivalent to /// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not @@ -133,42 +123,45 @@ } } +// Remove a value +void SymbolTable::remove(Value *N) { + assert(N->hasName() && "Value doesn't have name!"); -// removeEntry - Remove a value from the symbol table... -Value *SymbolTable::removeEntry(plane_iterator Plane, value_iterator Entry) { - assert(Plane != pmap.end() && - Entry != Plane->second.end() && "Invalid entry to remove!"); + plane_iterator PI = pmap.find(N->getType()); + assert(PI != pmap.end() && + "Trying to remove a value that doesn't have a type plane yet!"); + ValueMap &VM = PI->second; + value_iterator Entry = VM.find(N->getName()); + assert(Entry != VM.end() && "Invalid entry to remove!"); - Value *Result = Entry->second; #if DEBUG_SYMBOL_TABLE dump(); - std::cerr << " Removing Value: " << Result->getName() << "\n"; + std::cerr << " Removing Value: " << Entry->second->getName() << "\n"; #endif // Remove the value from the plane... - Plane->second.erase(Entry); + VM.erase(Entry); // If the plane is empty, remove it now! - if (Plane->second.empty()) { + if (VM.empty()) { // If the plane represented an abstract type that we were interested in, // unlink ourselves from this plane. // - if (Plane->first->isAbstract()) { + if (N->getType()->isAbstract()) { #if DEBUG_ABSTYPE std::cerr << "Plane Empty: Removing type: " - << Plane->first->getDescription() << "\n"; + << N->getType()->getDescription() << "\n"; #endif - cast(Plane->first)->removeAbstractTypeUser(this); + cast(N->getType())->removeAbstractTypeUser(this); } - pmap.erase(Plane); + pmap.erase(PI); } - return Result; } -// removeEntry - Remove a type from the symbol table... +// remove - Remove a type from the symbol table... Type* SymbolTable::remove(type_iterator Entry) { - assert( Entry != tmap.end() && "Invalid entry to remove!"); + assert(Entry != tmap.end() && "Invalid entry to remove!"); const Type* Result = Entry->second; From lattner at cs.uiuc.edu Sat Mar 5 23:55:56 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:55:56 -0600 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200503060555.j265tuRS024377@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.57 -> 1.58 --- Log message: rename insertEntry to insert --- Diffs of the changes: (+2 -1) SymbolTable.cpp | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.57 llvm/lib/VMCore/SymbolTable.cpp:1.58 --- llvm/lib/VMCore/SymbolTable.cpp:1.57 Sat Mar 5 23:51:09 2005 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Mar 5 23:55:40 2005 @@ -233,7 +233,8 @@ // insertEntry - Insert a value into the symbol table with the specified // name... // -void SymbolTable::insertEntry(const std::string& Name, const Type* T) { +void SymbolTable::insert(const std::string& Name, const Type* T) { + assert(T && "Can't insert null type into symbol table!"); // Check to see if there is a naming conflict. If so, rename this type! std::string UniqueName = Name; From lattner at cs.uiuc.edu Sat Mar 5 23:56:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 5 Mar 2005 23:56:15 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060556.j265uFMc024388@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.46 -> 1.47 --- Log message: the only caller of insertEntry is insert, inline it and remove insertEntry --- Diffs of the changes: (+1 -7) SymbolTable.h | 8 +------- 1 files changed, 1 insertion(+), 7 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.46 llvm/include/llvm/SymbolTable.h:1.47 --- llvm/include/llvm/SymbolTable.h:1.46 Sat Mar 5 23:50:49 2005 +++ llvm/include/llvm/SymbolTable.h Sat Mar 5 23:56:02 2005 @@ -143,10 +143,7 @@ /// allows a type with an existing entry in the symbol table to get /// a new name. /// @brief Insert a type under a new name. - inline void insert(const std::string &Name, const Type *Typ) { - assert(Typ && "Can't insert null type into symbol table!"); - insertEntry(Name, Typ); - } + void insert(const std::string &Name, const Type *Typ); /// This method removes a named value from the symbol table. The /// type and name of the Value are extracted from \p N and used to @@ -276,9 +273,6 @@ /// @brief Insert a value into the symbol table with the specified name. void insertEntry(const std::string &Name, const Type *Ty, Value *V); - /// @brief Insert a type into the symbol table with the specified name. - void insertEntry(const std::string &Name, const Type *T); - /// This function is called when one of the types in the type plane /// is refined. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); From lattner at cs.uiuc.edu Sun Mar 6 00:00:28 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 00:00:28 -0600 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200503060600.j2660SMX030482@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.76 -> 1.77 --- Log message: cleanup some html remove a statement that is no longer true remove comment about a dead method. --- Diffs of the changes: (+9 -12) ProgrammersManual.html | 21 +++++++++------------ 1 files changed, 9 insertions(+), 12 deletions(-) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.76 llvm/docs/ProgrammersManual.html:1.77 --- llvm/docs/ProgrammersManual.html:1.76 Sat Mar 5 20:37:21 2005 +++ llvm/docs/ProgrammersManual.html Sun Mar 6 00:00:13 2005 @@ -574,18 +574,18 @@ BasicBlocks. Here's a code snippet that prints out each instruction in a BasicBlock:

    -
      // blk is a pointer to a BasicBlock instance
    for (BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i)
    // the next statement works since operator<<(ostream&,...)
    // is overloaded for Instruction&
    cerr << *i << "\n";
    +
    +  // blk is a pointer to a BasicBlock instance
    +  for (BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i)
    +     // the next statement works since operator<<(ostream&,...)
    +     // is overloaded for Instruction&
    +     std::cerr << *i << "\n";
    +

    However, this isn't really the best way to print out the contents of a BasicBlock! Since the ostream operators are overloaded for virtually anything you'll care about, you could have just invoked the print routine on the -basic block itself: cerr << *blk << "\n";.

    - -

    Note that currently operator<< is implemented for Value*, so -it will print out the contents of the pointer, instead of the pointer value you -might expect. This is a deprecated interface that will be removed in the -future, so it's best not to depend on it. To print out the pointer value for -now, you must cast to void*.

    +basic block itself: std::cerr << *blk << "\n";.

    @@ -2035,9 +2035,6 @@
    This method returns a plane_iterator for iteration over the type planes starting at a specific plane, given by \p Ty.
    -
    const ValueMap* findPlane( const Type* Typ ) cons:
    -
    This method returns a ValueMap* for a specific type plane. This - interface is deprecated and may go away in the future.
    @@ -2052,7 +2049,7 @@ Dinakar Dhurjati and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2005/03/06 02:37:21 $ + Last modified: $Date: 2005/03/06 06:00:13 $ From lattner at cs.uiuc.edu Sun Mar 6 00:00:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 00:00:38 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060600.j2660cIe030491@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.47 -> 1.48 --- Log message: this method is never called. --- Diffs of the changes: (+0 -11) SymbolTable.h | 11 ----------- 1 files changed, 11 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.47 llvm/include/llvm/SymbolTable.h:1.48 --- llvm/include/llvm/SymbolTable.h:1.47 Sat Mar 5 23:56:02 2005 +++ llvm/include/llvm/SymbolTable.h Sun Mar 6 00:00:24 2005 @@ -255,17 +255,6 @@ return pmap.find(Typ); } - /// This method returns a ValueMap* for a specific type plane. This - /// interface is deprecated and may go away in the future. - /// @deprecated - /// @brief Find a type plane - inline const ValueMap* findPlane(const Type* Typ) const { - assert(Typ && "Can't find type plane with null type!"); - plane_const_iterator I = pmap.find(Typ); - if (I == pmap.end()) return 0; - return &I->second; - } - /// @} /// @name Internal Methods /// @{ From lattner at cs.uiuc.edu Sun Mar 6 00:04:00 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 00:04:00 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200503060604.j26640Jj030514@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.48 -> 1.49 --- Log message: move some method declarations around to make it clear that users should not call insert(Value *Val), remove(Value* Val), or changeName(Value *V, const std::string &Name) --- Diffs of the changes: (+52 -49) SymbolTable.h | 101 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 52 insertions(+), 49 deletions(-) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.48 llvm/include/llvm/SymbolTable.h:1.49 --- llvm/include/llvm/SymbolTable.h:1.48 Sun Mar 6 00:00:24 2005 +++ llvm/include/llvm/SymbolTable.h Sun Mar 6 00:03:44 2005 @@ -115,7 +115,7 @@ /// for the specified type. /// @brief Get a name unique to this symbol table std::string getUniqueName(const Type *Ty, - const std::string &BaseName) const; + const std::string &BaseName) const; /// This function can be used from the debugger to display the /// content of the symbol table while debugging. @@ -123,54 +123,6 @@ void dump() const; /// @} -/// @name Mutators -/// @{ -public: - - /// This method adds the provided value \p N to the symbol table. - /// The Value must have both a name and a type which are extracted - /// and used to place the value in the correct type plane under - /// the value's name. - /// @brief Add a named value to the symbol table - inline void insert(Value *Val) { - assert(Val && "Can't insert null type into symbol table!"); - assert(Val->hasName() && "Value must be named to go into symbol table!"); - insertEntry(Val->getName(), Val->getType(), Val); - } - - /// Inserts a type into the symbol table with the specified name. There - /// can be a many-to-one mapping between names and types. This method - /// allows a type with an existing entry in the symbol table to get - /// a new name. - /// @brief Insert a type under a new name. - void insert(const std::string &Name, const Type *Typ); - - /// This method removes a named value from the symbol table. The - /// type and name of the Value are extracted from \p N and used to - /// lookup the Value in the correct type plane. If the Value is - /// not in the symbol table, this method silently ignores the - /// request. - /// @brief Remove a named value from the symbol table. - void remove(Value* Val); - - /// Remove a type at the specified position in the symbol table. - /// @returns the removed Type. - Type* remove(type_iterator TI); - - /// changeName - Given a value with a non-empty name, remove its existing - /// entry from the symbol table and insert a new one for Name. This is - /// equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster, - /// and will not temporarily remove the symbol table plane if V is the last - /// value in the symtab with that name (which could invalidate iterators to - /// that plane). - void changeName(Value *V, const std::string &Name); - - /// This method will strip the symbol table of its names leaving - /// the type and values. - /// @brief Strip the symbol table. - bool strip(); - -/// @} /// @name Iteration /// @{ public: @@ -255,6 +207,57 @@ return pmap.find(Typ); } + +/// @} +/// @name Mutators +/// @{ +public: + + /// This method will strip the symbol table of its names leaving the type and + /// values. + /// @brief Strip the symbol table. + bool strip(); + + /// Inserts a type into the symbol table with the specified name. There can be + /// a many-to-one mapping between names and types. This method allows a type + /// with an existing entry in the symbol table to get a new name. + /// @brief Insert a type under a new name. + void insert(const std::string &Name, const Type *Typ); + + /// Remove a type at the specified position in the symbol table. + /// @returns the removed Type. + Type* remove(type_iterator TI); + +/// @} +/// @name Mutators used by Value::setName and other LLVM internals. +/// @{ +public: + + /// This method adds the provided value \p N to the symbol table. The Value + /// must have both a name and a type which are extracted and used to place the + /// value in the correct type plane under the value's name. + /// @brief Add a named value to the symbol table + inline void insert(Value *Val) { + assert(Val && "Can't insert null type into symbol table!"); + assert(Val->hasName() && "Value must be named to go into symbol table!"); + insertEntry(Val->getName(), Val->getType(), Val); + } + + /// This method removes a named value from the symbol table. The type and name + /// of the Value are extracted from \p N and used to lookup the Value in the + /// correct type plane. If the Value is not in the symbol table, this method + /// silently ignores the request. + /// @brief Remove a named value from the symbol table. + void remove(Value* Val); + + /// changeName - Given a value with a non-empty name, remove its existing + /// entry from the symbol table and insert a new one for Name. This is + /// equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster, + /// and will not temporarily remove the symbol table plane if V is the last + /// value in the symtab with that name (which could invalidate iterators to + /// that plane). + void changeName(Value *V, const std::string &Name); + /// @} /// @name Internal Methods /// @{ From alkis at cs.uiuc.edu Sun Mar 6 03:35:20 2005 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Sun, 6 Mar 2005 03:35:20 -0600 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200503060935.DAA27670@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.225 -> 1.226 --- Log message: Do not use the same names for local variables and globals. --- Diffs of the changes: (+2 -2) Compiler.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.225 llvm-java/lib/Compiler/Compiler.cpp:1.226 --- llvm-java/lib/Compiler/Compiler.cpp:1.225 Sun Feb 20 11:03:49 2005 +++ llvm-java/lib/Compiler/Compiler.cpp Sun Mar 6 03:35:09 2005 @@ -2110,7 +2110,7 @@ new CastInst(objRef, ObjectBaseRefTy, TMP, currentBB_); Value* vtable = new CallInst(getVtable_, objBase, TMP, currentBB_); vtable = new CastInst(vtable, vi->vtable->getType(), - className + "", currentBB_); + className + ".vtable", currentBB_); std::vector indices(1, ConstantUInt::get(Type::UIntTy, 0)); assert(vi->m2iMap.find(methodDescr) != vi->m2iMap.end() && "could not find slot for virtual function!"); @@ -2203,7 +2203,7 @@ Value* interfaceVTable = new GetElementPtrInst(interfaceVTables, indices, TMP, currentBB_); interfaceVTable = - new LoadInst(interfaceVTable, className + "", currentBB_); + new LoadInst(interfaceVTable, className + ".vtable", currentBB_); interfaceVTable = new CastInst(interfaceVTable, vi->vtable->getType(), TMP, currentBB_); // Get the function pointer. From lattner at cs.uiuc.edu Sun Mar 6 13:40:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 13:40:35 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2005-03-06-OffsetOfStructCrash.c Message-ID: <200503061940.j26JeZsM006954@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2005-03-06-OffsetOfStructCrash.c added (r1.1) --- Log message: new testcase reduced from the MultiSource/Applications/d failure last night. --- Diffs of the changes: (+14 -0) 2005-03-06-OffsetOfStructCrash.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+) Index: llvm/test/Regression/CFrontend/2005-03-06-OffsetOfStructCrash.c diff -c /dev/null llvm/test/Regression/CFrontend/2005-03-06-OffsetOfStructCrash.c:1.1 *** /dev/null Sun Mar 6 13:40:29 2005 --- llvm/test/Regression/CFrontend/2005-03-06-OffsetOfStructCrash.c Sun Mar 6 13:40:19 2005 *************** *** 0 **** --- 1,14 ---- + // RUN: %llvmgcc %s -S -o - + + struct Y {}; + struct XXX { + struct Y F; + }; + + void test1() { + (int)&((struct XXX*)(((void *)0)))->F; + } + + void test2() { + &((struct XXX*)(((void *)0)))->F; + } From lattner at cs.uiuc.edu Sun Mar 6 13:42:21 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 13:42:21 -0600 Subject: [llvm-commits] CVS: llvm-gcc/gcc/c-typeck.c Message-ID: <200503061942.j26JgLMA006970@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: c-typeck.c updated: 1.8 -> 1.9 --- Log message: Work around a bug in fold_convert that causes it to return types instead of expressions in some cases. This fixes Regression/CFrontend/2005-03-06-OffsetOfStructCrash.c and the Applications/d regression last night from the patch for PR533: http://llvm.cs.uiuc.edu/PR533 --- Diffs of the changes: (+1 -1) c-typeck.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm-gcc/gcc/c-typeck.c diff -u llvm-gcc/gcc/c-typeck.c:1.8 llvm-gcc/gcc/c-typeck.c:1.9 --- llvm-gcc/gcc/c-typeck.c:1.8 Sat Mar 5 12:49:59 2005 +++ llvm-gcc/gcc/c-typeck.c Sun Mar 6 13:42:06 2005 @@ -2453,7 +2453,7 @@ val = get_base_address (arg); if (val && TREE_CODE (val) == INDIRECT_REF && integer_zerop (TREE_OPERAND (val, 0))) - return fold_convert (argtype, fold_offsetof (arg)); + return fold(convert(argtype, fold_offsetof(arg))); From lattner at cs.uiuc.edu Sun Mar 6 14:55:50 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 14:55:50 -0600 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/LoopInfo.h Message-ID: <200503062055.j26KtoMD013393@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: LoopInfo.h updated: 1.43 -> 1.44 --- Log message: new helper method --- Diffs of the changes: (+15 -0) LoopInfo.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+) Index: llvm/include/llvm/Analysis/LoopInfo.h diff -u llvm/include/llvm/Analysis/LoopInfo.h:1.43 llvm/include/llvm/Analysis/LoopInfo.h:1.44 --- llvm/include/llvm/Analysis/LoopInfo.h:1.43 Mon Dec 6 22:03:45 2004 +++ llvm/include/llvm/Analysis/LoopInfo.h Sun Mar 6 14:55:34 2005 @@ -175,6 +175,21 @@ Blocks.push_back(BB); } + /// moveToHeader - This method is used to move BB (which must be part of this + /// loop) to be the loop header of the loop (the block that dominates all + /// others). + void moveToHeader(BasicBlock *BB) { + if (Blocks[0] == BB) return; + for (unsigned i = 0; ; ++i) { + assert(i != Blocks.size() && "Loop does not contain BB!"); + if (Blocks[i] == BB) { + Blocks[i] = Blocks[0]; + Blocks[0] = BB; + return; + } + } + } + /// removeBlockFromLoop - This removes the specified basic block from the /// current loop, updating the Blocks as appropriate. This does not update /// the mapping in the LoopInfo class. From lattner at cs.uiuc.edu Sun Mar 6 14:57:08 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 14:57:08 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll Message-ID: <200503062057.j26Kv8K1013422@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopUnroll: 2005-03-06-BadLoopInfoUpdate.ll added (r1.1) --- Log message: New testcase for PR532: http://llvm.cs.uiuc.edu/PR532 --- Diffs of the changes: (+29 -0) 2005-03-06-BadLoopInfoUpdate.ll | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+) Index: llvm/test/Regression/Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll:1.1 *** /dev/null Sun Mar 6 14:57:05 2005 --- llvm/test/Regression/Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll Sun Mar 6 14:56:55 2005 *************** *** 0 **** --- 1,29 ---- + ; RUN: llvm-as < %s | opt -loop-unroll -loopsimplify -disable-output + + implementation ; Functions: + + void %print_board() { + entry: + br label %no_exit.1 + + no_exit.1: ; preds = %cond_false.2, %entry + br label %no_exit.2 + + no_exit.2: ; preds = %no_exit.2, %no_exit.1 + %indvar1 = phi uint [ 0, %no_exit.1 ], [ %indvar.next2, %no_exit.2 ] ; [#uses=1] + %indvar.next2 = add uint %indvar1, 1 ; [#uses=2] + %exitcond3 = setne uint %indvar.next2, 7 ; [#uses=1] + br bool %exitcond3, label %no_exit.2, label %loopexit.2 + + loopexit.2: ; preds = %no_exit.2 + br bool false, label %cond_true.2, label %cond_false.2 + + cond_true.2: ; preds = %loopexit.2 + ret void + + cond_false.2: ; preds = %loopexit.2 + br bool false, label %no_exit.1, label %loopexit.1 + + loopexit.1: ; preds = %cond_false.2 + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 14:57:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 14:57:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp Message-ID: <200503062057.j26Kvj8j013434@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopUnroll.cpp updated: 1.15 -> 1.16 --- Log message: Fix a bug where we could corrupt a parent loop's header info if we unrolled a nested loop. This fixes Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll and PR532: http://llvm.cs.uiuc.edu/PR532 --- Diffs of the changes: (+17 -6) LoopUnroll.cpp | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.15 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.16 --- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.15 Sat Jan 8 13:37:20 2005 +++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp Sun Mar 6 14:57:32 2005 @@ -283,16 +283,27 @@ // Preheader. Preheader->replaceAllUsesWith(LoopExit); + Function *F = LoopExit->getParent(); + if (Parent) { + // Otherwise, if this is a sub-loop, and the preheader was the loop header + // of the parent loop, move the exit block to be the new parent loop header. + if (Parent->getHeader() == Preheader) { + assert(Parent->contains(LoopExit) && + "Exit block isn't contained in parent?"); + Parent->moveToHeader(LoopExit); + } + } else { + // If the preheader was the entry block of this function, move the exit + // block to be the new entry of the function. + if (Preheader == &F->front()) + F->getBasicBlockList().splice(F->begin(), + F->getBasicBlockList(), LoopExit); + } + // Remove BB and LoopExit from our analyses. LI->removeBlock(Preheader); LI->removeBlock(BB); - // If the preheader was the entry block of this function, move the exit block - // to be the new entry of the loop. - Function *F = LoopExit->getParent(); - if (Preheader == &F->front()) - F->getBasicBlockList().splice(F->begin(), F->getBasicBlockList(), LoopExit); - // Actually delete the blocks now. F->getBasicBlockList().erase(Preheader); F->getBasicBlockList().erase(BB); From lattner at cs.uiuc.edu Sun Mar 6 15:35:54 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 15:35:54 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200503062135.j26LZs5O013642@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.53 -> 1.54 --- Log message: trivial simplification --- Diffs of the changes: (+1 -1) LoopSimplify.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.53 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.54 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.53 Fri Jan 28 18:39:08 2005 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Sun Mar 6 15:35:38 2005 @@ -437,7 +437,7 @@ if (!isa(V) || DS.dominates(cast(V), PN)) { // This is a degenerate PHI already, don't modify it! PN->replaceAllUsesWith(V); - PN->getParent()->getInstList().erase(PN); + PN->eraseFromParent(); continue; } From lattner at cs.uiuc.edu Sun Mar 6 15:42:41 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 15:42:41 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/ Message-ID: <200503062142.j26LgflJ013668@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/Transforms/LoopStrengthReduce added to the repository --- Diffs of the changes: (+0 -0) 0 files changed From lattner at cs.uiuc.edu Sun Mar 6 15:43:15 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 15:43:15 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/dg.exp Message-ID: <200503062143.j26LhF8C013688@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: dg.exp added (r1.1) --- Log message: new directory --- Diffs of the changes: (+3 -0) dg.exp | 3 +++ 1 files changed, 3 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/dg.exp diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/dg.exp:1.1 *** /dev/null Sun Mar 6 15:43:09 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/dg.exp Sun Mar 6 15:42:59 2005 *************** *** 0 **** --- 1,3 ---- + load_lib llvm-dg.exp + + llvm-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] $objdir $srcdir $subdir $target_triplet $llvmgcc $llvmgxx $prcontext From lattner at cs.uiuc.edu Sun Mar 6 15:47:55 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 15:47:55 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/remove_indvar.ll Message-ID: <200503062147.j26LltEm013754@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: remove_indvar.ll added (r1.1) --- Log message: a regtest --- Diffs of the changes: (+19 -0) remove_indvar.ll | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/remove_indvar.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/remove_indvar.ll:1.1 *** /dev/null Sun Mar 6 15:47:50 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/remove_indvar.ll Sun Mar 6 15:47:40 2005 *************** *** 0 **** --- 1,19 ---- + ; Check that this test makes INDVAR and related stuff dead. + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep INDVAR + + declare bool %pred() + + void %test(int* %P) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %STRRED = getelementptr int* %P, int %INDVAR + store int 0, int* %STRRED + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 15:58:38 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 15:58:38 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503062158.j26LwcGB014104@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.8 -> 1.9 --- Log message: minor simplifications of the code. --- Diffs of the changes: (+8 -9) LoopStrengthReduce.cpp | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.8 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.9 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.8 Sat Mar 5 16:45:40 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Mar 6 15:58:22 2005 @@ -35,16 +35,15 @@ namespace { Statistic<> NumReduced ("loop-reduce", "Number of GEPs strength reduced"); - class GEPCache - { + class GEPCache { public: GEPCache() : CachedPHINode(0), Map() {} - GEPCache* operator[](Value *v) { + GEPCache *get(Value *v) { std::map::iterator I = Map.find(v); if (I == Map.end()) I = Map.insert(std::pair(v, GEPCache())).first; - return &(I->second); + return &I->second; } PHINode *CachedPHINode; @@ -135,7 +134,7 @@ BasicBlock *Header = L->getHeader(); BasicBlock *Preheader = L->getLoopPreheader(); bool AllConstantOperands = true; - Cache = (*Cache)[GEPI->getOperand(0)]; + Cache = Cache->get(GEPI->getOperand(0)); for (unsigned op = 1, e = GEPI->getNumOperands(); op != e; ++op) { Value *operand = GEPI->getOperand(op); @@ -164,7 +163,7 @@ AllConstantOperands = false; } else return; - Cache = (*Cache)[operand]; + Cache = Cache->get(operand); } assert(indvar > 0 && "Indvar used by GEP not found in operand list"); @@ -179,8 +178,8 @@ // Don't reduce multiplies that the target can handle via addressing modes. uint64_t sz = getAnalysis().getTypeSize(ty); - for (unsigned i = 1; i <= MaxTargetAMSize; i *= 2) - if (i == sz) + if (sz && (sz & (sz-1)) == 0) // Power of two? + if (sz <= (1ULL << (MaxTargetAMSize-1))) return; // If all operands of the GEP we are going to insert into the preheader @@ -248,7 +247,7 @@ GEPI->getName() + ".lsr", GEPI); GEPI->replaceAllUsesWith(newGEP); -} + } // The old GEP is now dead. DeadInsts.insert(GEPI); From lattner at cs.uiuc.edu Sun Mar 6 16:01:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:01:58 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/ops_after_indvar.ll Message-ID: <200503062201.j26M1wMH014164@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: ops_after_indvar.ll added (r1.1) --- Log message: Add test for this: Allow operands after the induction variable (no restrictions): int x; for (i) j = ..... a[i][x][j] --- Diffs of the changes: (+22 -0) ops_after_indvar.ll | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/ops_after_indvar.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/ops_after_indvar.ll:1.1 *** /dev/null Sun Mar 6 16:01:52 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/ops_after_indvar.ll Sun Mar 6 16:01:42 2005 *************** *** 0 **** --- 1,22 ---- + ; Check that this test makes INDVAR and related stuff dead, because P[indvar] + ; gets reduced, making INDVAR dead. + + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep INDVAR + + declare bool %pred() + declare int %getidx() + + void %test([10000 x int]* %P) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + %idx = call int %getidx() + %STRRED = getelementptr [10000 x int]* %P, int %INDVAR, int %idx + store int 0, int* %STRRED + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 16:04:43 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:04:43 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first.ll Message-ID: <200503062204.j26M4htj014240@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: invariant_value_first.ll added (r1.1) --- Log message: add test for this: (1) Allow loop invariant expressions to come before the induction variable (instead of just constants): int x; for (i) ...a[x][i] --- Diffs of the changes: (+21 -0) invariant_value_first.ll | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first.ll:1.1 *** /dev/null Sun Mar 6 16:04:37 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first.ll Sun Mar 6 16:04:27 2005 *************** *** 0 **** --- 1,21 ---- + ; Check that the index of 'P[outer]' is pulled out of the loop. + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'getelementptr.*%outer.*%INDVAR' + + declare bool %pred() + declare int %foo() + + void %test([10000 x int]* %P) { + %outer = call int %foo() + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %STRRED = getelementptr [10000 x int]* %P, int %outer, int %INDVAR + store int 0, int* %STRRED + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 16:06:22 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:06:22 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll Message-ID: <200503062206.j26M6Mk3014572@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: invariant_value_first_arg.ll added (r1.1) --- Log message: testcase for A[invariant][indvar] where invariant is an instruction. --- Diffs of the changes: (+19 -0) invariant_value_first_arg.ll | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll:1.1 *** /dev/null Sun Mar 6 16:06:19 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll Sun Mar 6 16:06:09 2005 *************** *** 0 **** --- 1,19 ---- + ; Check that the index of 'P[outer]' is pulled out of the loop. + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | not grep 'getelementptr.*%outer.*%INDVAR' + + declare bool %pred() + + void %test([10000 x int]* %P, int %outer) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %STRRED = getelementptr [10000 x int]* %P, int %outer, int %INDVAR + store int 0, int* %STRRED + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 16:06:35 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:06:35 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503062206.j26M6ZK1014581@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.9 -> 1.10 --- Log message: implement Transforms/LoopStrengthReduce/invariant_value_first_arg.ll --- Diffs of the changes: (+1 -1) LoopStrengthReduce.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.9 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.10 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.9 Sun Mar 6 15:58:22 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Mar 6 16:06:22 2005 @@ -154,7 +154,7 @@ inc_op_vector.push_back(ConstantInt::get(Ty, 1)); indvar = op; break; - } else if (isa(operand)) { + } else if (isa(operand) || isa(operand)) { pre_op_vector.push_back(operand); } else if (Instruction *inst = dyn_cast(operand)) { if (!DS->dominates(inst, Preheader->getTerminator())) From lattner at cs.uiuc.edu Sun Mar 6 16:15:39 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:15:39 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_reduce_bytes.ll Message-ID: <200503062215.j26MFdqN014712@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: dont_reduce_bytes.ll added (r1.1) --- Log message: Add testcase for this: (3) Do not reduce element sizes of small power of two: char s[10]; for (i) ...s[i] ... when the indvar is not eliminable. --- Diffs of the changes: (+21 -0) dont_reduce_bytes.ll | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_reduce_bytes.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/dont_reduce_bytes.ll:1.1 *** /dev/null Sun Mar 6 16:15:34 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/dont_reduce_bytes.ll Sun Mar 6 16:15:24 2005 *************** *** 0 **** --- 1,21 ---- + ; Don't reduce the byte access to P[i], at least not on targets that + ; support an efficient 'mem[r1+r2]' addressing mode. + + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep 'getelementptr.*PTR.*INDVAR' + + declare bool %pred(int) + + void %test(sbyte* %PTR) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %STRRED = getelementptr sbyte* %PTR, int %INDVAR + store sbyte 0, sbyte* %STRRED + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred(int %INDVAR2) ;; cannot eliminate indvar + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 16:23:46 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:23:46 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll Message-ID: <200503062223.j26MNkFg014807@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: dont_insert_redundant_ops.ll added (r1.1) --- Log message: check that we only insert one phi node per loop --- Diffs of the changes: (+42 -0) dont_insert_redundant_ops.ll | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll:1.1 *** /dev/null Sun Mar 6 16:23:41 2005 --- llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll Sun Mar 6 16:23:31 2005 *************** *** 0 **** --- 1,42 ---- + ; Check that this test makes INDVAR and related stuff dead. + ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep phi | wc -l | grep 2 + + declare bool %pred() + + void %test({ int, int }* %P) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %gep1 = getelementptr { int, int}* %P, int %INDVAR, uint 0 + store int 0, int* %gep1 + + %gep2 = getelementptr { int, int}* %P, int %INDVAR, uint 1 + store int 0, int* %gep2 + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } + + declare bool %pred() + + void %test([2 x int]* %P) { + br label %Loop + Loop: + %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] + + %gep1 = getelementptr [2 x int]* %P, int %INDVAR, uint 0 + store int 0, int* %gep1 + + %gep2 = getelementptr [2 x int]* %P, int %INDVAR, uint 1 + store int 0, int* %gep2 + + %INDVAR2 = add int %INDVAR, 1 + %cond = call bool %pred() + br bool %cond, label %Loop, label %Out + Out: + ret void + } From lattner at cs.uiuc.edu Sun Mar 6 16:24:58 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:24:58 -0600 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll Message-ID: <200503062224.j26MOw3W014823@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopStrengthReduce: dont_insert_redundant_ops.ll updated: 1.1 -> 1.2 --- Log message: cleanup the test --- Diffs of the changes: (+2 -4) dont_insert_redundant_ops.ll | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) Index: llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll diff -u llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll:1.1 llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll:1.2 --- llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll:1.1 Sun Mar 6 16:23:31 2005 +++ llvm/test/Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll Sun Mar 6 16:24:45 2005 @@ -3,7 +3,7 @@ declare bool %pred() -void %test({ int, int }* %P) { +void %test1({ int, int }* %P) { br label %Loop Loop: %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] @@ -21,9 +21,7 @@ ret void } -declare bool %pred() - -void %test([2 x int]* %P) { +void %test2([2 x int]* %P) { br label %Loop Loop: %INDVAR = phi int [0, %0], [%INDVAR2, %Loop] From lattner at cs.uiuc.edu Sun Mar 6 16:36:27 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:36:27 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503062236.j26MaRdq015559@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.10 -> 1.11 --- Log message: Fix Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll, hopefully not breaking too many other things. --- Diffs of the changes: (+1 -1) LoopStrengthReduce.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.10 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.11 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.10 Sun Mar 6 16:06:22 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Mar 6 16:36:12 2005 @@ -189,7 +189,7 @@ // that it was the induction variable, and has been replaced by a constant // null value. In this case, replace the GEP with a use of pointer directly. PHINode *NewPHI; - if (1) { + if (Cache->CachedPHINode == 0) { Value *PreGEP; if (AllConstantOperands && isa(GEPI->getOperand(0))) { Constant *C = dyn_cast(GEPI->getOperand(0)); From lattner at cs.uiuc.edu Sun Mar 6 16:52:45 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 16:52:45 -0600 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200503062252.j26MqjZP022783@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopStrengthReduce.cpp updated: 1.11 -> 1.12 --- Log message: fix a bug where we thought arguments were constants :( --- Diffs of the changes: (+7 -3) LoopStrengthReduce.cpp | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.11 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.12 --- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.11 Sun Mar 6 16:36:12 2005 +++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sun Mar 6 16:52:29 2005 @@ -154,15 +154,19 @@ inc_op_vector.push_back(ConstantInt::get(Ty, 1)); indvar = op; break; - } else if (isa(operand) || isa(operand)) { + } else if (isa(operand)) { + pre_op_vector.push_back(operand); + AllConstantOperands = false; + } else if (isa(operand)) { pre_op_vector.push_back(operand); } else if (Instruction *inst = dyn_cast(operand)) { if (!DS->dominates(inst, Preheader->getTerminator())) return; pre_op_vector.push_back(operand); AllConstantOperands = false; - } else - return; + } else { + return; // Cannot handle this. + } Cache = Cache->get(operand); } assert(indvar > 0 && "Indvar used by GEP not found in operand list"); From lattner at cs.uiuc.edu Sun Mar 6 20:59:52 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 20:59:52 -0600 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200503070259.j272xq5J024860@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.94 -> 1.95 --- Log message: Fix an apparent ambiguity compiling on PPC --- Diffs of the changes: (+1 -1) Writer.cpp | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.94 llvm/lib/Bytecode/Writer/Writer.cpp:1.95 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.94 Sat Mar 5 20:32:00 2005 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Mar 6 20:59:36 2005 @@ -1071,7 +1071,7 @@ if (I == End) continue; // Don't mess with an absent type... // Write the number of values in this plane - output_vbr(PI->second.size()); + output_vbr((unsigned)PI->second.size()); // Write the slot number of the type for this plane Slot = Table.getSlot(PI->first); From lattner at cs.uiuc.edu Sun Mar 6 21:20:05 2005 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 6 Mar 2005 21:20:05 -0600 Subject: [llvm-commits] CVS: llvm/tools/gccas/gccas.cpp Message-ID: <200503070320.j273K5ss025982@apoc.cs.uiuc.edu> Changes in directory llvm/tools/gccas: gccas.cpp updated: 1.108 -> 1.109 --- Log message: move the reassociation pass after the LICM pass. This speeds up mgrid from 10.27s to 9.57s with the CBE. --- Diffs of the changes: (+2 -2) gccas.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) Index: llvm/tools/gccas/gccas.cpp diff -u llvm/tools/gccas/gccas.cpp:1.108 llvm/tools/gccas/gccas.cpp:1.109 --- llvm/tools/gccas/gccas.cpp:1.108 Sat Jan 22 11:36:16 2005 +++ llvm/tools/gccas/gccas.cpp Sun Mar 6 21:19:50 2005 @@ -103,12 +103,12 @@ addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas addPass(PM, createInstructionCombiningPass()); // Combine silly seq's - addPass(PM, createReassociatePass()); // Reassociate expressions addPass(PM, createInstructionCombiningPass()); // Combine silly seq's addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createLICMPass()); // Hoist loop invariants - addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller + addPass(PM, createReassociatePass()); // Reassociate expressions + addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars addPass(PM, createLoopUnrollPass()); // Unroll small loops addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller