From daniel at zuster.org Mon Aug 3 00:02:47 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 05:02:47 -0000 Subject: [llvm-commits] [llvm] r77953 - in /llvm/trunk: include/llvm/System/Program.h lib/System/Unix/Program.inc lib/System/Win32/Program.inc Message-ID: <200908030502.n7352mES012160@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 00:02:46 2009 New Revision: 77953 URL: http://llvm.org/viewvc/llvm-project?rev=77953&view=rev Log: Fix a race condition in getting the process exit code on Win32. Modified: llvm/trunk/include/llvm/System/Program.h llvm/trunk/lib/System/Unix/Program.inc llvm/trunk/lib/System/Win32/Program.inc Modified: llvm/trunk/include/llvm/System/Program.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Program.h?rev=77953&r1=77952&r2=77953&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Program.h (original) +++ llvm/trunk/include/llvm/System/Program.h Mon Aug 3 00:02:46 2009 @@ -29,6 +29,9 @@ /// @since 1.4 /// @brief An abstraction for finding and executing programs. class Program { + /// Opaque handle for target specific data. + void *Data; + unsigned Pid_; // Noncopyable. @@ -39,9 +42,9 @@ /// @{ public: - Program() : Pid_(0) - {} - + Program(); + ~Program(); + /// Return process ID of this program. unsigned GetPid() { return Pid_; } Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=77953&r1=77952&r2=77953&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Mon Aug 3 00:02:46 2009 @@ -35,6 +35,10 @@ namespace llvm { using namespace sys; +Program::Program() : Pid_(0) {} + +Program::~Program() {} + // This function just uses the PATH environment variable to find the program. Path Program::FindProgramByName(const std::string& progName) { Modified: llvm/trunk/lib/System/Win32/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Program.inc?rev=77953&r1=77952&r2=77953&view=diff ============================================================================== --- llvm/trunk/lib/System/Win32/Program.inc (original) +++ llvm/trunk/lib/System/Win32/Program.inc Mon Aug 3 00:02:46 2009 @@ -25,6 +25,16 @@ namespace llvm { using namespace sys; +Program::Program() : Pid_(0), Data(0) {} + +Program::~Program() { + if (Data) { + HANDLE hProcess = (HANDLE) Data; + CloseHandle(hProcess); + Data = 0; + } +} + // This function just uses the PATH environment variable to find the program. Path Program::FindProgramByName(const std::string& progName) { @@ -122,6 +132,12 @@ const Path** redirects, unsigned memoryLimit, std::string* ErrMsg) { + if (Data) { + HANDLE hProcess = (HANDLE) Data; + CloseHandle(Data); + Data = 0; + } + if (!path.canExecute()) { if (ErrMsg) *ErrMsg = "program not executable"; @@ -250,9 +266,9 @@ return false; } Pid_ = pi.dwProcessId; - + Data = pi.hProcess; + // Make sure these get closed no matter what. - AutoHandle hProcess(pi.hProcess); AutoHandle hThread(pi.hThread); // Assign the process to a job if a memory limit is defined. @@ -286,13 +302,13 @@ int Program::Wait(unsigned secondsToWait, std::string* ErrMsg) { - if (Pid_ == 0) { + if (Data == 0) { MakeErrMsg(ErrMsg, "Process not started!"); return -1; } - AutoHandle hProcess = OpenProcess(SYNCHRONIZE, FALSE, Pid_); - + HANDLE hProcess = (HANDLE) Data; + // Wait for the process to terminate. DWORD millisecondsToWait = INFINITE; if (secondsToWait > 0) From daniel at zuster.org Mon Aug 3 00:03:08 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Sun, 2 Aug 2009 22:03:08 -0700 Subject: [llvm-commits] [llvm] r76340 - in /llvm/trunk: include/llvm/System/Program.h lib/System/Program.cpp lib/System/Unix/Program.inc lib/System/Win32/Program.inc In-Reply-To: <6a8523d60908012151x635f2843qe7a66d98bc7bba23@mail.gmail.com> References: <200907182143.n6ILhD0K003063@zion.cs.uiuc.edu> <6a8523d60908012151x635f2843qe7a66d98bc7bba23@mail.gmail.com> Message-ID: <6a8523d60908022203k2a6f379i47c5056194ffe8f1@mail.gmail.com> On Sat, Aug 1, 2009 at 9:51 PM, Daniel Dunbar wrote: > Hi Mikhail, > > Unfortunately I'm not seeing this until now, but this refactoring has > one key flaw. On Windows, it introduces a race condition between where > the program releases the process handle, and where it gets the handle > again in Program::Wait. I believe that the program needs to hold on to > the handle for as long as clients may want information about it. > > This causes substantial problems for the clang driver on Windows. Do > you think you can work out an alternate solution that avoids this > problem? Scratch that, fixed in r77953. - Daniel > On Sat, Jul 18, 2009 at 2:43 PM, Mikhail Glushenkov wrote: >> Author: foldr >> Date: Sat Jul 18 16:43:12 2009 >> New Revision: 76340 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=76340&view=rev >> Log: >> Remove duplication in Program::Execute{And,No}Wait. >> >> Implemented by moving the code out of static functions into methods of Program >> class. >> >> Modified: >> ? ?llvm/trunk/include/llvm/System/Program.h >> ? ?llvm/trunk/lib/System/Program.cpp >> ? ?llvm/trunk/lib/System/Unix/Program.inc >> ? ?llvm/trunk/lib/System/Win32/Program.inc >> >> Modified: llvm/trunk/include/llvm/System/Program.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Program.h?rev=76340&r1=76339&r2=76340&view=diff >> >> ============================================================================== >> --- llvm/trunk/include/llvm/System/Program.h (original) >> +++ llvm/trunk/include/llvm/System/Program.h Sat Jul 18 16:43:12 2009 >> @@ -19,6 +19,9 @@ >> ?namespace llvm { >> ?namespace sys { >> >> + ?// TODO: Add operations to communicate with the process, redirect its I/O, >> + ?// etc. >> + >> ? /// This class provides an abstraction for programs that are executable by the >> ? /// operating system. It provides a platform generic way to find executable >> ? /// programs from the path and to execute them in various ways. The sys::Path >> @@ -26,104 +29,112 @@ >> ? /// @since 1.4 >> ? /// @brief An abstraction for finding and executing programs. >> ? class Program { >> + ? ?unsigned Pid_; >> + >> + ? ?// Noncopyable. >> + ? ?Program(const Program& other); >> + ? ?Program& operator=(const Program& other); >> + >> ? ? /// @name Methods >> ? ? /// @{ >> - ? ?public: >> - ? ? ?/// This static constructor (factory) will attempt to locate a program in >> - ? ? ?/// the operating system's file system using some pre-determined set of >> - ? ? ?/// locations to search (e.g. the PATH on Unix). >> - ? ? ?/// @returns A Path object initialized to the path of the program or a >> - ? ? ?/// Path object that is empty (invalid) if the program could not be found. >> - ? ? ?/// @throws nothing >> - ? ? ?/// @brief Construct a Program by finding it by name. >> - ? ? ?static Path FindProgramByName(const std::string& name); >> - >> - ? ? ?/// This function executes the program using the \p arguments provided and >> - ? ? ?/// waits for the program to exit. This function will block the current >> - ? ? ?/// program until the invoked program exits. The invoked program will >> - ? ? ?/// inherit the stdin, stdout, and stderr file descriptors, the >> - ? ? ?/// environment and other configuration settings of the invoking program. >> - ? ? ?/// If Path::executable() does not return true when this function is >> - ? ? ?/// called then a std::string is thrown. >> - ? ? ?/// @returns an integer result code indicating the status of the program. >> - ? ? ?/// A zero or positive value indicates the result code of the program. A >> - ? ? ?/// negative value is the signal number on which it terminated. >> - ? ? ?/// @see FindProgrambyName >> - ? ? ?/// @brief Executes the program with the given set of \p args. >> - ? ? ?static int ExecuteAndWait( >> - ? ? ? ?const Path& path, ?///< sys::Path object providing the path of the >> - ? ? ? ? ?///< program to be executed. It is presumed this is the result of >> - ? ? ? ? ?///< the FindProgramByName method. >> - ? ? ? ?const char** args, ///< A vector of strings that are passed to the >> - ? ? ? ? ?///< program. ?The first element should be the name of the program. >> - ? ? ? ? ?///< The list *must* be terminated by a null char* entry. >> - ? ? ? ?const char ** env = 0, ///< An optional vector of strings to use for >> - ? ? ? ? ?///< the program's environment. If not provided, the current program's >> - ? ? ? ? ?///< environment will be used. >> - ? ? ? ?const sys::Path** redirects = 0, ///< An optional array of pointers to >> - ? ? ? ? ?///< Paths. If the array is null, no redirection is done. The array >> - ? ? ? ? ?///< should have a size of at least three. If the pointer in the array >> - ? ? ? ? ?///< are not null, then the inferior process's stdin(0), stdout(1), >> - ? ? ? ? ?///< and stderr(2) will be redirected to the corresponding Paths. >> - ? ? ? ? ?///< When an empty Path is passed in, the corresponding file >> - ? ? ? ? ?///< descriptor will be disconnected (ie, /dev/null'd) in a portable >> - ? ? ? ? ?///< way. >> - ? ? ? ?unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount >> - ? ? ? ? ?///< of time to wait for the child process to exit. If the time >> - ? ? ? ? ?///< expires, the child is killed and this call returns. If zero, >> - ? ? ? ? ?///< this function will wait until the child finishes or forever if >> - ? ? ? ? ?///< it doesn't. >> - ? ? ? ?unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount >> - ? ? ? ? ?///< of memory can be allocated by process. If memory usage will be >> - ? ? ? ? ?///< higher limit, the child is killed and this call returns. If zero >> - ? ? ? ? ?///< - no memory limit. >> - ? ? ? ?std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string >> - ? ? ? ? ?///< instance in which error messages will be returned. If the string >> - ? ? ? ? ?///< is non-empty upon return an error occurred while invoking the >> - ? ? ? ? ?///< program. >> + ?public: >> + >> + ? ?Program() : Pid_(0) >> + ? ?{} >> + >> + ? ?/// This function executes the program using the \p arguments provided. ?The >> + ? ?/// invoked program will inherit the stdin, stdout, and stderr file >> + ? ?/// descriptors, the environment and other configuration settings of the >> + ? ?/// invoking program. If Path::executable() does not return true when this >> + ? ?/// function is called then a std::string is thrown. >> + ? ?/// @returns false in case of error, true otherwise. >> + ? ?/// @see FindProgramByName >> + ? ?/// @brief Executes the program with the given set of \p args. >> + ? ?bool Execute >> + ? ?( const Path& path, ?///< sys::Path object providing the path of the >> + ? ? ?///< program to be executed. It is presumed this is the result of >> + ? ? ?///< the FindProgramByName method. >> + ? ? ?const char** args, ///< A vector of strings that are passed to the >> + ? ? ?///< program. ?The first element should be the name of the program. >> + ? ? ?///< The list *must* be terminated by a null char* entry. >> + ? ? ?const char ** env = 0, ///< An optional vector of strings to use for >> + ? ? ?///< the program's environment. If not provided, the current program's >> + ? ? ?///< environment will be used. >> + ? ? ?const sys::Path** redirects = 0, ///< An optional array of pointers to >> + ? ? ?///< Paths. If the array is null, no redirection is done. The array >> + ? ? ?///< should have a size of at least three. If the pointer in the array >> + ? ? ?///< are not null, then the inferior process's stdin(0), stdout(1), >> + ? ? ?///< and stderr(2) will be redirected to the corresponding Paths. >> + ? ? ?///< When an empty Path is passed in, the corresponding file >> + ? ? ?///< descriptor will be disconnected (ie, /dev/null'd) in a portable >> + ? ? ?///< way. >> + ? ? ?unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount >> + ? ? ?///< of memory can be allocated by process. If memory usage will be >> + ? ? ?///< higher limit, the child is killed and this call returns. If zero >> + ? ? ?///< - no memory limit. >> + ? ? ?std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string >> + ? ? ?///< instance in which error messages will be returned. If the string >> + ? ? ?///< is non-empty upon return an error occurred while invoking the >> + ? ? ?///< program. >> + ? ? ?); >> + >> + ? ?/// This function waits for the program to exit. This function will block >> + ? ?/// the current program until the invoked program exits. >> + ? ?/// @returns an integer result code indicating the status of the program. >> + ? ?/// A zero or positive value indicates the result code of the program. A >> + ? ?/// negative value is the signal number on which it terminated. >> + ? ?/// @see Execute >> + ? ?/// @brief Waits for the program to exit. >> + ? ?int Wait >> + ? ?( unsigned secondsToWait = 0, ///< If non-zero, this specifies the amount >> + ? ? ?///< of time to wait for the child process to exit. If the time >> + ? ? ?///< expires, the child is killed and this call returns. If zero, >> + ? ? ?///< this function will wait until the child finishes or forever if >> + ? ? ?///< it doesn't. >> + ? ? ?std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string >> + ? ? ?///< instance in which error messages will be returned. If the string >> + ? ? ?///< is non-empty upon return an error occurred while invoking the >> + ? ? ?///< program. >> ? ? ? ); >> - ? ? ?// These methods change the specified standard stream (stdin or stdout) to >> - ? ? ?// binary mode. They return true if an error occurred >> - ? ? ?static bool ChangeStdinToBinary(); >> - ? ? ?static bool ChangeStdoutToBinary(); >> + >> + ? ?/// This static constructor (factory) will attempt to locate a program in >> + ? ?/// the operating system's file system using some pre-determined set of >> + ? ?/// locations to search (e.g. the PATH on Unix). >> + ? ?/// @returns A Path object initialized to the path of the program or a >> + ? ?/// Path object that is empty (invalid) if the program could not be found. >> + ? ?/// @throws nothing >> + ? ?/// @brief Construct a Program by finding it by name. >> + ? ?static Path FindProgramByName(const std::string& name); >> + >> + ? ?// These methods change the specified standard stream (stdin or stdout) to >> + ? ?// binary mode. They return true if an error occurred >> + ? ?static bool ChangeStdinToBinary(); >> + ? ?static bool ChangeStdoutToBinary(); >> + >> + ? ?/// A convenience function equivalent to Program prg; prg.Execute(..); >> + ? ?/// prg.Wait(..); >> + ? ?/// @throws nothing >> + ? ?/// @see Execute, Wait >> + ? ?static int ExecuteAndWait(const Path& path, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char** args, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char ** env = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const sys::Path** redirects = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned secondsToWait = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned memoryLimit = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::string* ErrMsg = 0); >> + >> + ? ?/// A convenience function equivalent to Program prg; prg.Execute(..); >> + ? ?/// @throws nothing >> + ? ?/// @see Execute >> + ? ?static void ExecuteNoWait(const Path& path, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char** args, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const char ** env = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const sys::Path** redirects = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned memoryLimit = 0, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::string* ErrMsg = 0); >> + >> ? ? /// @} >> >> - ? ? /// This function executes the program using the \p arguments provided and >> - ? ? /// waits for the program to exit. This function will block the current >> - ? ? /// program until the invoked program exits. The invoked program will >> - ? ? /// inherit the stdin, stdout, and stderr file descriptors, the >> - ? ? /// environment and other configuration settings of the invoking program. >> - ? ? /// If Path::executable() does not return true when this function is >> - ? ? /// called then a std::string is thrown. >> - ? ? /// @returns an integer result code indicating the status of the program. >> - ? ? /// A zero or positive value indicates the result code of the program. A >> - ? ? /// negative value is the signal number on which it terminated. >> - ? ? /// @see FindProgrambyName >> - ? ? /// @brief Executes the program with the given set of \p args. >> - ? ? static void ExecuteNoWait( >> - ? ? ? ?const Path& path, ?///< sys::Path object providing the path of the >> - ? ? ? ?///< program to be executed. It is presumed this is the result of >> - ? ? ? ?///< the FindProgramByName method. >> - ? ? ? ?const char** args, ///< A vector of strings that are passed to the >> - ? ? ? ?///< program. ?The first element should be the name of the program. >> - ? ? ? ?///< The list *must* be terminated by a null char* entry. >> - ? ? ? ?const char ** env = 0, ///< An optional vector of strings to use for >> - ? ? ? ?///< the program's environment. If not provided, the current program's >> - ? ? ? ?///< environment will be used. >> - ? ? ? ?const sys::Path** redirects = 0, ///< An optional array of pointers to >> - ? ? ? ?///< Paths. If the array is null, no redirection is done. The array >> - ? ? ? ?///< should have a size of at least three. If the pointer in the array >> - ? ? ? ?///< are not null, then the inferior process's stdin(0), stdout(1), >> - ? ? ? ?///< and stderr(2) will be redirected to the corresponding Paths. >> - ? ? ? ?unsigned memoryLimit = 0, ///< If non-zero, this specifies max. amount >> - ? ? ? ?///< of memory can be allocated by process. If memory usage will be >> - ? ? ? ?///< higher limit, the child is killed and this call returns. If zero - >> - ? ? ? ?///< no memory limit. >> - ? ? ? ?std::string* ErrMsg = 0 ///< If non-zero, provides a pointer to a string >> - ? ? ? ?///< instance in which error messages will be returned. If the string >> - ? ? ? ?///< is non-empty upon return an error occurred while invoking the >> - ? ? ? ?///< program. >> - ? ? ? ?); >> ? }; >> ?} >> ?} >> >> Modified: llvm/trunk/lib/System/Program.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Program.cpp?rev=76340&r1=76339&r2=76340&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/System/Program.cpp (original) >> +++ llvm/trunk/lib/System/Program.cpp Sat Jul 18 16:43:12 2009 >> @@ -22,6 +22,33 @@ >> ?//=== ? ? ? ? ?independent code. >> ?//===----------------------------------------------------------------------===// >> >> +int >> +Program::ExecuteAndWait(const Path& path, >> + ? ? ? ? ? ? ? ? ? ? ? ?const char** args, >> + ? ? ? ? ? ? ? ? ? ? ? ?const char** envp, >> + ? ? ? ? ? ? ? ? ? ? ? ?const Path** redirects, >> + ? ? ? ? ? ? ? ? ? ? ? ?unsigned secondsToWait, >> + ? ? ? ? ? ? ? ? ? ? ? ?unsigned memoryLimit, >> + ? ? ? ? ? ? ? ? ? ? ? ?std::string* ErrMsg) { >> + ?Program prg; >> + ?if (prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg)) >> + ? ?return prg.Wait(secondsToWait, ErrMsg); >> + ?else >> + ? ?return -1; >> +} >> + >> +void >> +Program::ExecuteNoWait(const Path& path, >> + ? ? ? ? ? ? ? ? ? ? ? const char** args, >> + ? ? ? ? ? ? ? ? ? ? ? const char** envp, >> + ? ? ? ? ? ? ? ? ? ? ? const Path** redirects, >> + ? ? ? ? ? ? ? ? ? ? ? unsigned memoryLimit, >> + ? ? ? ? ? ? ? ? ? ? ? std::string* ErrMsg) { >> + ?Program prg; >> + ?prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg); >> +} >> + >> + >> ?} >> >> ?// Include the platform-specific parts of this class. >> >> Modified: llvm/trunk/lib/System/Unix/Program.inc >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=76340&r1=76339&r2=76340&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/System/Unix/Program.inc (original) >> +++ llvm/trunk/lib/System/Unix/Program.inc Sat Jul 18 16:43:12 2009 >> @@ -142,49 +142,47 @@ >> ?#endif >> ?} >> >> -int >> -Program::ExecuteAndWait(const Path& path, >> - ? ? ? ? ? ? ? ? ? ? ? ?const char** args, >> - ? ? ? ? ? ? ? ? ? ? ? ?const char** envp, >> - ? ? ? ? ? ? ? ? ? ? ? ?const Path** redirects, >> - ? ? ? ? ? ? ? ? ? ? ? ?unsigned secondsToWait, >> - ? ? ? ? ? ? ? ? ? ? ? ?unsigned memoryLimit, >> - ? ? ? ? ? ? ? ? ? ? ? ?std::string* ErrMsg) >> +bool >> +Program::Execute(const Path& path, >> + ? ? ? ? ? ? ? ? const char** args, >> + ? ? ? ? ? ? ? ? const char** envp, >> + ? ? ? ? ? ? ? ? const Path** redirects, >> + ? ? ? ? ? ? ? ? unsigned memoryLimit, >> + ? ? ? ? ? ? ? ? std::string* ErrMsg) >> ?{ >> ? if (!path.canExecute()) { >> ? ? if (ErrMsg) >> ? ? ? *ErrMsg = path.toString() + " is not executable"; >> - ? ?return -1; >> + ? ?return false; >> ? } >> >> -#ifdef HAVE_SYS_WAIT_H >> ? // Create a child process. >> ? int child = fork(); >> ? switch (child) { >> ? ? // An error occured: ?Return to the caller. >> ? ? case -1: >> ? ? ? MakeErrMsg(ErrMsg, "Couldn't fork"); >> - ? ? ?return -1; >> + ? ? ?return false; >> >> ? ? // Child process: Execute the program. >> ? ? case 0: { >> ? ? ? // Redirect file descriptors... >> ? ? ? if (redirects) { >> ? ? ? ? // Redirect stdin >> - ? ? ? ?if (RedirectIO(redirects[0], 0, ErrMsg)) { return -1; } >> + ? ? ? ?if (RedirectIO(redirects[0], 0, ErrMsg)) { return false; } >> ? ? ? ? // Redirect stdout >> - ? ? ? ?if (RedirectIO(redirects[1], 1, ErrMsg)) { return -1; } >> + ? ? ? ?if (RedirectIO(redirects[1], 1, ErrMsg)) { return false; } >> ? ? ? ? if (redirects[1] && redirects[2] && >> ? ? ? ? ? ? *(redirects[1]) == *(redirects[2])) { >> ? ? ? ? ? // If stdout and stderr should go to the same place, redirect stderr >> ? ? ? ? ? // to the FD already open for stdout. >> ? ? ? ? ? if (-1 == dup2(1,2)) { >> ? ? ? ? ? ? MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout"); >> - ? ? ? ? ? ?return -1; >> + ? ? ? ? ? ?return false; >> ? ? ? ? ? } >> ? ? ? ? } else { >> ? ? ? ? ? // Just redirect stderr >> - ? ? ? ? ?if (RedirectIO(redirects[2], 2, ErrMsg)) { return -1; } >> + ? ? ? ? ?if (RedirectIO(redirects[2], 2, ErrMsg)) { return false; } >> ? ? ? ? } >> ? ? ? } >> >> @@ -214,8 +212,23 @@ >> ? fsync(1); >> ? fsync(2); >> >> + ?Pid_ = child; >> + >> + ?return true; >> +} >> + >> +int >> +Program::Wait(unsigned secondsToWait, >> + ? ? ? ? ? ? ?std::string* ErrMsg) >> +{ >> +#ifdef HAVE_SYS_WAIT_H >> ? struct sigaction Act, Old; >> >> + ?if (Pid_ == 0) { >> + ? ?MakeErrMsg(ErrMsg, "Process not started!"); >> + ? ?return -1; >> + ?} >> + >> ? // Install a timeout handler. >> ? if (secondsToWait) { >> ? ? Timeout = false; >> @@ -229,6 +242,7 @@ >> >> ? // Parent process: Wait for the child process to terminate. >> ? int status; >> + ?int child = this->Pid_; >> ? while (wait(&status) != child) >> ? ? if (secondsToWait && errno == EINTR) { >> ? ? ? // Kill the child. >> @@ -274,78 +288,6 @@ >> >> ?} >> >> -void >> -Program::ExecuteNoWait(const Path& path, >> - ? ? ? ? ? ? ? ? ? ? ? const char** args, >> - ? ? ? ? ? ? ? ? ? ? ? const char** envp, >> - ? ? ? ? ? ? ? ? ? ? ? const Path** redirects, >> - ? ? ? ? ? ? ? ? ? ? ? unsigned memoryLimit, >> - ? ? ? ? ? ? ? ? ? ? ? std::string* ErrMsg) >> -{ >> - ?if (!path.canExecute()) { >> - ? ?if (ErrMsg) >> - ? ? ?*ErrMsg = path.toString() + " is not executable"; >> - ? ?return; >> - ?} >> - >> - ?// Create a child process. >> - ?int child = fork(); >> - ?switch (child) { >> - ? ?// An error occured: ?Return to the caller. >> - ? ?case -1: >> - ? ? ?MakeErrMsg(ErrMsg, "Couldn't fork"); >> - ? ? ?return; >> - >> - ? ?// Child process: Execute the program. >> - ? ?case 0: { >> - ? ? ?// Redirect file descriptors... >> - ? ? ?if (redirects) { >> - ? ? ? ?// Redirect stdin >> - ? ? ? ?if (RedirectIO(redirects[0], 0, ErrMsg)) { return; } >> - ? ? ? ?// Redirect stdout >> - ? ? ? ?if (RedirectIO(redirects[1], 1, ErrMsg)) { return; } >> - ? ? ? ?if (redirects[1] && redirects[2] && >> - ? ? ? ? ? ?*(redirects[1]) == *(redirects[2])) { >> - ? ? ? ? ?// If stdout and stderr should go to the same place, redirect stderr >> - ? ? ? ? ?// to the FD already open for stdout. >> - ? ? ? ? ?if (-1 == dup2(1,2)) { >> - ? ? ? ? ? ?MakeErrMsg(ErrMsg, "Can't redirect stderr to stdout"); >> - ? ? ? ? ? ?return; >> - ? ? ? ? ?} >> - ? ? ? ?} else { >> - ? ? ? ? ?// Just redirect stderr >> - ? ? ? ? ?if (RedirectIO(redirects[2], 2, ErrMsg)) { return; } >> - ? ? ? ?} >> - ? ? ?} >> - >> - ? ? ?// Set memory limits >> - ? ? ?if (memoryLimit!=0) { >> - ? ? ? ?SetMemoryLimits(memoryLimit); >> - ? ? ?} >> - >> - ? ? ?// Execute! >> - ? ? ?if (envp != 0) >> - ? ? ? ?execve (path.c_str(), (char**)args, (char**)envp); >> - ? ? ?else >> - ? ? ? ?execv (path.c_str(), (char**)args); >> - ? ? ?// If the execve() failed, we should exit and let the parent pick up >> - ? ? ?// our non-zero exit status. >> - ? ? ?exit (errno); >> - ? ?} >> - >> - ? ?// Parent process: Break out of the switch to do our processing. >> - ? ?default: >> - ? ? ?break; >> - ?} >> - >> - ?// Make sure stderr and stdout have been flushed >> - ?std::cerr << std::flush; >> - ?std::cout << std::flush; >> - ?fsync(1); >> - ?fsync(2); >> - >> -} >> - >> ?bool Program::ChangeStdinToBinary(){ >> ? // Do nothing, as Unix doesn't differentiate between text and binary. >> ? return false; >> >> Modified: llvm/trunk/lib/System/Win32/Program.inc >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Program.inc?rev=76340&r1=76339&r2=76340&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/System/Win32/Program.inc (original) >> +++ llvm/trunk/lib/System/Win32/Program.inc Sat Jul 18 16:43:12 2009 >> @@ -109,18 +109,17 @@ >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DWORD cbJobObjectInfoLength); >> ?#endif >> >> -int >> -Program::ExecuteAndWait(const Path& path, >> - ? ? ? ? ? ? ? ? ? ? ? ?const char** args, >> - ? ? ? ? ? ? ? ? ? ? ? ?const char** envp, >> - ? ? ? ? ? ? ? ? ? ? ? ?const Path** redirects, >> - ? ? ? ? ? ? ? ? ? ? ? ?unsigned secondsToWait, >> - ? ? ? ? ? ? ? ? ? ? ? ?unsigned memoryLimit, >> - ? ? ? ? ? ? ? ? ? ? ? ?std::string* ErrMsg) { >> +bool >> +Program::Execute(const Path& path, >> + ? ? ? ? ? ? ? ? const char** args, >> + ? ? ? ? ? ? ? ? const char** envp, >> + ? ? ? ? ? ? ? ? const Path** redirects, >> + ? ? ? ? ? ? ? ? unsigned memoryLimit, >> + ? ? ? ? ? ? ? ? std::string* ErrMsg) { >> ? if (!path.canExecute()) { >> ? ? if (ErrMsg) >> ? ? ? *ErrMsg = "program not executable"; >> - ? ?return -1; >> + ? ?return false; >> ? } >> >> ? // Windows wants a command line, not an array of args, to pass to the new >> @@ -195,13 +194,13 @@ >> ? ? si.hStdInput = RedirectIO(redirects[0], 0, ErrMsg); >> ? ? if (si.hStdInput == INVALID_HANDLE_VALUE) { >> ? ? ? MakeErrMsg(ErrMsg, "can't redirect stdin"); >> - ? ? ?return -1; >> + ? ? ?return false; >> ? ? } >> ? ? si.hStdOutput = RedirectIO(redirects[1], 1, ErrMsg); >> ? ? if (si.hStdOutput == INVALID_HANDLE_VALUE) { >> ? ? ? CloseHandle(si.hStdInput); >> ? ? ? MakeErrMsg(ErrMsg, "can't redirect stdout"); >> - ? ? ?return -1; >> + ? ? ?return false; >> ? ? } >> ? ? if (redirects[1] && redirects[2] && *(redirects[1]) == *(redirects[2])) { >> ? ? ? // If stdout and stderr should go to the same place, redirect stderr >> @@ -216,7 +215,7 @@ >> ? ? ? ? CloseHandle(si.hStdInput); >> ? ? ? ? CloseHandle(si.hStdOutput); >> ? ? ? ? MakeErrMsg(ErrMsg, "can't redirect stderr"); >> - ? ? ? ?return -1; >> + ? ? ? ?return false; >> ? ? ? } >> ? ? } >> ? } >> @@ -242,8 +241,9 @@ >> ? ? SetLastError(err); >> ? ? MakeErrMsg(ErrMsg, std::string("Couldn't execute program '") + >> ? ? ? ? ? ? ? ?path.toString() + "'"); >> - ? ?return -1; >> + ? ?return false; >> ? } >> + ?Pid_ = pi.dwProcessId; >> >> ? // Make sure these get closed no matter what. >> ? AutoHandle hProcess(pi.hProcess); >> @@ -270,204 +270,50 @@ >> ? ? ? MakeErrMsg(ErrMsg, std::string("Unable to set memory limit")); >> ? ? ? TerminateProcess(pi.hProcess, 1); >> ? ? ? WaitForSingleObject(pi.hProcess, INFINITE); >> - ? ? ?return -1; >> + ? ? ?return false; >> ? ? } >> ? } >> >> - ?// Wait for it to terminate. >> + ?return true; >> +} >> + >> +int >> +Program::Wait(unsigned secondsToWait, >> + ? ? ? ? ? ? ?std::string* ErrMsg) { >> + ?if (Pid_ == 0) { >> + ? ?MakeErrMsg(ErrMsg, "Process not started!"); >> + ? ?return -1; >> + ?} >> + >> + ?AutoHandle hProcess = OpenProcess(SYNCHRONIZE, FALSE, Pid_); >> + >> + ?// Wait for the process to terminate. >> ? DWORD millisecondsToWait = INFINITE; >> ? if (secondsToWait > 0) >> ? ? millisecondsToWait = secondsToWait * 1000; >> >> - ?if (WaitForSingleObject(pi.hProcess, millisecondsToWait) == WAIT_TIMEOUT) { >> - ? ?if (!TerminateProcess(pi.hProcess, 1)) { >> - ? ? ?MakeErrMsg(ErrMsg, std::string("Failed to terminate timed-out program '") >> - ? ? ? ? ?+ path.toString() + "'"); >> + ?if (WaitForSingleObject(hProcess, millisecondsToWait) == WAIT_TIMEOUT) { >> + ? ?if (!TerminateProcess(hProcess, 1)) { >> + ? ? ?MakeErrMsg(ErrMsg, "Failed to terminate timed-out program."); >> ? ? ? return -1; >> ? ? } >> - ? ?WaitForSingleObject(pi.hProcess, INFINITE); >> + ? ?WaitForSingleObject(hProcess, INFINITE); >> ? } >> >> ? // Get its exit status. >> ? DWORD status; >> - ?rc = GetExitCodeProcess(pi.hProcess, &status); >> - ?err = GetLastError(); >> + ?BOOL rc = GetExitCodeProcess(hProcess, &status); >> + ?DWORD err = GetLastError(); >> >> ? if (!rc) { >> ? ? SetLastError(err); >> - ? ?MakeErrMsg(ErrMsg, std::string("Failed getting status for program '") + >> - ? ? ? ? ? ? ? path.toString() + "'"); >> + ? ?MakeErrMsg(ErrMsg, "Failed getting status for program."); >> ? ? return -1; >> ? } >> >> ? return status; >> ?} >> >> -void >> -Program::ExecuteNoWait(const Path& path, >> - ? ? ? ? ? ? ? ? ? ? ? const char** args, >> - ? ? ? ? ? ? ? ? ? ? ? const char** envp, >> - ? ? ? ? ? ? ? ? ? ? ? const Path** redirects, >> - ? ? ? ? ? ? ? ? ? ? ? unsigned memoryLimit, >> - ? ? ? ? ? ? ? ? ? ? ? std::string* ErrMsg) { >> - ?if (!path.canExecute()) { >> - ? ?if (ErrMsg) >> - ? ? ?*ErrMsg = "program not executable"; >> - ? ?return; >> - ?} >> - >> - ?// Windows wants a command line, not an array of args, to pass to the new >> - ?// process. ?We have to concatenate them all, while quoting the args that >> - ?// have embedded spaces. >> - >> - ?// First, determine the length of the command line. >> - ?unsigned len = 0; >> - ?for (unsigned i = 0; args[i]; i++) { >> - ? ?len += strlen(args[i]) + 1; >> - ? ?if (strchr(args[i], ' ')) >> - ? ? ?len += 2; >> - ?} >> - >> - ?// Now build the command line. >> - ?char *command = reinterpret_cast(_alloca(len+1)); >> - ?char *p = command; >> - >> - ?for (unsigned i = 0; args[i]; i++) { >> - ? ?const char *arg = args[i]; >> - ? ?size_t len = strlen(arg); >> - ? ?bool needsQuoting = strchr(arg, ' ') != 0; >> - ? ?if (needsQuoting) >> - ? ? ?*p++ = '"'; >> - ? ?memcpy(p, arg, len); >> - ? ?p += len; >> - ? ?if (needsQuoting) >> - ? ? ?*p++ = '"'; >> - ? ?*p++ = ' '; >> - ?} >> - >> - ?*p = 0; >> - >> - ?// The pointer to the environment block for the new process. >> - ?char *envblock = 0; >> - >> - ?if (envp) { >> - ? ?// An environment block consists of a null-terminated block of >> - ? ?// null-terminated strings. Convert the array of environment variables to >> - ? ?// an environment block by concatenating them. >> - >> - ? ?// First, determine the length of the environment block. >> - ? ?len = 0; >> - ? ?for (unsigned i = 0; envp[i]; i++) >> - ? ? ?len += strlen(envp[i]) + 1; >> - >> - ? ?// Now build the environment block. >> - ? ?envblock = reinterpret_cast(_alloca(len+1)); >> - ? ?p = envblock; >> - >> - ? ?for (unsigned i = 0; envp[i]; i++) { >> - ? ? ?const char *ev = envp[i]; >> - ? ? ?size_t len = strlen(ev) + 1; >> - ? ? ?memcpy(p, ev, len); >> - ? ? ?p += len; >> - ? ?} >> - >> - ? ?*p = 0; >> - ?} >> - >> - ?// Create a child process. >> - ?STARTUPINFO si; >> - ?memset(&si, 0, sizeof(si)); >> - ?si.cb = sizeof(si); >> - ?si.hStdInput = INVALID_HANDLE_VALUE; >> - ?si.hStdOutput = INVALID_HANDLE_VALUE; >> - ?si.hStdError = INVALID_HANDLE_VALUE; >> - >> - ?if (redirects) { >> - ? ?si.dwFlags = STARTF_USESTDHANDLES; >> - >> - ? ?si.hStdInput = RedirectIO(redirects[0], 0, ErrMsg); >> - ? ?if (si.hStdInput == INVALID_HANDLE_VALUE) { >> - ? ? ?MakeErrMsg(ErrMsg, "can't redirect stdin"); >> - ? ? ?return; >> - ? ?} >> - ? ?si.hStdOutput = RedirectIO(redirects[1], 1, ErrMsg); >> - ? ?if (si.hStdOutput == INVALID_HANDLE_VALUE) { >> - ? ? ?CloseHandle(si.hStdInput); >> - ? ? ?MakeErrMsg(ErrMsg, "can't redirect stdout"); >> - ? ? ?return; >> - ? ?} >> - ? ?if (redirects[1] && redirects[2] && *(redirects[1]) == *(redirects[2])) { >> - ? ? ?// If stdout and stderr should go to the same place, redirect stderr >> - ? ? ?// to the handle already open for stdout. >> - ? ? ?DuplicateHandle(GetCurrentProcess(), si.hStdOutput, >> - ? ? ? ? ? ? ? ? ? ? ?GetCurrentProcess(), &si.hStdError, >> - ? ? ? ? ? ? ? ? ? ? ?0, TRUE, DUPLICATE_SAME_ACCESS); >> - ? ?} else { >> - ? ? ?// Just redirect stderr >> - ? ? ?si.hStdError = RedirectIO(redirects[2], 2, ErrMsg); >> - ? ? ?if (si.hStdError == INVALID_HANDLE_VALUE) { >> - ? ? ? ?CloseHandle(si.hStdInput); >> - ? ? ? ?CloseHandle(si.hStdOutput); >> - ? ? ? ?MakeErrMsg(ErrMsg, "can't redirect stderr"); >> - ? ? ? ?return; >> - ? ? ?} >> - ? ?} >> - ?} >> - >> - ?PROCESS_INFORMATION pi; >> - ?memset(&pi, 0, sizeof(pi)); >> - >> - ?fflush(stdout); >> - ?fflush(stderr); >> - ?BOOL rc = CreateProcess(path.c_str(), command, NULL, NULL, TRUE, 0, >> - ? ? ? ? ? ? ? ? ? ? ? ? ?envblock, NULL, &si, &pi); >> - ?DWORD err = GetLastError(); >> - >> - ?// Regardless of whether the process got created or not, we are done with >> - ?// the handles we created for it to inherit. >> - ?CloseHandle(si.hStdInput); >> - ?CloseHandle(si.hStdOutput); >> - ?CloseHandle(si.hStdError); >> - >> - ?// Now return an error if the process didn't get created. >> - ?if (!rc) >> - ?{ >> - ? ?SetLastError(err); >> - ? ?MakeErrMsg(ErrMsg, std::string("Couldn't execute program '") + >> - ? ? ? ? ? ? ? path.toString() + "'"); >> - ? ?return; >> - ?} >> - >> - ?// Make sure these get closed no matter what. >> - ?AutoHandle hProcess(pi.hProcess); >> - ?AutoHandle hThread(pi.hThread); >> - >> - ?// Assign the process to a job if a memory limit is defined. >> - ?AutoHandle hJob(0); >> - ?if (memoryLimit != 0) { >> - ? ?hJob = CreateJobObject(0, 0); >> - ? ?bool success = false; >> - ? ?if (hJob != 0) { >> - ? ? ?JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli; >> - ? ? ?memset(&jeli, 0, sizeof(jeli)); >> - ? ? ?jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_PROCESS_MEMORY; >> - ? ? ?jeli.ProcessMemoryLimit = uintptr_t(memoryLimit) * 1048576; >> - ? ? ?if (SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&jeli, sizeof(jeli))) { >> - ? ? ? ?if (AssignProcessToJobObject(hJob, pi.hProcess)) >> - ? ? ? ? ?success = true; >> - ? ? ?} >> - ? ?} >> - ? ?if (!success) { >> - ? ? ?SetLastError(GetLastError()); >> - ? ? ?MakeErrMsg(ErrMsg, std::string("Unable to set memory limit")); >> - ? ? ?TerminateProcess(pi.hProcess, 1); >> - ? ? ?WaitForSingleObject(pi.hProcess, INFINITE); >> - ? ? ?return; >> - ? ?} >> - ?} >> -} >> - >> ?bool Program::ChangeStdinToBinary(){ >> ? int result = _setmode( _fileno(stdin), _O_BINARY ); >> ? return result == -1; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From eli.friedman at gmail.com Mon Aug 3 00:08:04 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Sun, 2 Aug 2009 22:08:04 -0700 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: <38a0d8450908022033w46f17d6dy2f403ad3c1624653@mail.gmail.com> References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <38a0d8450908021953ld211ee2y426145b3b4312443@mail.gmail.com> <38a0d8450908022020y3cce3809sefbc5f7f3b3538b0@mail.gmail.com> <38a0d8450908022033w46f17d6dy2f403ad3c1624653@mail.gmail.com> Message-ID: On Sun, Aug 2, 2009 at 8:33 PM, Rafael Espindola wrote: >> I don't see any connection between the way it's written and for the >> assembler and the way the JIT deals with it. ?And you still haven't >> addressed the issue, which is that I'm pretty sure it was done for >> compatibility reasons. ?If you don't know anything about that, I would >> suggest switching it back to movd. > > Do you know what we are trying to be compatible with? I looked it up; we are trying to be compatible with OS X. See http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011849.html . -Eli From daniel at zuster.org Mon Aug 3 00:12:16 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 05:12:16 -0000 Subject: [llvm-commits] [llvm] r77954 - in /llvm/trunk/utils: FileUpdate/ FileUpdate/CMakeLists.txt FileUpdate/FileUpdate.cpp FileUpdate/Makefile Makefile Message-ID: <200908030512.n735CGLK012426@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 00:12:16 2009 New Revision: 77954 URL: http://llvm.org/viewvc/llvm-project?rev=77954&view=rev Log: Add FileUpdate tool, conditionally updates its output based on its input. - Gratuitous and unused, but possibly useful one day. Added: llvm/trunk/utils/FileUpdate/ (with props) llvm/trunk/utils/FileUpdate/CMakeLists.txt llvm/trunk/utils/FileUpdate/FileUpdate.cpp llvm/trunk/utils/FileUpdate/Makefile Modified: llvm/trunk/utils/Makefile Propchange: llvm/trunk/utils/FileUpdate/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Aug 3 00:12:16 2009 @@ -0,0 +1,3 @@ +Debug +Release-Asserts +Release Added: llvm/trunk/utils/FileUpdate/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileUpdate/CMakeLists.txt?rev=77954&view=auto ============================================================================== --- llvm/trunk/utils/FileUpdate/CMakeLists.txt (added) +++ llvm/trunk/utils/FileUpdate/CMakeLists.txt Mon Aug 3 00:12:16 2009 @@ -0,0 +1,11 @@ +add_executable(FileUpdate + FileUpdate.cpp + ) + +target_link_libraries(FileUpdate LLVMSupport LLVMSystem) +if( MINGW ) + target_link_libraries(FileUpdate imagehlp psapi) +endif( MINGW ) +if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD ) + target_link_libraries(FileUpdate pthread) +endif() Added: llvm/trunk/utils/FileUpdate/FileUpdate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileUpdate/FileUpdate.cpp?rev=77954&view=auto ============================================================================== --- llvm/trunk/utils/FileUpdate/FileUpdate.cpp (added) +++ llvm/trunk/utils/FileUpdate/FileUpdate.cpp Mon Aug 3 00:12:16 2009 @@ -0,0 +1,86 @@ +//===- FileUpdate.cpp - Conditionally update a file -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// FileUpdate is a utility for conditionally updating a file from its input +// based on whether the input differs from the output. It is used to avoid +// unnecessary modifications in a build system. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/System/Signals.h" +using namespace llvm; + +static cl::opt +Quiet("quiet", cl::desc("Don't print unnecessary status information"), + cl::init(false)); + +static cl::opt +InputFilename("input-file", cl::desc("Input file (defaults to stdin)"), + cl::init("-"), cl::value_desc("filename")); + +static cl::opt +OutputFilename(cl::Positional, cl::desc(""), cl::Required); + +int main(int argc, char **argv) { + sys::PrintStackTraceOnErrorSignal(); + PrettyStackTraceProgram X(argc, argv); + cl::ParseCommandLineOptions(argc, argv); + + // Get the input data. + std::string ErrorStr; + MemoryBuffer *In = + MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), &ErrorStr); + if (In == 0) { + errs() << argv[0] << ": error: Unable to get input '" + << InputFilename << "': " << ErrorStr << '\n'; + return 1; + } + + // Get the output data. + MemoryBuffer *Out = MemoryBuffer::getFile(OutputFilename.c_str(), &ErrorStr); + + // If the output exists and the contents match, we are done. + if (Out && In->getBufferSize() == Out->getBufferSize() && + memcmp(In->getBufferStart(), Out->getBufferStart(), + Out->getBufferSize()) == 0) { + if (!Quiet) + outs() << argv[0] << ": Not updating '" << OutputFilename + << "', contents match input.\n"; + return 0; + } + + delete Out; + + // Otherwise, overwrite the output. + if (!Quiet) + outs() << argv[0] << ": Updating '" << OutputFilename + << "', contents changed.\n"; + raw_fd_ostream OutStream(OutputFilename.c_str(), /*Binary=*/true, + /*Force=*/true, ErrorStr); + if (!ErrorStr.empty()) { + errs() << argv[0] << ": Unable to write output '" + << OutputFilename << "': " << ErrorStr << '\n'; + return 1; + } + + OutStream.write(In->getBufferStart(), In->getBufferSize()); + OutStream.close(); + + if (OutStream.has_error()) { + errs() << argv[0] << ": Could not open output file '" + << OutputFilename << "': " << ErrorStr << '\n'; + return 1; + } + + return 0; +} Added: llvm/trunk/utils/FileUpdate/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileUpdate/Makefile?rev=77954&view=auto ============================================================================== --- llvm/trunk/utils/FileUpdate/Makefile (added) +++ llvm/trunk/utils/FileUpdate/Makefile Mon Aug 3 00:12:16 2009 @@ -0,0 +1,18 @@ +##===- utils/FileUpdate/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../.. +TOOLNAME = FileUpdate +USEDLIBS = LLVMSupport.a LLVMSystem.a + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(LEVEL)/Makefile.common + Modified: llvm/trunk/utils/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/Makefile?rev=77954&r1=77953&r2=77954&view=diff ============================================================================== --- llvm/trunk/utils/Makefile (original) +++ llvm/trunk/utils/Makefile Mon Aug 3 00:12:16 2009 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = .. -PARALLEL_DIRS := TableGen fpcmp PerfectShuffle FileCheck unittest +PARALLEL_DIRS := TableGen fpcmp PerfectShuffle FileCheck FileUpdate unittest EXTRA_DIST := cgiplotNLT.pl check-each-file codegen-diff countloc.sh cvsupdate \ DSAclean.py DSAextract.py emacs findsym.pl GenLibDeps.pl \ From rafael.espindola at gmail.com Mon Aug 3 00:21:05 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 03 Aug 2009 05:21:05 -0000 Subject: [llvm-commits] [llvm] r77956 - in /llvm/trunk: lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/mmx-bitcast-to-i64.ll Message-ID: <200908030521.n735L5GJ012715@zion.cs.uiuc.edu> Author: rafael Date: Mon Aug 3 00:21:05 2009 New Revision: 77956 URL: http://llvm.org/viewvc/llvm-project?rev=77956&view=rev Log: Use movd instead of movq Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=77956&r1=77955&r2=77956&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Mon Aug 3 00:21:05 2009 @@ -164,11 +164,14 @@ []>; let neverHasSideEffects = 1 in { +// These are 64 bit moves, but since the OS X assembler doesn't +// recognize a register-register movq, we write them as +// movd. def MMX_MOVD64from64rr : MMXRI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR64:$src), - "movq\t{$src, $dst|$dst, $src}", []>; + "movd\t{$src, $dst|$dst, $src}", []>; def MMX_MOVD64rrv164 : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src), - "movq\t{$src, $dst|$dst, $src}", + "movd\t{$src, $dst|$dst, $src}", [(set VR64:$dst, (v1i64 (scalar_to_vector GR64:$src)))]>; } Modified: llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll?rev=77956&r1=77955&r2=77956&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll (original) +++ llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll Mon Aug 3 00:21:05 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86-64 | grep movq | count 8 +; RUN: llvm-as < %s | llc -march=x86-64 | grep movd | count 4 define i64 @foo(<1 x i64>* %p) { %t = load <1 x i64>* %p From espindola at google.com Mon Aug 3 00:21:48 2009 From: espindola at google.com (Rafael Espindola) Date: Mon, 3 Aug 2009 01:21:48 -0400 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <38a0d8450908021953ld211ee2y426145b3b4312443@mail.gmail.com> <38a0d8450908022020y3cce3809sefbc5f7f3b3538b0@mail.gmail.com> <38a0d8450908022033w46f17d6dy2f403ad3c1624653@mail.gmail.com> Message-ID: <38a0d8450908022221g249b491fscd19d17ce463a4fa@mail.gmail.com> > I looked it up; we are trying to be compatible with OS X. ?See > http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011849.html . Thanks. I updated both the old and the new code to use movd and added a comment explaining why. > -Eli > Cheers, -- Rafael Avila de Espindola Google | Gordon House | Barrow Street | Dublin 4 | Ireland Registered in Dublin, Ireland | Registration Number: 368047 From stoklund at 2pi.dk Mon Aug 3 00:28:33 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 3 Aug 2009 07:28:33 +0200 Subject: [llvm-commits] [llvm] r77904 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp test/CodeGen/Blackfin/load-intr.ll In-Reply-To: <92746321-5A4D-4AF1-BABD-63CB31689F86@apple.com> References: <200908021828.n72ISgpe023594@zion.cs.uiuc.edu> <92746321-5A4D-4AF1-BABD-63CB31689F86@apple.com> Message-ID: <8877A6FA-F9B8-4C42-9BD2-68E1BE821CD2@2pi.dk> On 03/08/2009, at 04.03, Evan Cheng wrote: > > On Aug 2, 2009, at 11:28 AM, Jakob Stoklund Olesen wrote: > >> >> /// setUsed - Set the register and its sub-registers as being used. >> void RegScavenger::setUsed(unsigned Reg) { >> RegsAvailable.reset(Reg); >> @@ -218,7 +226,7 @@ >> const MachineOperand MO = *UseMOs[i].first; >> unsigned Reg = MO.getReg(); >> >> - assert(isUsed(Reg) && "Using an undefined register!"); >> + assert((MO.isImplicit() || isUsed(Reg)) && "Using an undefined >> register!"); > > Hi Jakob, > > I don't understand why this is necessary. It's seems like it will end > up letting a lot of real errors go through. Clearly I was too quick to commit this part. Sorry about that. I will try to make it work with the stricter rule. Then I can back out this part. >> @@ -269,7 +277,8 @@ >> >> // Implicit def is allowed to "re-define" any register. Similarly, >> // implicitly defined registers can be clobbered. >> - assert((isReserved(Reg) || isUnused(Reg) || >> + assert((MO.isImplicit() || isReserved(Reg) || isUnused(Reg) || >> + isSuperRegUsed(Reg) || >> isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && >> "Re-defining a live register!"); >> setUsed(Reg); But this part is OK, right? can redefine a live register. /jakob From clattner at apple.com Mon Aug 3 00:34:55 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 2 Aug 2009 22:34:55 -0700 Subject: [llvm-commits] [PATCH] Scavenging callee-saved registers In-Reply-To: <5757CCF4-9B9B-4786-98E8-A7486B992C09@apple.com> References: <1D2FC7E7-BD36-451A-9BA4-D65B6F907748@apple.com> <2E97116B-1A5D-456B-91AE-541376595DA1@2pi.dk> <5757CCF4-9B9B-4786-98E8-A7486B992C09@apple.com> Message-ID: On Aug 2, 2009, at 1:00 PM, Evan Cheng wrote: >> >> I noticed that ARM tries to predict this situation so an extra CSR >> can be spilled. That probably means that ARM will never meet this >> situation. Unless it guesses wrong for some reason. Blackfin is not >> so advanced yet. It cannot predict scavenger use. > > Looks good. Please commit. > > I have a plan to completely revamp the use of register scavenger. > Basically I want PEI to introduce virtual registers instead of > scavenging. At the end of PEI it will do another round register > allocation using the scavenger. ... with the constraint that the new vregs have are defined by one instruction and killed by the next, right? -Chris From evan.cheng at apple.com Mon Aug 3 00:38:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 2 Aug 2009 22:38:13 -0700 Subject: [llvm-commits] [PATCH] Scavenging callee-saved registers In-Reply-To: References: <1D2FC7E7-BD36-451A-9BA4-D65B6F907748@apple.com> <2E97116B-1A5D-456B-91AE-541376595DA1@2pi.dk> <5757CCF4-9B9B-4786-98E8-A7486B992C09@apple.com> Message-ID: <7BC48F0F-8CA1-4CED-A9F3-2C5BABDE30C7@apple.com> On Aug 2, 2009, at 10:34 PM, Chris Lattner wrote: > > On Aug 2, 2009, at 1:00 PM, Evan Cheng wrote: > >>> >>> I noticed that ARM tries to predict this situation so an extra CSR >>> can be spilled. That probably means that ARM will never meet this >>> situation. Unless it guesses wrong for some reason. Blackfin is not >>> so advanced yet. It cannot predict scavenger use. >> >> Looks good. Please commit. >> >> I have a plan to completely revamp the use of register scavenger. >> Basically I want PEI to introduce virtual registers instead of >> scavenging. At the end of PEI it will do another round register >> allocation using the scavenger. > > ... with the constraint that the new vregs have are defined by one > instruction and killed by the next, right? Yes, with the exception of use-def by a series of two-address instructions. Evan > > -Chris > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Aug 3 00:42:26 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Sun, 2 Aug 2009 22:42:26 -0700 Subject: [llvm-commits] [llvm] r77904 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp test/CodeGen/Blackfin/load-intr.ll In-Reply-To: <8877A6FA-F9B8-4C42-9BD2-68E1BE821CD2@2pi.dk> References: <200908021828.n72ISgpe023594@zion.cs.uiuc.edu> <92746321-5A4D-4AF1-BABD-63CB31689F86@apple.com> <8877A6FA-F9B8-4C42-9BD2-68E1BE821CD2@2pi.dk> Message-ID: <9E2FF46A-8D50-487E-9DBA-B2943AAE1699@apple.com> On Aug 2, 2009, at 10:28 PM, Jakob Stoklund Olesen wrote: > > On 03/08/2009, at 04.03, Evan Cheng wrote: > >> >> On Aug 2, 2009, at 11:28 AM, Jakob Stoklund Olesen wrote: >> >>> >>> /// setUsed - Set the register and its sub-registers as being used. >>> void RegScavenger::setUsed(unsigned Reg) { >>> RegsAvailable.reset(Reg); >>> @@ -218,7 +226,7 @@ >>> const MachineOperand MO = *UseMOs[i].first; >>> unsigned Reg = MO.getReg(); >>> >>> - assert(isUsed(Reg) && "Using an undefined register!"); >>> + assert((MO.isImplicit() || isUsed(Reg)) && "Using an undefined >>> register!"); >> >> Hi Jakob, >> >> I don't understand why this is necessary. It's seems like it will end >> up letting a lot of real errors go through. > > Clearly I was too quick to commit this part. Sorry about that. It's ok. It didn't break anything. I am just concerned of it not catching some potential bugs. > > I will try to make it work with the stricter rule. Then I can back out > this part. Ok. Thanks. > >>> @@ -269,7 +277,8 @@ >>> >>> // Implicit def is allowed to "re-define" any register. Similarly, >>> // implicitly defined registers can be clobbered. >>> - assert((isReserved(Reg) || isUnused(Reg) || >>> + assert((MO.isImplicit() || isReserved(Reg) || isUnused(Reg) || >>> + isSuperRegUsed(Reg) || >>> isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && >>> "Re-defining a live register!"); >>> setUsed(Reg); > > But this part is OK, right? can redefine a live register. It shouldn't. Are you talking about re-defining part of a larger register? In that case, it should first kill the larger register and then redefine it. At least that's what livevariable does. It's unclear if it's realistic to enforce this in register scavenger. This might be too difficult to maintain. I need to see an example. Evan > > /jakob > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From eocallaghan at auroraux.org Mon Aug 3 00:59:48 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Mon, 03 Aug 2009 05:59:48 -0000 Subject: [llvm-commits] [compiler-rt] r77958 - in /compiler-rt/trunk: CMakeLists.txt ConfigureChecks.cmake cmake/ cmake/Modules/ cmake/Modules/MacroEnsureOutOfSourceBuild.cmake config.h.cmake lib/CMakeLists.txt lib/divdc3.c lib/divsc3.c lib/divxc3.c lib/floatundidf.c lib/int_lib.h lib/muldc3.c lib/mulsc3.c lib/mulxc3.c Message-ID: <200908030559.n735xnn4014007@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Aug 3 00:59:48 2009 New Revision: 77958 URL: http://llvm.org/viewvc/llvm-project?rev=77958&view=rev Log: Fix newlinew warning in floatundidf.c , Bulkout CMake system more, complete port to AuroraUX and Solaris. Added: compiler-rt/trunk/ConfigureChecks.cmake compiler-rt/trunk/cmake/ compiler-rt/trunk/cmake/Modules/ compiler-rt/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake compiler-rt/trunk/config.h.cmake Modified: compiler-rt/trunk/CMakeLists.txt compiler-rt/trunk/lib/CMakeLists.txt compiler-rt/trunk/lib/divdc3.c compiler-rt/trunk/lib/divsc3.c compiler-rt/trunk/lib/divxc3.c compiler-rt/trunk/lib/floatundidf.c compiler-rt/trunk/lib/int_lib.h compiler-rt/trunk/lib/muldc3.c compiler-rt/trunk/lib/mulsc3.c compiler-rt/trunk/lib/mulxc3.c Modified: compiler-rt/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/CMakeLists.txt (original) +++ compiler-rt/trunk/CMakeLists.txt Mon Aug 3 00:59:48 2009 @@ -8,14 +8,13 @@ set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvmbugs at cs.uiuc.edu") -if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) - message(FATAL_ERROR "In-source builds are not allowed. -CMake would overwrite the makefiles distributed with Compiler-RT. -Please create a directory and run cmake from there, passing the path -to this source directory as the last argument. -This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. -Please delete them.") -endif() +SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules ) + +# Disallow in-source build +INCLUDE( MacroEnsureOutOfSourceBuild ) +MACRO_ENSURE_OUT_OF_SOURCE_BUILD( + "${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." + ) install(DIRECTORY include DESTINATION . @@ -30,3 +29,5 @@ # Tests are being ignored for until the very basics are working. # ADD_SUBDIRECTORY( test ) +INCLUDE( ConfigureChecks.cmake ) +CONFIGURE_FILE( config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) Added: compiler-rt/trunk/ConfigureChecks.cmake URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/ConfigureChecks.cmake?rev=77958&view=auto ============================================================================== --- compiler-rt/trunk/ConfigureChecks.cmake (added) +++ compiler-rt/trunk/ConfigureChecks.cmake Mon Aug 3 00:59:48 2009 @@ -0,0 +1,16 @@ +INCLUDE( CheckIncludeFile ) +INCLUDE( CheckFunctionExists ) + +SET( PACKAGE ${PACKAGE_NAME} ) +SET( VERSION ${PACKAGE_VERSION} ) + +SET( BINARYDIR ${CMAKE_BINARY_DIR} ) +SET( SOURCEDIR ${CMAKE_SOURCE_DIR} ) + +# HEADER FILES +CHECK_INCLUDE_FILE( sys/byteorder.h HAVE_SYS_BYTEORDER_H ) + +# FUNCTIONS +#CHECK_FUNCTION_EXISTS( strlcpy HAVE_STRLCPY ) + +#Example ConfigureChecks.cmake Added: compiler-rt/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake?rev=77958&view=auto ============================================================================== --- compiler-rt/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake (added) +++ compiler-rt/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake Mon Aug 3 00:59:48 2009 @@ -0,0 +1,18 @@ +# MACRO_ENSURE_OUT_OF_SOURCE_BUILD() + +macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage ) + +string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource ) +if( _insource ) + message( SEND_ERROR "${_errorMessage}" ) + message( FATAL_ERROR + "In-source builds are not allowed. + CMake would overwrite the makefiles distributed with Compiler-RT. + Please create a directory and run cmake from there, passing the path + to this source directory as the last argument. + This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. + Please delete them." + ) +endif( _insource ) + +endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD ) Added: compiler-rt/trunk/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/config.h.cmake?rev=77958&view=auto ============================================================================== --- compiler-rt/trunk/config.h.cmake (added) +++ compiler-rt/trunk/config.h.cmake Mon Aug 3 00:59:48 2009 @@ -0,0 +1,3 @@ +#cmakedefine HAVE_SYS_BYTEORDER_H ${HAVE_SYS_BYTEORDER} + +#Example config.h.cmake Modified: compiler-rt/trunk/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/CMakeLists.txt?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/CMakeLists.txt (original) +++ compiler-rt/trunk/lib/CMakeLists.txt Mon Aug 3 00:59:48 2009 @@ -1,6 +1,10 @@ # # Create a library called "CompilerRT" which includes the source files. +#INCLUDE_DIRECTORIES( +# ${CMAKE_CURRENT_BINARY_DIR} +#) + # Generic functions needed for each architecture SET( SRCS Modified: compiler-rt/trunk/lib/divdc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divdc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/divdc3.c (original) +++ compiler-rt/trunk/lib/divdc3.c Mon Aug 3 00:59:48 2009 @@ -15,6 +15,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the quotient of (a + ib) / (c + id) double _Complex Modified: compiler-rt/trunk/lib/divsc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divsc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/divsc3.c (original) +++ compiler-rt/trunk/lib/divsc3.c Mon Aug 3 00:59:48 2009 @@ -15,6 +15,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the quotient of (a + ib) / (c + id) float _Complex Modified: compiler-rt/trunk/lib/divxc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divxc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/divxc3.c (original) +++ compiler-rt/trunk/lib/divxc3.c Mon Aug 3 00:59:48 2009 @@ -17,6 +17,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the quotient of (a + ib) / (c + id) long double _Complex Modified: compiler-rt/trunk/lib/floatundidf.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/floatundidf.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/floatundidf.c (original) +++ compiler-rt/trunk/lib/floatundidf.c Mon Aug 3 00:59:48 2009 @@ -98,4 +98,4 @@ fb.u.low = (su_int)a; // mantissa-low return fb.f; } -#endif \ No newline at end of file +#endif Modified: compiler-rt/trunk/lib/int_lib.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_lib.h?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/int_lib.h (original) +++ compiler-rt/trunk/lib/int_lib.h Mon Aug 3 00:59:48 2009 @@ -20,6 +20,34 @@ #include +// TODO: Improve this to minimal pre-processor hackish'ness. +#if defined (__SVR4) && defined (__sun) +// config.h build via CMake. +//#include + +// Solaris header for endian and byte swap +//#if defined HAVE_SYS_BYTEORDER_H +#include + +// Solaris defines endian by setting _LITTLE_ENDIAN or _BIG_ENDIAN +#ifdef _BIG_ENDIAN +# define IS_BIG_ENDIAN +#endif +#ifdef _LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN +#endif + +#ifdef IS_BIG_ENDIAN +#define __BIG_ENDIAN__ 1 +#define __LITTLE_ENDIAN__ 0 +#endif +#ifdef IS_LITTLE_ENDIAN +#define __BIG_ENDIAN__ 0 +#define __LITTLE_ENDIAN__ 1 +#endif + +#endif //End of Solaris ifdef. + #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _YUGA_LITTLE_ENDIAN 1 Modified: compiler-rt/trunk/lib/muldc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/muldc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/muldc3.c (original) +++ compiler-rt/trunk/lib/muldc3.c Mon Aug 3 00:59:48 2009 @@ -15,6 +15,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the product of a + ib and c + id double _Complex Modified: compiler-rt/trunk/lib/mulsc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulsc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/mulsc3.c (original) +++ compiler-rt/trunk/lib/mulsc3.c Mon Aug 3 00:59:48 2009 @@ -15,6 +15,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the product of a + ib and c + id float _Complex Modified: compiler-rt/trunk/lib/mulxc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulxc3.c?rev=77958&r1=77957&r2=77958&view=diff ============================================================================== --- compiler-rt/trunk/lib/mulxc3.c (original) +++ compiler-rt/trunk/lib/mulxc3.c Mon Aug 3 00:59:48 2009 @@ -17,6 +17,10 @@ #include #include +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif + // Returns: the product of a + ib and c + id long double _Complex From clattner at apple.com Mon Aug 3 01:17:19 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 2 Aug 2009 23:17:19 -0700 Subject: [llvm-commits] [Backend API CHANGE] Calling-convention lowering proposal update In-Reply-To: <658EABAC-26A5-47E1-B35C-917891E1BE42@apple.com> References: <658EABAC-26A5-47E1-B35C-917891E1BE42@apple.com> Message-ID: On Aug 2, 2009, at 12:15 PM, Dan Gohman wrote: > Hello, > > Here is a new version of my major calling-convention patch, which was > first described here: > > http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-April/021908.html > > In summary, this patch simpifies the way information is passed between > target-independent code and target-dependent code. Instead of encoding > lots of information in FORMAL_ARGUMENTS, CALL, and RET nodes > which must be decoded, the information is now kept in regular data > structures, and communicated via APIs. It also reworks how tail > calls are > lowered. Looks very nice to me! -Chris From dpatel at apple.com Mon Aug 3 01:19:02 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 03 Aug 2009 06:19:02 -0000 Subject: [llvm-commits] [llvm] r77959 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp Message-ID: <200908030619.n736J2Oc014713@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 3 01:19:01 2009 New Revision: 77959 URL: http://llvm.org/viewvc/llvm-project?rev=77959&view=rev Log: Add NamedMDNode destructor. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=77959&r1=77958&r2=77959&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Mon Aug 3 01:19:01 2009 @@ -200,6 +200,15 @@ return new NamedMDNode(N, MDs, NumMDs, M); } + /// eraseFromParent - Drop all references and remove the node from parent + /// module. + void eraseFromParent(); + + /// dropAllReferences - Remove all uses and clear node vector. + void dropAllReferences(); + + ~NamedMDNode(); + typedef SmallVectorImpl::const_iterator const_elem_iterator; /// getParent - Get the module that holds this named metadata collection. Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=77959&r1=77958&r2=77959&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Mon Aug 3 01:19:01 2009 @@ -83,3 +83,20 @@ if (ParentModule) ParentModule->getNamedMDList().push_back(this); } + +/// eraseFromParent - Drop all references and remove the node from parent +/// module. +void NamedMDNode::eraseFromParent() { + dropAllReferences(); + getParent()->getNamedMDList().erase(this); +} + +/// dropAllReferences - Remove all uses and clear node vector. +void NamedMDNode::dropAllReferences() { + // FIXME: Update metadata use list. + Node.clear(); +} + +NamedMDNode::~NamedMDNode() { + dropAllReferences(); +} From stoklund at 2pi.dk Mon Aug 3 01:37:02 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 3 Aug 2009 08:37:02 +0200 Subject: [llvm-commits] [Backend API CHANGE] Calling-convention lowering proposal update In-Reply-To: <658EABAC-26A5-47E1-B35C-917891E1BE42@apple.com> References: <658EABAC-26A5-47E1-B35C-917891E1BE42@apple.com> Message-ID: <04AC113E-7DD7-4A4F-BCAC-BB8BDB13568A@2pi.dk> On 02/08/2009, at 21.15, Dan Gohman wrote: > Hello, > > Here is a new version of my major calling-convention patch, which was > first described here: > > http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-April/021908.html > > In summary, this patch simpifies the way information is passed between > target-independent code and target-dependent code. Instead of encoding > lots of information in FORMAL_ARGUMENTS, CALL, and RET nodes > which must be decoded, the information is now kept in regular data > structures, and communicated via APIs. It also reworks how tail > calls are > lowered. Very nice. While you are at it: It seems like every target defines an identical RET_FLAG node. I wonder if that could be lifted to common code as well? [...] > - Ported to trunk and updated for all targets (including Blackfin!). Impressive! [...] > Oh, and I haven't tested Blackfin yet, but I will as soon as it > settles in. But it appears to be a straight-forward target, so I'm not > worried. I quickly tested your patch, and it looks OK to me. The Blackfin call lowering code is almost entirely cargo cult programming, the XCore target was particularly nice to steal from. If something looks odd it is probably because of a mistake, not because I was being clever. I have not tried actually running the generated code yet, neither on silicon nor on a simulator, so there are probably bugs. I can just as easily fix them in your new code than in the old cargo cult code, so don't delay committing this because you haven't properly tested Blackfin yet. /jakob From clattner at apple.com Mon Aug 3 01:38:31 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 2 Aug 2009 23:38:31 -0700 Subject: [llvm-commits] [llvm] r77897 - in /llvm/trunk: include/llvm/ADT/ lib/Support/ lib/Target/Blackfin/ lib/Target/Blackfin/AsmPrinter/ lib/Target/Blackfin/TargetInfo/ test/CodeGen/Blackfin/ In-Reply-To: <200908021732.n72HWDeN021521@zion.cs.uiuc.edu> References: <200908021732.n72HWDeN021521@zion.cs.uiuc.edu> Message-ID: <9400D51E-1FC4-44DD-A33D-8B0E6701D975@apple.com> On Aug 2, 2009, at 10:32 AM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Sun Aug 2 12:32:10 2009 > New Revision: 77897 > > Analog Devices Blackfin back-end. > > Generate code for the Blackfin family of DSPs from Analog Devices: > > http://www.analog.com/en/embedded-processing-dsp/blackfin/processors/index.html Very nice! Here are my last round of nit-picky comments :) > + > + // We must load delta into ScratchReg and add that. > + loadConstant(MBB, I, DL, ScratchReg, delta); > + if (BF::PRegClass.contains(Reg)) { > + assert (BF::PRegClass.contains(ScratchReg)); Minor syntax thing: please don't use a space after assert, assert is a function-like macro, not a control flow construct. > +void BlackfinRegisterInfo:: > +eliminateCallFramePseudoInstr(MachineFunction &MF, > + MachineBasicBlock &MBB, > + MachineBasicBlock::iterator I) const { > + if (!hasReservedCallFrame(MF)) { > + int64_t Amount = I->getOperand(0).getImm(); > + if (Amount != 0) { > + assert(Amount%4 == 0); Also, it is good practice to add some sort of message to the asserts. Something like: assert(Amount%4 == 0 && "stack should be 4 byte aligned"); Would be good. > > +void BlackfinRegisterInfo::eliminateFrameIndex > (MachineBasicBlock::iterator II, > + int SPAdj, > + RegScavenger *RS) > const { > + unsigned i; Please shrink the live range of i by declaring it right before it is used. Also, it is best to only name things "i" if they are loop induction variables defined in the loop but not live out. Since this is an important value used throughout the function, it would be best to name it something more evocative. > + MachineInstr &MI = *II; > + MachineBasicBlock &MBB = *MI.getParent(); > + MachineFunction &MF = *MBB.getParent(); > + DebugLoc DL = MI.getDebugLoc(); > + > + for (i=0; !MI.getOperand(i).isFI(); i++) { Please use preincrement (++i). Even though it doesn't matter for ints, it is good for consistency. > +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.h Sun Aug 2 > 12:32:10 2009 > @@ -0,0 +1,114 @@ > + > + template > + static inline bool isImm(int x) { > + return x >= -(1<<(N-1)) && x < (1<<(N-1)); > + } > + > + template > + static inline bool isUimm(unsigned x) { > + return x < (1< + } This looks like a generally handy set of templates, can you hoist these up to llvm/Support/MathExtras.h and turn them into templates on the integer type like: template static inline bool isUimm(T x) { return x < ((T)1< +BlackfinTargetAsmInfo::BlackfinTargetAsmInfo() { > + GlobalPrefix = "_"; > + CommentString = "//"; Ah, I knew we supported multicharacter comments for a reason ;-) Thanks for building this! -Chris From clattner at apple.com Mon Aug 3 01:46:13 2009 From: clattner at apple.com (Chris Lattner) Date: Sun, 2 Aug 2009 23:46:13 -0700 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <4A7458D7.9090808@obbligato.org> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <311483A5-7349-4EDE-8179-54BB2B81BAFB@apple.com> <4A7458D7.9090808@obbligato.org> Message-ID: <679A075B-43B1-4ACD-B18C-0B8C7356BA2A@apple.com> On Aug 1, 2009, at 8:01 AM, David Greene wrote: Chris Lattner wrote: >> I'm not seeing this kick in. On X86, I'm seeing stuff like: >> >> _get_results: >> LBB2_0: ## entry >> pushl %ebx >> pushl %edi >> pushl %esi >> subl $48, %esp >> testl %edx, %edx >> movl %ecx, %esi >> je LBB2_4 ## bb >> >> >> Shouldn't the esp/edx/esi be lined up? What am I missing here? > > Two things: > > - There aren't any tabs in X86InstInfo.td (after the mnemonic, that > is) Aha, duh. Ok :). > - FirstOperandColumn = 0 and MaxOperandLength = 0 in X86TargetAsmInfo > which disables the padding. Ok, this gets back to another question I have. I don't think that these should be properties of TAI, at least not unless there are other clients of this information. The TAI::getOperandColumn() method in particular seems like an implementation detail of the asmprinter, not something that should be in TAI. However, more broadly, these are not properties that should be checked when the asmprinter is running. If these were properties of the "InstrInfo" class in the .td files, then X86 (for example), could be defined like this (X86.td): def X86InstrInfo : InstrInfo { let FirstOperandColumn = 42; // or whatever. let MaxOperandLength = 20; ... The nice thing about doing this is that if the target doesn't opt in to this, that the tblgen generated code for the asmwriter *wouldn't treat tab specially at all* and would not have to dynamically decide not to do column padding. The generated code would still have to dynamically check whether verbose-asm is enabled, but there should be no need to dynamically check to see if the asm syntax likes tabs. Making these values constants also allows them to constant fold in the generated code. >>> +/// PadToColumn - This gets called every time a tab is emitted. If >>> +/// column padding is turned on, we replace the tab with the >>> +/// appropriate amount of padding. If not, we replace the tab >>> with a >>> +/// space, except for the first operand so that initial operands >>> are >>> +/// always lined up by tabs. >>> +void AsmPrinter::PadToColumn(unsigned Operand) const { >>> + if (TAI->getOperandColumn(Operand) > 0) { >> >> Is this just a complex way to test for "FirstOperandColumn != 0" ? > > No, it's testing 0 for any operand, not just the first. Ok, maybe I'm not following it right then. When does this check fail? Can this be removed by moving the "column padding turned on" flag to the .td files? >>> @@ -852,6 +733,8 @@ >>> << " if (TAI->getOperandColumn(1) > 0) {\n" >>> << " // Don't emit trailing whitespace, let the column padding >>> do it. This\n" >>> << " // guarantees that a stray long opcode + tab won't upset >>> the alignment.\n" >>> + << " // We need to handle this special case here because >>> sometimes the initial\n" >>> + << " // mnemonic string includes a tab or space and >>> sometimes >>> it doesn't.\n" >>> << " unsigned OpLength = std::strlen(AsmStrs+(Bits & " << (1 >>> << >>> AsmStrBits)-1 << "));\n" >>> << " if (OpLength > 0 &&\n" >>> << " ((AsmStrs+(Bits & " << (1 << AsmStrBits)-1 << >>> "))[OpLength-1] == ' ' ||\n" >> >> Should this just be a considered a bug in .td files that don't do >> this >> right? What is the harm of just leaving this out? > > Because AsmStrs gets generated by TableGen. I'm not sure that .td > files actually have control over it since TableGen does the encoding > compaction itself. Look at X86GenAsdmWriter[1].inc for example. I'm not following what you mean here. Can you give me an example that shows what this does? -Chris From sabre at nondot.org Mon Aug 3 01:49:39 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 3 Aug 2009 01:49:39 -0500 Subject: [llvm-commits] CVS: llvm-www/ProjectsWithLLVM/index.html Message-ID: <200908030649.n736ndhX015797@zion.cs.uiuc.edu> Changes in directory llvm-www/ProjectsWithLLVM: index.html updated: 1.48 -> 1.49 --- Log message: add macruby --- Diffs of the changes: (+35 -0) index.html | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+) Index: llvm-www/ProjectsWithLLVM/index.html diff -u llvm-www/ProjectsWithLLVM/index.html:1.48 llvm-www/ProjectsWithLLVM/index.html:1.49 --- llvm-www/ProjectsWithLLVM/index.html:1.48 Sun Apr 26 20:27:24 2009 +++ llvm-www/ProjectsWithLLVM/index.html Mon Aug 3 01:48:42 2009 @@ -35,6 +35,7 @@ + + + + + +
+

+MacRuby is a free software project, +sponsored by Apple. +The goal of the MacRuby project is to be 100% compatible +syntactically and behaviorally with Ruby 1.9, +while providing seamless integration with Objective-C. +So, there are significant differences in the internals of the runtime. +

+ +

+For example, +MacRuby classes and objects are actually Objective-C objects, +allowing subclassing, method overloading, +and conversion-free object exchange with the Objective-C runtime. +MacRuby also uses the new Objective-C garbage collector engine, +instead of the traditional Ruby GC. +For more information, see the +Overview. +

+ +
+ + From stoklund at 2pi.dk Mon Aug 3 01:53:55 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 3 Aug 2009 08:53:55 +0200 Subject: [llvm-commits] [llvm] r77904 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp test/CodeGen/Blackfin/load-intr.ll In-Reply-To: <9E2FF46A-8D50-487E-9DBA-B2943AAE1699@apple.com> References: <200908021828.n72ISgpe023594@zion.cs.uiuc.edu> <92746321-5A4D-4AF1-BABD-63CB31689F86@apple.com> <8877A6FA-F9B8-4C42-9BD2-68E1BE821CD2@2pi.dk> <9E2FF46A-8D50-487E-9DBA-B2943AAE1699@apple.com> Message-ID: <0288F26C-52F6-40C5-A693-6A5110D12E6B@2pi.dk> On 03/08/2009, at 07.42, Evan Cheng wrote: >> >> But this part is OK, right? can redefine a live register. > > It shouldn't. Are you talking about re-defining part of a larger > register? In that case, it should first kill the larger register and > then redefine it. At least that's what livevariable does. It's unclear > if it's realistic to enforce this in register scavenger. This might be > too difficult to maintain. I need to see an example. At least that makes the rules clearer - no special treatment for implicit operands. This means that you must always know if a register is dead or alive before use use of define it in any way. It could work. I don't think the scavenger should enforce this rule through assertions. A double define does not break the scavenger in any way, it just makes it a bit less efficient - it is a missed available register, that is all. I think the machine code verifier should catch these bugs, and the scavenger should only assert when stuff would break. Use of undefined registers is another matter. It means that a register was killed too soon, and the scavenger could mistakenly overwrite it. That would be bad, and an assert is in order. I will implement the strict rules in the verifier. Then we can see how bad the status quo is and get some examples of breakage. /jakob From nicholas at mxc.ca Mon Aug 3 01:54:58 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 02 Aug 2009 23:54:58 -0700 Subject: [llvm-commits] [llvm] r77956 - in /llvm/trunk: lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: <200908030521.n735L5GJ012715@zion.cs.uiuc.edu> References: <200908030521.n735L5GJ012715@zion.cs.uiuc.edu> Message-ID: <4A7689C2.7080408@mxc.ca> Rafael, this patch is causing tablegen to emit: Warning: neverHasSideEffects set on instruction 'MMX_MOVD64rrv164' which already has a pattern You can see this on a buildbot such as: http://google1.osuosl.org:8011/builders/llvm-x86_64-linux/builds/6062/steps/compile/logs/stdio Please take a look. Nick Rafael Espindola wrote: > Author: rafael > Date: Mon Aug 3 00:21:05 2009 > New Revision: 77956 > > URL: http://llvm.org/viewvc/llvm-project?rev=77956&view=rev > Log: > Use movd instead of movq > > Modified: > llvm/trunk/lib/Target/X86/X86InstrMMX.td > llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll > > Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=77956&r1=77955&r2=77956&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Mon Aug 3 00:21:05 2009 > @@ -164,11 +164,14 @@ > []>; > > let neverHasSideEffects = 1 in { > +// These are 64 bit moves, but since the OS X assembler doesn't > +// recognize a register-register movq, we write them as > +// movd. > def MMX_MOVD64from64rr : MMXRI<0x7E, MRMDestReg, > (outs GR64:$dst), (ins VR64:$src), > - "movq\t{$src, $dst|$dst, $src}", []>; > + "movd\t{$src, $dst|$dst, $src}", []>; > def MMX_MOVD64rrv164 : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src), > - "movq\t{$src, $dst|$dst, $src}", > + "movd\t{$src, $dst|$dst, $src}", > [(set VR64:$dst, (v1i64 (scalar_to_vector GR64:$src)))]>; > } > > > Modified: llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll?rev=77956&r1=77955&r2=77956&view=diff > > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll (original) > +++ llvm/trunk/test/CodeGen/X86/mmx-bitcast-to-i64.ll Mon Aug 3 00:21:05 2009 > @@ -1,4 +1,4 @@ > -; RUN: llvm-as < %s | llc -march=x86-64 | grep movq | count 8 > +; RUN: llvm-as < %s | llc -march=x86-64 | grep movd | count 4 > > define i64 @foo(<1 x i64>* %p) { > %t = load <1 x i64>* %p > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From evan.cheng at apple.com Mon Aug 3 02:13:47 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 00:13:47 -0700 Subject: [llvm-commits] [llvm] r77904 - in /llvm/trunk: include/llvm/CodeGen/RegisterScavenging.h lib/CodeGen/RegisterScavenging.cpp test/CodeGen/Blackfin/load-intr.ll In-Reply-To: <0288F26C-52F6-40C5-A693-6A5110D12E6B@2pi.dk> References: <200908021828.n72ISgpe023594@zion.cs.uiuc.edu> <92746321-5A4D-4AF1-BABD-63CB31689F86@apple.com> <8877A6FA-F9B8-4C42-9BD2-68E1BE821CD2@2pi.dk> <9E2FF46A-8D50-487E-9DBA-B2943AAE1699@apple.com> <0288F26C-52F6-40C5-A693-6A5110D12E6B@2pi.dk> Message-ID: <3ADC65B6-778B-498C-8FCD-C9FF3FC72984@apple.com> On Aug 2, 2009, at 11:53 PM, Jakob Stoklund Olesen wrote: > > On 03/08/2009, at 07.42, Evan Cheng wrote: > >>> >>> But this part is OK, right? can redefine a live register. >> >> It shouldn't. Are you talking about re-defining part of a larger >> register? In that case, it should first kill the larger register and >> then redefine it. At least that's what livevariable does. It's >> unclear >> if it's realistic to enforce this in register scavenger. This might >> be >> too difficult to maintain. I need to see an example. > > At least that makes the rules clearer - no special treatment for > implicit operands. This means that you must always know if a register > is dead or alive before use use of define it in any way. It could > work. Right. > > I don't think the scavenger should enforce this rule through > assertions. A double define does not break the scavenger in any way, > it just makes it a bit less efficient - it is a missed available > register, that is all. I think the machine code verifier should catch > these bugs, and the scavenger should only assert when stuff would > break. You are absolutely right. But we're not yet running the machine verifier by default that means we are using the scavenger for that purpose. It caught a lot of corner cases like these. On more than one occasion I'd thought about just removing the assertions. :-) Note the assertions are turned off in release mode so these bugs are being left through. > > Use of undefined registers is another matter. It means that a register > was killed too soon, and the scavenger could mistakenly overwrite it. > That would be bad, and an assert is in order. Right. We ought to use the newly introduced error reporting mechanism instead. Assertions are not strong enough here. The only concern I have is the compile time cost. Some of the assertions checks are implemented less than optimally. > > I will implement the strict rules in the verifier. Then we can see how > bad the status quo is and get some examples of breakage. Ok thanks. This is really really hard to get right. I really appreciate that someone else is hacking on it. :-) Please see my replies to [PATCH] Fix Bug 4657: register scavenger asserts with subreg lowering and [PATCH] Accidental on two-address operand for more discussion on these issues. Evan > > /jakob > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090803/cb9fd9ae/attachment.html From nicholas at mxc.ca Mon Aug 3 02:16:43 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Aug 2009 07:16:43 -0000 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp Message-ID: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> Author: nicholas Date: Mon Aug 3 02:16:42 2009 New Revision: 77960 URL: http://llvm.org/viewvc/llvm-project?rev=77960&view=rev Log: Remove the GCC path from libLTO. This has been superceded by setAssemblerPath. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOCodeGenerator.h llvm/trunk/tools/lto/lto.cpp Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=77960&r1=77959&r2=77960&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Aug 3 02:16:42 2009 @@ -76,7 +76,7 @@ _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL), _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false), _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), - _nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL) + _nativeObjectFile(NULL), _assemblerPath(NULL) { InitializeAllTargets(); InitializeAllAsmPrinters(); @@ -126,13 +126,6 @@ return true; } -void LTOCodeGenerator::setGccPath(const char* path) -{ - if ( _gccPath ) - delete _gccPath; - _gccPath = new sys::Path(path); -} - void LTOCodeGenerator::setAssemblerPath(const char* path) { if ( _assemblerPath ) @@ -240,9 +233,6 @@ if ( _assemblerPath ) { tool = *_assemblerPath; needsCompilerOptions = false; - } - else if ( _gccPath ) { - tool = *_gccPath; } else { // find compiler driver tool = sys::Program::FindProgramByName("gcc"); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=77960&r1=77959&r2=77960&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Mon Aug 3 02:16:42 2009 @@ -37,7 +37,6 @@ bool addModule(class LTOModule*, std::string& errMsg); bool setDebugInfo(lto_debug_model, std::string& errMsg); bool setCodePICModel(lto_codegen_model, std::string& errMsg); - void setGccPath(const char* path); void setAssemblerPath(const char* path); void addMustPreserveSymbol(const char* sym); bool writeMergedModules(const char* path, @@ -63,7 +62,6 @@ StringSet _mustPreserveSymbols; llvm::MemoryBuffer* _nativeObjectFile; std::vector _codegenOptions; - llvm::sys::Path* _gccPath; llvm::sys::Path* _assemblerPath; }; Modified: llvm/trunk/tools/lto/lto.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=77960&r1=77959&r2=77960&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.cpp (original) +++ llvm/trunk/tools/lto/lto.cpp Mon Aug 3 02:16:42 2009 @@ -203,14 +203,6 @@ } // -// sets the path to gcc -// -void lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path) -{ - cg->setGccPath(path); -} - -// // sets the path to the assembler tool // void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path) From eli.friedman at gmail.com Mon Aug 3 03:07:15 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 3 Aug 2009 01:07:15 -0700 Subject: [llvm-commits] [llvm] r77927 - in /llvm/trunk: include/llvm/Target/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CBackend/ lib/Target/CellSPU/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Target/MSP430/ lib/Target/Mips/ lib/Ta Message-ID: On Sun, Aug 2, 2009 at 4:37 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Sun Aug ?2 18:37:13 2009 > New Revision: 77927 > > URL: http://llvm.org/viewvc/llvm-project?rev=77927&view=rev > Log: > Move most targets TargetMachine constructor to only taking a target triple. > ?- The C, C++, MSIL, and Mips backends still need the module. I took care of the Mips backend earlier. It looks like the C, C++ and MSIL backends need the DataLayout member of the Module; perhaps the standard signature for initializing a target should include that as a separate argument? -Eli From asl at math.spbu.ru Mon Aug 3 03:12:59 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:12:59 -0000 Subject: [llvm-commits] [llvm] r77962 - in /llvm/trunk: lib/Target/X86/X86CallingConv.td lib/Target/X86/X86CompilationCallback_Win64.asm lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86TargetMachine.cpp test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll Message-ID: <200908030813.n738D4Qg030803@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:12:53 2009 New Revision: 77962 URL: http://llvm.org/viewvc/llvm-project?rev=77962&view=rev Log: Unbreak Win64 CC. Step one: honour register save area, fix some alignment and provide a different set of call-clobberred registers. Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll llvm/trunk/test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Mon Aug 3 03:12:53 2009 @@ -201,8 +201,8 @@ [XMM0, XMM1, XMM2, XMM3]>>, // Integer/FP values get stored in stack slots that are 8 bytes in size and - // 16-byte aligned if there are no more registers to hold them. - CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 16>>, + // 8-byte aligned if there are no more registers to hold them. + CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>, // Long doubles get stack slots whose size and alignment depends on the // subtarget. @@ -211,8 +211,8 @@ // Vectors get 16-byte stack slots that are 16-byte aligned. CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>, - // __m64 vectors get 8-byte stack slots that are 16-byte aligned. - CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 16>> + // __m64 vectors get 8-byte stack slots that are 8-byte aligned. + CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 8>> ]>; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm (original) +++ llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm Mon Aug 3 03:12:53 2009 @@ -15,52 +15,52 @@ .code X86CompilationCallback proc + ; Save all int arg registers into register spill area. + mov [rsp+ 8], rcx + mov [rsp+16], rdx + mov [rsp+24], r8 + mov [rsp+32], r9 + push rbp - ; Save RSP + ; Save RSP. mov rbp, rsp - ; Save all int arg registers - push rcx - push rdx - push r8 - push r9 - ; Align stack on 16-byte boundary. and rsp, -16 - ; Save all XMM arg registers - sub rsp, 64 - movaps [rsp], xmm0 - movaps [rsp+16], xmm1 - movaps [rsp+32], xmm2 - movaps [rsp+48], xmm3 + ; Save all XMM arg registers. Also allocate reg spill area. + sub rsp, 96 + movaps [rsp +32], xmm0 + movaps [rsp+16+32], xmm1 + movaps [rsp+32+32], xmm2 + movaps [rsp+48+32], xmm3 ; JIT callee - ; Pass prev frame and return address + ; Pass prev frame and return address. mov rcx, rbp mov rdx, qword ptr [rbp+8] call X86CompilationCallback2 - ; Restore all XMM arg registers - movaps xmm3, [rsp+48] - movaps xmm2, [rsp+32] - movaps xmm1, [rsp+16] - movaps xmm0, [rsp] + ; Restore all XMM arg registers. + movaps xmm3, [rsp+48+32] + movaps xmm2, [rsp+32+32] + movaps xmm1, [rsp+16+32] + movaps xmm0, [rsp +32] - ; Restore RSP + ; Restore RSP. mov rsp, rbp - ; Restore all int arg registers - sub rsp, 32 - pop r9 - pop r8 - pop rdx - pop rcx - - ; Restore RBP + ; Restore RBP. pop rbp + + ; Restore all int arg registers. + mov r9, [rsp+32] + mov r8, [rsp+24] + mov rdx, [rsp+16] + mov rcx, [rsp+ 8] + ret X86CompilationCallback endp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Aug 3 03:12:53 2009 @@ -1228,7 +1228,7 @@ MVT::v2i64, InFlag).getValue(1); Val = Chain.getValue(0); Val = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i64, - Val, DAG.getConstant(0, MVT::i64)); + Val, DAG.getConstant(0, MVT::i64)); } else { Chain = DAG.getCopyFromReg(Chain, dl, VA.getLocReg(), MVT::i64, InFlag).getValue(1); @@ -1628,8 +1628,9 @@ const CCValAssign &VA, SDValue Chain, SDValue Arg, ISD::ArgFlagsTy Flags) { + const unsigned FirstStackArgOffset = (Subtarget->isTargetWin64() ? 32 : 0); DebugLoc dl = TheCall->getDebugLoc(); - unsigned LocMemOffset = VA.getLocMemOffset(); + unsigned LocMemOffset = FirstStackArgOffset + VA.getLocMemOffset(); SDValue PtrOff = DAG.getIntPtrConstant(LocMemOffset); PtrOff = DAG.getNode(ISD::ADD, dl, getPointerTy(), StackPtr, PtrOff); if (Flags.isByVal()) { Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Aug 3 03:12:53 2009 @@ -128,13 +128,37 @@ def CALL64pcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i64i32imm_pcrel:$dst, variable_ops), "call\t$dst", []>, - Requires<[In64BitMode]>; + Requires<[In64BitMode, NotWin64]>; def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), - "call\t{*}$dst", [(X86call GR64:$dst)]>; + "call\t{*}$dst", [(X86call GR64:$dst)]>, + Requires<[NotWin64]>; def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), - "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>; + "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>, + Requires<[NotWin64]>; } + // FIXME: We need to teach codegen about single list of call-clobbered registers. +let isCall = 1 in + // All calls clobber the non-callee saved registers. RSP is marked as + // a use to prevent stack-pointer assignments that appear immediately + // before calls from potentially appearing dead. Uses for argument + // registers are added manually. + let Defs = [RAX, RCX, RDX, R8, R9, R10, R11, + FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, + MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, + XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, EFLAGS], + Uses = [RSP] in { + def WINCALL64pcrel32 : I<0xE8, RawFrm, + (outs), (ins i64i32imm:$dst, variable_ops), + "call\t${dst:call}", [(X86call imm:$dst)]>, + Requires<[IsWin64]>; + def WINCALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), + "call\t{*}$dst", + [(X86call GR64:$dst)]>, Requires<[IsWin64]>; + def WINCALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), + "call\t{*}$dst", + [(X86call (loadi64 addr:$dst))]>, Requires<[IsWin64]>; + } let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in @@ -1495,9 +1519,14 @@ // Direct PC relative function call for small code model. 32-bit displacement // sign extended to 64-bit. def : Pat<(X86call (i64 tglobaladdr:$dst)), - (CALL64pcrel32 tglobaladdr:$dst)>; + (CALL64pcrel32 tglobaladdr:$dst)>, Requires<[NotWin64]>; def : Pat<(X86call (i64 texternalsym:$dst)), - (CALL64pcrel32 texternalsym:$dst)>; + (CALL64pcrel32 texternalsym:$dst)>, Requires<[NotWin64]>; + +def : Pat<(X86call (i64 tglobaladdr:$dst)), + (WINCALL64pcrel32 tglobaladdr:$dst)>, Requires<[IsWin64]>; +def : Pat<(X86call (i64 texternalsym:$dst)), + (WINCALL64pcrel32 texternalsym:$dst)>, Requires<[IsWin64]>; def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), (CALL64pcrel32 tglobaladdr:$dst)>; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Aug 3 03:12:53 2009 @@ -254,6 +254,8 @@ def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">; def In32BitMode : Predicate<"!Subtarget->is64Bit()">; def In64BitMode : Predicate<"Subtarget->is64Bit()">; +def IsWin64 : Predicate<"Subtarget->isTargetWin64()">; +def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">; def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">; def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">; def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">; Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Aug 3 03:12:53 2009 @@ -484,15 +484,18 @@ int X86RegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const { - int Offset = MF.getFrameInfo()->getObjectOffset(FI) + SlotSize; - uint64_t StackSize = MF.getFrameInfo()->getStackSize(); + const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo(); + MachineFrameInfo *MFI = MF.getFrameInfo(); + + int Offset = MFI->getObjectOffset(FI) - TFI.getOffsetOfLocalArea(); + uint64_t StackSize = MFI->getStackSize(); if (needsStackRealignment(MF)) { if (FI < 0) // Skip the saved EBP Offset += SlotSize; else { - unsigned Align = MF.getFrameInfo()->getObjectAlignment(FI); + unsigned Align = MFI->getObjectAlignment(FI); assert( (-(Offset + StackSize)) % Align == 0); Align = 0; return Offset + StackSize; @@ -622,14 +625,14 @@ void X86RegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS) const { - MachineFrameInfo *FFI = MF.getFrameInfo(); + MachineFrameInfo *MFI = MF.getFrameInfo(); // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). - unsigned MaxAlign = std::max(FFI->getMaxAlignment(), - calculateMaxStackAlignment(FFI)); + unsigned MaxAlign = std::max(MFI->getMaxAlignment(), + calculateMaxStackAlignment(MFI)); - FFI->setMaxAlignment(MaxAlign); + MFI->setMaxAlignment(MaxAlign); X86MachineFunctionInfo *X86FI = MF.getInfo(); int32_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta(); @@ -643,18 +646,18 @@ // ... // } // [EBP] - MF.getFrameInfo()-> - CreateFixedObject(-TailCallReturnAddrDelta, - (-1*SlotSize)+TailCallReturnAddrDelta); + MFI->CreateFixedObject(-TailCallReturnAddrDelta, + (-1*SlotSize)+TailCallReturnAddrDelta); } + if (hasFP(MF)) { assert((TailCallReturnAddrDelta <= 0) && "The Delta should always be zero or negative"); // Create a frame entry for the EBP register that must be saved. - int FrameIdx = MF.getFrameInfo()->CreateFixedObject(SlotSize, - (int)SlotSize * -2+ - TailCallReturnAddrDelta); - assert(FrameIdx == MF.getFrameInfo()->getObjectIndexBegin() && + int FrameIdx = MFI->CreateFixedObject(SlotSize, + (int)SlotSize * -2+ + TailCallReturnAddrDelta); + assert(FrameIdx == MFI->getObjectIndexBegin() && "Slot for EBP register must be last in order to be found!"); FrameIdx = 0; } @@ -887,6 +890,11 @@ StackSize = std::max(MinSize, StackSize > 128 ? StackSize - 128 : 0); MFI->setStackSize(StackSize); + } else if (Subtarget->isTargetWin64()) { + // We need to always allocate 32 bytes as register spill area. + // FIXME: we might reuse these 32 bytes for leaf functions. + StackSize += 32; + MFI->setStackSize(StackSize); } // Insert stack pointer adjustment for later moving of return addr. Only Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Aug 3 03:12:53 2009 @@ -64,7 +64,9 @@ Subtarget(TT, FS, is64Bit), DataLayout(Subtarget.getDataLayout()), FrameInfo(TargetFrameInfo::StackGrowsDown, - Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4), + Subtarget.getStackAlignment(), + (Subtarget.isTargetWin64() ? -40 : + (Subtarget.is64Bit() ? -8 : -4))), InstrInfo(*this), JITInfo(*this), TLInfo(*this), ELFWriterInfo(*this) { DefRelocModel = getRelocationModel(); Modified: llvm/trunk/test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll Mon Aug 3 03:12:53 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc | grep "subq.*\\\$8, \\\%rsp" +; RUN: llvm-as < %s | llc | grep "subq.*\\\$40, \\\%rsp" target triple = "x86_64-mingw64" define x86_fp80 @a(i64 %x) nounwind readnone { Modified: llvm/trunk/test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll?rev=77962&r1=77961&r2=77962&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll Mon Aug 3 03:12:53 2009 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -o %t1 -f -; RUN: grep "subq.*\\\$40, \\\%rsp" %t1 -; RUN: grep "movaps \\\%xmm8, \\\(\\\%rsp\\\)" %t1 -; RUN: grep "movaps \\\%xmm7, 16\\\(\\\%rsp\\\)" %t1 +; RUN: grep "subq.*\\\$72, \\\%rsp" %t1 +; RUN: grep "movaps \\\%xmm8, 32\\\(\\\%rsp\\\)" %t1 +; RUN: grep "movaps \\\%xmm7, 48\\\(\\\%rsp\\\)" %t1 target triple = "x86_64-mingw64" define i32 @a() nounwind { From asl at math.spbu.ru Mon Aug 3 03:13:25 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:13:25 -0000 Subject: [llvm-commits] [llvm] r77963 - in /llvm/trunk/lib/Target/X86: X86CallingConv.td X86ISelLowering.cpp Message-ID: <200908030813.n738DQmv030831@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:13:24 2009 New Revision: 77963 URL: http://llvm.org/viewvc/llvm-project?rev=77963&view=rev Log: Cleanup Darwin MMX calling conv stuff - make the stuff more generic. This also fixes a subtle bug, when 6th v1i64 argument passed wrongly. Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=77963&r1=77962&r2=77963&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Mon Aug 3 03:13:24 2009 @@ -137,26 +137,26 @@ // The 'nest' parameter, if any, is passed in R10. CCIfNest>, + // The first 6 v1i64 vector arguments are passed in GPRs on Darwin. + CCIfType<[v1i64], + CCIfSubtarget<"isTargetDarwin()", + CCBitConvertToType>>, + // The first 6 integer arguments are passed in integer registers. CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D, R9D]>>, CCIfType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8 , R9 ]>>, - - // The first 8 FP/Vector arguments are passed in XMM registers. - CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], - CCIfSubtarget<"hasSSE1()", - CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>, // The first 8 MMX (except for v1i64) vector arguments are passed in XMM // registers on Darwin. CCIfType<[v8i8, v4i16, v2i32, v2f32], CCIfSubtarget<"isTargetDarwin()", CCIfSubtarget<"hasSSE2()", - CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>>, + CCPromoteToType>>>, - // The first 8 v1i64 vector arguments are passed in GPRs on Darwin. - CCIfType<[v1i64], - CCIfSubtarget<"isTargetDarwin()", - CCAssignToReg<[RDI, RSI, RDX, RCX, R8]>>>, + // The first 8 FP/Vector arguments are passed in XMM registers. + CCIfType<[f32, f64, v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], + CCIfSubtarget<"hasSSE1()", + CCAssignToReg<[XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]>>>, // Integer/FP values get stored in stack slots that are 8 bytes in size and // 8-byte aligned if there are no more registers to hold them. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77963&r1=77962&r2=77963&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Aug 3 03:13:24 2009 @@ -1429,24 +1429,10 @@ RC = X86::FR64RegisterClass; else if (RegVT.isVector() && RegVT.getSizeInBits() == 128) RC = X86::VR128RegisterClass; - else if (RegVT.isVector()) { - assert(RegVT.getSizeInBits() == 64); - if (!Is64Bit) - RC = X86::VR64RegisterClass; // MMX values are passed in MMXs. - else { - // Darwin calling convention passes MMX values in either GPRs or - // XMMs in x86-64. Other targets pass them in memory. - if (RegVT != MVT::v1i64 && Subtarget->hasSSE2()) { - RC = X86::VR128RegisterClass; // MMX values are passed in XMMs. - RegVT = MVT::v2i64; - } else { - RC = X86::GR64RegisterClass; // v1i64 values are passed in GPRs. - RegVT = MVT::i64; - } - } - } else { + else if (RegVT.isVector() && RegVT.getSizeInBits() == 64) + RC = X86::VR64RegisterClass; + else llvm_unreachable("Unknown argument type!"); - } unsigned Reg = MF.addLiveIn(VA.getLocReg(), RC); SDValue ArgValue = DAG.getCopyFromReg(Root, dl, Reg, RegVT); @@ -1460,19 +1446,19 @@ else if (VA.getLocInfo() == CCValAssign::ZExt) ArgValue = DAG.getNode(ISD::AssertZext, dl, RegVT, ArgValue, DAG.getValueType(VA.getValVT())); + else if (VA.getLocInfo() == CCValAssign::BCvt) + ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, RegVT, ArgValue, + DAG.getValueType(VA.getValVT())); - if (VA.getLocInfo() != CCValAssign::Full) - ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue); - - // Handle MMX values passed in GPRs. - if (Is64Bit && RegVT != VA.getLocVT()) { - if (RegVT.getSizeInBits() == 64 && RC == X86::GR64RegisterClass) - ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, VA.getLocVT(), ArgValue); - else if (RC == X86::VR128RegisterClass) { + if (VA.getLocInfo() != CCValAssign::Full && + VA.getLocInfo() != CCValAssign::BCvt) { + // Handle MMX values passed in XMM regs. + if (RegVT.isVector()) { ArgValue = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i64, ArgValue, DAG.getConstant(0, MVT::i64)); - ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, VA.getLocVT(), ArgValue); - } + ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, VA.getValVT(), ArgValue); + } else + ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue); } ArgValues.push_back(ArgValue); @@ -1734,6 +1720,7 @@ // of tail call optimization arguments are handle later. for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; + MVT RegVT = VA.getLocVT(); SDValue Arg = TheCall->getArg(i); ISD::ArgFlagsTy Flags = TheCall->getArgFlags(i); bool isByVal = Flags.isByVal(); @@ -1743,39 +1730,26 @@ default: llvm_unreachable("Unknown loc info!"); case CCValAssign::Full: break; case CCValAssign::SExt: - Arg = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), Arg); + Arg = DAG.getNode(ISD::SIGN_EXTEND, dl, RegVT, Arg); break; case CCValAssign::ZExt: - Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, VA.getLocVT(), Arg); + Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, RegVT, Arg); break; case CCValAssign::AExt: - Arg = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), Arg); + if (RegVT.isVector() && RegVT.getSizeInBits() == 128) { + // Special case: passing MMX values in XMM registers. + Arg = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::i64, Arg); + Arg = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v2i64, Arg); + Arg = getMOVL(DAG, dl, MVT::v2i64, DAG.getUNDEF(MVT::v2i64), Arg); + } else + Arg = DAG.getNode(ISD::ANY_EXTEND, dl, RegVT, Arg); + break; + case CCValAssign::BCvt: + Arg = DAG.getNode(ISD::BIT_CONVERT, dl, RegVT, Arg); break; } if (VA.isRegLoc()) { - if (Is64Bit) { - MVT RegVT = VA.getLocVT(); - if (RegVT.isVector() && RegVT.getSizeInBits() == 64) - switch (VA.getLocReg()) { - default: - break; - case X86::RDI: case X86::RSI: case X86::RDX: case X86::RCX: - case X86::R8: { - // Special case: passing MMX values in GPR registers. - Arg = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::i64, Arg); - break; - } - case X86::XMM0: case X86::XMM1: case X86::XMM2: case X86::XMM3: - case X86::XMM4: case X86::XMM5: case X86::XMM6: case X86::XMM7: { - // Special case: passing MMX values in XMM registers. - Arg = DAG.getNode(ISD::BIT_CONVERT, dl, MVT::i64, Arg); - Arg = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, MVT::v2i64, Arg); - Arg = getMOVL(DAG, dl, MVT::v2i64, DAG.getUNDEF(MVT::v2i64), Arg); - break; - } - } - } RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg)); } else { if (!IsTailCall || (IsTailCall && isByVal)) { From asl at math.spbu.ru Mon Aug 3 03:13:57 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:13:57 -0000 Subject: [llvm-commits] [llvm] r77964 - in /llvm/trunk: include/llvm/CodeGen/CallingConvLower.h include/llvm/Target/TargetCallingConv.td lib/Target/X86/X86CallingConv.td lib/Target/X86/X86ISelLowering.cpp utils/TableGen/CallingConvEmitter.cpp Message-ID: <200908030813.n738Dw0G030864@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:13:56 2009 New Revision: 77964 URL: http://llvm.org/viewvc/llvm-project?rev=77964&view=rev Log: Add 'Indirect' LocInfo class and use to pass __m128 on win64. Also minore fixes here and there (mostly __m64). Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h llvm/trunk/include/llvm/Target/TargetCallingConv.td llvm/trunk/lib/Target/X86/X86CallingConv.td llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CallingConvLower.h?rev=77964&r1=77963&r2=77964&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CallingConvLower.h (original) +++ llvm/trunk/include/llvm/CodeGen/CallingConvLower.h Mon Aug 3 03:13:56 2009 @@ -33,32 +33,33 @@ SExt, // The value is sign extended in the location. ZExt, // The value is zero extended in the location. AExt, // The value is extended with undefined upper bits. - BCvt // The value is bit-converted in the location. + BCvt, // The value is bit-converted in the location. + Indirect // The location contains pointer to the value. // TODO: a subset of the value is in the location. }; private: /// ValNo - This is the value number begin assigned (e.g. an argument number). unsigned ValNo; - + /// Loc is either a stack offset or a register number. unsigned Loc; - + /// isMem - True if this is a memory loc, false if it is a register loc. bool isMem : 1; - + /// isCustom - True if this arg/retval requires special handling. bool isCustom : 1; /// Information about how the value is assigned. LocInfo HTP : 6; - + /// ValVT - The type of the value being assigned. MVT ValVT; /// LocVT - The type of the location being assigned to. MVT LocVT; public: - + static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP) { @@ -95,7 +96,7 @@ Ret.LocVT = LocVT; return Ret; } - + static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP) { @@ -110,14 +111,18 @@ bool isRegLoc() const { return !isMem; } bool isMemLoc() const { return isMem; } - + bool needsCustom() const { return isCustom; } unsigned getLocReg() const { assert(isRegLoc()); return Loc; } unsigned getLocMemOffset() const { assert(isMemLoc()); return Loc; } MVT getLocVT() const { return LocVT; } - + LocInfo getLocInfo() const { return HTP; } + bool isExtInLoc() const { + return (HTP == AExt || HTP == SExt || HTP == ZExt); + } + }; /// CCAssignFn - This function assigns a location for Val, updating State to @@ -143,22 +148,22 @@ const TargetRegisterInfo &TRI; SmallVector &Locs; LLVMContext &Context; - + unsigned StackOffset; SmallVector UsedRegs; public: CCState(unsigned CC, bool isVarArg, const TargetMachine &TM, SmallVector &locs, LLVMContext &C); - + void addLoc(const CCValAssign &V) { Locs.push_back(V); } - + LLVMContext &getContext() const { return Context; } const TargetMachine &getTarget() const { return TM; } unsigned getCallingConv() const { return CallingConv; } bool isVarArg() const { return IsVarArg; } - + unsigned getNextStackOffset() const { return StackOffset; } /// isAllocated - Return true if the specified register (or an alias) is @@ -166,15 +171,15 @@ bool isAllocated(unsigned Reg) const { return UsedRegs[Reg/32] & (1 << (Reg&31)); } - + /// AnalyzeFormalArguments - Analyze an ISD::FORMAL_ARGUMENTS node, /// incorporating info about the formals into this state. void AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn); - + /// AnalyzeReturn - Analyze the returned values of an ISD::RET node, /// incorporating info about the result values into this state. void AnalyzeReturn(SDNode *TheRet, CCAssignFn Fn); - + /// AnalyzeCallOperands - Analyze an ISD::CALL node, incorporating info /// about the passed values into this state. void AnalyzeCallOperands(CallSDNode *TheCall, CCAssignFn Fn); @@ -188,7 +193,7 @@ /// AnalyzeCallResult - Analyze the return values of an ISD::CALL node, /// incorporating info about the passed values into this state. void AnalyzeCallResult(CallSDNode *TheCall, CCAssignFn Fn); - + /// AnalyzeCallResult - Same as above except it's specialized for calls which /// produce a single value. void AnalyzeCallResult(MVT VT, CCAssignFn Fn); @@ -201,7 +206,7 @@ return i; return NumRegs; } - + /// AllocateReg - Attempt to allocate one register. If it is not available, /// return zero. Otherwise, return the register, marking it and any aliases /// as allocated. Modified: llvm/trunk/include/llvm/Target/TargetCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetCallingConv.td?rev=77964&r1=77963&r2=77964&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetCallingConv.td (original) +++ llvm/trunk/include/llvm/Target/TargetCallingConv.td Mon Aug 3 03:13:56 2009 @@ -109,6 +109,12 @@ ValueType DestTy = destTy; } +/// CCPassIndirect - If applied, this stores the value to stack and passes the pointer +/// as normal argument. +class CCPassIndirect : CCAction { + ValueType DestTy = destTy; +} + /// CCDelegateTo - This action invokes the specified sub-calling-convention. It /// is successful if the specified CC matches. class CCDelegateTo : CCAction { Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=77964&r1=77963&r2=77964&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CallingConv.td (original) +++ llvm/trunk/lib/Target/X86/X86CallingConv.td Mon Aug 3 03:13:56 2009 @@ -89,7 +89,7 @@ // X86-Win64 C return-value convention. def RetCC_X86_Win64_C : CallingConv<[ // The X86-Win64 calling convention always returns __m64 values in RAX. - CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToReg<[RAX]>>, + CCIfType<[v8i8, v4i16, v2i32, v1i64], CCBitConvertToType>, // And FP in XMM0 only. CCIfType<[f32], CCAssignToReg<[XMM0]>>, @@ -184,6 +184,13 @@ // The 'nest' parameter, if any, is passed in R10. CCIfNest>, + // 128 bit vectors are passed by pointer + CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCPassIndirect>, + + // The first 4 MMX vector arguments are passed in GPRs. + CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32], + CCBitConvertToType>, + // The first 4 integer arguments are passed in integer registers. CCIfType<[i32], CCAssignToRegWithShadow<[ECX , EDX , R8D , R9D ], [XMM0, XMM1, XMM2, XMM3]>>, @@ -195,11 +202,6 @@ CCAssignToRegWithShadow<[XMM0, XMM1, XMM2, XMM3], [RCX , RDX , R8 , R9 ]>>, - // The first 4 MMX vector arguments are passed in GPRs. - CCIfType<[v8i8, v4i16, v2i32, v1i64, v2f32], - CCAssignToRegWithShadow<[RCX , RDX , R8 , R9 ], - [XMM0, XMM1, XMM2, XMM3]>>, - // Integer/FP values get stored in stack slots that are 8 bytes in size and // 8-byte aligned if there are no more registers to hold them. CCIfType<[i32, i64, f32, f64], CCAssignToStack<8, 8>>, @@ -208,9 +210,6 @@ // subtarget. CCIfType<[f80], CCAssignToStack<0, 0>>, - // Vectors get 16-byte stack slots that are 16-byte aligned. - CCIfType<[v16i8, v8i16, v4i32, v2i64, v4f32, v2f64], CCAssignToStack<16, 16>>, - // __m64 vectors get 8-byte stack slots that are 8-byte aligned. CCIfType<[v8i8, v4i16, v2i32, v1i64], CCAssignToStack<8, 8>> ]>; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77964&r1=77963&r2=77964&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Aug 3 03:13:56 2009 @@ -1408,6 +1408,7 @@ SmallVector ArgValues; unsigned LastVal = ~0U; + SDValue ArgValue; for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { CCValAssign &VA = ArgLocs[i]; // TODO: If an arg is passed in two places (e.g. reg and stack), skip later @@ -1435,7 +1436,7 @@ llvm_unreachable("Unknown argument type!"); unsigned Reg = MF.addLiveIn(VA.getLocReg(), RC); - SDValue ArgValue = DAG.getCopyFromReg(Root, dl, Reg, RegVT); + ArgValue = DAG.getCopyFromReg(Root, dl, Reg, RegVT); // If this is an 8 or 16-bit value, it is really passed promoted to 32 // bits. Insert an assert[sz]ext to capture this, then truncate to the @@ -1450,8 +1451,7 @@ ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, RegVT, ArgValue, DAG.getValueType(VA.getValVT())); - if (VA.getLocInfo() != CCValAssign::Full && - VA.getLocInfo() != CCValAssign::BCvt) { + if (VA.isExtInLoc()) { // Handle MMX values passed in XMM regs. if (RegVT.isVector()) { ArgValue = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, MVT::i64, @@ -1460,12 +1460,16 @@ } else ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue); } - - ArgValues.push_back(ArgValue); } else { assert(VA.isMemLoc()); - ArgValues.push_back(LowerMemArgument(Op, DAG, VA, MFI, CC, Root, i)); + ArgValue = LowerMemArgument(Op, DAG, VA, MFI, CC, Root, i); } + + // If value is passed via pointer - do a load. + if (VA.getLocInfo() == CCValAssign::Indirect) + ArgValue = DAG.getLoad(VA.getValVT(), dl, Root, ArgValue, NULL, 0); + + ArgValues.push_back(ArgValue); } // The x86-64 ABI for returning structs by value requires that we copy @@ -1747,6 +1751,15 @@ case CCValAssign::BCvt: Arg = DAG.getNode(ISD::BIT_CONVERT, dl, RegVT, Arg); break; + case CCValAssign::Indirect: { + // Store the argument. + SDValue SpillSlot = DAG.CreateStackTemporary(VA.getValVT()); + int FI = cast(SpillSlot)->getIndex(); + Chain = DAG.getStore(Chain, dl, Arg, SpillSlot, + PseudoSourceValue::getFixedStack(FI), 0); + Arg = SpillSlot; + break; + } } if (VA.isRegLoc()) { Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=77964&r1=77963&r2=77964&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Mon Aug 3 03:13:56 2009 @@ -186,6 +186,10 @@ Record *DestTy = Action->getValueAsDef("DestTy"); O << IndentStr << "LocVT = " << getEnumName(getValueType(DestTy)) <<";\n"; O << IndentStr << "LocInfo = CCValAssign::BCvt;\n"; + } else if (Action->isSubClassOf("CCPassIndirect")) { + Record *DestTy = Action->getValueAsDef("DestTy"); + O << IndentStr << "LocVT = " << getEnumName(getValueType(DestTy)) <<";\n"; + O << IndentStr << "LocInfo = CCValAssign::Indirect;\n"; } else if (Action->isSubClassOf("CCPassByVal")) { int Size = Action->getValueAsInt("Size"); int Align = Action->getValueAsInt("Align"); From asl at math.spbu.ru Mon Aug 3 03:14:15 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:14:15 -0000 Subject: [llvm-commits] [llvm] r77965 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <200908030814.n738EG93030882@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:14:14 2009 New Revision: 77965 URL: http://llvm.org/viewvc/llvm-project?rev=77965&view=rev Log: Perform bitconvert to proper type Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=77965&r1=77964&r2=77965&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Aug 3 03:14:14 2009 @@ -1448,8 +1448,7 @@ ArgValue = DAG.getNode(ISD::AssertZext, dl, RegVT, ArgValue, DAG.getValueType(VA.getValVT())); else if (VA.getLocInfo() == CCValAssign::BCvt) - ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, RegVT, ArgValue, - DAG.getValueType(VA.getValVT())); + ArgValue = DAG.getNode(ISD::BIT_CONVERT, dl, VA.getValVT(), ArgValue); if (VA.isExtInLoc()) { // Handle MMX values passed in XMM regs. From asl at math.spbu.ru Mon Aug 3 03:14:30 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:14:30 -0000 Subject: [llvm-commits] [llvm] r77966 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200908030814.n738EVva030905@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:14:30 2009 New Revision: 77966 URL: http://llvm.org/viewvc/llvm-project?rev=77966&view=rev Log: Create proper frame index for FP Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=77966&r1=77965&r2=77966&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Aug 3 03:14:30 2009 @@ -653,9 +653,11 @@ if (hasFP(MF)) { assert((TailCallReturnAddrDelta <= 0) && "The Delta should always be zero or negative"); + const TargetFrameInfo &TFI = *MF.getTarget().getFrameInfo(); // Create a frame entry for the EBP register that must be saved. int FrameIdx = MFI->CreateFixedObject(SlotSize, - (int)SlotSize * -2+ + -(int)SlotSize + + TFI.getOffsetOfLocalArea() + TailCallReturnAddrDelta); assert(FrameIdx == MFI->getObjectIndexBegin() && "Slot for EBP register must be last in order to be found!"); From evan.cheng at apple.com Mon Aug 3 03:42:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 03 Aug 2009 08:42:10 -0000 Subject: [llvm-commits] [llvm] r77967 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll Message-ID: <200908030842.n738gEJK031723@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 3 03:41:59 2009 New Revision: 77967 URL: http://llvm.org/viewvc/llvm-project?rev=77967&view=rev Log: Fix a coaelescer bug. If a copy val# is extended to eliminate a non-trivially coalesced copy, and the copy kills its source register. Trim the source register's live range to the last use if possible. This fixes up kill marker to make the scavenger happy. Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=77967&r1=77966&r2=77967&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Aug 3 03:41:59 2009 @@ -123,7 +123,8 @@ assert(BValNo->def == CopyIdx && "Copy doesn't define the value?"); // AValNo is the value number in A that defines the copy, A3 in the example. - LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyIdx-1); + unsigned CopyUseIdx = li_->getUseIndex(CopyIdx); + LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyUseIdx); assert(ALR != IntA.end() && "Live range not found!"); VNInfo *AValNo = ALR->valno; // If it's re-defined by an early clobber somewhere in the live range, then @@ -227,6 +228,12 @@ IntB.removeKill(ValLR->valno, FillerStart); } + // If the copy instruction was killing the destination register before the + // merge, find the last use and trim the live range. That will also add the + // isKill marker. + if (CopyMI->killsRegister(IntA.reg)) + TrimLiveIntervalToLastUse(CopyUseIdx, CopyMI->getParent(), IntA, ALR); + ++numExtends; return true; } Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll?rev=77967&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-08-02-CoalescerBug.ll Mon Aug 3 03:41:59 2009 @@ -0,0 +1,46 @@ +; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin9 -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim + + type { void (%"struct.xalanc_1_8::FormatterToXML"*, i16)*, i32 } ; type %0 + type { void (%"struct.xalanc_1_8::FormatterToXML"*, i16*)*, i32 } ; type %1 + type { void (%"struct.xalanc_1_8::FormatterToXML"*, %"struct.xalanc_1_8::XalanDOMString"*)*, i32 } ; type %2 + type { void (%"struct.xalanc_1_8::FormatterToXML"*, i16*, i32, i32)*, i32 } ; type %3 + type { void (%"struct.xalanc_1_8::FormatterToXML"*)*, i32 } ; type %4 + %"struct.std::CharVectorType" = type { %"struct.std::_Vector_base >" } + %"struct.std::_Bit_const_iterator" = type { %"struct.std::_Bit_iterator_base" } + %"struct.std::_Bit_iterator_base" = type { i32*, i32 } + %"struct.std::_Bvector_base >" = type { %"struct.std::_Bvector_base >::_Bvector_impl" } + %"struct.std::_Bvector_base >::_Bvector_impl" = type { %"struct.std::_Bit_const_iterator", %"struct.std::_Bit_const_iterator", i32* } + %"struct.std::_Vector_base >" = type { %"struct.std::_Vector_base >::_Vector_impl" } + %"struct.std::_Vector_base >::_Vector_impl" = type { i8*, i8*, i8* } + %"struct.std::_Vector_base >" = type { %"struct.std::_Vector_base >::_Vector_impl" } + %"struct.std::_Vector_base >::_Vector_impl" = type { i16*, i16*, i16* } + %"struct.std::basic_ostream >.base" = type { i32 (...)** } + %"struct.std::vector >" = type { %"struct.std::_Bvector_base >" } + %"struct.std::vector >" = type { %"struct.std::_Vector_base >" } + %"struct.xalanc_1_8::FormatterListener" = type { %"struct.std::basic_ostream >.base", %"struct.std::basic_ostream >.base"*, i32 } + %"struct.xalanc_1_8::FormatterToXML" = type { %"struct.xalanc_1_8::FormatterListener", %"struct.std::basic_ostream >.base"*, %"struct.xalanc_1_8::XalanOutputStream"*, i16, [256 x i16], [256 x i16], i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %"struct.xalanc_1_8::XalanDOMString", %"struct.xalanc_1_8::XalanDOMString", %"struct.xalanc_1_8::XalanDOMString", i32, i32, %"struct.std::vector >", %"struct.xalanc_1_8::XalanDOMString", i8, i8, i8, i8, i8, %"struct.xalanc_1_8::XalanDOMString", %"struct.xalanc_1_8::XalanDOMString", %"struct.xalanc_1_8::XalanDOMString", %"struct.xalanc_1_8::XalanDOMString", %"struct.std::vector >", i32, %"struct.std::CharVectorType", %"struct.std::vector >", %0, %1, %2, %3, %0, %1, %2, %3, %4, i16*, i32 } + %"struct.xalanc_1_8::XalanDOMString" = type { %"struct.std::vector >", i32 } + %"struct.xalanc_1_8::XalanOutputStream" = type { i32 (...)**, i32, %"struct.std::basic_ostream >.base"*, i32, %"struct.std::vector >", %"struct.xalanc_1_8::XalanDOMString", i8, i8, %"struct.std::CharVectorType" } + +declare arm_apcscc void @_ZN10xalanc_1_814FormatterToXML17writeParentTagEndEv(%"struct.xalanc_1_8::FormatterToXML"*) + +define arm_apcscc void @_ZN10xalanc_1_814FormatterToXML5cdataEPKtj(%"struct.xalanc_1_8::FormatterToXML"* %this, i16* %ch, i32 %length) { +entry: + %0 = getelementptr %"struct.xalanc_1_8::FormatterToXML"* %this, i32 0, i32 13 ; [#uses=1] + br i1 undef, label %bb4, label %bb + +bb: ; preds = %entry + store i8 0, i8* %0, align 1 + %1 = getelementptr %"struct.xalanc_1_8::FormatterToXML"* %this, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] + %2 = load i32 (...)*** %1, align 4 ; [#uses=1] + %3 = getelementptr i32 (...)** %2, i32 11 ; [#uses=1] + %4 = load i32 (...)** %3, align 4 ; [#uses=1] + %5 = bitcast i32 (...)* %4 to void (%"struct.xalanc_1_8::FormatterToXML"*, i16*, i32)* ; [#uses=1] + tail call arm_apcscc void %5(%"struct.xalanc_1_8::FormatterToXML"* %this, i16* %ch, i32 %length) + ret void + +bb4: ; preds = %entry + tail call arm_apcscc void @_ZN10xalanc_1_814FormatterToXML17writeParentTagEndEv(%"struct.xalanc_1_8::FormatterToXML"* %this) + tail call arm_apcscc void undef(%"struct.xalanc_1_8::FormatterToXML"* %this, i16* %ch, i32 0, i32 %length, i8 zeroext undef) + ret void +} From asl at math.spbu.ru Mon Aug 3 03:43:38 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 03 Aug 2009 08:43:38 -0000 Subject: [llvm-commits] [llvm] r77968 - /llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm Message-ID: <200908030843.n738hcGX031777@zion.cs.uiuc.edu> Author: asl Date: Mon Aug 3 03:43:36 2009 New Revision: 77968 URL: http://llvm.org/viewvc/llvm-project?rev=77968&view=rev Log: Unbreak win64 compilation callback. Since we're generating stubs by hands we don't follow the ABI and don't create a register spill area. Don't use this area in compilation callback! Modified: llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm Modified: llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm?rev=77968&r1=77967&r2=77968&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm (original) +++ llvm/trunk/lib/Target/X86/X86CompilationCallback_Win64.asm Mon Aug 3 03:43:36 2009 @@ -15,17 +15,18 @@ .code X86CompilationCallback proc - ; Save all int arg registers into register spill area. - mov [rsp+ 8], rcx - mov [rsp+16], rdx - mov [rsp+24], r8 - mov [rsp+32], r9 - push rbp ; Save RSP. mov rbp, rsp + ; Save all int arg registers + ; WARNING: We cannot use register spill area - we're generating stubs by hands! + push rcx + push rdx + push r8 + push r9 + ; Align stack on 16-byte boundary. and rsp, -16 @@ -52,15 +53,15 @@ ; Restore RSP. mov rsp, rbp + ; Restore all int arg registers + sub rsp, 32 + pop r9 + pop r8 + pop rdx + pop rcx + ; Restore RBP. pop rbp - - ; Restore all int arg registers. - mov r9, [rsp+32] - mov r8, [rsp+24] - mov rdx, [rsp+16] - mov rcx, [rsp+ 8] - ret X86CompilationCallback endp From nicolas.geoffray at lip6.fr Mon Aug 3 04:01:16 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 11:01:16 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> Message-ID: <4A76A75C.4040509@lip6.fr> Hi Dan, Dan Gohman wrote: > Author: djg > Date: Fri Jul 31 13:36:25 2009 > New Revision: 77706 > > URL: http://llvm.org/viewvc/llvm-project?rev=77706&view=rev > Log: > Remove Annotation.h, which is no longer used in the LLVM tree. > I know this has been long waiting for LLVM and I'm happy you got rid of it. Unfortunately, I was using Annotations to add VM-info per function in VMKit (e.g. a way to get the Java method out of a llvm::Function), and I'm reluctant into using a table to store that information now that the Annotation class is removed. Another way for me is to derive the llvm::Function class, add the information in the new class and always create this new class instead of llvm::Function. Do you know if that won't mess with the llvm passes? To implement this solution, one obvious change I need to do in the llvm source tree is to set the llvm::Function constructor protected instead of private. Let me know what you think. Thanks, Nicolas From nicolas.geoffray at lip6.fr Mon Aug 3 05:14:56 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 12:14:56 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <4A76A75C.4040509@lip6.fr> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> Message-ID: <4A76B8A0.3030004@lip6.fr> Hi again Dan, Nicolas Geoffray wrote: > Hi Dan, > > Dan Gohman wrote: > >> Author: djg >> Date: Fri Jul 31 13:36:25 2009 >> New Revision: 77706 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=77706&view=rev >> Log: >> Remove Annotation.h, which is no longer used in the LLVM tree. >> > > > Another way for me is to derive the llvm::Function class, add the > information in the new class and always create this new class instead of > llvm::Function. Do you know if that won't mess with the llvm passes? > Just to let you know that creating a derive class of llvm::Function works fine in VMKit. All that is needed is to set the llvm::Function constructor to protected instead of private. So I just wanted to make sure creating a derive class of llvm::Function won't break any llvm assumptions. Otherwise, I'll commit the private --> protected patch. Thanks, Nicolas From ggreif at gmail.com Mon Aug 3 05:28:04 2009 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 3 Aug 2009 03:28:04 -0700 (PDT) Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <4A76B8A0.3030004@lip6.fr> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <4A76B8A0.3030004@lip6.fr> Message-ID: Hi Nicolas! When subclassing LLVM entities you have to be very careful. Did you test whether deserialization from bitcode create the right subclass? Cheers, Gabor On Aug 3, 12:14?pm, Nicolas Geoffray wrote: > Hi again Dan, > > > > Nicolas Geoffray wrote: > > Hi Dan, > > > Dan Gohman wrote: > > >> Author: djg > >> Date: Fri Jul 31 13:36:25 2009 > >> New Revision: 77706 > > >> URL:http://llvm.org/viewvc/llvm-project?rev=77706&view=rev > >> Log: > >> Remove Annotation.h, which is no longer used in the LLVM tree. > > > Another way for me is to derive the llvm::Function class, add the > > information in the new class and always create this new class instead of > > llvm::Function. Do you know if that won't mess with the llvm passes? > > Just to let you know that creating a derive class of llvm::Function > works fine in VMKit. All that is needed is to set the llvm::Function > constructor to protected instead of private. > > So I just wanted to make sure creating a derive class of llvm::Function > won't break any llvm assumptions. Otherwise, I'll commit the private --> > protected patch. > > Thanks, > Nicolas > _______________________________________________ > llvm-commits mailing list > llvm-comm... at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicolas.geoffray at lip6.fr Mon Aug 3 06:17:08 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 13:17:08 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <4A76B8A0.3030004@lip6.fr> Message-ID: <4A76C734.1050403@lip6.fr> Hi Gabor, Gabor Greif wrote: > Hi Nicolas! > > When subclassing LLVM entities you have to be very careful. OK. > Did you > test whether > deserialization from bitcode create the right subclass? > > I've just tested. Serialization of a llvm::Function subclass works fine. Deserialization creates a llvm::Function, as expected. Where can there be a problem? Thanks for the warning! Nicolas > Cheers, > > Gabor > > On Aug 3, 12:14 pm, Nicolas Geoffray wrote: > >> Hi again Dan, >> >> >> >> Nicolas Geoffray wrote: >> >>> Hi Dan, >>> >>> Dan Gohman wrote: >>> >>>> Author: djg >>>> Date: Fri Jul 31 13:36:25 2009 >>>> New Revision: 77706 >>>> >>>> URL:http://llvm.org/viewvc/llvm-project?rev=77706&view=rev >>>> Log: >>>> Remove Annotation.h, which is no longer used in the LLVM tree. >>>> >>> Another way for me is to derive the llvm::Function class, add the >>> information in the new class and always create this new class instead of >>> llvm::Function. Do you know if that won't mess with the llvm passes? >>> >> Just to let you know that creating a derive class of llvm::Function >> works fine in VMKit. All that is needed is to set the llvm::Function >> constructor to protected instead of private. >> >> So I just wanted to make sure creating a derive class of llvm::Function >> won't break any llvm assumptions. Otherwise, I'll commit the private --> >> protected patch. >> >> Thanks, >> Nicolas >> _______________________________________________ >> llvm-commits mailing list >> llvm-comm... at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From daniel at zuster.org Mon Aug 3 10:11:06 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 3 Aug 2009 08:11:06 -0700 Subject: [llvm-commits] [llvm] r77927 - in /llvm/trunk: include/llvm/Target/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CBackend/ lib/Target/CellSPU/ lib/Target/CppBackend/ lib/Target/MSIL/ lib/Target/MSP430/ lib/Target/Mips/ lib/Ta In-Reply-To: References: Message-ID: <6a8523d60908030811m3c1e5565p85deafcef537c0df@mail.gmail.com> On Mon, Aug 3, 2009 at 1:07 AM, Eli Friedman wrote: > On Sun, Aug 2, 2009 at 4:37 PM, Daniel Dunbar wrote: >> Author: ddunbar >> Date: Sun Aug ?2 18:37:13 2009 >> New Revision: 77927 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=77927&view=rev >> Log: >> Move most targets TargetMachine constructor to only taking a target triple. >> ?- The C, C++, MSIL, and Mips backends still need the module. > > I took care of the Mips backend earlier. Thanks! > It looks like the C, C++ and MSIL backends need the DataLayout member of > the Module; perhaps the standard signature for initializing a target should include > that as a separate argument? I'm not sure that is the right way to go; currently it is a little odd that the targets make up their own DataLayout independent of what was specified in the module, and various bits of code use that instead of the module layout. Intrinsically this seems bad, it seems like the module layout should be used everywhere, and the target should just validate that that layout is sane. But I don't really know how getTargetData is used in the back end, an alternate approach is to have each target provide a default layout string, and have the base TargetMachine class select either the default layout or the module layout, after it has the module available. This would also kill the unnecessarily duplicated getTargetData methods. - Daniel From devang.patel at gmail.com Mon Aug 3 10:59:07 2009 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 3 Aug 2009 08:59:07 -0700 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp In-Reply-To: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> References: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> Message-ID: <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> On Mon, Aug 3, 2009 at 12:16 AM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Aug ?3 02:16:42 2009 > New Revision: 77960 > > URL: http://llvm.org/viewvc/llvm-project?rev=77960&view=rev > Log: > Remove the GCC path from libLTO. This has been superceded by setAssemblerPath. > > Modified: > ? ?llvm/trunk/tools/lto/LTOCodeGenerator.cpp > ? ?llvm/trunk/tools/lto/LTOCodeGenerator.h > ? ?llvm/trunk/tools/lto/lto.cpp What about lto_codegen_set_gcc_path() ? This is breaking (removing) C api. Is it really necessary ? - Devang > > Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=77960&r1=77959&r2=77960&view=diff > > ============================================================================== > --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) > +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Aug ?3 02:16:42 2009 > @@ -76,7 +76,7 @@ > ? ? ? _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL), > ? ? ? _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false), > ? ? ? _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), > - ? ? ?_nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL) > + ? ? ?_nativeObjectFile(NULL), _assemblerPath(NULL) > ?{ > ? ? InitializeAllTargets(); > ? ? InitializeAllAsmPrinters(); > @@ -126,13 +126,6 @@ > ? ? return true; > ?} > > -void LTOCodeGenerator::setGccPath(const char* path) > -{ > - ? ?if ( _gccPath ) > - ? ? ? ?delete _gccPath; > - ? ?_gccPath = new sys::Path(path); > -} > - > ?void LTOCodeGenerator::setAssemblerPath(const char* path) > ?{ > ? ? if ( _assemblerPath ) > @@ -240,9 +233,6 @@ > ? ? if ( _assemblerPath ) { > ? ? ? ? tool = *_assemblerPath; > ? ? ? ? needsCompilerOptions = false; > - ? ?} > - ? ?else if ( _gccPath ) { > - ? ? ? ?tool = *_gccPath; > ? ? } else { > ? ? ? ? // find compiler driver > ? ? ? ? tool = sys::Program::FindProgramByName("gcc"); > > Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=77960&r1=77959&r2=77960&view=diff > > ============================================================================== > --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) > +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Mon Aug ?3 02:16:42 2009 > @@ -37,7 +37,6 @@ > ? ? bool ? ? ? ? ? ? ? ?addModule(class LTOModule*, std::string& errMsg); > ? ? bool ? ? ? ? ? ? ? ?setDebugInfo(lto_debug_model, std::string& errMsg); > ? ? bool ? ? ? ? ? ? ? ?setCodePICModel(lto_codegen_model, std::string& errMsg); > - ? ?void ? ? ? ? ? ? ? ?setGccPath(const char* path); > ? ? void ? ? ? ? ? ? ? ?setAssemblerPath(const char* path); > ? ? void ? ? ? ? ? ? ? ?addMustPreserveSymbol(const char* sym); > ? ? bool ? ? ? ? ? ? ? ?writeMergedModules(const char* path, > @@ -63,7 +62,6 @@ > ? ? StringSet ? ? ? ? ? ? ? ? ? _mustPreserveSymbols; > ? ? llvm::MemoryBuffer* ? ? ? ? _nativeObjectFile; > ? ? std::vector ? ?_codegenOptions; > - ? ?llvm::sys::Path* ? ? ? ? ? ?_gccPath; > ? ? llvm::sys::Path* ? ? ? ? ? ?_assemblerPath; > ?}; > > > Modified: llvm/trunk/tools/lto/lto.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=77960&r1=77959&r2=77960&view=diff > > ============================================================================== > --- llvm/trunk/tools/lto/lto.cpp (original) > +++ llvm/trunk/tools/lto/lto.cpp Mon Aug ?3 02:16:42 2009 > @@ -203,14 +203,6 @@ > ?} > > ?// > -// sets the path to gcc > -// > -void lto_codegen_set_gcc_path(lto_code_gen_t cg, const char* path) > -{ > - ?cg->setGccPath(path); > -} > - > -// > ?// sets the path to the assembler tool > ?// > ?void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -- - Devang From clattner at apple.com Mon Aug 3 11:29:23 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 09:29:23 -0700 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp In-Reply-To: <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> References: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> Message-ID: On Aug 3, 2009, at 8:59 AM, Devang Patel wrote: > On Mon, Aug 3, 2009 at 12:16 AM, Nick Lewycky wrote: >> Author: nicholas >> Date: Mon Aug 3 02:16:42 2009 >> New Revision: 77960 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=77960&view=rev >> Log: >> Remove the GCC path from libLTO. This has been superceded by >> setAssemblerPath. >> >> Modified: >> llvm/trunk/tools/lto/LTOCodeGenerator.cpp >> llvm/trunk/tools/lto/LTOCodeGenerator.h >> llvm/trunk/tools/lto/lto.cpp > > What about lto_codegen_set_gcc_path() ? This is breaking (removing) C > api. Is it really necessary ? Is anyone using it? -Chris From clattner at apple.com Mon Aug 3 11:34:23 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 09:34:23 -0700 Subject: [llvm-commits] [llvm] r77962 - in /llvm/trunk: lib/Target/X86/X86CallingConv.td lib/Target/X86/X86CompilationCallback_Win64.asm lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86Instr64bit.td lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86TargetMachine.cpp test/CodeGen/X86/2009-06-03-Win64DisableRedZone.ll test/CodeGen/X86/2009-06-03-Win64SpillXMM.ll In-Reply-To: <200908030813.n738D4Qg030803@zion.cs.uiuc.edu> References: <200908030813.n738D4Qg030803@zion.cs.uiuc.edu> Message-ID: <72E8EEC5-0ADC-462D-BD8A-EB90D51CA7C2@apple.com> On Aug 3, 2009, at 1:12 AM, Anton Korobeynikov wrote: > Author: asl > Date: Mon Aug 3 03:12:53 2009 > New Revision: 77962 > > URL: http://llvm.org/viewvc/llvm-project?rev=77962&view=rev > Log: > Unbreak Win64 CC. Step one: honour register save area, fix some > alignment and provide a different set of call-clobberred registers. Nice. > +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Mon Aug 3 > 03:12:53 2009 > @@ -64,7 +64,9 @@ > Subtarget(TT, FS, is64Bit), > DataLayout(Subtarget.getDataLayout()), > FrameInfo(TargetFrameInfo::StackGrowsDown, > - Subtarget.getStackAlignment(), Subtarget.is64Bit() ? > -8 : -4), > + Subtarget.getStackAlignment(), > + (Subtarget.isTargetWin64() ? -40 : > + (Subtarget.is64Bit() ? -8 : -4))), Please split this out to be a static function or a method on subtarget. -Chris From clattner at apple.com Mon Aug 3 11:35:55 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 09:35:55 -0700 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <4A76A75C.4040509@lip6.fr> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> Message-ID: <0BECC467-15D3-4E73-8085-BE55E8A4133B@apple.com> On Aug 3, 2009, at 2:01 AM, Nicolas Geoffray wrote: > Hi Dan, > > Dan Gohman wrote: >> Author: djg >> Date: Fri Jul 31 13:36:25 2009 >> New Revision: 77706 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=77706&view=rev >> Log: >> Remove Annotation.h, which is no longer used in the LLVM tree. >> > > I know this has been long waiting for LLVM and I'm happy you got rid > of > it. Unfortunately, I was using Annotations to add VM-info per function > in VMKit (e.g. a way to get the Java method out of a llvm::Function), > and I'm reluctant into using a table to store that information now > that > the Annotation class is removed. > Hi Nicolas, Why can't you just use a std::map or DenseMap on the side? Trying to actually *attach* data to LLVM IR objects is a really fragile thing to try to do. If the entire rest of the compiler can get away without it, I don't see why vmkit needs to do it. -Chris From ggreif at gmail.com Mon Aug 3 11:36:39 2009 From: ggreif at gmail.com (Gabor Greif) Date: Mon, 3 Aug 2009 09:36:39 -0700 (PDT) Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <4A76C734.1050403@lip6.fr> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <4A76B8A0.3030004@lip6.fr> <4A76C734.1050403@lip6.fr> Message-ID: <2d90c157-6127-409f-b026-deaaae567ee3@26g2000yqk.googlegroups.com> On Aug 3, 1:17?pm, Nicolas Geoffray wrote: > Hi Gabor, > > Gabor Greif wrote: > > Hi Nicolas! > > > When subclassing LLVM entities you have to be very careful. > > OK. > > > Did you > > test whether > > deserialization from bitcode create the right subclass? > > I've just tested. Serialization of a llvm::Function subclass works fine. > Deserialization creates a llvm::Function, as expected. Where can there > be a problem? I understood that you are subclassing llvm::Function to carry your annotations. When your function objects get serialized, do the annotations appear in the bitcode? If not, you have lost them. And when deserializing, do you get back your defined sublass? The BitcodeReader might need to be updated to deal with your subclass otherwise slicing may happen. But there is a chance that I understood your solution in the wrong way :-) Cheers, Gabor > > Thanks for the warning! > Nicolas > > > > > Cheers, > > > ? ? Gabor > > > On Aug 3, 12:14 pm, Nicolas Geoffray wrote: > > >> Hi again Dan, > > >> Nicolas Geoffray wrote: > > >>> Hi Dan, > > >>> Dan Gohman wrote: > > >>>> Author: djg > >>>> Date: Fri Jul 31 13:36:25 2009 > >>>> New Revision: 77706 > > >>>> URL:http://llvm.org/viewvc/llvm-project?rev=77706&view=rev > >>>> Log: > >>>> Remove Annotation.h, which is no longer used in the LLVM tree. > > >>> Another way for me is to derive the llvm::Function class, add the > >>> information in the new class and always create this new class instead of > >>> llvm::Function. Do you know if that won't mess with the llvm passes? > > >> Just to let you know that creating a derive class of llvm::Function > >> works fine in VMKit. All that is needed is to set the llvm::Function > >> constructor to protected instead of private. > > >> So I just wanted to make sure creating a derive class of llvm::Function > >> won't break any llvm assumptions. Otherwise, I'll commit the private --> > >> protected patch. > > >> Thanks, > >> Nicolas > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-comm... at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > > llvm-commits mailing list > > llvm-comm... at cs.uiuc.edu > >http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-comm... at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From greened at obbligato.org Mon Aug 3 11:46:20 2009 From: greened at obbligato.org (David A. Greene) Date: Mon, 3 Aug 2009 11:46:20 -0500 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <679A075B-43B1-4ACD-B18C-0B8C7356BA2A@apple.com> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <4A7458D7.9090808@obbligato.org> <679A075B-43B1-4ACD-B18C-0B8C7356BA2A@apple.com> Message-ID: <200908031146.20758.greened@obbligato.org> On Monday 03 August 2009 01:46, Chris Lattner wrote: > > - FirstOperandColumn = 0 and MaxOperandLength = 0 in X86TargetAsmInfo > > which disables the padding. > > Ok, this gets back to another question I have. I don't think that > these should be properties of TAI, at least not unless there are other > clients of this information. The TAI::getOperandColumn() method in > particular seems like an implementation detail of the asmprinter, not > something that should be in TAI. Agreed that getOperandColumn could be moved. But the column and operand length information really is target-specific. > However, more broadly, these are not properties that should be checked > when the asmprinter is running. If these were properties of the > "InstrInfo" class in the .td files, then X86 (for example), could be > defined like this (X86.td): > > def X86InstrInfo : InstrInfo { > let FirstOperandColumn = 42; // or whatever. > let MaxOperandLength = 20; > ... Interesting idea. > The nice thing about doing this is that if the target doesn't opt in > to this, that the tblgen generated code for the asmwriter *wouldn't > treat tab specially at all* and would not have to dynamically decide > not to do column padding. The generated code would still have to > dynamically check whether verbose-asm is enabled, but there should be > no need to dynamically check to see if the asm syntax likes tabs. > Making these values constants also allows them to constant fold in the > generated code. I agree that this could be pretty good. Unfortunately, I don't have the time to implement it at the moment. It would involve a bit of TableGen hacking, I imagine. I might be able to get to it after I've got my current set of patches sent upstream (well over a hundred at the moment). > >> Is this just a complex way to test for "FirstOperandColumn != 0" ? > > > > No, it's testing 0 for any operand, not just the first. > > Ok, maybe I'm not following it right then. When does this check > fail? Can this be removed by moving the "column padding turned on" > flag to the .td files? Yes, the check could be removed then. Right now the check fails if FirstOperandColumn == 0 or MaxOperandLength == 0. > >> Should this just be a considered a bug in .td files that don't do > >> this > >> right? What is the harm of just leaving this out? > > > > Because AsmStrs gets generated by TableGen. I'm not sure that .td > > files actually have control over it since TableGen does the encoding > > compaction itself. Look at X86GenAsdmWriter[1].inc for example. > > I'm not following what you mean here. Can you give me an example that > shows what this does? Oh! This changed since the last time I looked at it. It used to be that the tabs were embedded into the AsmStrs array and some opcodes had tabs after them and others didn't. I see now that in X86GenAsmWriter1.inc the asm boilerplate emits the tab after the opcode: O << "\t"; // Emit the opcode for the instruction. unsigned Bits = OpInfo[MI->getOpcode()]; if (Bits == 0) return false; How interesting. But then how does this work? case 10: // CMPPDrmi, CMPPDrri O << "pd"; PadToColumn(OperandColumn++); printOperand(MI, 0); O << ", "; break; Looks like the "pd" for packed cmp is emitted after the tab! What am I missing? -Dave From benny.kra at googlemail.com Mon Aug 3 08:34:08 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 03 Aug 2009 13:34:08 -0000 Subject: [llvm-commits] [llvm] r77971 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/ExecutionEngine/Interpreter/Execution.cpp lib/ExecutionEngine/JIT/Intercept.cpp lib/Target/ARM/ARMCodeEmitter.cpp Message-ID: <200908031334.n73DYW1Z009022@zion.cs.uiuc.edu> Author: d0k Date: Mon Aug 3 08:33:33 2009 New Revision: 77971 URL: http://llvm.org/viewvc/llvm-project?rev=77971&view=rev Log: llvm_report_error already prints "LLVM ERROR:". So stop reporting errors like "LLVM ERROR: llvm: error:" or "LLVM ERROR: ERROR:". Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=77971&r1=77970&r2=77971&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Mon Aug 3 08:33:33 2009 @@ -112,7 +112,7 @@ /// @note This has to exist, because this is a pass, but it should never be /// used. TargetData() : ImmutablePass(&ID) { - llvm_report_error("ERROR: Bad TargetData ctor used. " + llvm_report_error("Bad TargetData ctor used. " "Tool did not specify a TargetData to use?"); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=77971&r1=77970&r2=77971&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Aug 3 08:33:33 2009 @@ -5074,7 +5074,7 @@ Input.ConstraintVT.isInteger()) || (OpInfo.ConstraintVT.getSizeInBits() != Input.ConstraintVT.getSizeInBits())) { - llvm_report_error("llvm: error: Unsupported asm: input constraint" + llvm_report_error("Unsupported asm: input constraint" " with a matching output constraint of incompatible" " type!"); } @@ -5179,7 +5179,7 @@ // Copy the output from the appropriate register. Find a register that // we can use. if (OpInfo.AssignedRegs.Regs.empty()) { - llvm_report_error("llvm: error: Couldn't allocate output reg for" + llvm_report_error("Couldn't allocate output reg for" " constraint '" + OpInfo.ConstraintCode + "'!"); } @@ -5233,8 +5233,7 @@ || (OpFlag & 7) == 6 /* EARLYCLOBBER REGDEF */) { // Add (OpFlag&0xffff)>>3 registers to MatchedRegs. if (OpInfo.isIndirect) { - llvm_report_error("llvm: error: " - "Don't know how to handle tied indirect " + llvm_report_error("Don't know how to handle tied indirect " "register inputs yet!"); } RegsForValue MatchedRegs; @@ -5277,7 +5276,7 @@ TLI.LowerAsmOperandForConstraint(InOperandVal, OpInfo.ConstraintCode[0], hasMemory, Ops, DAG); if (Ops.empty()) { - llvm_report_error("llvm: error: Invalid operand for inline asm" + llvm_report_error("Invalid operand for inline asm" " constraint '" + OpInfo.ConstraintCode + "'!"); } @@ -5308,7 +5307,7 @@ // Copy the input into the appropriate registers. if (OpInfo.AssignedRegs.Regs.empty()) { - llvm_report_error("llvm: error: Couldn't allocate input reg for" + llvm_report_error("Couldn't allocate input reg for" " constraint '"+ OpInfo.ConstraintCode +"'!"); } Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp?rev=77971&r1=77970&r2=77971&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp Mon Aug 3 08:33:33 2009 @@ -644,7 +644,7 @@ } void Interpreter::visitUnreachableInst(UnreachableInst &I) { - llvm_report_error("ERROR: Program executed an 'unreachable' instruction!"); + llvm_report_error("Program executed an 'unreachable' instruction!"); } void Interpreter::visitBranchInst(BranchInst &I) { Modified: llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp?rev=77971&r1=77970&r2=77971&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp Mon Aug 3 08:33:33 2009 @@ -141,7 +141,7 @@ return RP; if (AbortOnFailure) { - llvm_report_error("ERROR: Program used external function '"+Name+ + llvm_report_error("Program used external function '"+Name+ "' which could not be resolved!"); } return 0; Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=77971&r1=77970&r2=77971&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Mon Aug 3 08:33:33 2009 @@ -749,7 +749,7 @@ const TargetInstrDesc &TID = MI.getDesc(); if (TID.Opcode == ARM::BFC) { - llvm_report_error("ERROR: ARMv6t2 JIT is not yet supported."); + llvm_report_error("ARMv6t2 JIT is not yet supported."); } // Part of binary is determined by TableGn. From dag at cray.com Mon Aug 3 11:50:17 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 11:50:17 -0500 Subject: [llvm-commits] [PATCH] Asm Loop Nest Comments In-Reply-To: <0F3CDC02-9267-4A6D-AFE4-7DCF9715CB64@apple.com> References: <200907301739.26152.dag@cray.com> <0F3CDC02-9267-4A6D-AFE4-7DCF9715CB64@apple.com> Message-ID: <200908031150.18088.dag@cray.com> On Saturday 01 August 2009 15:01, Dan Gohman wrote: > Hi Dave, > > This looks good! Here are some comments: > > Instead of using LoopInfo and Loop, this should use > MachineLoopInfo and MachineLoop. Ok. Those didn't exist when I initially did this. :) > Would be be practical to compute loop headers just-in-time > instead of precomputing it and storing it in a map? Switching > to MachineLoop would simplify this also. I'll take a look. > Would you mind making the default scale be 2 instead of 3? > That's what LoopInfo's print function uses, for example. But > it's not critical. Sure, no problem. > I'm a little confused about this: > > + inline Indent indent(int lvl, int amt = 3) { > + return(Indent(lvl, amt)); > + } > > This defines a function named indent which wraps a > constructor for Indent? Why not just have clients invoke > the class constructor directly? It's the IO manipulator syntax: os << indent(3) << string; It's indent(3) vs. Indent(3). Ok, not huge but it looks more "standard C++ like." I'll change it. > Minor style point: return values shouldn't be enclosed in parens. Gotcha. -Dave From dag at cray.com Mon Aug 3 11:51:21 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 11:51:21 -0500 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: References: <200907301710.32176.dag@cray.com> Message-ID: <200908031151.22285.dag@cray.com> On Saturday 01 August 2009 19:57, Evan Cheng wrote: > Do we really need Dump.h? Since it's Machine specific, perhaps it's ok > just put it in MachineFunction.h? But it gets used by MachineBasicBlock and MachineInstr too. -Dave From nicolas.geoffray at lip6.fr Mon Aug 3 12:05:25 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 19:05:25 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <0BECC467-15D3-4E73-8085-BE55E8A4133B@apple.com> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <0BECC467-15D3-4E73-8085-BE55E8A4133B@apple.com> Message-ID: <4A7718D5.50604@lip6.fr> Hi Chris, Chris Lattner wrote: > Hi Nicolas, > > Why can't you just use a std::map or DenseMap on the side? Trying to > actually *attach* data to LLVM IR objects is a really fragile thing to > try to do. Yes, that's what I fear :( > If the entire rest of the compiler can get away without > it, I don't see why vmkit needs to do it. > I can surely use maps for that. My problem is that (a) I haven't coded a map implementation where I can control the allocations, and that's very important for the runtime. DenseMap and std::map have their own malloc allocators (the allocator in stl isn't usable). Using annotations and subclassing were easier solutions, timely speaking. And (b) I can't avoid a global map, and I hate global maps (needs locking and a global allocator). When llvm wants vmkit to materialize a llvm::function, I have no way of knowing what is the context of this function. For example, a context in Java is a class loader. By being able to attach this "context" to annotations or subclasses, there was no need of the global map. Nicolas > -Chris > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From nicolas.geoffray at lip6.fr Mon Aug 3 12:10:25 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 19:10:25 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <2d90c157-6127-409f-b026-deaaae567ee3@26g2000yqk.googlegroups.com> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <4A76B8A0.3030004@lip6.fr> <4A76C734.1050403@lip6.fr> <2d90c157-6127-409f-b026-deaaae567ee3@26g2000yqk.googlegroups.com> Message-ID: <4A771A01.7090000@lip6.fr> Gabor Greif wrote: > > I understood that you are subclassing llvm::Function to carry your > annotations. > No, I was using the Annotation class previously to attach per-function information. Now that the Annotation class is deleted, I would like to subclass the llvm::Function to put these informations in the subclass. Serialization happens fine with the subclass. When I deserialize the bitcode I get llvm::Function and not the subclass. As expected. Nicolas From gohman at apple.com Mon Aug 3 12:32:27 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 3 Aug 2009 10:32:27 -0700 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <4A7718D5.50604@lip6.fr> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <0BECC467-15D3-4E73-8085-BE55E8A4133B@apple.com> <4A7718D5.50604@lip6.fr> Message-ID: <1ED15384-C3EE-4FD7-9ECA-041D11C0973D@apple.com> On Aug 3, 2009, at 10:05 AM, Nicolas Geoffray wrote: > >> If the entire rest of the compiler can get away without >> it, I don't see why vmkit needs to do it. >> > > I can surely use maps for that. My problem is that (a) I haven't > coded a > map implementation where I can control the allocations, and that's > very > important for the runtime. DenseMap and std::map have their own malloc > allocators (the allocator in stl isn't usable). Using annotations and > subclassing were easier solutions, timely speaking. And (b) I can't > avoid a global map, and I hate global maps (needs locking and a global > allocator). When llvm wants vmkit to materialize a llvm::function, I > have no way of knowing what is the context of this function. For > example, a context in Java is a class loader. By being able to attach > this "context" to annotations or subclasses, there was no need of the > global map. What if you put a map member in your ModuleProvider subclass? That shouldn't require any locking beyond whatever is already present to protect the Module itself. Does vmkit assign contexts to Functions when the Module is created? If so, all of the map's allocation would happen at the same time, and materializeFunction calls wouldn't see any additional allocations. Dan From daniel at zuster.org Mon Aug 3 12:34:37 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 17:34:37 -0000 Subject: [llvm-commits] [llvm] r77973 - /llvm/trunk/tools/llc/llc.cpp Message-ID: <200908031734.n73HYdox018026@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 12:34:19 2009 New Revision: 77973 URL: http://llvm.org/viewvc/llvm-project?rev=77973&view=rev Log: Provide target data from the module if the target machine doesn't have any. Modified: llvm/trunk/tools/llc/llc.cpp Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=77973&r1=77972&r2=77973&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Mon Aug 3 12:34:19 2009 @@ -310,7 +310,13 @@ // used by strange things like the C backend. if (Target.WantsWholeFile()) { PassManager PM; - PM.add(new TargetData(*Target.getTargetData())); + + // Add the target data from the target machine, if it exists, or the module. + if (const TargetData *TD = Target.getTargetData()) + PM.add(new TargetData(*TD)); + else + PM.add(new TargetData(&mod)); + if (!NoVerify) PM.add(createVerifierPass()); @@ -328,7 +334,12 @@ // Build up all of the passes that we want to do to the module. ExistingModuleProvider Provider(M.release()); FunctionPassManager Passes(&Provider); - Passes.add(new TargetData(*Target.getTargetData())); + + // Add the target data from the target machine, if it exists, or the module. + if (const TargetData *TD = Target.getTargetData()) + Passes.add(new TargetData(*TD)); + else + Passes.add(new TargetData(&mod)); #ifndef NDEBUG if (!NoVerify) From sanjiv.gupta at microchip.com Mon Aug 3 12:35:24 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Mon, 03 Aug 2009 17:35:24 -0000 Subject: [llvm-commits] [llvm] r77974 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Message-ID: <200908031735.n73HZPBp018060@zion.cs.uiuc.edu> Author: sgupta Date: Mon Aug 3 12:35:21 2009 New Revision: 77974 URL: http://llvm.org/viewvc/llvm-project?rev=77974&view=rev Log: Allow targets to custom handle softening of results or operands before trying the standard stuff. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=77974&r1=77973&r2=77974&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Mon Aug 3 12:35:21 2009 @@ -47,6 +47,10 @@ errs() << "\n"); SDValue R = SDValue(); + // See if the target wants to custom handle softening this result. + if (CustomLowerNode(N, N->getValueType(ResNo), true)) + return; + switch (N->getOpcode()) { default: #ifndef NDEBUG @@ -535,6 +539,10 @@ errs() << "\n"); SDValue Res = SDValue(); + // See if target wants to custom handle softening this operand. + if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) + return false; + switch (N->getOpcode()) { default: #ifndef NDEBUG From daniel at zuster.org Mon Aug 3 12:40:53 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 17:40:53 -0000 Subject: [llvm-commits] [llvm] r77975 - in /llvm/trunk/lib/Target: CBackend/CTargetMachine.h CppBackend/CPPTargetMachine.h MSIL/MSILWriter.cpp Message-ID: <200908031740.n73HeupH018286@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 12:40:25 2009 New Revision: 77975 URL: http://llvm.org/viewvc/llvm-project?rev=77975&view=rev Log: Change C, CBE, MSIL to not provide target data via getTargetData(). - The theory is these should never actually be called, since these boil down to passes which can access the target data via the standard mechanism. Modified: llvm/trunk/lib/Target/CBackend/CTargetMachine.h llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Modified: llvm/trunk/lib/Target/CBackend/CTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CTargetMachine.h?rev=77975&r1=77974&r2=77975&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CTargetMachine.h (original) +++ llvm/trunk/lib/Target/CBackend/CTargetMachine.h Mon Aug 3 12:40:25 2009 @@ -32,7 +32,7 @@ CodeGenFileType FileType, CodeGenOpt::Level OptLevel); - virtual const TargetData *getTargetData() const { return &DataLayout; } + virtual const TargetData *getTargetData() const { return 0; } }; extern Target TheCBackendTarget; Modified: llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h?rev=77975&r1=77974&r2=77975&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h (original) +++ llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h Mon Aug 3 12:40:25 2009 @@ -34,7 +34,7 @@ CodeGenFileType FileType, CodeGenOpt::Level OptLevel); - virtual const TargetData *getTargetData() const { return &DataLayout; } + virtual const TargetData *getTargetData() const { return 0; } }; extern Target TheCppBackendTarget; Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=77975&r1=77974&r2=77975&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Mon Aug 3 12:40:25 2009 @@ -42,7 +42,7 @@ CodeGenFileType FileType, CodeGenOpt::Level OptLevel); - virtual const TargetData *getTargetData() const { return &DataLayout; } + virtual const TargetData *getTargetData() const { return 0; } }; } From parseerror at gmail.com Mon Aug 3 12:48:04 2009 From: parseerror at gmail.com (Ryan Flynn) Date: Mon, 3 Aug 2009 13:48:04 -0400 Subject: [llvm-commits] [commit-after-approval] printf("foo %s baz\n", "bar") -> puts("foo bar baz") Message-ID: given a printf() call format containing a single "%s" conversion specifier and a constant string parameter, inlines parameter into format and lowers printf() to puts(). it's a bit more complex than the other printf() optimizations, but i happened to run into the situation and it seemed pretty common and straightforward to implement. my first attempt at an optimization, constructive criticism appreciated. -------------- next part -------------- A non-text attachment was scrubbed... Name: printf-inline-string-param.patch Type: text/x-diff Size: 2477 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090803/b8beb86d/attachment.bin From devang.patel at gmail.com Mon Aug 3 12:49:10 2009 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 3 Aug 2009 10:49:10 -0700 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp In-Reply-To: References: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> Message-ID: <352a1fb20908031049o2b30eb5dq40c87145a8799ab2@mail.gmail.com> On Mon, Aug 3, 2009 at 9:29 AM, Chris Lattner wrote: > > On Aug 3, 2009, at 8:59 AM, Devang Patel wrote: > >> On Mon, Aug 3, 2009 at 12:16 AM, Nick Lewycky wrote: >>> Author: nicholas >>> Date: Mon Aug ?3 02:16:42 2009 >>> New Revision: 77960 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=77960&view=rev >>> Log: >>> Remove the GCC path from libLTO. This has been superceded by >>> setAssemblerPath. >>> >>> Modified: >>> ? ?llvm/trunk/tools/lto/LTOCodeGenerator.cpp >>> ? ?llvm/trunk/tools/lto/LTOCodeGenerator.h >>> ? ?llvm/trunk/tools/lto/lto.cpp >> >> What about lto_codegen_set_gcc_path() ? This is breaking (removing) C >> api. Is it really necessary ? > > Is anyone using it? I do not know. Typically lto clients are not in llvm svn. AFAIK, Darwin ld64 does not use lto_codegen_set_gcc_path(). I am not sure about other clients. - Devang From sabre at nondot.org Mon Aug 3 13:04:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 18:04:54 -0000 Subject: [llvm-commits] [llvm] r77976 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200908031804.n73I4xYd019191@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 13:04:42 2009 New Revision: 77976 URL: http://llvm.org/viewvc/llvm-project?rev=77976&view=rev Log: make SwitchToSection accept null sections for now. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=77976&r1=77975&r2=77976&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 3 13:04:42 2009 @@ -132,9 +132,14 @@ } /// SwitchToSection - Switch to the specified section of the executable if we -/// are not already in it! +/// are not already in it! If "NS" is null, then this causes us to exit the +/// current section and not reenter another one. This is generally used for +/// asmprinter hacks. +/// +/// FIXME: Remove support for null sections. +/// void AsmPrinter::SwitchToSection(const MCSection *NS) { - const std::string &NewSection = NS->getName(); + const std::string &NewSection = NS ? NS->getName() : ""; // If we're already in this section, we're done. if (CurrentSection == NewSection) return; @@ -165,7 +170,7 @@ O << TAI->getDataSectionStartSuffix() << '\n'; } - IsInTextSection = NS->getKind().isText(); + IsInTextSection = NS ? NS->getKind().isText() : false; } void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { From sabre at nondot.org Mon Aug 3 13:06:09 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 18:06:09 -0000 Subject: [llvm-commits] [llvm] r77977 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Message-ID: <200908031806.n73I6Ahh019244@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 13:06:07 2009 New Revision: 77977 URL: http://llvm.org/viewvc/llvm-project?rev=77977&view=rev Log: eliminate textual section switching from intel asm printer. This will cause it to enter the ".text" section instead of "_text" but masm is already broken. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=77977&r1=77976&r2=77977&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Mon Aug 3 13:06:07 2009 @@ -143,7 +143,8 @@ decorateName(CurrentFnName, F); - SwitchToTextSection("_text", F); + SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); + switch (F->getLinkage()) { default: llvm_unreachable("Unsupported linkage type!"); case Function::PrivateLinkage: @@ -494,14 +495,14 @@ case GlobalValue::LinkOnceODRLinkage: case GlobalValue::WeakAnyLinkage: case GlobalValue::WeakODRLinkage: - SwitchToDataSection(""); + SwitchToSection(0); O << name << "?\tSEGEMNT PARA common 'COMMON'\n"; bCustomSegment = true; // FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256 // are also available. break; case GlobalValue::AppendingLinkage: - SwitchToDataSection(""); + SwitchToSection(0); O << name << "?\tSEGMENT PARA public 'DATA'\n"; bCustomSegment = true; // FIXME: the default alignment is 16 bytes, but 1, 2, 4, and 256 @@ -538,7 +539,7 @@ bool X86IntelAsmPrinter::doFinalization(Module &M) { // Output linker support code for dllexported globals if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) { - SwitchToDataSection(""); + SwitchToSection(0); O << "; WARNING: The following code is valid only with MASM v8.x" << "and (possible) higher\n" << "; This version of MASM is usually shipped with Microsoft " @@ -548,24 +549,23 @@ << "; dllexported symbols in the earlier versions of MASM in fully " << "automatic way\n\n"; O << "_drectve\t segment info alias('.drectve')\n"; - } - for (StringSet<>::iterator i = DLLExportedGVs.begin(), - e = DLLExportedGVs.end(); - i != e; ++i) - O << "\t db ' /EXPORT:" << i->getKeyData() << ",data'\n"; - - for (StringSet<>::iterator i = DLLExportedFns.begin(), - e = DLLExportedFns.end(); - i != e; ++i) - O << "\t db ' /EXPORT:" << i->getKeyData() << "'\n"; + for (StringSet<>::iterator i = DLLExportedGVs.begin(), + e = DLLExportedGVs.end(); + i != e; ++i) + O << "\t db ' /EXPORT:" << i->getKeyData() << ",data'\n"; + + for (StringSet<>::iterator i = DLLExportedFns.begin(), + e = DLLExportedFns.end(); + i != e; ++i) + O << "\t db ' /EXPORT:" << i->getKeyData() << "'\n"; - if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) O << "_drectve\t ends\n"; + } // Bypass X86SharedAsmPrinter::doFinalization(). bool Result = AsmPrinter::doFinalization(M); - SwitchToDataSection(""); + SwitchToSection(0); O << "\tend\n"; return Result; } From evan.cheng at apple.com Mon Aug 3 13:07:23 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 03 Aug 2009 18:07:23 -0000 Subject: [llvm-commits] [llvm] r77978 - /llvm/trunk/lib/Target/X86/X86InstrMMX.td Message-ID: <200908031807.n73I7NYs019290@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 3 13:07:19 2009 New Revision: 77978 URL: http://llvm.org/viewvc/llvm-project?rev=77978&view=rev Log: Remove neverHasSideEffects on MMX_MOVD64rrv164 since it has a matching pattern. Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=77978&r1=77977&r2=77978&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Mon Aug 3 13:07:19 2009 @@ -163,7 +163,7 @@ "movd\t{$src, $dst|$dst, $src}", []>; -let neverHasSideEffects = 1 in { +let neverHasSideEffects = 1 in // These are 64 bit moves, but since the OS X assembler doesn't // recognize a register-register movq, we write them as // movd. @@ -173,7 +173,6 @@ def MMX_MOVD64rrv164 : MMXI<0x6E, MRMSrcReg, (outs VR64:$dst), (ins GR64:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR64:$dst, (v1i64 (scalar_to_vector GR64:$src)))]>; -} let neverHasSideEffects = 1 in def MMX_MOVQ64rr : MMXI<0x6F, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src), From daniel at zuster.org Mon Aug 3 13:18:54 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 18:18:54 -0000 Subject: [llvm-commits] [zorg] r77979 - in /zorg/trunk/buildbot/smooshlab: master/org.llvm.smooshlab.master.plist slave/org.llvm.smooshlab.slave.plist Message-ID: <200908031819.n73IJ2ZC019632@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 13:18:15 2009 New Revision: 77979 URL: http://llvm.org/viewvc/llvm-project?rev=77979&view=rev Log: Fix typos Modified: zorg/trunk/buildbot/smooshlab/master/org.llvm.smooshlab.master.plist zorg/trunk/buildbot/smooshlab/slave/org.llvm.smooshlab.slave.plist Modified: zorg/trunk/buildbot/smooshlab/master/org.llvm.smooshlab.master.plist URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/buildbot/smooshlab/master/org.llvm.smooshlab.master.plist?rev=77979&r1=77978&r2=77979&view=diff ============================================================================== --- zorg/trunk/buildbot/smooshlab/master/org.llvm.smooshlab.master.plist (original) +++ zorg/trunk/buildbot/smooshlab/master/org.llvm.smooshlab.master.plist Mon Aug 3 13:18:15 2009 @@ -11,7 +11,7 @@ WorkingDirectory - /Users/buildmaster/zorg/buildbot/masters/smooshlab + /Users/buildmaster/zorg/buildbot/smooshlab/master ProgramArguments Modified: zorg/trunk/buildbot/smooshlab/slave/org.llvm.smooshlab.slave.plist URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/buildbot/smooshlab/slave/org.llvm.smooshlab.slave.plist?rev=77979&r1=77978&r2=77979&view=diff ============================================================================== --- zorg/trunk/buildbot/smooshlab/slave/org.llvm.smooshlab.slave.plist (original) +++ zorg/trunk/buildbot/smooshlab/slave/org.llvm.smooshlab.slave.plist Mon Aug 3 13:18:15 2009 @@ -5,11 +5,13 @@ Label org.llvm.smooshlab.slave + UserName buildslave + WorkingDirectory - /Users/buildslave/zorg/buildbot/slaves/smooshlab + /Users/buildslave/zorg/buildbot/smooshlab/slave ProgramArguments From bruno.cardoso at gmail.com Mon Aug 3 13:23:11 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 3 Aug 2009 15:23:11 -0300 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> Message-ID: <275e64e40908031123p3ddc4547qa74bf4326fb2d321@mail.gmail.com> Is it ok to commit this? On Fri, Jul 31, 2009 at 8:03 PM, Bruno Cardoso Lopes wrote: > Hi all, > > The X86CodeEmitter has the following behaviour: > > 1) When emiting displacements: > - Only use pc_relative relocations for x86_64 (globals, cstpools and jmptables) > - For x86, only uses pc_rel ou pic_re > This two items above do not always work for ELF. > > 2) RIP addressing: > The way emitMemModRMByte works now uses RIP relocation for all cases > where RegBase=0, IndexReg=0, and when the displacement needs relocation. And > for those cases, it will never generate a SIB byte + absolute > relocation, which ELF > needs. > > 3) The JIT can get the real address of cstpools and jmptables during > code emission, > but the same won't work for relocatable object files. > > This patch try to solve the 3 problems above to properly emit elf > binaries for x86/x86_64. With > this changes applied (together with elf improvements I've not commited > yet) I was able > to run 209/243 (83%) of SinglesSources using ELF object files emited by LLC :) > and with no regressions for JIT. > > The way the patch was done tries to ensure that no previous JIT code > emission mechanism will > be changed, trying to avoid loss in performance and new JIT bugs. > > The patch also introduces a new x86 relocation type reloc_absolute_word_sext, > which is lowered to x86 elf reloc type R_X86_64_32S. > > Please, review and comment :) > > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc > -- Bruno Cardoso Lopes http://www.brunocardoso.cc From daniel at zuster.org Mon Aug 3 13:30:23 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 03 Aug 2009 18:30:23 -0000 Subject: [llvm-commits] [zorg] r77980 - /zorg/trunk/buildbot/README.txt Message-ID: <200908031830.n73IUQj0020050@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 13:29:40 2009 New Revision: 77980 URL: http://llvm.org/viewvc/llvm-project?rev=77980&view=rev Log: Add description of the steps necessary to create a build slave based on the smooshlab skeleton. Added: zorg/trunk/buildbot/README.txt Added: zorg/trunk/buildbot/README.txt URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/buildbot/README.txt?rev=77980&view=auto ============================================================================== --- zorg/trunk/buildbot/README.txt (added) +++ zorg/trunk/buildbot/README.txt Mon Aug 3 13:29:40 2009 @@ -0,0 +1,22 @@ +This directory contains a working skeleton for setting up a buildbot system +for testing LLVM. + +Build Slaves +------------ +These are the steps to install a buildslave based on this skeleton: + + 1. Install buildbot. + + 2. Create a user for the buildslave, e.g. "buildslave". + + 3. Check out the "zorg" SVN module somewhere as the buildslave user, + e.g. ~buildslave/zorg. + + 4. Edit "zorg/buildbot/smooshlab/Config.py" and fix getBuildmasterHost to + return the correct host name. You may also need to fix the buildslave + name and password to match what the master expects. + + 5. Configure your system to start the buildbot automatically. On Mac + OS X this means copying the sample .plist to /Library/LaunchDaemons + (editing it as appropriate if the user name or slave directories are + different), and using 'launchctl' to load and start it. From clattner at apple.com Mon Aug 3 14:00:48 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 12:00:48 -0700 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> Message-ID: <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> On Jul 31, 2009, at 4:03 PM, Bruno Cardoso Lopes wrote: > Hi all, > > The X86CodeEmitter has the following behaviour: > > 1) When emiting displacements: > - Only use pc_relative relocations for x86_64 (globals, cstpools and > jmptables) > - For x86, only uses pc_rel ou pic_re > This two items above do not always work for ELF. Hi Bruno, I don't have an opinion about this patch specifically, but would it be possible to make the code emitter be driven off the asm operand flags instead of making equivalent decisions that have to mirror what isel does? Specifically, MO.getTargetFlags() should tell the code emitter how to handle the CPI/JT/GA/ExtSym operands, X86ATTAsmPrinter.cpp has stuff like this: switch (MO.getTargetFlags()) { default: llvm_unreachable("Unknown target flag on GV operand"); case X86II::MO_NO_FLAG: // No flag. break; case X86II::MO_DARWIN_NONLAZY: case X86II::MO_DARWIN_HIDDEN_NONLAZY: case X86II::MO_DLLIMPORT: case X86II::MO_DARWIN_STUB: // These affect the name of the symbol, not any suffix. break; case X86II::MO_GOT_ABSOLUTE_ADDRESS: O << " + [.-"; PrintPICBaseSymbol(); O << ']'; break; case X86II::MO_PIC_BASE_OFFSET: case X86II::MO_DARWIN_NONLAZY_PIC_BASE: case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: O << '-'; PrintPICBaseSymbol(); break; case X86II::MO_TLSGD: O << "@TLSGD"; break; case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break; case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break; case X86II::MO_TPOFF: O << "@TPOFF"; break; case X86II::MO_NTPOFF: O << "@NTPOFF"; break; case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break; case X86II::MO_GOT: O << "@GOT"; break; case X86II::MO_GOTOFF: O << "@GOTOFF"; break; case X86II::MO_PLT: O << "@PLT"; break; } For example. It would be better to base the encoding on this flag than checking things like Is64BitMode, IsPIC etc. > This patch try to solve the 3 problems above to properly emit elf > binaries for x86/x86_64. With > this changes applied (together with elf improvements I've not commited > yet) I was able > to run 209/243 (83%) of SinglesSources using ELF object files emited > by LLC :) > and with no regressions for JIT. Wow, nice!! -Chris From clattner at apple.com Mon Aug 3 14:01:28 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 12:01:28 -0700 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp In-Reply-To: <352a1fb20908031049o2b30eb5dq40c87145a8799ab2@mail.gmail.com> References: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> <352a1fb20908031049o2b30eb5dq40c87145a8799ab2@mail.gmail.com> Message-ID: <259EE804-34CE-4AC7-BE16-90311185FA8F@apple.com> On Aug 3, 2009, at 10:49 AM, Devang Patel wrote: >>>> >>>> Modified: >>>> llvm/trunk/tools/lto/LTOCodeGenerator.cpp >>>> llvm/trunk/tools/lto/LTOCodeGenerator.h >>>> llvm/trunk/tools/lto/lto.cpp >>> >>> What about lto_codegen_set_gcc_path() ? This is breaking >>> (removing) C >>> api. Is it really necessary ? >> >> Is anyone using it? > > I do not know. Typically lto clients are not in llvm svn. AFAIK, > Darwin ld64 does not use lto_codegen_set_gcc_path(). I am not sure > about other clients. Ok, since we didn't ship it in llvm 2.5, unless someone knows of a client of this, I think it is fine to remove it. -Chris From bob.wilson at apple.com Mon Aug 3 14:06:16 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 3 Aug 2009 12:06:16 -0700 Subject: [llvm-commits] [llvm] r77974 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp In-Reply-To: <200908031735.n73HZPBp018060@zion.cs.uiuc.edu> References: <200908031735.n73HZPBp018060@zion.cs.uiuc.edu> Message-ID: <7D467673-881E-40C5-86E7-685A3E4BCFA3@apple.com> This patch broke 3 of the ARM dejagnu tests. I've reverted it for now. On Aug 3, 2009, at 10:35 AM, Sanjiv Gupta wrote: > Author: sgupta > Date: Mon Aug 3 12:35:21 2009 > New Revision: 77974 > > URL: http://llvm.org/viewvc/llvm-project?rev=77974&view=rev > Log: > Allow targets to custom handle softening of results or operands > before trying the standard stuff. > > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=77974&r1=77973&r2=77974&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp > (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Mon > Aug 3 12:35:21 2009 > @@ -47,6 +47,10 @@ > errs() << "\n"); > SDValue R = SDValue(); > > + // See if the target wants to custom handle softening this result. > + if (CustomLowerNode(N, N->getValueType(ResNo), true)) > + return; > + > switch (N->getOpcode()) { > default: > #ifndef NDEBUG > @@ -535,6 +539,10 @@ > errs() << "\n"); > SDValue Res = SDValue(); > > + // See if target wants to custom handle softening this operand. > + if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) > + return false; > + > switch (N->getOpcode()) { > default: > #ifndef NDEBUG > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Mon Aug 3 14:07:00 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 03 Aug 2009 19:07:00 -0000 Subject: [llvm-commits] [llvm] r77982 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Message-ID: <200908031907.n73J7DfT021342@zion.cs.uiuc.edu> Author: bwilson Date: Mon Aug 3 14:06:29 2009 New Revision: 77982 URL: http://llvm.org/viewvc/llvm-project?rev=77982&view=rev Log: Revert 77974. It breaks 3 of the ARM tests. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=77982&r1=77981&r2=77982&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Mon Aug 3 14:06:29 2009 @@ -47,10 +47,6 @@ errs() << "\n"); SDValue R = SDValue(); - // See if the target wants to custom handle softening this result. - if (CustomLowerNode(N, N->getValueType(ResNo), true)) - return; - switch (N->getOpcode()) { default: #ifndef NDEBUG @@ -539,10 +535,6 @@ errs() << "\n"); SDValue Res = SDValue(); - // See if target wants to custom handle softening this operand. - if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) - return false; - switch (N->getOpcode()) { default: #ifndef NDEBUG From sabre at nondot.org Mon Aug 3 14:10:59 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 19:10:59 -0000 Subject: [llvm-commits] [llvm] r77983 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200908031911.n73JB8Md021493@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 14:10:44 2009 New Revision: 77983 URL: http://llvm.org/viewvc/llvm-project?rev=77983&view=rev Log: remove a dead switch directive, replace it with some code that I will be using shortly. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=77983&r1=77982&r2=77983&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Aug 3 14:10:44 2009 @@ -899,7 +899,8 @@ } if (Subtarget->isTargetDarwin()) { - SwitchToDataSection(""); + //TargetLoweringObjectFileMachO &TLOFMacho = + // static_cast(getObjFileLowering()); // Add the (possibly multiple) personalities to the set of global value // stubs. Only referenced functions get into the Personalities list. From eli.friedman at gmail.com Mon Aug 3 14:15:55 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 03 Aug 2009 19:15:55 -0000 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> Author: efriedma Date: Mon Aug 3 14:15:42 2009 New Revision: 77986 URL: http://llvm.org/viewvc/llvm-project?rev=77986&view=rev Log: Make SimplifyDemandedUseBits generate vector constants where appropriate. Patch per report on llvmdev. No testcase because the original report didn't come with a testcase, and I can't come up with a case that actually fails. Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=77986&r1=77985&r2=77986&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Aug 3 14:15:42 2009 @@ -1014,7 +1014,7 @@ if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { // all known if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) { - Constant *AndC = ConstantInt::get(*Context, + Constant *AndC = ConstantInt::get(VTy, ~RHSKnownOne & DemandedMask); Instruction *And = BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp"); @@ -1407,7 +1407,7 @@ // If the client is only demanding bits that we know, return the known // constant. if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { - Constant *C = ConstantInt::get(*Context, RHSKnownOne); + Constant *C = ConstantInt::get(VTy, RHSKnownOne); if (isa(V->getType())) C = ConstantExpr::getIntToPtr(C, V->getType()); return C; From sabre at nondot.org Mon Aug 3 14:12:44 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 19:12:44 -0000 Subject: [llvm-commits] [llvm] r77984 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/Target/TargetLowering.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200908031913.n73JD1qe021564@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 14:12:26 2009 New Revision: 77984 URL: http://llvm.org/viewvc/llvm-project?rev=77984&view=rev Log: make getObjFileLowering() return a non-const reference. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=77984&r1=77983&r2=77984&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Aug 3 14:12:26 2009 @@ -77,7 +77,7 @@ TargetMachine &TM; /// getObjFileLowering - Return information about object file lowering. - const TargetLoweringObjectFile &getObjFileLowering() const; + TargetLoweringObjectFile &getObjFileLowering() const; /// Target Asm Printer information. /// Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=77984&r1=77983&r2=77984&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Mon Aug 3 14:12:26 2009 @@ -107,7 +107,7 @@ TargetMachine &getTargetMachine() const { return TM; } const TargetData *getTargetData() const { return TD; } - const TargetLoweringObjectFile &getObjFileLowering() const { return TLOF; } + TargetLoweringObjectFile &getObjFileLowering() const { return TLOF; } bool isBigEndian() const { return !IsLittleEndian; } bool isLittleEndian() const { return IsLittleEndian; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=77984&r1=77983&r2=77984&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 3 14:12:26 2009 @@ -74,7 +74,7 @@ delete &OutContext; } -const TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const { +TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const { return TM.getTargetLowering()->getObjFileLowering(); } From stoklund at 2pi.dk Mon Aug 3 14:33:01 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 03 Aug 2009 19:33:01 -0000 Subject: [llvm-commits] [llvm] r77987 - in /llvm/trunk/lib/Target/Blackfin: AsmPrinter/BlackfinAsmPrinter.cpp BlackfinISelLowering.cpp BlackfinRegisterInfo.cpp Message-ID: <200908031933.n73JX5in022345@zion.cs.uiuc.edu> Author: stoklund Date: Mon Aug 3 14:32:30 2009 New Revision: 77987 URL: http://llvm.org/viewvc/llvm-project?rev=77987&view=rev Log: Minor stylistic cleanups in the Blackfin target. Thanks Chris. Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp?rev=77987&r1=77986&r2=77987&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/BlackfinAsmPrinter.cpp Mon Aug 3 14:32:30 2009 @@ -159,8 +159,8 @@ const TargetRegisterInfo &RI = *TM.getRegisterInfo(); switch (MO.getType()) { case MachineOperand::MO_Register: - assert (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && - "Virtual registers should be already mapped!"); + assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && + "Virtual registers should be already mapped!"); O << RI.get(MO.getReg()).AsmName; break; Modified: llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp?rev=77987&r1=77986&r2=77987&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp Mon Aug 3 14:32:30 2009 @@ -188,8 +188,8 @@ MVT RegVT = VA.getLocVT(); TargetRegisterClass *RC = VA.getLocReg() == BF::P0 ? BF::PRegisterClass : BF::DRegisterClass; - assert(RC->contains(VA.getLocReg())); - assert(RC->hasType(RegVT)); + assert(RC->contains(VA.getLocReg()) && "Unexpected regclass in CCState"); + assert(RC->hasType(RegVT) && "Unexpected regclass in CCState"); unsigned Reg = MF.getRegInfo().createVirtualRegister(RC); MF.getRegInfo().addLiveIn(VA.getLocReg(), Reg); @@ -210,7 +210,7 @@ ArgValues.push_back(ArgValue); } else { - assert(VA.isMemLoc()); + assert(VA.isMemLoc() && "CCValAssign must be RegLoc or MemLoc"); unsigned ObjSize = VA.getLocVT().getStoreSizeInBits()/8; int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset()); SDValue FIN = DAG.getFrameIndex(FI, MVT::i32); @@ -331,10 +331,10 @@ if (VA.isRegLoc()) { RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg)); } else { - assert(VA.isMemLoc()); + assert(VA.isMemLoc() && "CCValAssign must be RegLoc or MemLoc"); int Offset = VA.getLocMemOffset(); - assert(Offset%4 == 0); - assert(VA.getLocVT()==MVT::i32); + assert(Offset%4 == 0 && "Unaligned LocMemOffset"); + assert(VA.getLocVT()==MVT::i32 && "Illegal CCValAssign type"); SDValue SPN = DAG.getCopyFromReg(Chain, dl, BF::SP, MVT::i32); SDValue OffsetN = DAG.getIntPtrConstant(Offset); OffsetN = DAG.getNode(ISD::ADD, dl, MVT::i32, SPN, OffsetN); Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp?rev=77987&r1=77986&r2=77987&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Mon Aug 3 14:32:30 2009 @@ -126,13 +126,15 @@ // We must load delta into ScratchReg and add that. loadConstant(MBB, I, DL, ScratchReg, delta); if (BF::PRegClass.contains(Reg)) { - assert (BF::PRegClass.contains(ScratchReg)); + assert(BF::PRegClass.contains(ScratchReg) && + "ScratchReg must be a P register"); BuildMI(MBB, I, DL, TII.get(BF::ADDpp), Reg) .addReg(Reg, RegState::Kill) .addReg(ScratchReg, RegState::Kill); } else { - assert (BF::DRegClass.contains(Reg)); - assert (BF::DRegClass.contains(ScratchReg)); + assert(BF::DRegClass.contains(Reg) && "Reg must be a D or P register"); + assert(BF::DRegClass.contains(ScratchReg) && + "ScratchReg must be a D register"); BuildMI(MBB, I, DL, TII.get(BF::ADD), Reg) .addReg(Reg, RegState::Kill) .addReg(ScratchReg, RegState::Kill); @@ -179,11 +181,12 @@ if (!hasReservedCallFrame(MF)) { int64_t Amount = I->getOperand(0).getImm(); if (Amount != 0) { - assert(Amount%4 == 0); + assert(Amount%4 == 0 && "Unaligned call frame size"); if (I->getOpcode() == BF::ADJCALLSTACKDOWN) { adjustRegister(MBB, I, I->getDebugLoc(), BF::SP, BF::P1, -Amount); } else { - assert(I->getOpcode() == BF::ADJCALLSTACKUP); + assert(I->getOpcode() == BF::ADJCALLSTACKUP && + "Unknown call frame pseudo instruction"); adjustRegister(MBB, I, I->getDebugLoc(), BF::SP, BF::P1, Amount); } } @@ -207,22 +210,23 @@ void BlackfinRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, RegScavenger *RS) const { - unsigned i; MachineInstr &MI = *II; MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); DebugLoc DL = MI.getDebugLoc(); - for (i=0; !MI.getOperand(i).isFI(); i++) { - assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!"); + unsigned FIPos; + for (FIPos=0; !MI.getOperand(FIPos).isFI(); ++FIPos) { + assert(FIPos < MI.getNumOperands() && + "Instr doesn't have FrameIndex operand!"); } - int FrameIndex = MI.getOperand(i).getIndex(); - assert(i+1 < MI.getNumOperands() && MI.getOperand(i+1).isImm()); + int FrameIndex = MI.getOperand(FIPos).getIndex(); + assert(FIPos+1 < MI.getNumOperands() && MI.getOperand(FIPos+1).isImm()); int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) - + MI.getOperand(i+1).getImm(); + + MI.getOperand(FIPos+1).getImm(); unsigned BaseReg = BF::FP; if (hasFP(MF)) { - assert(SPAdj==0); + assert(SPAdj==0 && "Unexpected SP adjust in function with frame pointer"); } else { BaseReg = BF::SP; Offset += MF.getFrameInfo()->getStackSize() + SPAdj; @@ -234,10 +238,10 @@ case BF::STORE32fi: isStore = true; case BF::LOAD32fi: { - assert(Offset%4 == 0 && "Badly aligned i32 stack access"); - assert(i==1); - MI.getOperand(i).ChangeToRegister(BaseReg, false); - MI.getOperand(i+1).setImm(Offset); + assert(Offset%4 == 0 && "Unaligned i32 stack access"); + assert(FIPos==1 && "Bad frame index operand"); + MI.getOperand(FIPos).ChangeToRegister(BaseReg, false); + MI.getOperand(FIPos+1).setImm(Offset); if (isUimm<6>(Offset)) { MI.setDesc(TII.get(isStore ? BF::STORE32p_uimm6m4 @@ -248,7 +252,7 @@ MI.setDesc(TII.get(isStore ? BF::STORE32fp_nimm7m4 : BF::LOAD32fp_nimm7m4)); - MI.getOperand(i+1).setImm(-Offset); + MI.getOperand(FIPos+1).setImm(-Offset); return; } if (isImm<18>(Offset)) { @@ -263,12 +267,12 @@ break; } case BF::ADDpp: { - assert(MI.getOperand(0).isReg()); + assert(MI.getOperand(0).isReg() && "ADD instruction needs a register"); unsigned DestReg = MI.getOperand(0).getReg(); // We need to produce a stack offset in a P register. We emit: // P0 = offset; // P0 = BR + P0; - assert(i==1); + assert(FIPos==1 && "Bad frame index operand"); loadConstant(MBB, II, DL, DestReg, Offset); MI.getOperand(1).ChangeToRegister(DestReg, false, false, true); MI.getOperand(2).ChangeToRegister(BaseReg, false); @@ -277,11 +281,11 @@ case BF::STORE16fi: isStore = true; case BF::LOAD16fi: { - assert(Offset%2 == 0 && "Badly aligned i16 stack access"); - assert(i==1); + assert(Offset%2 == 0 && "Unaligned i16 stack access"); + assert(FIPos==1 && "Bad frame index operand"); // We need a P register to use as an address unsigned ScratchReg = findScratchRegister(II, RS, &BF::PRegClass, SPAdj); - assert(ScratchReg); + assert(ScratchReg && "Could not scavenge register"); loadConstant(MBB, II, DL, ScratchReg, Offset); BuildMI(MBB, II, DL, TII.get(BF::ADDpp), ScratchReg) .addReg(ScratchReg, RegState::Kill) @@ -293,10 +297,10 @@ } case BF::STORE8fi: { // This is an AnyCC spill, we need a scratch register. - assert(i==1); + assert(FIPos==1 && "Bad frame index operand"); MachineOperand SpillReg = MI.getOperand(0); unsigned ScratchReg = findScratchRegister(II, RS, &BF::DRegClass, SPAdj); - assert(ScratchReg); + assert(ScratchReg && "Could not scavenge register"); if (SpillReg.getReg()==BF::NCC) { BuildMI(MBB, II, DL, TII.get(BF::MOVENCC_z), ScratchReg) .addOperand(SpillReg); @@ -309,20 +313,20 @@ // STORE D MI.setDesc(TII.get(BF::STORE8p_imm16)); MI.getOperand(0).ChangeToRegister(ScratchReg, false, false, true); - MI.getOperand(i).ChangeToRegister(BaseReg, false); - MI.getOperand(i+1).setImm(Offset); + MI.getOperand(FIPos).ChangeToRegister(BaseReg, false); + MI.getOperand(FIPos+1).setImm(Offset); break; } case BF::LOAD8fi: { // This is an restore, we need a scratch register. - assert(i==1); + assert(FIPos==1 && "Bad frame index operand"); MachineOperand SpillReg = MI.getOperand(0); unsigned ScratchReg = findScratchRegister(II, RS, &BF::DRegClass, SPAdj); - assert(ScratchReg); + assert(ScratchReg && "Could not scavenge register"); MI.setDesc(TII.get(BF::LOAD32p_imm16_8z)); MI.getOperand(0).ChangeToRegister(ScratchReg, true); - MI.getOperand(i).ChangeToRegister(BaseReg, false); - MI.getOperand(i+1).setImm(Offset); + MI.getOperand(FIPos).ChangeToRegister(BaseReg, false); + MI.getOperand(FIPos+1).setImm(Offset); ++II; if (SpillReg.getReg()==BF::CC) { // CC = D @@ -376,8 +380,8 @@ } if (!hasFP(MF)) { - // So far we only support FP elimination on leaf functions - assert(!MFI->hasCalls()); + assert(!MFI->hasCalls() && + "FP elimination on a non-leaf function is not supported"); adjustRegister(MBB, MBBI, dl, BF::SP, BF::P1, -FrameSize); return; } @@ -417,8 +421,8 @@ assert(FrameSize%4 == 0 && "Misaligned frame size"); if (!hasFP(MF)) { - // So far we only support FP elimination on leaf functions - assert(!MFI->hasCalls()); + assert(!MFI->hasCalls() && + "FP elimination on a non-leaf function is not supported"); adjustRegister(MBB, MBBI, dl, BF::SP, BF::P1, FrameSize); return; } From stoklund at 2pi.dk Mon Aug 3 15:08:35 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 03 Aug 2009 20:08:35 -0000 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll Message-ID: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> Author: stoklund Date: Mon Aug 3 15:08:18 2009 New Revision: 77989 URL: http://llvm.org/viewvc/llvm-project?rev=77989&view=rev Log: Fix Bug 4657: register scavenger asserts with subreg lowering When LowerSubregsInstructionPass::LowerInsert eliminates an INSERT_SUBREG instriction because it is an identity copy, make sure that the same registers are alive before and after the elimination. When the super-register is marked this requires inserting an IMPLICIT_DEF instruction to make sure the super register is live. Fix a related bug where a kill flag on the inserted sub-register was not transferred properly. Finally, clear the undef flag in MachineInstr::addRegisterKilled. Undef implies dead and kill implies live, so they cant both be valid. Added: llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=77989&r1=77988&r2=77989&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original) +++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Mon Aug 3 15:08:18 2009 @@ -19,6 +19,7 @@ #include "llvm/Function.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" @@ -130,6 +131,7 @@ MII != MBB->end(); ++MII) if (MII->killsRegister(DstReg, &TRI)) { MII->addRegisterKilled(SuperReg, &TRI, /*AddIfNotFound=*/true); + DOUT << "\nsubreg: killed here: " << *MII; break; } } else { @@ -231,7 +233,7 @@ assert(DstReg == SrcReg && "insert_subreg not a two-address instruction?"); assert(SubIdx != 0 && "Invalid index for insert_subreg"); unsigned DstSubReg = TRI.getSubReg(DstReg, SubIdx); - + assert(DstSubReg && "invalid subregister index for register"); assert(TargetRegisterInfo::isPhysicalRegister(SrcReg) && "Insert superreg source must be in a physical register"); assert(TargetRegisterInfo::isPhysicalRegister(InsReg) && @@ -240,24 +242,45 @@ DOUT << "subreg: CONVERTING: " << *MI; if (DstSubReg == InsReg) { - // No need to insert an identify copy instruction. - DOUT << "subreg: eliminated!"; + // No need to insert an identity copy instruction. If the SrcReg was + // , we need to make sure it is alive by inserting an IMPLICIT_DEF + if (MI->getOperand(1).isUndef() && !MI->getOperand(0).isDead()) { + BuildMI(*MBB, MI, MI->getDebugLoc(), + TII.get(TargetInstrInfo::IMPLICIT_DEF), DstReg) + .addReg(InsReg, RegState::ImplicitKill); + } else { + DOUT << "subreg: eliminated!\n"; + MBB->erase(MI); + return true; + } } else { // Insert sub-register copy const TargetRegisterClass *TRC0= TRI.getPhysicalRegisterRegClass(DstSubReg); const TargetRegisterClass *TRC1= TRI.getPhysicalRegisterRegClass(InsReg); TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1); + MachineBasicBlock::iterator CopyMI = MI; + --CopyMI; + // Transfer the kill/dead flags, if needed. - if (MI->getOperand(0).isDead()) + if (MI->getOperand(0).isDead()) { TransferDeadFlag(MI, DstSubReg, TRI); - if (MI->getOperand(1).isKill()) + // Also add a SrcReg of the super register. + CopyMI->addOperand(MachineOperand::CreateReg(DstReg, false, true, true)); + } else if (MI->getOperand(1).isUndef()) { + // If SrcReg was marked we must make sure it is alive after this + // replacement. Add a SrcReg operand. + CopyMI->addOperand(MachineOperand::CreateReg(DstReg, true, true)); + } + + // Make sure the inserted register gets killed + if (MI->getOperand(2).isKill()) TransferKillFlag(MI, InsReg, TRI); + } #ifndef NDEBUG - MachineBasicBlock::iterator dMI = MI; - DOUT << "subreg: " << *(--dMI); + MachineBasicBlock::iterator dMI = MI; + DOUT << "subreg: " << *(--dMI); #endif - } DOUT << "\n"; MBB->erase(MI); Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=77989&r1=77988&r2=77989&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Aug 3 15:08:18 2009 @@ -1041,6 +1041,8 @@ if (MO.isKill()) // The register is already marked kill. return true; + // This operand can no longer be undef since Reg is live-in. + MO.setIsUndef(false); if (isPhysReg && isRegTiedToDefOperand(i)) // Two-address uses of physregs must not be marked kill. return true; Added: llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll?rev=77989&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll Mon Aug 3 15:08:18 2009 @@ -0,0 +1,29 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon +; PR4657 + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64" +target triple = "armv7-apple-darwin9" + +define arm_apcscc <4 x i32> @scale(<4 x i32> %v, i32 %f) nounwind { +entry: + %v_addr = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] + %f_addr = alloca i32 ; [#uses=2] + %retval = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] + %0 = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store <4 x i32> %v, <4 x i32>* %v_addr + store i32 %f, i32* %f_addr + %1 = load <4 x i32>* %v_addr, align 16 ; <<4 x i32>> [#uses=1] + %2 = load i32* %f_addr, align 4 ; [#uses=1] + %3 = insertelement <4 x i32> undef, i32 %2, i32 0 ; <<4 x i32>> [#uses=1] + %4 = shufflevector <4 x i32> %3, <4 x i32> undef, <4 x i32> zeroinitializer ; <<4 x i32>> [#uses=1] + %5 = mul <4 x i32> %1, %4 ; <<4 x i32>> [#uses=1] + store <4 x i32> %5, <4 x i32>* %0, align 16 + %6 = load <4 x i32>* %0, align 16 ; <<4 x i32>> [#uses=1] + store <4 x i32> %6, <4 x i32>* %retval, align 16 + br label %return + +return: ; preds = %entry + %retval1 = load <4 x i32>* %retval ; <<4 x i32>> [#uses=1] + ret <4 x i32> %retval1 +} From isanbard at gmail.com Mon Aug 3 15:17:11 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 3 Aug 2009 13:17:11 -0700 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> References: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> Message-ID: <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> Eli, This is breaking the bootstrap of llvm-gcc: Assertion failed: (C->getType() == Ty->getScalarType() && "ConstantInt type doesn't match the type implied by its value!"), function get, file /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm.src/lib/VMCore/Constants.cpp, line 288. /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm-gcc.src/gcc/cse.c:8188: internal compiler error: Abort trap Please submit a full bug report, with preprocessed source if appropriate. See for instructions. make[3]: *** [cse.o] Error 1 make[3]: *** Waiting for unfinished jobs.... Could you investigate? -bw On Mon, Aug 3, 2009 at 12:15 PM, Eli Friedman wrote: > Author: efriedma > Date: Mon Aug ?3 14:15:42 2009 > New Revision: 77986 > > URL: http://llvm.org/viewvc/llvm-project?rev=77986&view=rev > Log: > Make SimplifyDemandedUseBits generate vector constants where > appropriate. ?Patch per report on llvmdev. ?No testcase because the > original report didn't come with a testcase, and I can't come up with a case > that actually fails. > > > Modified: > ? ?llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=77986&r1=77985&r2=77986&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Aug ?3 14:15:42 2009 > @@ -1014,7 +1014,7 @@ > ? ? if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { > ? ? ? // all known > ? ? ? if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) { > - ? ? ? ?Constant *AndC = ConstantInt::get(*Context, > + ? ? ? ?Constant *AndC = ConstantInt::get(VTy, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ~RHSKnownOne & DemandedMask); > ? ? ? ? Instruction *And = > ? ? ? ? ? BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp"); > @@ -1407,7 +1407,7 @@ > ? // If the client is only demanding bits that we know, return the known > ? // constant. > ? if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { > - ? ?Constant *C = ConstantInt::get(*Context, RHSKnownOne); > + ? ?Constant *C = ConstantInt::get(VTy, RHSKnownOne); > ? ? if (isa(V->getType())) > ? ? ? C = ConstantExpr::getIntToPtr(C, V->getType()); > ? ? return C; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From mrs at apple.com Mon Aug 3 15:22:15 2009 From: mrs at apple.com (Mike Stump) Date: Mon, 3 Aug 2009 13:22:15 -0700 Subject: [llvm-commits] [commit-after-approval] printf("foo %s baz\n", "bar") -> puts("foo bar baz") In-Reply-To: References: Message-ID: <1370445E-DCE1-4ECE-BC23-3F20F488D403@apple.com> On Aug 3, 2009, at 10:48 AM, Ryan Flynn wrote: > given a printf() call format containing a single "%s" conversion > specifier and a constant string parameter, inlines parameter into > format and lowers printf() to puts(). -fno-builtin needs to avoid having this done in general. Some environments are carefully crafted (-ffreestanding -mkernel) and the transform can break them. From stoklund at 2pi.dk Mon Aug 3 15:34:08 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 3 Aug 2009 22:34:08 +0200 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> Message-ID: On 03/08/2009, at 04.23, Evan Cheng wrote: >> The generated code looks like this: >> >> %reg1032 = MOVENCC_z %reg1031 >> %reg1032 = BITTGL %reg1032, 0 >> >> In this case a kill flag is also added to BITTGL, and >> TwoAddressInstructionPass fails to remove it again. Probably because >> it is expecting SSA code as input? > > I am confused. Is BITTGL a two-address instruction? Is MOVENCC_z the > copy instruction? If so, then this is perfectly legal. Yes and Yes, but both can be inserted by copyRegToReg /before/ two- address pass. That means non-SSA instructions before two-address has run. From bob.wilson at apple.com Mon Aug 3 15:37:12 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 03 Aug 2009 20:37:12 -0000 Subject: [llvm-commits] [llvm] r77992 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/vcombine.ll Message-ID: <200908032037.n73KbN7M024487@zion.cs.uiuc.edu> Author: bwilson Date: Mon Aug 3 15:36:38 2009 New Revision: 77992 URL: http://llvm.org/viewvc/llvm-project?rev=77992&view=rev Log: Lower CONCAT_VECTOR during legalization instead of matching it during isel. Add a testcase. Added: llvm/trunk/test/CodeGen/ARM/vcombine.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=77992&r1=77991&r2=77992&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Mon Aug 3 15:36:38 2009 @@ -1267,27 +1267,6 @@ MVT::Other, Ops, 3); } - case ISD::CONCAT_VECTORS: { - MVT VT = Op.getValueType(); - assert(VT.is128BitVector() && Op.getNumOperands() == 2 && - "unexpected CONCAT_VECTORS"); - SDValue N0 = Op.getOperand(0); - SDValue N1 = Op.getOperand(1); - SDNode *Result = - CurDAG->getTargetNode(TargetInstrInfo::IMPLICIT_DEF, dl, VT); - if (N0.getOpcode() != ISD::UNDEF) - Result = CurDAG->getTargetNode(TargetInstrInfo::INSERT_SUBREG, dl, VT, - SDValue(Result, 0), N0, - CurDAG->getTargetConstant(arm_dsubreg_0, - MVT::i32)); - if (N1.getOpcode() != ISD::UNDEF) - Result = CurDAG->getTargetNode(TargetInstrInfo::INSERT_SUBREG, dl, VT, - SDValue(Result, 0), N1, - CurDAG->getTargetConstant(arm_dsubreg_1, - MVT::i32)); - return Result; - } - case ISD::VECTOR_SHUFFLE: { MVT VT = Op.getValueType(); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=77992&r1=77991&r2=77992&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Aug 3 15:36:38 2009 @@ -2312,10 +2312,24 @@ return DAG.getNode(ISD::TRUNCATE, dl, VT, Op); } -static SDValue LowerCONCAT_VECTORS(SDValue Op) { - if (Op.getValueType().is128BitVector() && Op.getNumOperands() == 2) - return Op; - return SDValue(); +static SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) { + // The only time a CONCAT_VECTORS operation can have legal types is when + // two 64-bit vectors are concatenated to a 128-bit vector. + assert(Op.getValueType().is128BitVector() && Op.getNumOperands() == 2 && + "unexpected CONCAT_VECTORS"); + DebugLoc dl = Op.getDebugLoc(); + SDValue Val = DAG.getUNDEF(MVT::v2f64); + SDValue Op0 = Op.getOperand(0); + SDValue Op1 = Op.getOperand(1); + if (Op0.getOpcode() != ISD::UNDEF) + Val = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, MVT::v2f64, Val, + DAG.getNode(ISD::BIT_CONVERT, dl, MVT::f64, Op0), + DAG.getIntPtrConstant(0)); + if (Op1.getOpcode() != ISD::UNDEF) + Val = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, MVT::v2f64, Val, + DAG.getNode(ISD::BIT_CONVERT, dl, MVT::f64, Op1), + DAG.getIntPtrConstant(1)); + return DAG.getNode(ISD::BIT_CONVERT, dl, Op.getValueType(), Val); } SDValue ARMTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) { @@ -2351,7 +2365,7 @@ case ISD::VECTOR_SHUFFLE: return LowerVECTOR_SHUFFLE(Op, DAG); case ISD::SCALAR_TO_VECTOR: return LowerSCALAR_TO_VECTOR(Op, DAG); case ISD::EXTRACT_VECTOR_ELT: return LowerEXTRACT_VECTOR_ELT(Op, DAG); - case ISD::CONCAT_VECTORS: return LowerCONCAT_VECTORS(Op); + case ISD::CONCAT_VECTORS: return LowerCONCAT_VECTORS(Op, DAG); } return SDValue(); } Added: llvm/trunk/test/CodeGen/ARM/vcombine.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vcombine.ll?rev=77992&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vcombine.ll (added) +++ llvm/trunk/test/CodeGen/ARM/vcombine.ll Mon Aug 3 15:36:38 2009 @@ -0,0 +1,36 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon + +define <16 x i8> @vcombine8(<8 x i8>* %A, <8 x i8>* %B) nounwind { + %tmp1 = load <8 x i8>* %A + %tmp2 = load <8 x i8>* %B + %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <16 x i32> + ret <16 x i8> %tmp3 +} + +define <8 x i16> @vcombine16(<4 x i16>* %A, <4 x i16>* %B) nounwind { + %tmp1 = load <4 x i16>* %A + %tmp2 = load <4 x i16>* %B + %tmp3 = shufflevector <4 x i16> %tmp1, <4 x i16> %tmp2, <8 x i32> + ret <8 x i16> %tmp3 +} + +define <4 x i32> @vcombine32(<2 x i32>* %A, <2 x i32>* %B) nounwind { + %tmp1 = load <2 x i32>* %A + %tmp2 = load <2 x i32>* %B + %tmp3 = shufflevector <2 x i32> %tmp1, <2 x i32> %tmp2, <4 x i32> + ret <4 x i32> %tmp3 +} + +define <4 x float> @vcombinefloat(<2 x float>* %A, <2 x float>* %B) nounwind { + %tmp1 = load <2 x float>* %A + %tmp2 = load <2 x float>* %B + %tmp3 = shufflevector <2 x float> %tmp1, <2 x float> %tmp2, <4 x i32> + ret <4 x float> %tmp3 +} + +define <2 x i64> @vcombine64(<1 x i64>* %A, <1 x i64>* %B) nounwind { + %tmp1 = load <1 x i64>* %A + %tmp2 = load <1 x i64>* %B + %tmp3 = shufflevector <1 x i64> %tmp1, <1 x i64> %tmp2, <2 x i32> + ret <2 x i64> %tmp3 +} From eli.friedman at gmail.com Mon Aug 3 15:48:35 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 3 Aug 2009 13:48:35 -0700 Subject: [llvm-commits] [commit-after-approval] printf("foo %s baz\n", "bar") -> puts("foo bar baz") In-Reply-To: <1370445E-DCE1-4ECE-BC23-3F20F488D403@apple.com> References: <1370445E-DCE1-4ECE-BC23-3F20F488D403@apple.com> Message-ID: On Mon, Aug 3, 2009 at 1:22 PM, Mike Stump wrote: > On Aug 3, 2009, at 10:48 AM, Ryan Flynn wrote: >> given a printf() call format containing a single "%s" conversion >> specifier and a constant string parameter, inlines parameter into >> format and lowers printf() to puts(). > > -fno-builtin needs to avoid having this done in general. ?Some > environments are carefully crafted (-ffreestanding -mkernel) and the > transform can break them. That seems tangential; there are all sorts of transformations in SimplifyLibCalls that can break freestanding environments. -Eli From isanbard at gmail.com Mon Aug 3 15:58:13 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 03 Aug 2009 20:58:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r77994 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Message-ID: <200908032058.n73KwKRf025269@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 15:57:57 2009 New Revision: 77994 URL: http://llvm.org/viewvc/llvm-project?rev=77994&view=rev Log: Wow! This is not good. So, it looks like we needed to generate "i8* null" for the last argument of an llvm.eh.selector call for the @finally block. Daniel explained some of the horrid behavior of the exception system. After I recovered from that nightmare, we determined that ObjC needed to handle the @finally as a C++ cleanup method. Hence, the "i8* null". This is only needed in 64-bit mode. Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=77994&r1=77993&r2=77994&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Mon Aug 3 15:57:57 2009 @@ -8229,6 +8229,19 @@ static struct objc_try_context *cur_try_context; +/* LLVM LOCAL begin 7069718 */ +#ifdef ENABLE_LLVM +/* Do nothing (return NULL_TREE). */ +static tree return_null_tree (void); + +tree +return_null_tree (void) +{ + return NULL_TREE; +} +#endif +/* LLVM LOCAL end 7069718 */ + /* This hook, called via lang_eh_runtime_type, generates a runtime object that represents TYPE. For Objective-C, this is just the class name. */ /* ??? Isn't there a class object or some such? Is it easy to get? */ @@ -8312,6 +8325,13 @@ lang_eh_runtime_type = objc_eh_runtime_type; } #endif + + /* LLVM LOCAL begin 7069718 */ +#ifdef ENABLE_LLVM + if (flag_objc_zerocost_exceptions) + lang_eh_catch_all = return_null_tree; +#endif + /* LLVM LOCAL end 7069718 */ } /* Build an EXC_PTR_EXPR, or the moral equivalent. In the case of Darwin, From bob.wilson at apple.com Mon Aug 3 16:18:56 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 03 Aug 2009 21:18:56 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r77998 - /llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Message-ID: <200908032118.n73LIvBC026114@zion.cs.uiuc.edu> Author: bwilson Date: Mon Aug 3 16:18:56 2009 New Revision: 77998 URL: http://llvm.org/viewvc/llvm-project?rev=77998&view=rev Log: Reenable default to Thumb for ARMv7, now that Thumb is working well enough to build libgcc. (Radar 7113812) Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=77998&r1=77997&r2=77998&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Mon Aug 3 16:18:56 2009 @@ -1459,10 +1459,6 @@ /* APPLE LOCAL end ARM interworking */ } -/* LLVM LOCAL */ -/* LLVM does not yet support Thumb2, so Thumb should not be enabled - by default for llvm-gcc. */ -#ifndef ENABLE_LLVM /* APPLE LOCAL begin 6150882 use thumb2 by default for v7 */ /* If we're compiling for v7, we should default to using thumb2 codegen. */ @@ -1470,8 +1466,6 @@ && thumb_option < 0) thumb_option = 1; /* APPLE LOCAL end 6150882 use thumb2 by default for v7 */ -#endif -/* LLVM LOCAL */ if (TARGET_THUMB && !(insn_flags & FL_THUMB)) { From eli.friedman at gmail.com Mon Aug 3 16:19:46 2009 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 3 Aug 2009 14:19:46 -0700 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> References: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> Message-ID: On Mon, Aug 3, 2009 at 1:17 PM, Bill Wendling wrote: > Eli, > > This is breaking the bootstrap of llvm-gcc: > > Assertion failed: (C->getType() == Ty->getScalarType() && "ConstantInt > type doesn't match the type implied by its value!"), function get, > file /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm.src/lib/VMCore/Constants.cpp, > line 288. > /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm-gcc.src/gcc/cse.c:8188: > internal compiler error: Abort trap > Please submit a full bug report, > with preprocessed source if appropriate. > See for instructions. > make[3]: *** [cse.o] Error 1 > make[3]: *** Waiting for unfinished jobs.... > > Could you investigate? llvm-gcc bootstrap seems to work fine on my computer; can you get a failing .bc file? -Eli From isanbard at gmail.com Mon Aug 3 16:23:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 3 Aug 2009 14:23:54 -0700 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: References: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> Message-ID: <16e5fdf90908031423o2b3e508erc07826c5d2f244da@mail.gmail.com> On Mon, Aug 3, 2009 at 2:19 PM, Eli Friedman wrote: > On Mon, Aug 3, 2009 at 1:17 PM, Bill Wendling wrote: >> Eli, >> >> This is breaking the bootstrap of llvm-gcc: >> >> Assertion failed: (C->getType() == Ty->getScalarType() && "ConstantInt >> type doesn't match the type implied by its value!"), function get, >> file /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm.src/lib/VMCore/Constants.cpp, >> line 288. >> /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm-gcc.src/gcc/cse.c:8188: >> internal compiler error: Abort trap >> Please submit a full bug report, >> with preprocessed source if appropriate. >> See for instructions. >> make[3]: *** [cse.o] Error 1 >> make[3]: *** Waiting for unfinished jobs.... >> >> Could you investigate? > > llvm-gcc bootstrap seems to work fine on my computer; can you get a > failing .bc file? > I'll see what I can do, but it's one of the buildbots which is failing, so the files aren't kept around... -bw From clattner at apple.com Mon Aug 3 16:29:24 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 14:29:24 -0700 Subject: [llvm-commits] [llvm] r77987 - in /llvm/trunk/lib/Target/Blackfin: AsmPrinter/BlackfinAsmPrinter.cpp BlackfinISelLowering.cpp BlackfinRegisterInfo.cpp In-Reply-To: <200908031933.n73JX5in022345@zion.cs.uiuc.edu> References: <200908031933.n73JX5in022345@zion.cs.uiuc.edu> Message-ID: <28E42D75-22E4-48E4-923E-0644F7E896C3@apple.com> On Aug 3, 2009, at 12:33 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Mon Aug 3 14:32:30 2009 > New Revision: 77987 > > URL: http://llvm.org/viewvc/llvm-project?rev=77987&view=rev > Log: > Minor stylistic cleanups in the Blackfin target. Very nice, I think that bfin is probably llvm's prettiest and most consistent "best practices" target now :) -Chris From gohman at apple.com Mon Aug 3 16:29:56 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 3 Aug 2009 14:29:56 -0700 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: References: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> Message-ID: <92365DC5-5CB9-4438-B167-17FAEF91DA23@apple.com> On Aug 3, 2009, at 2:19 PM, Eli Friedman wrote: > On Mon, Aug 3, 2009 at 1:17 PM, Bill Wendling > wrote: > >> Eli, >> >> >> >> This is breaking the bootstrap of llvm-gcc: >> >> >> >> Assertion failed: (C->getType() == Ty->getScalarType() && >> "ConstantInt >> >> type doesn't match the type implied by its value!"), function get, >> >> file /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/ >> llvm.src/lib/VMCore/Constants.cpp, >> >> line 288. >> >> /Volumes/Sandbox/Buildbot/llvm/build.llvm-gcc-i386-darwin9/llvm- >> gcc.src/gcc/cse.c:8188: >> >> internal compiler error: Abort trap >> >> Please submit a full bug report, >> >> with preprocessed source if appropriate. >> >> See for instructions. >> >> make[3]: *** [cse.o] Error 1 >> >> make[3]: *** Waiting for unfinished jobs.... >> >> >> >> Could you investigate? >> > > llvm-gcc bootstrap seems to work fine on my computer; can you get a > failing .bc file? I reproduced the failure. The problem is that VTy can have pointer type. I'll check in a fix shortly. Dan From clattner at apple.com Mon Aug 3 16:32:22 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 14:32:22 -0700 Subject: [llvm-commits] [commit-after-approval] printf("foo %s baz\n", "bar") -> puts("foo bar baz") In-Reply-To: References: <1370445E-DCE1-4ECE-BC23-3F20F488D403@apple.com> Message-ID: <20987922-EF7B-4B74-86DE-FD188C2BB686@apple.com> On Aug 3, 2009, at 1:48 PM, Eli Friedman wrote: > On Mon, Aug 3, 2009 at 1:22 PM, Mike Stump wrote: >> On Aug 3, 2009, at 10:48 AM, Ryan Flynn wrote: >>> given a printf() call format containing a single "%s" conversion >>> specifier and a constant string parameter, inlines parameter into >>> format and lowers printf() to puts(). >> >> -fno-builtin needs to avoid having this done in general. Some >> environments are carefully crafted (-ffreestanding -mkernel) and the >> transform can break them. > > That seems tangential; there are all sorts of transformations in > SimplifyLibCalls that can break freestanding environments. Right, simplifylibcalls is libc specific, llvm-gcc and clang shouldn't run it in free standing mode. I'm pretty sure that at least llvm-gcc gets this right. -Chris From evan.cheng at apple.com Mon Aug 3 16:37:09 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 14:37:09 -0700 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> Message-ID: On Aug 3, 2009, at 1:34 PM, Jakob Stoklund Olesen wrote: > > On 03/08/2009, at 04.23, Evan Cheng wrote: > >>> The generated code looks like this: >>> >>> %reg1032 = MOVENCC_z %reg1031 >>> %reg1032 = BITTGL %reg1032, 0 >>> >>> In this case a kill flag is also added to BITTGL, and >>> TwoAddressInstructionPass fails to remove it again. Probably because >>> it is expecting SSA code as input? >> >> I am confused. Is BITTGL a two-address instruction? Is MOVENCC_z the >> copy instruction? If so, then this is perfectly legal. > > Yes and Yes, but both can be inserted by copyRegToReg /before/ two- > address pass. That means non-SSA instructions before two-address has > run. Hrm. It's not legal to insert non-ssa instructions before 2addr pass. Evan > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Mon Aug 3 16:38:45 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 3 Aug 2009 14:38:45 -0700 Subject: [llvm-commits] [llvm] r77986 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp In-Reply-To: <92365DC5-5CB9-4438-B167-17FAEF91DA23@apple.com> References: <200908031915.n73JFuTZ021665@zion.cs.uiuc.edu> <16e5fdf90908031317p2b588a6cr4977b247f580222e@mail.gmail.com> <92365DC5-5CB9-4438-B167-17FAEF91DA23@apple.com> Message-ID: <16e5fdf90908031438y652e76b0xe191c9efe063d324@mail.gmail.com> On Mon, Aug 3, 2009 at 2:29 PM, Dan Gohman wrote: > I reproduced the failure. The problem is that VTy can have > pointer type. I'll check in a fix shortly. > Thanks, Dan. I have a .bc file if you want it... -bw From evan.cheng at apple.com Mon Aug 3 16:40:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 14:40:24 -0700 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> Message-ID: On Aug 3, 2009, at 1:08 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Mon Aug 3 15:08:18 2009 > New Revision: 77989 > > URL: http://llvm.org/viewvc/llvm-project?rev=77989&view=rev > Log: > Fix Bug 4657: register scavenger asserts with subreg lowering > > When LowerSubregsInstructionPass::LowerInsert eliminates an > INSERT_SUBREG > instriction because it is an identity copy, make sure that the same > registers > are alive before and after the elimination. > > When the super-register is marked this requires inserting an > IMPLICIT_DEF instruction to make sure the super register is live. > > Fix a related bug where a kill flag on the inserted sub-register was > not transferred properly. Thanks! > > Finally, clear the undef flag in MachineInstr::addRegisterKilled. > Undef implies dead and kill implies live, so they cant both be valid. That's not necessary. Undef doesn't implies dead. It just means its garbage and it has no liveness. Evan > > Added: > llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll > Modified: > llvm/trunk/lib/CodeGen/LowerSubregs.cpp > llvm/trunk/lib/CodeGen/MachineInstr.cpp > > Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=77989&r1=77988&r2=77989&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original) > +++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Mon Aug 3 15:08:18 2009 > @@ -19,6 +19,7 @@ > #include "llvm/Function.h" > #include "llvm/CodeGen/MachineFunctionPass.h" > #include "llvm/CodeGen/MachineInstr.h" > +#include "llvm/CodeGen/MachineInstrBuilder.h" > #include "llvm/CodeGen/MachineRegisterInfo.h" > #include "llvm/Target/TargetRegisterInfo.h" > #include "llvm/Target/TargetInstrInfo.h" > @@ -130,6 +131,7 @@ > MII != MBB->end(); ++MII) > if (MII->killsRegister(DstReg, &TRI)) { > MII->addRegisterKilled(SuperReg, &TRI, /*AddIfNotFound=*/ > true); > + DOUT << "\nsubreg: killed here: " << *MII; > break; > } > } else { > @@ -231,7 +233,7 @@ > assert(DstReg == SrcReg && "insert_subreg not a two-address > instruction?"); > assert(SubIdx != 0 && "Invalid index for insert_subreg"); > unsigned DstSubReg = TRI.getSubReg(DstReg, SubIdx); > - > + assert(DstSubReg && "invalid subregister index for register"); > assert(TargetRegisterInfo::isPhysicalRegister(SrcReg) && > "Insert superreg source must be in a physical register"); > assert(TargetRegisterInfo::isPhysicalRegister(InsReg) && > @@ -240,24 +242,45 @@ > DOUT << "subreg: CONVERTING: " << *MI; > > if (DstSubReg == InsReg) { > - // No need to insert an identify copy instruction. > - DOUT << "subreg: eliminated!"; > + // No need to insert an identity copy instruction. If the > SrcReg was > + // , we need to make sure it is alive by inserting an > IMPLICIT_DEF > + if (MI->getOperand(1).isUndef() && !MI->getOperand(0).isDead()) { > + BuildMI(*MBB, MI, MI->getDebugLoc(), > + TII.get(TargetInstrInfo::IMPLICIT_DEF), DstReg) > + .addReg(InsReg, RegState::ImplicitKill); > + } else { > + DOUT << "subreg: eliminated!\n"; > + MBB->erase(MI); > + return true; > + } > } else { > // Insert sub-register copy > const TargetRegisterClass *TRC0= TRI.getPhysicalRegisterRegClass > (DstSubReg); > const TargetRegisterClass *TRC1= TRI.getPhysicalRegisterRegClass > (InsReg); > TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1); > + MachineBasicBlock::iterator CopyMI = MI; > + --CopyMI; > + > // Transfer the kill/dead flags, if needed. > - if (MI->getOperand(0).isDead()) > + if (MI->getOperand(0).isDead()) { > TransferDeadFlag(MI, DstSubReg, TRI); > - if (MI->getOperand(1).isKill()) > + // Also add a SrcReg of the super register. > + CopyMI->addOperand(MachineOperand::CreateReg(DstReg, false, > true, true)); > + } else if (MI->getOperand(1).isUndef()) { > + // If SrcReg was marked we must make sure it is alive > after this > + // replacement. Add a SrcReg operand. > + CopyMI->addOperand(MachineOperand::CreateReg(DstReg, true, > true)); > + } > + > + // Make sure the inserted register gets killed > + if (MI->getOperand(2).isKill()) > TransferKillFlag(MI, InsReg, TRI); > + } > > #ifndef NDEBUG > - MachineBasicBlock::iterator dMI = MI; > - DOUT << "subreg: " << *(--dMI); > + MachineBasicBlock::iterator dMI = MI; > + DOUT << "subreg: " << *(--dMI); > #endif > - } > > DOUT << "\n"; > MBB->erase(MI); > > Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=77989&r1=77988&r2=77989&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Aug 3 15:08:18 2009 > @@ -1041,6 +1041,8 @@ > if (MO.isKill()) > // The register is already marked kill. > return true; > + // This operand can no longer be undef since Reg is live-in. > + MO.setIsUndef(false); > if (isPhysReg && isRegTiedToDefOperand(i)) > // Two-address uses of physregs must not be marked kill. > return true; > > Added: llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert- > Neon.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll?rev=77989&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert- > Neon.ll (added) > +++ llvm/trunk/test/CodeGen/ARM/2009-08-02-RegScavengerAssert- > Neon.ll Mon Aug 3 15:08:18 2009 > @@ -0,0 +1,29 @@ > +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > +; PR4657 > + > +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64" > +target triple = "armv7-apple-darwin9" > + > +define arm_apcscc <4 x i32> @scale(<4 x i32> %v, i32 %f) nounwind { > +entry: > + %v_addr = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] > + %f_addr = alloca i32 ; [#uses=2] > + %retval = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] > + %0 = alloca <4 x i32> ; <<4 x i32>*> [#uses=2] > + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] > + store <4 x i32> %v, <4 x i32>* %v_addr > + store i32 %f, i32* %f_addr > + %1 = load <4 x i32>* %v_addr, align 16 ; <<4 x i32>> [#uses=1] > + %2 = load i32* %f_addr, align 4 ; [#uses=1] > + %3 = insertelement <4 x i32> undef, i32 %2, i32 0 ; <<4 x i32>> > [#uses=1] > + %4 = shufflevector <4 x i32> %3, <4 x i32> undef, <4 x i32> > zeroinitializer ; <<4 x i32>> [#uses=1] > + %5 = mul <4 x i32> %1, %4 ; <<4 x i32>> [#uses=1] > + store <4 x i32> %5, <4 x i32>* %0, align 16 > + %6 = load <4 x i32>* %0, align 16 ; <<4 x i32>> [#uses=1] > + store <4 x i32> %6, <4 x i32>* %retval, align 16 > + br label %return > + > +return: ; preds = %entry > + %retval1 = load <4 x i32>* %retval ; <<4 x i32>> [#uses=1] > + ret <4 x i32> %retval1 > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Aug 3 16:53:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 21:53:27 -0000 Subject: [llvm-commits] [llvm] r78002 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200908032153.n73LrRkY027499@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 16:53:27 2009 New Revision: 78002 URL: http://llvm.org/viewvc/llvm-project?rev=78002&view=rev Log: Eliminate textual section switching from the x86 backend, one more step towards "semantics sections" Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78002&r1=78001&r2=78002&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Mon Aug 3 16:53:27 2009 @@ -26,7 +26,6 @@ class Mangler; class TargetMachine; - class TargetLoweringObjectFile { MCContext *Ctx; protected: @@ -250,6 +249,11 @@ /// FIXME: REMOVE this (rdar://7071300) virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *) const; + + /// getMachOSection - Return the MCSection for the specified mach-o section. + /// FIXME: Switch this to a semantic view eventually. + const MCSection *getMachOSection(const char *Name, bool isDirective, + SectionKind K); }; @@ -264,6 +268,11 @@ virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const; + + /// getCOFFSection - Return the MCSection for the specified COFF section. + /// FIXME: Switch this to a semantic view eventually. + const MCSection *getCOFFSection(const char *Name, bool isDirective, + SectionKind K); }; } // end namespace llvm Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78002&r1=78001&r2=78002&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Aug 3 16:53:27 2009 @@ -532,6 +532,14 @@ // MachO //===----------------------------------------------------------------------===// +const MCSection *TargetLoweringObjectFileMachO:: +getMachOSection(const char *Name, bool isDirective, SectionKind K) { + // FOR NOW, Just forward. + return getOrCreateSection(Name, isDirective, K); +} + + + void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, const TargetMachine &TM) { TargetLoweringObjectFile::Initialize(Ctx, TM); @@ -733,6 +741,11 @@ // COFF //===----------------------------------------------------------------------===// +const MCSection *TargetLoweringObjectFileCOFF:: +getCOFFSection(const char *Name, bool isDirective, SectionKind K) { + return getOrCreateSection(Name, isDirective, K); +} + void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, const TargetMachine &TM) { TargetLoweringObjectFile::Initialize(Ctx, TM); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=78002&r1=78001&r2=78002&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Aug 3 16:53:27 2009 @@ -899,8 +899,9 @@ } if (Subtarget->isTargetDarwin()) { - //TargetLoweringObjectFileMachO &TLOFMacho = - // static_cast(getObjFileLowering()); + // All darwin targets use mach-o. + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast(getObjFileLowering()); // Add the (possibly multiple) personalities to the set of global value // stubs. Only referenced functions get into the Personalities list. @@ -916,8 +917,11 @@ // Output stubs for dynamically-linked functions if (!FnStubs.empty()) { - SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs," - "self_modifying_code+pure_instructions,5", 0); + const MCSection *TheSection = + TLOFMacho.getMachOSection("\t.section __IMPORT,__jump_table,symbol_stubs," + "self_modifying_code+pure_instructions,5", true, + SectionKind::getMetadata()); + SwitchToSection(TheSection); for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) O << I->getKeyData() << ":\n" << "\t.indirect_symbol " << I->second @@ -927,8 +931,11 @@ // Output stubs for external and common global variables. if (!GVStubs.empty()) { - SwitchToDataSection( - "\t.section __IMPORT,__pointers,non_lazy_symbol_pointers"); + const MCSection *TheSection = + TLOFMacho.getMachOSection("\t.section __IMPORT,__pointers," + "non_lazy_symbol_pointers", true, + SectionKind::getMetadata()); + SwitchToSection(TheSection); for (StringMap::iterator I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) O << I->getKeyData() << ":\n\t.indirect_symbol " @@ -963,16 +970,17 @@ // Output linker support code for dllexported globals on windows. - if (!DLLExportedGVs.empty()) { - SwitchToDataSection(".section .drectve"); + if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) { + // dllexport symbols only exist on coff targets. + TargetLoweringObjectFileCOFF &TLOFMacho = + static_cast(getObjFileLowering()); + + SwitchToSection(TLOFMacho.getCOFFSection(".section .drectve", true, + SectionKind::getMetadata())); for (StringSet<>::iterator i = DLLExportedGVs.begin(), e = DLLExportedGVs.end(); i != e; ++i) O << "\t.ascii \" -export:" << i->getKeyData() << ",data\"\n"; - } - - if (!DLLExportedFns.empty()) { - SwitchToDataSection(".section .drectve"); for (StringSet<>::iterator i = DLLExportedFns.begin(), e = DLLExportedFns.end(); From greened at obbligato.org Mon Aug 3 16:55:09 2009 From: greened at obbligato.org (David Greene) Date: Mon, 03 Aug 2009 21:55:09 -0000 Subject: [llvm-commits] [llvm] r78003 - in /llvm/trunk: include/llvm/CodeGen/Dump.h include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/MachineBasicBlock.h include/llvm/CodeGen/MachineFunction.h lib/CodeGen/Dump.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/MachineBasicBlock.cpp lib/CodeGen/MachineFunction.cpp Message-ID: <200908032155.n73Lt9fI027569@zion.cs.uiuc.edu> Author: greened Date: Mon Aug 3 16:55:09 2009 New Revision: 78003 URL: http://llvm.org/viewvc/llvm-project?rev=78003&view=rev Log: Re-apply LiveInterval index dumping patch, with fixes suggested by Bill and others. Added: llvm/trunk/include/llvm/CodeGen/Dump.h llvm/trunk/lib/CodeGen/Dump.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp Added: llvm/trunk/include/llvm/CodeGen/Dump.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Dump.h?rev=78003&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Dump.h (added) +++ llvm/trunk/include/llvm/CodeGen/Dump.h Mon Aug 3 16:55:09 2009 @@ -0,0 +1,60 @@ +//===- llvm/Support/Dump.h - Easy way to tailor dump output -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides the PrefixPrinter interface to pass to MachineFunction +// and MachineBasicBlock print methods to output additional information before +// blocks and instructions are printed. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_DUMP_H +#define LLVM_CODEGEN_DUMP_H + +#include + +namespace llvm { + +class MachineBasicBlock; +class MachineInstr; +class raw_ostream; + +/// PrefixPrinter - Print some additional information before printing +/// basic blocks and instructions. +class PrefixPrinter { +public: + virtual ~PrefixPrinter(); + + /// operator() - Print a prefix before each MachineBasicBlock + virtual raw_ostream &operator()(raw_ostream &out, + const MachineBasicBlock &) const { + return out; + } + + /// operator() - Print a prefix before each MachineInstr + virtual raw_ostream &operator()(raw_ostream &out, + const MachineInstr &) const { + return out; + } + + /// operator() - Print a prefix before each MachineBasicBlock + virtual std::ostream &operator()(std::ostream &out, + const MachineBasicBlock &) const { + return out; + } + + /// operator() - Print a prefix before each MachineInstr + virtual std::ostream &operator()(std::ostream &out, + const MachineInstr &) const { + return out; + } +}; + +} // End llvm namespace + +#endif Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Aug 3 16:55:09 2009 @@ -538,6 +538,37 @@ void printRegName(unsigned reg) const; }; + /// IntervalPrefixPrinter - Print live interval indices before each + /// instruction. + class IntervalPrefixPrinter : public PrefixPrinter { + private: + const LiveIntervals &liinfo; + + public: + IntervalPrefixPrinter(const LiveIntervals &lii) + : liinfo(lii) {}; + + // We need null implementations of the other virtual functions to + // avoid warnings about hidden virtual functions. + + raw_ostream &operator()(raw_ostream &out, + const MachineBasicBlock &instr) const { + return out; + } + + raw_ostream &operator()(raw_ostream &out, + const MachineInstr &instr) const; + + std::ostream &operator()(std::ostream &out, + const MachineBasicBlock &instr) const { + return out; + } + + std::ostream &operator()(std::ostream &out, + const MachineInstr &instr) const { + return out; + } + }; } // End llvm namespace #endif Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Mon Aug 3 16:55:09 2009 @@ -16,6 +16,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/ADT/GraphTraits.h" +#include "llvm/CodeGen/Dump.h" namespace llvm { @@ -310,10 +311,18 @@ // Debugging methods. void dump() const; - void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } - void print(raw_ostream &OS) const; - void print(raw_ostream *OS) const { if (OS) print(*OS); } + void print(std::ostream &OS, + const PrefixPrinter &prefix = PrefixPrinter()) const; + void print(std::ostream *OS, + const PrefixPrinter &prefix = PrefixPrinter()) const { + if (OS) print(*OS, prefix); + } + void print(raw_ostream &OS, + const PrefixPrinter &prefix = PrefixPrinter()) const; + void print(raw_ostream *OS, + const PrefixPrinter &prefix = PrefixPrinter()) const { + if (OS) print(*OS, prefix); + } /// getNumber - MachineBasicBlocks are uniquely numbered at the function /// level, unless they're not in a MachineFunction yet, in which case this Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Mon Aug 3 16:55:09 2009 @@ -20,6 +20,7 @@ #include "llvm/ADT/ilist.h" #include "llvm/Support/DebugLoc.h" +#include "llvm/CodeGen/Dump.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Recycler.h" @@ -206,8 +207,12 @@ /// print - Print out the MachineFunction in a format suitable for debugging /// to the specified stream. /// - void print(std::ostream &OS) const; - void print(std::ostream *OS) const { if (OS) print(*OS); } + void print(std::ostream &OS, + const PrefixPrinter &prefix = PrefixPrinter()) const; + void print(std::ostream *OS, + const PrefixPrinter &prefix = PrefixPrinter()) const { + if (OS) print(*OS, prefix); + } /// viewCFG - This function is meant for use from the debugger. You can just /// say 'call F->viewCFG()' and a ghostview window should pop up from the Added: llvm/trunk/lib/CodeGen/Dump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Dump.cpp?rev=78003&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/Dump.cpp (added) +++ llvm/trunk/lib/CodeGen/Dump.cpp Mon Aug 3 16:55:09 2009 @@ -0,0 +1,18 @@ +//===- lib/Support/Dump.h - Virtual function homes --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides the PrefixPrinter virtual function homes. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/Dump.h" + +using namespace llvm; + +PrefixPrinter::~PrefixPrinter() {} Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Aug 3 16:55:09 2009 @@ -2501,3 +2501,9 @@ return LR; } + +raw_ostream & +IntervalPrefixPrinter::operator()(raw_ostream &out, + const MachineInstr &instr) const { + return out << liinfo.getInstructionIndex(&instr); +} Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Mon Aug 3 16:55:09 2009 @@ -153,12 +153,14 @@ os << " %reg" << RegNo; } -void MachineBasicBlock::print(std::ostream &OS) const { +void MachineBasicBlock::print(std::ostream &OS, + const PrefixPrinter &prefix) const { raw_os_ostream RawOS(OS); - print(RawOS); + print(RawOS, prefix); } -void MachineBasicBlock::print(raw_ostream &OS) const { +void MachineBasicBlock::print(raw_ostream &OS, + const PrefixPrinter &prefix) const { const MachineFunction *MF = getParent(); if(!MF) { OS << "Can't print out MachineBasicBlock because parent MachineFunction" @@ -191,7 +193,7 @@ } for (const_iterator I = begin(); I != end(); ++I) { - OS << "\t"; + prefix(OS, *I) << "\t"; I->print(OS, &getParent()->getTarget()); } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=78003&r1=78002&r2=78003&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Aug 3 16:55:09 2009 @@ -218,7 +218,8 @@ print(*cerr.stream()); } -void MachineFunction::print(std::ostream &OS) const { +void MachineFunction::print(std::ostream &OS, + const PrefixPrinter &prefix) const { OS << "# Machine code for " << Fn->getNameStr () << "():\n"; // Print Frame Information @@ -260,8 +261,10 @@ OS << "\n"; } - for (const_iterator BB = begin(); BB != end(); ++BB) - BB->print(OS); + for (const_iterator BB = begin(); BB != end(); ++BB) { + prefix(OS, *BB); + BB->print(OS, prefix); + } OS << "\n# End machine code for " << Fn->getNameStr () << "().\n\n"; } From sabre at nondot.org Mon Aug 3 16:57:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 21:57:05 -0000 Subject: [llvm-commits] [llvm] r78004 - /llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Message-ID: <200908032157.n73Lv609027658@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 16:57:00 2009 New Revision: 78004 URL: http://llvm.org/viewvc/llvm-project?rev=78004&view=rev Log: this really shouldn't switch sections without telling the asmprinter, but hey it uses .previous, so it should work :) Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Modified: llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp?rev=78004&r1=78003&r2=78004&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp Mon Aug 3 16:57:00 2009 @@ -421,7 +421,7 @@ } bool MipsAsmPrinter::doInitialization(Module &M) { - // FIXME: Use SwitchToDataSection. + // FIXME: Use SwitchToSection. // Tell the assembler which ABI we are using O << "\t.section .mdebug." << emitCurrentABIString() << '\n'; From gohman at apple.com Mon Aug 3 17:07:34 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 03 Aug 2009 22:07:34 -0000 Subject: [llvm-commits] [llvm] r78005 - in /llvm/trunk: include/llvm/Constant.h lib/Transforms/Scalar/InstructionCombining.cpp lib/VMCore/Constants.cpp test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Message-ID: <200908032207.n73M7Ypq028151@zion.cs.uiuc.edu> Author: djg Date: Mon Aug 3 17:07:33 2009 New Revision: 78005 URL: http://llvm.org/viewvc/llvm-project?rev=78005&view=rev Log: Add a new Constant::getIntegerValue helper function, and convert a few places in InstCombine to use it, to fix problems handling pointer types. This fixes the recent llvm-gcc bootstrap error. Added: llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Modified: llvm/trunk/include/llvm/Constant.h llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/include/llvm/Constant.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constant.h?rev=78005&r1=78004&r2=78005&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constant.h (original) +++ llvm/trunk/include/llvm/Constant.h Mon Aug 3 17:07:33 2009 @@ -17,6 +17,8 @@ #include "llvm/User.h" namespace llvm { + class APInt; + template class SmallVectorImpl; class LLVMContext; @@ -142,6 +144,10 @@ /// its bits set to true. /// @brief Get the all ones value static Constant* getAllOnesValue(const Type* Ty); + + /// getIntegerValue - Return the value for an integer or pointer constant, + /// or a vector thereof, with the given scalar value. + static Constant* getIntegerValue(const Type* Ty, const APInt &V); }; } // End llvm namespace Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=78005&r1=78004&r2=78005&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Aug 3 17:07:33 2009 @@ -1014,8 +1014,8 @@ if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { // all known if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) { - Constant *AndC = ConstantInt::get(VTy, - ~RHSKnownOne & DemandedMask); + Constant *AndC = Constant::getIntegerValue(VTy, + ~RHSKnownOne & DemandedMask); Instruction *And = BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp"); return InsertNewInstBefore(And, *I); @@ -1406,12 +1406,8 @@ // If the client is only demanding bits that we know, return the known // constant. - if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { - Constant *C = ConstantInt::get(VTy, RHSKnownOne); - if (isa(V->getType())) - C = ConstantExpr::getIntToPtr(C, V->getType()); - return C; - } + if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) + return Constant::getIntegerValue(VTy, RHSKnownOne); return false; } Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=78005&r1=78004&r2=78005&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Aug 3 17:07:33 2009 @@ -70,6 +70,23 @@ } } +Constant* Constant::getIntegerValue(const Type* Ty, const APInt &V) { + const Type *ScalarTy = Ty->getScalarType(); + + // Create the base integer constant. + Constant *C = ConstantInt::get(Ty->getContext(), V); + + // Convert an integer to a pointer, if necessary. + if (const PointerType *PTy = dyn_cast(ScalarTy)) + C = ConstantExpr::getIntToPtr(C, PTy); + + // Broadcast a scalar to a vector, if necessary. + if (const VectorType *VTy = dyn_cast(Ty)) + C = ConstantVector::get(std::vector(VTy->getNumElements(), C)); + + return C; +} + Constant* Constant::getAllOnesValue(const Type* Ty) { if (const IntegerType* ITy = dyn_cast(Ty)) return ConstantInt::get(Ty->getContext(), Added: llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll?rev=78005&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Mon Aug 3 17:07:33 2009 @@ -0,0 +1,84 @@ +; RUN: llvm-as < %s | opt -instcombine + +; SimplifyDemandedBits should cope with pointer types. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + %struct.VEC_rtx_base = type { i32, i32, [1 x %struct.rtx_def*] } + %struct.VEC_rtx_gc = type { %struct.VEC_rtx_base } + %struct.block_symbol = type { [3 x %struct.rtunion], %struct.object_block*, i64 } + %struct.object_block = type { %struct.section*, i32, i64, %struct.VEC_rtx_gc*, %struct.VEC_rtx_gc* } + %struct.omp_clause_subcode = type { i32 } + %struct.rtunion = type { i8* } + %struct.rtx_def = type { i16, i8, i8, %struct.u } + %struct.section = type { %struct.unnamed_section } + %struct.u = type { %struct.block_symbol } + %struct.unnamed_section = type { %struct.omp_clause_subcode, void (i8*)*, i8*, %struct.section* } + +define fastcc void @cse_insn(%struct.rtx_def* %insn, %struct.rtx_def* %libcall_insn) nounwind { +entry: + br i1 undef, label %bb43, label %bb88 + +bb43: ; preds = %entry + br label %bb88 + +bb88: ; preds = %bb43, %entry + br i1 undef, label %bb95, label %bb107 + +bb95: ; preds = %bb88 + unreachable + +bb107: ; preds = %bb88 + %0 = load i16* undef, align 8 ; [#uses=1] + %1 = icmp eq i16 %0, 38 ; [#uses=1] + %src_eqv_here.0 = select i1 %1, %struct.rtx_def* null, %struct.rtx_def* null ; <%struct.rtx_def*> [#uses=1] + br i1 undef, label %bb127, label %bb125 + +bb125: ; preds = %bb107 + br i1 undef, label %bb127, label %bb126 + +bb126: ; preds = %bb125 + br i1 undef, label %bb129, label %bb133 + +bb127: ; preds = %bb125, %bb107 + unreachable + +bb129: ; preds = %bb126 + br label %bb133 + +bb133: ; preds = %bb129, %bb126 + br i1 undef, label %bb134, label %bb146 + +bb134: ; preds = %bb133 + unreachable + +bb146: ; preds = %bb133 + br i1 undef, label %bb180, label %bb186 + +bb180: ; preds = %bb146 + %2 = icmp eq %struct.rtx_def* null, null ; [#uses=1] + %3 = zext i1 %2 to i8 ; [#uses=1] + %4 = icmp ne %struct.rtx_def* %src_eqv_here.0, null ; [#uses=1] + %5 = zext i1 %4 to i8 ; [#uses=1] + %toBool181 = icmp ne i8 %3, 0 ; [#uses=1] + %toBool182 = icmp ne i8 %5, 0 ; [#uses=1] + %6 = and i1 %toBool181, %toBool182 ; [#uses=1] + %7 = zext i1 %6 to i8 ; [#uses=1] + %toBool183 = icmp ne i8 %7, 0 ; [#uses=1] + br i1 %toBool183, label %bb184, label %bb186 + +bb184: ; preds = %bb180 + br i1 undef, label %bb185, label %bb186 + +bb185: ; preds = %bb184 + br label %bb186 + +bb186: ; preds = %bb185, %bb184, %bb180, %bb146 + br i1 undef, label %bb190, label %bb195 + +bb190: ; preds = %bb186 + unreachable + +bb195: ; preds = %bb186 + unreachable +} From dag at cray.com Mon Aug 3 17:11:30 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 17:11:30 -0500 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <200908031705.59956.dag@cray.com> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <200908031146.20758.greened@obbligato.org> <200908031705.59956.dag@cray.com> Message-ID: <200908031711.30871.dag@cray.com> On Monday 03 August 2009 17:05, David Greene wrote: > On Monday 03 August 2009 11:46, David A. Greene wrote: > > > I'm not following what you mean here. Can you give me an example that > > > shows what this does? > > > > Oh! This changed since the last time I looked at it. It used to be that > > the tabs were embedded into the AsmStrs array and some opcodes had tabs > > after them and others didn't. I see now that in X86GenAsmWriter1.inc the > > asm boilerplate emits the tab after the opcode: > > > > O << "\t"; > > Oh, never mind. This is the tab to align the mnemonics. > > It still changed though. There used to be tabs embedded in AsmStrs. Now I > don't know how they get generated. > > I am thoroughly confused now. :-/ Confusion ended. Of course this changed with the definition of PadToColumn in AsmPrinter: void AsmPrinter::PadToColumn(unsigned Operand) const { if (getOperandColumn(Operand) > 0) { O.PadToColumn(getOperandColumn(Operand), 1); } else { if (Operand == 1) { // Emit the tab after the mnemonic. O << '\t'; } else { // Replace the tab with a space. O << ' '; } } } AsmWriterEmitter no longer emits tabs into the AsmStrs because of this. So you're right, all this ugly complexity can go away. Hmm...except this probably doesn't work for "pd" suffixed mnemonics as I pointed out earlier. So there's a bug here. I'll figure that out. -Dave From sabre at nondot.org Mon Aug 3 17:16:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 22:16:58 -0000 Subject: [llvm-commits] [llvm] r78006 - /llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200908032216.n73MGxHF028407@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 17:16:57 2009 New Revision: 78006 URL: http://llvm.org/viewvc/llvm-project?rev=78006&view=rev Log: hoist some common code out of a switch Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=78006&r1=78005&r2=78006&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Aug 3 17:16:57 2009 @@ -169,23 +169,22 @@ DecorateCygMingName(CurrentFnName, F); SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); + EmitAlignment(FnAlign, F); + switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); case Function::InternalLinkage: // Symbols default to internal. case Function::PrivateLinkage: case Function::LinkerPrivateLinkage: - EmitAlignment(FnAlign, F); break; case Function::DLLExportLinkage: case Function::ExternalLinkage: - EmitAlignment(FnAlign, F); O << "\t.globl\t" << CurrentFnName << '\n'; break; case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: case Function::WeakAnyLinkage: case Function::WeakODRLinkage: - EmitAlignment(FnAlign, F); if (Subtarget->isTargetDarwin()) { O << "\t.globl\t" << CurrentFnName << '\n'; O << TAI->getWeakDefDirective() << CurrentFnName << '\n'; From sabre at nondot.org Mon Aug 3 17:18:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 22:18:16 -0000 Subject: [llvm-commits] [llvm] r78007 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200908032218.n73MIGOI028459@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 17:18:15 2009 New Revision: 78007 URL: http://llvm.org/viewvc/llvm-project?rev=78007&view=rev Log: convert macho stub emission to use SwitchToSection instead of textual sections. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78007&r1=78006&r2=78007&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Aug 3 17:18:15 2009 @@ -1269,49 +1269,65 @@ bool ARMAsmPrinter::doFinalization(Module &M) { if (Subtarget->isTargetDarwin()) { - SwitchToDataSection(""); - + // All darwin targets use mach-o. + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast(getObjFileLowering()); + O << '\n'; - // Output stubs for dynamically-linked functions - for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); - I != E; ++I) { - const FnStubInfo &Info = I->second; + + if (!FnStubs.empty()) { + const MCSection *StubSection; if (TM.getRelocationModel() == Reloc::PIC_) - SwitchToTextSection(".section __TEXT,__picsymbolstub4,symbol_stubs," - "none,16", 0); + StubSection = TLOFMacho.getMachOSection(".section __TEXT,__picsymbolstu" + "b4,symbol_stubs,none,16", true, + SectionKind::getText()); else - SwitchToTextSection(".section __TEXT,__symbol_stub4,symbol_stubs," - "none,12", 0); - - EmitAlignment(2); - O << "\t.code\t32\n"; + StubSection = TLOFMacho.getMachOSection(".section __TEXT,__symbol_stub4" + ",symbol_stubs,none,12", true, + SectionKind::getText()); + + const MCSection *LazySymbolPointerSection + = TLOFMacho.getMachOSection(".lazy_symbol_pointer", true, + SectionKind::getMetadata()); + + // Output stubs for dynamically-linked functions + for (StringMap::iterator I = FnStubs.begin(), + E = FnStubs.end(); I != E; ++I) { + const FnStubInfo &Info = I->second; + + SwitchToSection(StubSection); + EmitAlignment(2); + O << "\t.code\t32\n"; - O << Info.Stub << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; - O << "\tldr ip, " << Info.SLP << '\n'; - if (TM.getRelocationModel() == Reloc::PIC_) { - O << Info.SCV << ":\n"; - O << "\tadd ip, pc, ip\n"; + O << Info.Stub << ":\n"; + O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\tldr ip, " << Info.SLP << '\n'; + if (TM.getRelocationModel() == Reloc::PIC_) { + O << Info.SCV << ":\n"; + O << "\tadd ip, pc, ip\n"; + } + O << "\tldr pc, [ip, #0]\n"; + O << Info.SLP << ":\n"; + O << "\t.long\t" << Info.LazyPtr; + if (TM.getRelocationModel() == Reloc::PIC_) + O << "-(" << Info.SCV << "+8)"; + O << '\n'; + + SwitchToSection(LazySymbolPointerSection); + O << Info.LazyPtr << ":\n"; + O << "\t.indirect_symbol " << I->getKeyData() << "\n"; + O << "\t.long\tdyld_stub_binding_helper\n"; } - O << "\tldr pc, [ip, #0]\n"; - O << Info.SLP << ":\n"; - O << "\t.long\t" << Info.LazyPtr; - if (TM.getRelocationModel() == Reloc::PIC_) - O << "-(" << Info.SCV << "+8)"; O << '\n'; - - SwitchToDataSection(".lazy_symbol_pointer", 0); - O << Info.LazyPtr << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << "\n"; - O << "\t.long\tdyld_stub_binding_helper\n"; } - O << '\n'; - + // Output non-lazy-pointers for external and common global variables. if (!GVNonLazyPtrs.empty()) { - SwitchToDataSection("\t.non_lazy_symbol_pointer", 0); - for (StringMap::iterator I = GVNonLazyPtrs.begin(), - E = GVNonLazyPtrs.end(); I != E; ++I) { + SwitchToSection(TLOFMacho.getMachOSection(".non_lazy_symbol_pointer", + true, + SectionKind::getMetadata())); + for (StringMap::iterator I = GVNonLazyPtrs.begin(), + E = GVNonLazyPtrs.end(); I != E; ++I) { O << I->second << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << "\n"; O << "\t.long\t0\n"; From isanbard at gmail.com Mon Aug 3 17:21:23 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 3 Aug 2009 15:21:23 -0700 Subject: [llvm-commits] [llvm] r78005 - in /llvm/trunk: include/llvm/Constant.h lib/Transforms/Scalar/InstructionCombining.cpp lib/VMCore/Constants.cpp test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll In-Reply-To: <200908032207.n73M7Ypq028151@zion.cs.uiuc.edu> References: <200908032207.n73M7Ypq028151@zion.cs.uiuc.edu> Message-ID: <16e5fdf90908031521n3bf9e4a3kc6d00f9be5fbbe8d@mail.gmail.com> On Mon, Aug 3, 2009 at 3:07 PM, Dan Gohman wrote: > +; RUN: llvm-as < %s | opt -instcombine > + Should maybe use -disable-output? -bw From gohman at apple.com Mon Aug 3 17:24:22 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 03 Aug 2009 22:24:22 -0000 Subject: [llvm-commits] [llvm] r78009 - /llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Message-ID: <200908032224.n73MOMmE028750@zion.cs.uiuc.edu> Author: djg Date: Mon Aug 3 17:24:22 2009 New Revision: 78009 URL: http://llvm.org/viewvc/llvm-project?rev=78009&view=rev Log: Add -disable-output. Thanks Bill! Modified: llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Modified: llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll?rev=78009&r1=78008&r2=78009&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/simplify-demanded-bits-pointer.ll Mon Aug 3 17:24:22 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | opt -instcombine +; RUN: llvm-as < %s | opt -instcombine -disable-output ; SimplifyDemandedBits should cope with pointer types. From bruno.cardoso at gmail.com Mon Aug 3 17:25:32 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 3 Aug 2009 19:25:32 -0300 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> Message-ID: <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> On Mon, Aug 3, 2009 at 4:00 PM, Chris Lattner wrote: > > On Jul 31, 2009, at 4:03 PM, Bruno Cardoso Lopes wrote: > >> Hi all, >> >> The X86CodeEmitter has the following behaviour: >> >> 1) When emiting displacements: >> - Only use pc_relative relocations for x86_64 (globals, cstpools and >> jmptables) >> - For x86, only uses pc_rel ou pic_re >> This two items above do not always work for ELF. > > Hi Bruno, > > I don't have an opinion about this patch specifically, but would it be > possible to make the code emitter be driven off the asm operand flags > instead of making equivalent decisions that have to mirror what isel does? > > Specifically, MO.getTargetFlags() should tell the code emitter how to handle > the CPI/JT/GA/ExtSym operands, X86ATTAsmPrinter.cpp has stuff like this: > > ?switch (MO.getTargetFlags()) { > ?default: > ? ?llvm_unreachable("Unknown target flag on GV operand"); > ?case X86II::MO_NO_FLAG: ? ?// No flag. > ? ?break; > ?case X86II::MO_DARWIN_NONLAZY: > ?case X86II::MO_DARWIN_HIDDEN_NONLAZY: > ?case X86II::MO_DLLIMPORT: > ?case X86II::MO_DARWIN_STUB: > ? ?// These affect the name of the symbol, not any suffix. > ? ?break; > ?case X86II::MO_GOT_ABSOLUTE_ADDRESS: > ? ?O << " + [.-"; > ? ?PrintPICBaseSymbol(); > ? ?O << ']'; > ? ?break; > ?case X86II::MO_PIC_BASE_OFFSET: > ?case X86II::MO_DARWIN_NONLAZY_PIC_BASE: > ?case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: > ? ?O << '-'; > ? ?PrintPICBaseSymbol(); > ? ?break; > ?case X86II::MO_TLSGD: ? ? O << "@TLSGD"; ? ? break; > ?case X86II::MO_GOTTPOFF: ?O << "@GOTTPOFF"; ?break; > ?case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break; > ?case X86II::MO_TPOFF: ? ? O << "@TPOFF"; ? ? break; > ?case X86II::MO_NTPOFF: ? ?O << "@NTPOFF"; ? ?break; > ?case X86II::MO_GOTPCREL: ?O << "@GOTPCREL"; ?break; > ?case X86II::MO_GOT: ? ? ? O << "@GOT"; ? ? ? break; > ?case X86II::MO_GOTOFF: ? ?O << "@GOTOFF"; ? ?break; > ?case X86II::MO_PLT: ? ? ? O << "@PLT"; ? ? ? break; > ?} > > For example. ?It would be better to base the encoding on this flag than > checking things like Is64BitMode, IsPIC etc. Yes, that's the right way to go. I thought about that when I started hacking the x86 code emitter, but the problem here is that I'm afraid of breaking JIT stuff and lose the focus on the elf object code emission. I would be happy to work on this clean up as a next step after elf is working, but I would prefer to apply this patch for now if that's ok for you. But it's your call then. Thanks, >> This patch try to solve the 3 problems above to properly emit elf >> binaries for x86/x86_64. With >> this changes applied (together with elf improvements I've not commited >> yet) I was able >> to run 209/243 (83%) of SinglesSources using ELF object files emited by >> LLC :) >> and with no regressions for JIT. > > Wow, nice!! > > -Chris > > -- Bruno Cardoso Lopes http://www.brunocardoso.cc From gohman at apple.com Mon Aug 3 17:27:11 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 3 Aug 2009 15:27:11 -0700 Subject: [llvm-commits] [llvm] r77747 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp In-Reply-To: <4A75FBFE.3060901@obbligato.org> References: <200907312241.n6VMfM0B022916@zion.cs.uiuc.edu> <4A75FBFE.3060901@obbligato.org> Message-ID: On Aug 2, 2009, at 1:50 PM, David Greene wrote: > Dan Gohman wrote: > > >>> Yes, a vector of pointers isn't legal; we only support integer and >>> >>> FP vectors. >>> >> >> >> And if that ever changes (:-)) >> > > Oh Dan, do tell! :) I don't have anything to tell. It's just a feature that I can see someone wanting some day. Dan From gohman at apple.com Mon Aug 3 17:30:19 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 03 Aug 2009 22:30:19 -0000 Subject: [llvm-commits] [llvm] r78010 - /llvm/trunk/include/llvm/DerivedTypes.h Message-ID: <200908032230.n73MUK8Z028973@zion.cs.uiuc.edu> Author: djg Date: Mon Aug 3 17:30:18 2009 New Revision: 78010 URL: http://llvm.org/viewvc/llvm-project?rev=78010&view=rev Log: Minor whitespace fix, so this doesn't look like a unary *. Modified: llvm/trunk/include/llvm/DerivedTypes.h Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=78010&r1=78009&r2=78010&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Aug 3 17:30:18 2009 @@ -431,7 +431,7 @@ /// @brief Return the number of bits in the Vector type. inline unsigned getBitWidth() const { - return NumElements *getElementType()->getPrimitiveSizeInBits(); + return NumElements * getElementType()->getPrimitiveSizeInBits(); } // Implement the AbstractTypeUser interface. From sabre at nondot.org Mon Aug 3 17:32:52 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 22:32:52 -0000 Subject: [llvm-commits] [llvm] r78011 - /llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200908032232.n73MWqww029065@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 17:32:50 2009 New Revision: 78011 URL: http://llvm.org/viewvc/llvm-project?rev=78011&view=rev Log: use TLOF to compute the section for a function instead of replicating the logic manually. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78011&r1=78010&r2=78011&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Aug 3 17:32:50 2009 @@ -253,18 +253,19 @@ // NOTE: we don't print out constant pools here, they are handled as // instructions. - O << "\n"; + O << '\n'; + // Print out labels for the function. const Function *F = MF.getFunction(); + SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM)); + switch (F->getLinkage()) { default: llvm_unreachable("Unknown linkage type!"); case Function::PrivateLinkage: case Function::LinkerPrivateLinkage: case Function::InternalLinkage: - SwitchToTextSection("\t.text", F); break; case Function::ExternalLinkage: - SwitchToTextSection("\t.text", F); O << "\t.globl\t" << CurrentFnName << "\n"; break; case Function::WeakAnyLinkage: @@ -272,8 +273,6 @@ case Function::LinkOnceAnyLinkage: case Function::LinkOnceODRLinkage: if (Subtarget->isTargetDarwin()) { - SwitchToTextSection( - ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F); O << "\t.globl\t" << CurrentFnName << "\n"; O << "\t.weak_definition\t" << CurrentFnName << "\n"; } else { From dag at cray.com Mon Aug 3 17:35:23 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 17:35:23 -0500 Subject: [llvm-commits] =?iso-8859-1?q?=5Bllvm=5D_r77747=09-_/llvm/trunk/l?= =?iso-8859-1?q?ib/CodeGen/SelectionDAG/SelectionDAGBuild=2Ecpp?= In-Reply-To: References: <200907312241.n6VMfM0B022916@zion.cs.uiuc.edu> <4A75FBFE.3060901@obbligato.org> Message-ID: <200908031735.23251.dag@cray.com> On Monday 03 August 2009 17:27, Dan Gohman wrote: > On Aug 2, 2009, at 1:50 PM, David Greene wrote: > > Dan Gohman wrote: > >>> Yes, a vector of pointers isn't legal; we only support integer and > >>> > >>> FP vectors. > >> > >> And if that ever changes (:-)) > > > > Oh Dan, do tell! :) > > I don't have anything to tell. It's just a feature that > I can see someone wanting some day. Rats! From dpatel at apple.com Mon Aug 3 17:51:10 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 03 Aug 2009 22:51:10 -0000 Subject: [llvm-commits] [llvm] r78012 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp Message-ID: <200908032251.n73MpAJM029620@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 3 17:51:10 2009 New Revision: 78012 URL: http://llvm.org/viewvc/llvm-project?rev=78012&view=rev Log: Keep track of metadata used by other metadata. Modified: llvm/trunk/include/llvm/Metadata.h llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=78012&r1=78011&r2=78012&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Mon Aug 3 17:51:10 2009 @@ -16,7 +16,7 @@ #ifndef LLVM_MDNODE_H #define LLVM_MDNODE_H -#include "llvm/Value.h" +#include "llvm/User.h" #include "llvm/Type.h" #include "llvm/OperandTraits.h" #include "llvm/ADT/FoldingSet.h" @@ -31,11 +31,17 @@ //===----------------------------------------------------------------------===// // MetadataBase - A base class for MDNode, MDString and NamedMDNode. -class MetadataBase : public Value { +class MetadataBase : public User { +private: + /// ReservedSpace - The number of operands actually allocated. NumOperands is + /// the number actually in use. + unsigned ReservedSpace; + protected: MetadataBase(const Type *Ty, unsigned scid) - : Value(Ty, scid) {} + : User(Ty, scid, NULL, 0), ReservedSpace(0) {} + void resizeOperands(unsigned NumOps); public: /// getType() specialization - Type is always MetadataTy. /// @@ -64,13 +70,19 @@ /// MDString is always unnamd. class MDString : public MetadataBase { MDString(const MDString &); // DO NOT IMPLEMENT - StringRef Str; + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + unsigned getNumOperands(); // DO NOT IMPLEMENT + StringRef Str; protected: explicit MDString(const char *begin, unsigned l) : MetadataBase(Type::MetadataTy, Value::MDStringVal), Str(begin, l) {} public: + // Do not allocate any space for operands. + void *operator new(size_t s) { + return User::operator new(s, 0); + } static MDString *get(LLVMContext &Context, const StringRef &Str); StringRef getString() const { return Str; } @@ -97,38 +109,49 @@ /// These contain a list of the values that represent the metadata. /// MDNode is always unnamed. class MDNode : public MetadataBase, public FoldingSetNode { - MDNode(const MDNode &); // DO NOT IMPLEMENT + MDNode(const MDNode &); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + // getNumOperands - Make this only available for private uses. + unsigned getNumOperands() { return User::getNumOperands(); } SmallVector Node; - typedef SmallVectorImpl::iterator elem_iterator; - protected: explicit MDNode(Value*const* Vals, unsigned NumVals); public: + // Do not allocate any space for operands. + void *operator new(size_t s) { + return User::operator new(s, 0); + } + // Constructors and destructors. static MDNode *get(LLVMContext &Context, Value* const* Vals, unsigned NumVals); - - typedef SmallVectorImpl::const_iterator const_elem_iterator; + /// dropAllReferences - Remove all uses and clear node vector. + void dropAllReferences(); + + /// ~MDNode - Destroy NamedMDNode. + ~MDNode(); + + /// getElement - Return specified element. Value *getElement(unsigned i) const { + assert (getNumElements() > i && "Invalid element number!"); return Node[i]; } + /// getNumElements - Return number of MDNode elements. unsigned getNumElements() const { return Node.size(); } - bool elem_empty() const { - return Node.empty(); - } - - const_elem_iterator elem_begin() const { - return Node.begin(); - } - - const_elem_iterator elem_end() const { - return Node.end(); - } + // Element access + typedef SmallVectorImpl::const_iterator const_elem_iterator; + typedef SmallVectorImpl::iterator elem_iterator; + /// elem_empty - Return true if MDNode is empty. + bool elem_empty() const { return Node.empty(); } + const_elem_iterator elem_begin() const { return Node.begin(); } + const_elem_iterator elem_end() const { return Node.end(); } + elem_iterator elem_begin() { return Node.begin(); } + elem_iterator elem_end() { return Node.end(); } /// getType() specialization - Type is always MetadataTy. /// @@ -183,10 +206,13 @@ class NamedMDNode : public MetadataBase, public ilist_node { friend class SymbolTableListTraits; - NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT - friend class LLVMContextImpl; + NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + // getNumOperands - Make this only available for private uses. + unsigned getNumOperands() { return User::getNumOperands(); } + Module *Parent; SmallVector Node; typedef SmallVectorImpl::iterator elem_iterator; @@ -195,6 +221,10 @@ explicit NamedMDNode(const Twine &N, MetadataBase*const* Vals, unsigned NumVals, Module *M = 0); public: + // Do not allocate any space for operands. + void *operator new(size_t s) { + return User::operator new(s, 0); + } static NamedMDNode *Create(const Twine &N, MetadataBase*const*MDs, unsigned NumMDs, Module *M = 0) { return new NamedMDNode(N, MDs, NumMDs, M); @@ -207,39 +237,38 @@ /// dropAllReferences - Remove all uses and clear node vector. void dropAllReferences(); + /// ~NamedMDNode - Destroy NamedMDNode. ~NamedMDNode(); - typedef SmallVectorImpl::const_iterator const_elem_iterator; - /// getParent - Get the module that holds this named metadata collection. inline Module *getParent() { return Parent; } inline const Module *getParent() const { return Parent; } void setParent(Module *M) { Parent = M; } + /// getElement - Return specified element. MetadataBase *getElement(unsigned i) const { + assert (getNumElements() > i && "Invalid element number!"); return Node[i]; } + /// getNumElements - Return number of NamedMDNode elements. unsigned getNumElements() const { return Node.size(); } /// addElement - Add metadata element. void addElement(MetadataBase *M) { + resizeOperands(0); + OperandList[NumOperands++] = M; Node.push_back(WeakMetadataVH(M)); } - bool elem_empty() const { - return Node.empty(); - } - - const_elem_iterator elem_begin() const { - return Node.begin(); - } - - const_elem_iterator elem_end() const { - return Node.end(); - } + typedef SmallVectorImpl::const_iterator const_elem_iterator; + bool elem_empty() const { return Node.empty(); } + const_elem_iterator elem_begin() const { return Node.begin(); } + const_elem_iterator elem_end() const { return Node.end(); } + elem_iterator elem_begin() { return Node.begin(); } + elem_iterator elem_end() { return Node.end(); } /// getType() specialization - Type is always MetadataTy. /// Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=78012&r1=78011&r2=78012&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Mon Aug 3 17:51:10 2009 @@ -19,6 +19,34 @@ using namespace llvm; //===----------------------------------------------------------------------===// +//MetadataBase implementation +// + +/// resizeOperands - Metadata keeps track of other metadata uses using +/// OperandList. Resize this list to hold anticipated number of metadata +/// operands. +void MetadataBase::resizeOperands(unsigned NumOps) { + unsigned e = getNumOperands(); + if (NumOps == 0) { + NumOps = e*2; + if (NumOps < 2) NumOps = 2; + } else if (NumOps > NumOperands) { + // No resize needed. + if (ReservedSpace >= NumOps) return; + } else if (NumOps == NumOperands) { + if (ReservedSpace == NumOps) return; + } else { + return; + } + + ReservedSpace = NumOps; + Use *OldOps = OperandList; + Use *NewOps = allocHungoffUses(NumOps); + std::copy(OldOps, OldOps + e, NewOps); + OperandList = NewOps; + if (OldOps) Use::zap(OldOps, OldOps + e, true); +} +//===----------------------------------------------------------------------===// //MDString implementation // MDString *MDString::get(LLVMContext &Context, const StringRef &Str) { @@ -38,8 +66,14 @@ // MDNode::MDNode(Value*const* Vals, unsigned NumVals) : MetadataBase(Type::MetadataTy, Value::MDNodeVal) { - for (unsigned i = 0; i != NumVals; ++i) + NumOperands = 0; + resizeOperands(NumVals); + for (unsigned i = 0; i != NumVals; ++i) { + // Only record metadata uses. + if (MetadataBase *MB = dyn_cast_or_null(Vals[i])) + OperandList[NumOperands++] = MB; Node.push_back(WeakVH(Vals[i])); + } } void MDNode::Profile(FoldingSetNodeID &ID) const { @@ -71,6 +105,15 @@ return N; } +/// dropAllReferences - Remove all uses and clear node vector. +void MDNode::dropAllReferences() { + User::dropAllReferences(); + Node.clear(); +} + +MDNode::~MDNode() { + dropAllReferences(); +} //===----------------------------------------------------------------------===// //NamedMDNode implementation // @@ -78,8 +121,14 @@ unsigned NumMDs, Module *ParentModule) : MetadataBase(Type::MetadataTy, Value::NamedMDNodeVal), Parent(0) { setName(N); - for (unsigned i = 0; i != NumMDs; ++i) + NumOperands = 0; + resizeOperands(NumMDs); + + for (unsigned i = 0; i != NumMDs; ++i) { + if (MDs[i]) + OperandList[NumOperands++] = MDs[i]; Node.push_back(WeakMetadataVH(MDs[i])); + } if (ParentModule) ParentModule->getNamedMDList().push_back(this); } @@ -87,13 +136,12 @@ /// eraseFromParent - Drop all references and remove the node from parent /// module. void NamedMDNode::eraseFromParent() { - dropAllReferences(); getParent()->getNamedMDList().erase(this); } /// dropAllReferences - Remove all uses and clear node vector. void NamedMDNode::dropAllReferences() { - // FIXME: Update metadata use list. + User::dropAllReferences(); Node.clear(); } From sabre at nondot.org Mon Aug 3 17:52:21 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 22:52:21 -0000 Subject: [llvm-commits] [llvm] r78013 - /llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Message-ID: <200908032252.n73MqLSx029667@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 17:52:21 2009 New Revision: 78013 URL: http://llvm.org/viewvc/llvm-project?rev=78013&view=rev Log: switch ppc to using SwitchToSection instead of textual section stuff. Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=78013&r1=78012&r2=78013&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Mon Aug 3 17:52:21 2009 @@ -854,14 +854,22 @@ // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. - SwitchToTextSection("\t.section __TEXT,__textcoal_nt,coalesced," - "pure_instructions"); + + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast(getObjFileLowering()); + SwitchToSection(TLOFMacho.getMachOSection("\t.section __TEXT,__textcoal_nt," + "coalesced,pure_instructions", true, + SectionKind::getText())); if (TM.getRelocationModel() == Reloc::PIC_) { - SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs," - "pure_instructions,32"); + SwitchToSection(TLOFMacho.getMachOSection("\t.section __TEXT,__picsymbolstu" + "b1,symbol_stubs," + "pure_instructions,32", true, + SectionKind::getText())); } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) { - SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs," - "pure_instructions,16"); + SwitchToSection(TLOFMacho.getMachOSection("\t.section __TEXT,__symbol_stub1" + ",symbol_stubs," + "pure_instructions,16", true, + SectionKind::getText())); } SwitchToSection(getObjFileLowering().getTextSection()); @@ -980,12 +988,23 @@ bool isPPC64 = TD->getPointerSizeInBits() == 64; + // Darwin/PPC always uses mach-o. + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast(getObjFileLowering()); + // Output stubs for dynamically-linked functions if (TM.getRelocationModel() == Reloc::PIC_ && !FnStubs.empty()) { + const MCSection *StubSection = + TLOFMacho.getMachOSection("\t.section __TEXT,__picsymbolstub1," + "symbol_stubs,pure_instructions,32", true, + SectionKind::getText()); + const MCSection *LSPSection = + TLOFMacho.getMachOSection(".lazy_symbol_pointer", true, + SectionKind::getMetadata()); + for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { - SwitchToTextSection("\t.section __TEXT,__picsymbolstub1,symbol_stubs," - "pure_instructions,32"); + SwitchToSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; O << Info.Stub << ":\n"; @@ -1002,16 +1021,23 @@ O << "\tmtctr r12\n"; O << "\tbctr\n"; - SwitchToDataSection(".lazy_symbol_pointer"); + SwitchToSection(LSPSection); O << Info.LazyPtr << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; } } else if (!FnStubs.empty()) { + const MCSection *StubSection = + TLOFMacho.getMachOSection("\t.section __TEXT,__symbol_stub1,symbol_stubs," + "pure_instructions,16", true, + SectionKind::getText()); + const MCSection *LSPSection = + TLOFMacho.getMachOSection(".lazy_symbol_pointer", true, + SectionKind::getMetadata()); + for (StringMap::iterator I = FnStubs.begin(), E = FnStubs.end(); I != E; ++I) { - SwitchToTextSection("\t.section __TEXT,__symbol_stub1,symbol_stubs," - "pure_instructions,16"); + SwitchToSection(StubSection); EmitAlignment(4); const FnStubInfo &Info = I->second; O << Info.Stub << ":\n"; @@ -1021,7 +1047,7 @@ O << Info.LazyPtr << ")(r11)\n"; O << "\tmtctr r12\n"; O << "\tbctr\n"; - SwitchToDataSection(".lazy_symbol_pointer"); + SwitchToSection(LSPSection); O << Info.LazyPtr << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << '\n'; O << (isPPC64 ? "\t.quad" : "\t.long") << " dyld_stub_binding_helper\n"; @@ -1042,9 +1068,12 @@ } } - // Output stubs for external and common global variables. + // Output macho stubs for external and common global variables. if (!GVStubs.empty()) { - SwitchToDataSection(".non_lazy_symbol_pointer"); + const MCSection *TheSection = + TLOFMacho.getMachOSection(".non_lazy_symbol_pointer", true, + SectionKind::getMetadata()); + SwitchToSection(TheSection); for (StringMap::iterator I = GVStubs.begin(), E = GVStubs.end(); I != E; ++I) { O << I->second << ":\n"; From clattner at apple.com Mon Aug 3 17:58:44 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 3 Aug 2009 15:58:44 -0700 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> Message-ID: <4060CD96-A773-4622-8471-DF5BFBBCF50D@apple.com> On Aug 3, 2009, at 3:25 PM, Bruno Cardoso Lopes wrote: >> >> For example. It would be better to base the encoding on this flag >> than >> checking things like Is64BitMode, IsPIC etc. > > Yes, that's the right way to go. I thought about that when I started > hacking the > x86 code emitter, but the problem here is that I'm afraid of > breaking JIT stuff > and lose the focus on the elf object code emission. I would be happy > to > work on this clean up as a next step after elf is working, but I would > prefer to > apply this patch for now if that's ok for you. But it's your call > then. Sure, makes sense to me. Evan, are you ok with this patch? -Chris From sabre at nondot.org Mon Aug 3 18:02:50 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 23:02:50 -0000 Subject: [llvm-commits] [llvm] r78014 - /llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Message-ID: <200908032302.n73N2pA4030027@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 18:02:45 2009 New Revision: 78014 URL: http://llvm.org/viewvc/llvm-project?rev=78014&view=rev Log: remove an unneeded section switch. Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Modified: llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp?rev=78014&r1=78013&r2=78014&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp Mon Aug 3 18:02:45 2009 @@ -485,7 +485,6 @@ bool LinuxAsmPrinter::doInitialization(Module &M) { bool Result = AsmPrinter::doInitialization(M); DW = getAnalysisIfAvailable(); - SwitchToTextSection("\t.text"); return Result; } From sabre at nondot.org Mon Aug 3 18:10:36 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 23:10:36 -0000 Subject: [llvm-commits] [llvm] r78015 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200908032310.n73NAbnP030292@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 18:10:34 2009 New Revision: 78015 URL: http://llvm.org/viewvc/llvm-project?rev=78015&view=rev Log: Kill off SwitchToDataSection and SwitchToTextSection, woo. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=78015&r1=78014&r2=78015&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Aug 3 18:10:34 2009 @@ -143,34 +143,6 @@ /// bool isVerbose() const { return VerboseAsm; } - /// SwitchToTextSection - Switch to the specified section of the executable - /// if we are not already in it! If GV is non-null and if the global has an - /// explicitly requested section, we switch to the section indicated for the - /// global instead of NewSection. - /// - /// If the new section is an empty string, this method forgets what the - /// current section is, but does not emit a .section directive. - /// - /// This method is used when about to emit executable code. - /// - void SwitchToTextSection(const char *NewSection, - const GlobalValue *GV = NULL); - - /// SwitchToDataSection - Switch to the specified section of the executable - /// if we are not already in it! If GV is non-null and if the global has an - /// explicitly requested section, we switch to the section indicated for the - /// global instead of NewSection. - /// - /// If the new section is an empty string, this method forgets what the - /// current section is, but does not emit a .section directive. - /// - /// This method is used when about to emit data. For most assemblers, this - /// is the same as the SwitchToTextSection method, but not all assemblers - /// are the same. - /// - void SwitchToDataSection(const char *NewSection, - const GlobalValue *GV = NULL); - /// SwitchToSection - Switch to the specified section of the executable if /// we are not already in it! void SwitchToSection(const MCSection *NS); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=78015&r1=78014&r2=78015&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 3 18:10:34 2009 @@ -78,59 +78,6 @@ return TM.getTargetLowering()->getObjFileLowering(); } - -/// SwitchToTextSection - Switch to the specified text section of the executable -/// if we are not already in it! -/// -void AsmPrinter::SwitchToTextSection(const char *NewSection, - const GlobalValue *GV) { - std::string NS; - if (GV && GV->hasSection()) - NS = TAI->getSwitchToSectionDirective() + GV->getSection(); - else - NS = NewSection; - - // If we're already in this section, we're done. - if (CurrentSection == NS) return; - - // Close the current section, if applicable. - if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) - O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n'; - - CurrentSection = NS; - - if (!CurrentSection.empty()) - O << CurrentSection << TAI->getTextSectionStartSuffix() << '\n'; - - IsInTextSection = true; -} - -/// SwitchToDataSection - Switch to the specified data section of the executable -/// if we are not already in it! -/// -void AsmPrinter::SwitchToDataSection(const char *NewSection, - const GlobalValue *GV) { - std::string NS; - if (GV && GV->hasSection()) - NS = TAI->getSwitchToSectionDirective() + GV->getSection(); - else - NS = NewSection; - - // If we're already in this section, we're done. - if (CurrentSection == NS) return; - - // Close the current section, if applicable. - if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) - O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n'; - - CurrentSection = NS; - - if (!CurrentSection.empty()) - O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n'; - - IsInTextSection = false; -} - /// SwitchToSection - Switch to the specified section of the executable if we /// are not already in it! If "NS" is null, then this causes us to exit the /// current section and not reenter another one. This is generally used for @@ -210,7 +157,7 @@ << '\n' << TAI->getCommentString() << " End of file scope inline assembly\n"; - SwitchToDataSection(""); // Reset back to no section. + SwitchToSection(0); // Reset back to no section to close off sections. if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) { @@ -241,7 +188,7 @@ // to stuff that is actually used. Note that doing so would require targets // to notice uses in operands (due to constant exprs etc). This should // happen with the MC stuff eventually. - SwitchToDataSection(""); + SwitchToSection(0); // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); @@ -250,8 +197,7 @@ O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n'; } - for (Module::const_iterator I = M.begin(), E = M.end(); - I != E; ++I) { + for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { if (I->hasExternalWeakLinkage()) O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n'; } From sabre at nondot.org Mon Aug 3 18:20:29 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 03 Aug 2009 23:20:29 -0000 Subject: [llvm-commits] [llvm] r78017 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200908032320.n73NKUrK030672@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 18:20:21 2009 New Revision: 78017 URL: http://llvm.org/viewvc/llvm-project?rev=78017&view=rev Log: eliminate CurrentSection, rename CurrentSection_ -> CurrentSection, make it private, eliminate IsInTextSection. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=78017&r1=78016&r2=78017&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Aug 3 18:20:21 2009 @@ -60,6 +60,10 @@ typedef gcp_map_type::iterator gcp_iterator; gcp_map_type GCMetadataPrinters; + /// CurrentSection - The current section we are emitting to. This is + /// controlled and used by the SwitchToSection method. + const MCSection *CurrentSection; + protected: /// MMI - If available, this is a pointer to the current MachineModuleInfo. MachineModuleInfo *MMI; @@ -110,14 +114,9 @@ /// std::string CurrentFnName; - /// CurrentSection - The current section we are emitting to. This is - /// controlled and used by the SwitchSection method. - std::string CurrentSection; - const MCSection *CurrentSection_; - - /// IsInTextSection - True if the current section we are emitting to is a - /// text section. - bool IsInTextSection; + /// getCurrentSection() - Return the current section we are emitting to. + const MCSection *getCurrentSection() const { return CurrentSection; } + /// VerboseAsm - Emit comments in assembly output if this is true. /// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=78017&r1=78016&r2=78017&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 3 18:20:21 2009 @@ -55,8 +55,9 @@ OutContext(*new MCContext()), OutStreamer(*createAsmStreamer(OutContext, O)), - IsInTextSection(false), LastMI(0), LastFn(0), Counter(~0U), + LastMI(0), LastFn(0), Counter(~0U), PrevDLT(0, ~0U, ~0U) { + CurrentSection = 0; DW = 0; MMI = 0; switch (AsmVerbose) { case cl::BOU_UNSET: VerboseAsm = VDef; break; @@ -86,20 +87,16 @@ /// FIXME: Remove support for null sections. /// void AsmPrinter::SwitchToSection(const MCSection *NS) { - const std::string &NewSection = NS ? NS->getName() : ""; - // If we're already in this section, we're done. - if (CurrentSection == NewSection) return; + if (CurrentSection == NS) return; // Close the current section, if applicable. - if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) - O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n'; + if (NS != 0 && TAI->getSectionEndDirectiveSuffix()) + O << NS->getName() << TAI->getSectionEndDirectiveSuffix() << '\n'; - // FIXME: Make CurrentSection a Section* in the future - CurrentSection = NewSection; - CurrentSection_ = NS; + CurrentSection = NS; - if (!CurrentSection.empty()) { + if (NS != 0) { // If section is named we need to switch into it via special '.section' // directive and also append funky flags. Otherwise - section name is just // some magic assembler directive. @@ -109,15 +106,12 @@ getObjFileLowering().getSectionFlagsAsString(NS->getKind(), FlagsStr); O << TAI->getSwitchToSectionDirective() - << CurrentSection - << FlagsStr.c_str(); + << CurrentSection->getName() << FlagsStr.c_str(); } else { - O << CurrentSection; + O << CurrentSection->getName(); } O << TAI->getDataSectionStartSuffix() << '\n'; } - - IsInTextSection = NS ? NS->getKind().isText() : false; } void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { @@ -787,12 +781,11 @@ if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits; O << TAI->getAlignDirective() << NumBits; - unsigned FillValue = TAI->getTextAlignFillValue(); - UseFillExpr &= IsInTextSection && FillValue; - if (UseFillExpr) { - O << ','; - PrintHex(FillValue); - } + if (CurrentSection && CurrentSection->getKind().isText()) + if (unsigned FillValue = TAI->getTextAlignFillValue()) { + O << ','; + PrintHex(FillValue); + } O << '\n'; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=78017&r1=78016&r2=78017&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 3 18:20:21 2009 @@ -1463,7 +1463,7 @@ // Get function line info. if (!Lines.empty()) { // Get section line info. - unsigned ID = SectionMap.insert(Asm->CurrentSection_); + unsigned ID = SectionMap.insert(Asm->getCurrentSection()); if (SectionSourceLines.size() < ID) SectionSourceLines.resize(ID); std::vector &SectionLineInfos = SectionSourceLines[ID-1]; // Append the function info to section info. From dag at cray.com Mon Aug 3 17:05:59 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 17:05:59 -0500 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <200908031146.20758.greened@obbligato.org> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <679A075B-43B1-4ACD-B18C-0B8C7356BA2A@apple.com> <200908031146.20758.greened@obbligato.org> Message-ID: <200908031705.59956.dag@cray.com> On Monday 03 August 2009 11:46, David A. Greene wrote: > > I'm not following what you mean here. Can you give me an example that > > shows what this does? > > Oh! This changed since the last time I looked at it. It used to be that > the tabs were embedded into the AsmStrs array and some opcodes had tabs > after them and others didn't. I see now that in X86GenAsmWriter1.inc the > asm boilerplate emits the tab after the opcode: > > O << "\t"; Oh, never mind. This is the tab to align the mnemonics. It still changed though. There used to be tabs embedded in AsmStrs. Now I don't know how they get generated. I am thoroughly confused now. :-/ -Dave From dag at cray.com Mon Aug 3 18:36:50 2009 From: dag at cray.com (David Greene) Date: Mon, 3 Aug 2009 18:36:50 -0500 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <200908031711.30871.dag@cray.com> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <200908031705.59956.dag@cray.com> <200908031711.30871.dag@cray.com> Message-ID: <200908031836.51123.dag@cray.com> On Monday 03 August 2009 17:11, David Greene wrote: > > AsmWriterEmitter no longer emits tabs into the AsmStrs because of this. So > you're right, all this ugly complexity can go away. Hmm...except this > probably doesn't work for "pd" suffixed mnemonics as I pointed out earlier. > So there's a bug here. I'll figure that out. I've got a fix for this and a cleanup to boot. Testing now, will apply probably tomorrow. -Dave From kremenek at apple.com Mon Aug 3 18:44:05 2009 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 03 Aug 2009 23:44:05 -0000 Subject: [llvm-commits] [llvm] r78020 - in /llvm/trunk/lib: CodeGen/CMakeLists.txt Target/Blackfin/AsmPrinter/CMakeLists.txt Target/Blackfin/TargetInfo/CMakeLists.txt Message-ID: <200908032344.n73Ni8ia031393@zion.cs.uiuc.edu> Author: kremenek Date: Mon Aug 3 18:44:01 2009 New Revision: 78020 URL: http://llvm.org/viewvc/llvm-project?rev=78020&view=rev Log: Update CMake files. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=78020&r1=78019&r2=78020&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Mon Aug 3 18:44:01 2009 @@ -2,6 +2,7 @@ BranchFolding.cpp CodePlacementOpt.cpp DeadMachineInstructionElim.cpp + Dump.cpp DwarfEHPrepare.cpp ELFCodeEmitter.cpp ELFWriter.cpp Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt?rev=78020&r1=78019&r2=78020&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt Mon Aug 3 18:44:01 2009 @@ -1,3 +1,4 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) add_llvm_library(LLVMBlackfinAsmPrinter BlackfinAsmPrinter.cpp) + BlackfinAsmPrinter.cpp add_dependencies(LLVMBlackfinAsmPrinter BlackfinCodeGenTable_gen) Modified: llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt?rev=78020&r1=78019&r2=78020&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt Mon Aug 3 18:44:01 2009 @@ -1,3 +1,4 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) add_llvm_library(LLVMBlackfinInfo BlackfinTargetInfo.cpp) + BlackfinTargetInfo.cpp add_dependencies(LLVMBlackfinInfo BlackfinCodeGenTable_gen) From gohman at apple.com Mon Aug 3 19:24:52 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 04 Aug 2009 00:24:52 -0000 Subject: [llvm-commits] [llvm] r78023 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <200908040024.n740Ounb032729@zion.cs.uiuc.edu> Author: djg Date: Mon Aug 3 19:24:42 2009 New Revision: 78023 URL: http://llvm.org/viewvc/llvm-project?rev=78023&view=rev Log: Propogate the Depth argument when calling TLI.computeMaskedBitsForTargetNode from ComputeMaskedBits, since the former may call back into the latter. This fixes a major compile time problem on a testcase that happnened to hit this in a particularly bad way, PR4643. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=78023&r1=78022&r2=78023&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Aug 3 19:24:42 2009 @@ -1987,7 +1987,8 @@ case ISD::INTRINSIC_WO_CHAIN: case ISD::INTRINSIC_W_CHAIN: case ISD::INTRINSIC_VOID: - TLI.computeMaskedBitsForTargetNode(Op, Mask, KnownZero, KnownOne, *this); + TLI.computeMaskedBitsForTargetNode(Op, Mask, KnownZero, KnownOne, *this, + Depth); } return; } From bob.wilson at apple.com Mon Aug 3 19:25:02 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 00:25:02 -0000 Subject: [llvm-commits] [llvm] r78024 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <200908040025.n740P3h9032745@zion.cs.uiuc.edu> Author: bwilson Date: Mon Aug 3 19:25:01 2009 New Revision: 78024 URL: http://llvm.org/viewvc/llvm-project?rev=78024&view=rev Log: Minor cleanup. No functional changes intended. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=78024&r1=78023&r2=78024&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Aug 3 19:25:01 2009 @@ -1320,17 +1320,16 @@ SDValue ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) { - MVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); unsigned IntNo = cast(Op.getOperand(0))->getZExtValue(); DebugLoc dl = Op.getDebugLoc(); switch (IntNo) { default: return SDValue(); // Don't custom lower most intrinsics. - case Intrinsic::arm_thread_pointer: - return DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT); + case Intrinsic::arm_thread_pointer: { + MVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); + return DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT); + } case Intrinsic::eh_sjlj_setjmp: - SDValue Res = DAG.getNode(ARMISD::EH_SJLJ_SETJMP, dl, MVT::i32, - Op.getOperand(1)); - return Res; + return DAG.getNode(ARMISD::EH_SJLJ_SETJMP, dl, MVT::i32, Op.getOperand(1)); } } From bob.wilson at apple.com Mon Aug 3 19:36:17 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 00:36:17 -0000 Subject: [llvm-commits] [llvm] r78025 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h ARMInstrNEON.td Message-ID: <200908040036.n740aHAn000672@zion.cs.uiuc.edu> Author: bwilson Date: Mon Aug 3 19:36:16 2009 New Revision: 78025 URL: http://llvm.org/viewvc/llvm-project?rev=78025&view=rev Log: Lower Neon VLD* intrinsics to custom DAG nodes, and manually allocate the results to fixed registers. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=78025&r1=78024&r2=78025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Aug 3 19:36:16 2009 @@ -323,6 +323,7 @@ // We want to custom lower some of our intrinsics. setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom); + setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom); setOperationAction(ISD::SETCC, MVT::i32, Expand); setOperationAction(ISD::SETCC, MVT::f32, Expand); @@ -463,6 +464,9 @@ case ARMISD::VGETLANEu: return "ARMISD::VGETLANEu"; case ARMISD::VGETLANEs: return "ARMISD::VGETLANEs"; case ARMISD::VDUPLANEQ: return "ARMISD::VDUPLANEQ"; + case ARMISD::VLD2D: return "ARMISD::VLD2D"; + case ARMISD::VLD3D: return "ARMISD::VLD3D"; + case ARMISD::VLD4D: return "ARMISD::VLD4D"; } } @@ -1318,6 +1322,60 @@ return DAG.getNode(ARMISD::PIC_ADD, dl, PtrVT, Result, PICLabel); } +static SDValue LowerNeonVLDIntrinsic(SDValue Op, SelectionDAG &DAG, + unsigned Opcode, unsigned NumVecs) { + SDNode *Node = Op.getNode(); + MVT VT = Node->getValueType(0); + DebugLoc dl = Op.getDebugLoc(); + + if (!VT.is64BitVector()) + return SDValue(); // unimplemented + + SDValue Ops[] = { Node->getOperand(0), + Node->getOperand(1) }; + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); + SDValue Result = DAG.getNode(Opcode, dl, Tys, Ops, 2); + + static const unsigned VLDRegs[] = { + ARM::D0, ARM::D1, ARM::D2, ARM::D3 + }; + + SmallVector ResultVals; + SDValue Chain = Result.getValue(0); + SDValue Flag = Result.getValue(1); + for (unsigned N = 0; N < NumVecs; ++N) { + Chain = DAG.getCopyFromReg(Chain, dl, VLDRegs[N], VT, Flag).getValue(1); + ResultVals.push_back(Chain.getValue(0)); + Flag = Chain.getValue(2); + } + ResultVals.push_back(Chain); + return DAG.getNode(ISD::MERGE_VALUES, dl, Node->getVTList(), + ResultVals.data(), NumVecs + 1); +} + +SDValue +ARMTargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) { + unsigned IntNo = cast(Op.getOperand(1))->getZExtValue(); + switch (IntNo) { + case Intrinsic::arm_neon_vld2i: + case Intrinsic::arm_neon_vld2f: + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD2D, 2); + case Intrinsic::arm_neon_vld3i: + case Intrinsic::arm_neon_vld3f: + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD3D, 3); + case Intrinsic::arm_neon_vld4i: + case Intrinsic::arm_neon_vld4f: + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD4D, 4); + case Intrinsic::arm_neon_vst2i: + case Intrinsic::arm_neon_vst2f: + case Intrinsic::arm_neon_vst3i: + case Intrinsic::arm_neon_vst3f: + case Intrinsic::arm_neon_vst4i: + case Intrinsic::arm_neon_vst4f: + default: return SDValue(); // Don't custom lower most intrinsics. + } +} + SDValue ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) { unsigned IntNo = cast(Op.getOperand(0))->getZExtValue(); @@ -2354,6 +2412,7 @@ case ISD::RETURNADDR: break; case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); case ISD::GLOBAL_OFFSET_TABLE: return LowerGLOBAL_OFFSET_TABLE(Op, DAG); + case ISD::INTRINSIC_W_CHAIN: return LowerINTRINSIC_W_CHAIN(Op, DAG); case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG); case ISD::BIT_CONVERT: return ExpandBIT_CONVERT(Op.getNode(), DAG); case ISD::SHL: Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=78025&r1=78024&r2=78025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Mon Aug 3 19:36:16 2009 @@ -114,7 +114,12 @@ VGETLANEs, // sign-extend vector extract element // Vector duplicate lane (128-bit result only; 64-bit is a shuffle) - VDUPLANEQ // splat a lane from a 64-bit vector to a 128-bit vector + VDUPLANEQ, // splat a lane from a 64-bit vector to a 128-bit vector + + // Vector load/store with (de)interleaving + VLD2D, + VLD3D, + VLD4D }; } @@ -237,6 +242,7 @@ SDNode *LowerCallResult(SDValue Chain, SDValue InFlag, CallSDNode *TheCall, unsigned CallingConv, SelectionDAG &DAG); SDValue LowerCALL(SDValue Op, SelectionDAG &DAG); + SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG); SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG); SDValue LowerRET(SDValue Op, SelectionDAG &DAG); SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG); Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78025&r1=78024&r2=78025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon Aug 3 19:36:16 2009 @@ -68,6 +68,14 @@ def NEONvduplaneq : SDNode<"ARMISD::VDUPLANEQ", SDTypeProfile<1, 2, [SDTCisVT<2, i32>]>>; +def SDTARMVLD : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; +def NEONvld2d : SDNode<"ARMISD::VLD2D", SDTARMVLD, + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; +def NEONvld3d : SDNode<"ARMISD::VLD3D", SDTARMVLD, + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; +def NEONvld4d : SDNode<"ARMISD::VLD4D", SDTARMVLD, + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; + //===----------------------------------------------------------------------===// // NEON operand definitions //===----------------------------------------------------------------------===// From evan.cheng at apple.com Mon Aug 3 20:21:12 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 18:21:12 -0700 Subject: [llvm-commits] [llvm] r78025 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h ARMInstrNEON.td In-Reply-To: <200908040036.n740aHAn000672@zion.cs.uiuc.edu> References: <200908040036.n740aHAn000672@zion.cs.uiuc.edu> Message-ID: <4B0840D7-EB4A-470F-B8A3-28F7C6404010@apple.com> On Aug 3, 2009, at 5:36 PM, Bob Wilson wrote: > > > +static SDValue LowerNeonVLDIntrinsic(SDValue Op, SelectionDAG &DAG, > + unsigned Opcode, unsigned > NumVecs) { > + SDNode *Node = Op.getNode(); > + MVT VT = Node->getValueType(0); > + DebugLoc dl = Op.getDebugLoc(); > + > + if (!VT.is64BitVector()) > + return SDValue(); // unimplemented > + > + SDValue Ops[] = { Node->getOperand(0), > + Node->getOperand(1) }; > + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); > + SDValue Result = DAG.getNode(Opcode, dl, Tys, Ops, 2); > + > + static const unsigned VLDRegs[] = { > + ARM::D0, ARM::D1, ARM::D2, ARM::D3 > + }; Is this a temporary solution? Perhaps we want to do a post-isel pre- allocation pass to be a little bit smarter about what registers to pre- allocate to? Evan > + > + SmallVector ResultVals; > + SDValue Chain = Result.getValue(0); > + SDValue Flag = Result.getValue(1); > + for (unsigned N = 0; N < NumVecs; ++N) { > + Chain = DAG.getCopyFromReg(Chain, dl, VLDRegs[N], VT, > Flag).getValue(1); > + ResultVals.push_back(Chain.getValue(0)); > + Flag = Chain.getValue(2); > + } > + ResultVals.push_back(Chain); > + return DAG.getNode(ISD::MERGE_VALUES, dl, Node->getVTList(), > + ResultVals.data(), NumVecs + 1); > +} > + > +SDValue > +ARMTargetLowering::LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG > &DAG) { > + unsigned IntNo = cast(Op.getOperand(1))- > >getZExtValue(); > + switch (IntNo) { > + case Intrinsic::arm_neon_vld2i: > + case Intrinsic::arm_neon_vld2f: > + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD2D, 2); > + case Intrinsic::arm_neon_vld3i: > + case Intrinsic::arm_neon_vld3f: > + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD3D, 3); > + case Intrinsic::arm_neon_vld4i: > + case Intrinsic::arm_neon_vld4f: > + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD4D, 4); > + case Intrinsic::arm_neon_vst2i: > + case Intrinsic::arm_neon_vst2f: > + case Intrinsic::arm_neon_vst3i: > + case Intrinsic::arm_neon_vst3f: > + case Intrinsic::arm_neon_vst4i: > + case Intrinsic::arm_neon_vst4f: > + default: return SDValue(); // Don't custom lower most > intrinsics. > + } > +} > + > SDValue > ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG > &DAG) { > unsigned IntNo = cast(Op.getOperand(0))- > >getZExtValue(); > @@ -2354,6 +2412,7 @@ > case ISD::RETURNADDR: break; > case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); > case ISD::GLOBAL_OFFSET_TABLE: return LowerGLOBAL_OFFSET_TABLE(Op, > DAG); > + case ISD::INTRINSIC_W_CHAIN: return LowerINTRINSIC_W_CHAIN(Op, > DAG); > case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, > DAG); > case ISD::BIT_CONVERT: return ExpandBIT_CONVERT(Op.getNode(), > DAG); > case ISD::SHL: > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=78025&r1=78024&r2=78025&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Mon Aug 3 19:36:16 > 2009 > @@ -114,7 +114,12 @@ > VGETLANEs, // sign-extend vector extract element > > // Vector duplicate lane (128-bit result only; 64-bit is a > shuffle) > - VDUPLANEQ // splat a lane from a 64-bit vector to a 128- > bit vector > + VDUPLANEQ, // splat a lane from a 64-bit vector to a 128- > bit vector > + > + // Vector load/store with (de)interleaving > + VLD2D, > + VLD3D, > + VLD4D > }; > } > > @@ -237,6 +242,7 @@ > SDNode *LowerCallResult(SDValue Chain, SDValue InFlag, > CallSDNode *TheCall, > unsigned CallingConv, SelectionDAG &DAG); > SDValue LowerCALL(SDValue Op, SelectionDAG &DAG); > + SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG); > SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG); > SDValue LowerRET(SDValue Op, SelectionDAG &DAG); > SDValue LowerGlobalAddressDarwin(SDValue Op, SelectionDAG &DAG); > > Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78025&r1=78024&r2=78025&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) > +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon Aug 3 19:36:16 2009 > @@ -68,6 +68,14 @@ > def NEONvduplaneq : SDNode<"ARMISD::VDUPLANEQ", > SDTypeProfile<1, 2, [SDTCisVT<2, i32>]>>; > > +def SDTARMVLD : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; > +def NEONvld2d : SDNode<"ARMISD::VLD2D", SDTARMVLD, > + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; > +def NEONvld3d : SDNode<"ARMISD::VLD3D", SDTARMVLD, > + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; > +def NEONvld4d : SDNode<"ARMISD::VLD4D", SDTARMVLD, > + [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; > + > // > = > = > = > ----------------------------------------------------------------------= > ==// > // NEON operand definitions > // > = > = > = > ----------------------------------------------------------------------= > ==// > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Aug 3 20:41:17 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 01:41:17 -0000 Subject: [llvm-commits] [llvm] r78030 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/thumb2-sub.ll Message-ID: <200908040141.n741fJef002688@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 3 20:41:15 2009 New Revision: 78030 URL: http://llvm.org/viewvc/llvm-project?rev=78030&view=rev Log: Emit sub r, #c instead of transforming it to add r, #-c if c fits in 8-bit. This is a bit of pre-mature optimization. 8-bit variant makes it likely it will be narrowed to a 16-bit instruction. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/CodeGen/Thumb2/thumb2-sub.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=78030&r1=78029&r2=78030&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Aug 3 20:41:15 2009 @@ -83,6 +83,10 @@ return (uint32_t)(-N->getZExtValue()) < 4096; }], imm_neg_XFORM>; +def imm0_255_neg : PatLeaf<(i32 imm), [{ + return (uint32_t)(-N->getZExtValue()) < 255; +}], imm_neg_XFORM>; + /// imm0_65535 predicate - True if the 32-bit immediate is in the range /// [0.65535]. def imm0_65535 : PatLeaf<(i32 imm), [{ @@ -619,12 +623,12 @@ let mayLoad = 1 in def t2LDM : T2XI<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dst1, variable_ops), - "ldm${addr:submode}${p}.w $addr, $dst1", []>; + "ldm${addr:submode}${p} $addr, $dst1", []>; let mayStore = 1 in def t2STM : T2XI<(outs), (ins addrmode4:$addr, pred:$p, reglist:$src1, variable_ops), - "stm${addr:submode}${p}.w $addr, $src1", []>; + "stm${addr:submode}${p} $addr, $src1", []>; //===----------------------------------------------------------------------===// // Move Instructions. @@ -704,6 +708,9 @@ defm t2RSBS : T2I_rbin_s_is <"rsb", BinOpFrag<(subc node:$LHS, node:$RHS)>>; // (sub X, imm) gets canonicalized to (add X, -imm). Match this form. +let AddedComplexity = 1 in +def : T2Pat<(add GPR:$src, imm0_255_neg:$imm), + (t2SUBri GPR:$src, imm0_255_neg:$imm)>; def : T2Pat<(add GPR:$src, t2_so_imm_neg:$imm), (t2SUBri GPR:$src, t2_so_imm_neg:$imm)>; def : T2Pat<(add GPR:$src, imm0_4095_neg:$imm), Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-sub.ll?rev=78030&r1=78029&r2=78030&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-sub.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-sub.ll Mon Aug 3 20:41:15 2009 @@ -1,31 +1,49 @@ -; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {sub\\.w\\W*r\[0-9\],\\W*r\[0-9\],\\W*#\[0-9\]*} | grep {#171\\|#1179666\\|#872428544\\|#1448498774\\|#510} | count 5 +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | FileCheck %s ; 171 = 0x000000ab define i32 @f1(i32 %a) { +; CHECK: f1: +; CHECK: sub.w r0, r0, #171 %tmp = sub i32 %a, 171 ret i32 %tmp } ; 1179666 = 0x00120012 define i32 @f2(i32 %a) { +; CHECK: f2: +; CHECK: sub.w r0, r0, #1179666 %tmp = sub i32 %a, 1179666 ret i32 %tmp } ; 872428544 = 0x34003400 define i32 @f3(i32 %a) { +; CHECK: f3: +; CHECK: sub.w r0, r0, #872428544 %tmp = sub i32 %a, 872428544 ret i32 %tmp } ; 1448498774 = 0x56565656 define i32 @f4(i32 %a) { +; CHECK: f4: +; CHECK: sub.w r0, r0, #1448498774 %tmp = sub i32 %a, 1448498774 ret i32 %tmp } ; 510 = 0x000001fe define i32 @f5(i32 %a) { +; CHECK: f5: +; CHECK: sub.w r0, r0, #510 %tmp = sub i32 %a, 510 ret i32 %tmp } + +; Don't change this to an add. +define i32 @f6(i32 %a) { +; CHECK: f6: +; CHECK: sub.w r0, r0, #1 + %tmp = sub i32 %a, 1 + ret i32 %tmp +} From evan.cheng at apple.com Mon Aug 3 20:43:46 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 01:43:46 -0000 Subject: [llvm-commits] [llvm] r78031 - in /llvm/trunk/lib/Target/ARM: ARMLoadStoreOptimizer.cpp AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200908040143.n741hkT0002792@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 3 20:43:45 2009 New Revision: 78031 URL: http://llvm.org/viewvc/llvm-project?rev=78031&view=rev Log: Load / store multiple pass fixes for Thumb2. Not enabled yet. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=78031&r1=78030&r2=78031&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Mon Aug 3 20:43:45 2009 @@ -143,12 +143,20 @@ return 0; } +static bool isT2i32Load(unsigned Opc) { + return Opc == ARM::t2LDRi12 || Opc == ARM::t2LDRi8; +} + static bool isi32Load(unsigned Opc) { - return Opc == ARM::LDR || Opc == ARM::t2LDRi12 || Opc == ARM::t2LDRi8; + return Opc == ARM::LDR || isT2i32Load(Opc); +} + +static bool isT2i32Store(unsigned Opc) { + return Opc == ARM::t2STRi12 || Opc == ARM::t2STRi8; } static bool isi32Store(unsigned Opc) { - return Opc == ARM::STR || Opc == ARM::t2STRi12 || Opc == ARM::t2STRi8; + return Opc == ARM::STR || isT2i32Store(Opc); } /// MergeOps - Create and insert a LDM or STM with Base as base register and @@ -211,7 +219,7 @@ } bool isDPR = Opcode == ARM::FLDD || Opcode == ARM::FSTD; - bool isDef = Opcode == ARM::LDR || Opcode == ARM::FLDS || Opcode == ARM::FLDD; + bool isDef = isi32Load(Opcode) || Opcode == ARM::FLDS || Opcode == ARM::FLDD; Opcode = getLoadStoreMultipleOpcode(Opcode); MachineInstrBuilder MIB = (isAM4) ? BuildMI(MBB, MBBI, dl, TII->get(Opcode)) @@ -309,24 +317,18 @@ } static inline bool isMatchingDecrement(MachineInstr *MI, unsigned Base, - unsigned Bytes, ARMCC::CondCodes Pred, - unsigned PredReg, bool isThumb2) { + unsigned Bytes, unsigned Limit, + ARMCC::CondCodes Pred, unsigned PredReg){ unsigned MyPredReg = 0; if (!MI) return false; - if (isThumb2) { - if (MI->getOpcode() != ARM::t2SUBri) - return false; - // Make sure the offset fits in 8 bits. - if (Bytes <= 0 || Bytes >= 0x100) - return false; - } else { - if (MI->getOpcode() != ARM::SUBri) - return false; - // Make sure the offset fits in 12 bits. - if (Bytes <= 0 || Bytes >= 0x1000) - return false; - } + if (MI->getOpcode() != ARM::t2SUBri && + MI->getOpcode() != ARM::SUBri) + return false; + + // Make sure the offset fits in 8 bits. + if (Bytes <= 0 || (Limit && Bytes >= Limit)) + return false; return (MI->getOperand(0).getReg() == Base && MI->getOperand(1).getReg() == Base && @@ -336,24 +338,18 @@ } static inline bool isMatchingIncrement(MachineInstr *MI, unsigned Base, - unsigned Bytes, ARMCC::CondCodes Pred, - unsigned PredReg, bool isThumb2) { + unsigned Bytes, unsigned Limit, + ARMCC::CondCodes Pred, unsigned PredReg){ unsigned MyPredReg = 0; if (!MI) return false; - if (isThumb2) { - if (MI->getOpcode() != ARM::t2ADDri) - return false; + if (MI->getOpcode() != ARM::t2ADDri && + MI->getOpcode() != ARM::ADDri) + return false; + + if (Bytes <= 0 || (Limit && Bytes >= Limit)) // Make sure the offset fits in 8 bits. - if (Bytes <= 0 || Bytes >= 0x100) - return false; - } else { - if (MI->getOpcode() != ARM::ADDri) - return false; - // Make sure the offset fits in 12 bits. - if (Bytes <= 0 || Bytes >= 0x1000) - return false; - } + return false; return (MI->getOperand(0).getReg() == Base && MI->getOperand(1).getReg() == Base && @@ -379,6 +375,8 @@ return 8; case ARM::LDM: case ARM::STM: + case ARM::t2LDM: + case ARM::t2STM: return (MI->getNumOperands() - 4) * 4; case ARM::FLDMS: case ARM::FSTMS: @@ -428,13 +426,12 @@ if (MBBI != MBB.begin()) { MachineBasicBlock::iterator PrevMBBI = prior(MBBI); if (Mode == ARM_AM::ia && - isMatchingDecrement(PrevMBBI, Base, Bytes, Pred, PredReg, isThumb2)) { + isMatchingDecrement(PrevMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM4ModeImm(ARM_AM::db, true)); MBB.erase(PrevMBBI); return true; } else if (Mode == ARM_AM::ib && - isMatchingDecrement(PrevMBBI, Base, Bytes, Pred, PredReg, - isThumb2)) { + isMatchingDecrement(PrevMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM4ModeImm(ARM_AM::da, true)); MBB.erase(PrevMBBI); return true; @@ -444,7 +441,7 @@ if (MBBI != MBB.end()) { MachineBasicBlock::iterator NextMBBI = next(MBBI); if ((Mode == ARM_AM::ia || Mode == ARM_AM::ib) && - isMatchingIncrement(NextMBBI, Base, Bytes, Pred, PredReg, isThumb2)) { + isMatchingIncrement(NextMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM4ModeImm(Mode, true)); if (NextMBBI == I) { Advance = true; @@ -453,8 +450,7 @@ MBB.erase(NextMBBI); return true; } else if ((Mode == ARM_AM::da || Mode == ARM_AM::db) && - isMatchingDecrement(NextMBBI, Base, Bytes, Pred, PredReg, - isThumb2)) { + isMatchingDecrement(NextMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM4ModeImm(Mode, true)); if (NextMBBI == I) { Advance = true; @@ -474,7 +470,7 @@ if (MBBI != MBB.begin()) { MachineBasicBlock::iterator PrevMBBI = prior(MBBI); if (Mode == ARM_AM::ia && - isMatchingDecrement(PrevMBBI, Base, Bytes, Pred, PredReg, isThumb2)) { + isMatchingDecrement(PrevMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM5Opc(ARM_AM::db, true, Offset)); MBB.erase(PrevMBBI); return true; @@ -484,7 +480,7 @@ if (MBBI != MBB.end()) { MachineBasicBlock::iterator NextMBBI = next(MBBI); if (Mode == ARM_AM::ia && - isMatchingIncrement(NextMBBI, Base, Bytes, Pred, PredReg, isThumb2)) { + isMatchingIncrement(NextMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM5Opc(ARM_AM::ia, true, Offset)); if (NextMBBI == I) { Advance = true; @@ -550,14 +546,16 @@ unsigned Bytes = getLSMultipleTransferSize(MI); int Opcode = MI->getOpcode(); DebugLoc dl = MI->getDebugLoc(); + bool isAM5 = Opcode == ARM::FLDD || Opcode == ARM::FLDS || + Opcode == ARM::FSTD || Opcode == ARM::FSTS; bool isAM2 = Opcode == ARM::LDR || Opcode == ARM::STR; if (isAM2 && ARM_AM::getAM2Offset(MI->getOperand(3).getImm()) != 0) return false; - else if (!isAM2 && !isThumb2 && - ARM_AM::getAM5Offset(MI->getOperand(2).getImm()) != 0) - return false; - else if (isThumb2 && MI->getOperand(2).getImm() != 0) + else if (isAM5 && ARM_AM::getAM5Offset(MI->getOperand(2).getImm()) != 0) return false; + else if (isT2i32Load(Opcode) || isT2i32Store(Opcode)) + if (MI->getOperand(2).getImm() != 0) + return false; bool isLd = isi32Load(Opcode) || Opcode == ARM::FLDS || Opcode == ARM::FLDD; // Can't do the merge if the destination register is the same as the would-be @@ -570,14 +568,16 @@ bool DoMerge = false; ARM_AM::AddrOpc AddSub = ARM_AM::add; unsigned NewOpc = 0; + // AM2 - 12 bits, thumb2 - 8 bits. + unsigned Limit = isAM5 ? 0 : (isAM2 ? 0x1000 : 0x100); if (MBBI != MBB.begin()) { MachineBasicBlock::iterator PrevMBBI = prior(MBBI); - if (isMatchingDecrement(PrevMBBI, Base, Bytes, Pred, PredReg, isThumb2)) { + if (isMatchingDecrement(PrevMBBI, Base, Bytes, Limit, Pred, PredReg)) { DoMerge = true; AddSub = ARM_AM::sub; NewOpc = getPreIndexedLoadStoreOpcode(Opcode); - } else if (isAM2 && isMatchingIncrement(PrevMBBI, Base, Bytes, - Pred, PredReg, isThumb2)) { + } else if (!isAM5 && + isMatchingIncrement(PrevMBBI, Base, Bytes, Limit,Pred,PredReg)) { DoMerge = true; NewOpc = getPreIndexedLoadStoreOpcode(Opcode); } @@ -587,13 +587,12 @@ if (!DoMerge && MBBI != MBB.end()) { MachineBasicBlock::iterator NextMBBI = next(MBBI); - if (isAM2 && isMatchingDecrement(NextMBBI, Base, Bytes, Pred, PredReg, - isThumb2)) { + if (!isAM5 && + isMatchingDecrement(NextMBBI, Base, Bytes, Limit, Pred, PredReg)) { DoMerge = true; AddSub = ARM_AM::sub; NewOpc = getPostIndexedLoadStoreOpcode(Opcode); - } else if (isMatchingIncrement(NextMBBI, Base, Bytes, Pred, PredReg, - isThumb2)) { + } else if (isMatchingIncrement(NextMBBI, Base, Bytes, Limit,Pred,PredReg)) { DoMerge = true; NewOpc = getPostIndexedLoadStoreOpcode(Opcode); } @@ -610,36 +609,46 @@ return false; bool isDPR = NewOpc == ARM::FLDMD || NewOpc == ARM::FSTMD; - unsigned Offset = isAM2 - ? ARM_AM::getAM2Opc(AddSub, Bytes, ARM_AM::no_shift) - : (isThumb2 - ? Bytes - : ARM_AM::getAM5Opc((AddSub == ARM_AM::sub) ? ARM_AM::db : ARM_AM::ia, - true, isDPR ? 2 : 1)); + unsigned Offset = isAM5 + ? ARM_AM::getAM5Opc((AddSub == ARM_AM::sub) ? ARM_AM::db : ARM_AM::ia, + true, isDPR ? 2 : 1) + : (isAM2 + ? ARM_AM::getAM2Opc(AddSub, Bytes, ARM_AM::no_shift) + : Bytes); if (isLd) { - if (isAM2 || isThumb2) - // LDR_PRE, LDR_POST, t2LDR_PRE, t2LDR_POST - BuildMI(MBB, MBBI, dl, TII->get(NewOpc), MI->getOperand(0).getReg()) - .addReg(Base, RegState::Define) - .addReg(Base).addReg(0).addImm(Offset).addImm(Pred).addReg(PredReg); - else if (!isThumb2) + if (isAM5) // FLDMS, FLDMD BuildMI(MBB, MBBI, dl, TII->get(NewOpc)) .addReg(Base, getKillRegState(BaseKill)) .addImm(Offset).addImm(Pred).addReg(PredReg) .addReg(MI->getOperand(0).getReg(), RegState::Define); - } else { - MachineOperand &MO = MI->getOperand(0); - if (isAM2 || isThumb2) - // STR_PRE, STR_POST, t2STR_PRE, t2STR_POST - BuildMI(MBB, MBBI, dl, TII->get(NewOpc), Base) - .addReg(MO.getReg(), getKillRegState(MO.isKill())) + else if (isAM2) + // LDR_PRE, LDR_POST, + BuildMI(MBB, MBBI, dl, TII->get(NewOpc), MI->getOperand(0).getReg()) + .addReg(Base, RegState::Define) .addReg(Base).addReg(0).addImm(Offset).addImm(Pred).addReg(PredReg); else + // t2LDR_PRE, t2LDR_POST + BuildMI(MBB, MBBI, dl, TII->get(NewOpc), MI->getOperand(0).getReg()) + .addReg(Base, RegState::Define) + .addReg(Base).addImm(Offset).addImm(Pred).addReg(PredReg); + } else { + MachineOperand &MO = MI->getOperand(0); + if (isAM5) // FSTMS, FSTMD BuildMI(MBB, MBBI, dl, TII->get(NewOpc)).addReg(Base).addImm(Offset) .addImm(Pred).addReg(PredReg) .addReg(MO.getReg(), getKillRegState(MO.isKill())); + else if (isAM2) + // STR_PRE, STR_POST + BuildMI(MBB, MBBI, dl, TII->get(NewOpc), Base) + .addReg(MO.getReg(), getKillRegState(MO.isKill())) + .addReg(Base).addReg(0).addImm(Offset).addImm(Pred).addReg(PredReg); + else + // t2STR_PRE, t2STR_POST + BuildMI(MBB, MBBI, dl, TII->get(NewOpc), Base) + .addReg(MO.getReg(), getKillRegState(MO.isKill())) + .addReg(Base).addImm(Offset).addImm(Pred).addReg(PredReg); } MBB.erase(MBBI); @@ -1010,13 +1019,13 @@ MachineInstr *PrevMI = prior(MBBI); if (PrevMI->getOpcode() == ARM::LDM || PrevMI->getOpcode() == ARM::t2LDM) { MachineOperand &MO = PrevMI->getOperand(PrevMI->getNumOperands()-1); - if (MO.getReg() == ARM::LR) { - unsigned NewOpc = isThumb2 ? ARM::t2LDM_RET : ARM::LDM_RET; - PrevMI->setDesc(TII->get(NewOpc)); - MO.setReg(ARM::PC); - MBB.erase(MBBI); - return true; - } + if (MO.getReg() != ARM::LR) + return false; + unsigned NewOpc = isThumb2 ? ARM::t2LDM_RET : ARM::LDM_RET; + PrevMI->setDesc(TII->get(NewOpc)); + MO.setReg(ARM::PC); + MBB.erase(MBBI); + return true; } } return false; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78031&r1=78030&r2=78031&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Mon Aug 3 20:43:45 2009 @@ -596,8 +596,10 @@ ARM_AM::AMSubMode Mode = ARM_AM::getAM4SubMode(MO2.getImm()); if (Modifier && strcmp(Modifier, "submode") == 0) { if (MO1.getReg() == ARM::SP) { + // FIXME bool isLDM = (MI->getOpcode() == ARM::LDM || - MI->getOpcode() == ARM::LDM_RET); + MI->getOpcode() == ARM::LDM_RET || + MI->getOpcode() == ARM::t2LDM_RET); O << ARM_AM::getAMSubModeAltStr(Mode, isLDM); } else O << ARM_AM::getAMSubModeStr(Mode); From evan.cheng at apple.com Mon Aug 3 20:56:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 01:56:10 -0000 Subject: [llvm-commits] [llvm] r78032 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.cpp ARMInstrInfo.h Message-ID: <200908040156.n741uAEb003237@zion.cs.uiuc.edu> Author: evancheng Date: Mon Aug 3 20:56:09 2009 New Revision: 78032 URL: http://llvm.org/viewvc/llvm-project?rev=78032&view=rev Log: Remove ARM specific getInlineAsmLength. We'll rely on the simpler (and faster) generic algorithm for now. If more accurate computation is needed, we'll rely on the disassembler. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=78032&r1=78031&r2=78032&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Mon Aug 3 20:56:09 2009 @@ -99,163 +99,3 @@ MBB.insert(I, MI); } -/// Count the number of comma-separated arguments. -/// Do not try to detect errors. -static unsigned countArguments(const char* p, - const TargetAsmInfo &TAI) { - unsigned count = 0; - while (*p && isspace(*p) && *p != '\n') - p++; - count++; - while (*p && *p!='\n' && - strncmp(p, TAI.getCommentString(), - strlen(TAI.getCommentString())) != 0) { - if (*p==',') - count++; - p++; - } - return count; -} - -/// Count the length of a string enclosed in quote characters. -/// Do not try to detect errors. -static unsigned countString(const char *p) { - unsigned count = 0; - while (*p && isspace(*p) && *p!='\n') - p++; - if (!*p || *p != '\"') - return count; - while (*++p && *p != '\"') - count++; - return count; -} - -/// ARM-specific version of TargetAsmInfo::getInlineAsmLength. -unsigned ARMInstrInfo::getInlineAsmLength(const char *s, - const TargetAsmInfo &TAI) const { - // Make a lowercase-folded version of s for counting purposes. - char *q, *s_copy = (char *)malloc(strlen(s) + 1); - strcpy(s_copy, s); - for (q=s_copy; *q; q++) - *q = tolower(*q); - const char *Str = s_copy; - - // Count the number of bytes in the asm. - bool atInsnStart = true; - bool inTextSection = true; - unsigned Length = 0; - for (; *Str; ++Str) { - if (atInsnStart) { - // Skip whitespace - while (*Str && isspace(*Str) && *Str != '\n') - Str++; - // Skip label - for (const char* p = Str; *p && !isspace(*p); p++) - if (*p == ':') { - Str = p+1; - while (*Str && isspace(*Str) && *Str != '\n') - Str++; - break; - } - - if (*Str == 0) break; - - // Ignore everything from comment char(s) to EOL - if (strncmp(Str, TAI.getCommentString(), - strlen(TAI.getCommentString())) == 0) - atInsnStart = false; - // FIXME do something like the following for non-Darwin - else if (*Str == '.' && Subtarget.isTargetDarwin()) { - // Directive. - atInsnStart = false; - - // Some change the section, but don't generate code. - if (strncmp(Str, ".literal4", strlen(".literal4"))==0 || - strncmp(Str, ".literal8", strlen(".literal8"))==0 || - strncmp(Str, ".const", strlen(".const"))==0 || - strncmp(Str, ".constructor", strlen(".constructor"))==0 || - strncmp(Str, ".cstring", strlen(".cstring"))==0 || - strncmp(Str, ".data", strlen(".data"))==0 || - strncmp(Str, ".destructor", strlen(".destructor"))==0 || - strncmp(Str, ".fvmlib_init0", strlen(".fvmlib_init0"))==0 || - strncmp(Str, ".fvmlib_init1", strlen(".fvmlib_init1"))==0 || - strncmp(Str, ".mod_init_func", strlen(".mod_init_func"))==0 || - strncmp(Str, ".mod_term_func", strlen(".mod_term_func"))==0 || - strncmp(Str, ".picsymbol_stub", strlen(".picsymbol_stub"))==0 || - strncmp(Str, ".symbol_stub", strlen(".symbol_stub"))==0 || - strncmp(Str, ".static_data", strlen(".static_data"))==0 || - strncmp(Str, ".section", strlen(".section"))==0 || - strncmp(Str, ".lazy_symbol_pointer", strlen(".lazy_symbol_pointer"))==0 || - strncmp(Str, ".non_lazy_symbol_pointer", strlen(".non_lazy_symbol_pointer"))==0 || - strncmp(Str, ".dyld", strlen(".dyld"))==0 || - strncmp(Str, ".const_data", strlen(".const_data"))==0 || - strncmp(Str, ".objc", strlen(".objc"))==0 || //// many directives - strncmp(Str, ".static_const", strlen(".static_const"))==0) - inTextSection=false; - else if (strncmp(Str, ".text", strlen(".text"))==0) - inTextSection = true; - // Some can't really be handled without implementing significant pieces - // of an assembler. Others require dynamic adjustment of block sizes in - // AdjustBBOffsetsAfter; it's a big compile-time speed hit to check every - // instruction in there, and none of these are currently used in the kernel. - else if (strncmp(Str, ".macro", strlen(".macro"))==0 || - strncmp(Str, ".if", strlen(".if"))==0 || - strncmp(Str, ".align", strlen(".align"))==0 || - strncmp(Str, ".fill", strlen(".fill"))==0 || - strncmp(Str, ".space", strlen(".space"))==0 || - strncmp(Str, ".zerofill", strlen(".zerofill"))==0 || - strncmp(Str, ".p2align", strlen(".p2align"))==0 || - strncmp(Str, ".p2alignw", strlen(".p2alignw"))==0 || - strncmp(Str, ".p2alignl", strlen(".p2alignl"))==0 || - strncmp(Str, ".align32", strlen(".p2align32"))==0 || - strncmp(Str, ".include", strlen(".include"))==0) - cerr << "Directive " << Str << " in asm may lead to invalid offsets for" << - " constant pools (the assembler will tell you if this happens).\n"; - // Some generate code, but this is only interesting in the text section. - else if (inTextSection) { - if (strncmp(Str, ".long", strlen(".long"))==0) - Length += 4*countArguments(Str+strlen(".long"), TAI); - else if (strncmp(Str, ".short", strlen(".short"))==0) - Length += 2*countArguments(Str+strlen(".short"), TAI); - else if (strncmp(Str, ".byte", strlen(".byte"))==0) - Length += 1*countArguments(Str+strlen(".byte"), TAI); - else if (strncmp(Str, ".single", strlen(".single"))==0) - Length += 4*countArguments(Str+strlen(".single"), TAI); - else if (strncmp(Str, ".double", strlen(".double"))==0) - Length += 8*countArguments(Str+strlen(".double"), TAI); - else if (strncmp(Str, ".quad", strlen(".quad"))==0) - Length += 16*countArguments(Str+strlen(".quad"), TAI); - else if (strncmp(Str, ".ascii", strlen(".ascii"))==0) - Length += countString(Str+strlen(".ascii")); - else if (strncmp(Str, ".asciz", strlen(".asciz"))==0) - Length += countString(Str+strlen(".asciz"))+1; - } - } else if (inTextSection) { - // An instruction - atInsnStart = false; - if (Subtarget.isThumb()) { // FIXME thumb2 - // BL and BLX are 4 bytes, all others 2. - if (strncmp(Str, "blx", strlen("blx"))==0) { - const char* p = Str+3; - while (*p && isspace(*p)) - p++; - if (*p == 'r' || *p=='R') - Length += 2; // BLX reg - else - Length += 4; // BLX non-reg - } else if (strncmp(Str, "bl", strlen("bl"))==0) - Length += 4; // BL - else - Length += 2; // Thumb anything else - } - else - Length += 4; // ARM - } - } - if (*Str == '\n' || *Str == TAI.getSeparatorChar()) - atInsnStart = true; - } - free(s_copy); - return Length; -} - Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=78032&r1=78031&r2=78032&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Mon Aug 3 20:56:09 2009 @@ -45,9 +45,6 @@ void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig) const; - - virtual unsigned getInlineAsmLength(const char *Str, - const TargetAsmInfo &TAI) const; }; } From sanjiv.gupta at microchip.com Mon Aug 3 21:16:45 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 04 Aug 2009 07:46:45 +0530 Subject: [llvm-commits] [llvm] r77974 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp In-Reply-To: <7D467673-881E-40C5-86E7-685A3E4BCFA3@apple.com> References: <200908031735.n73HZPBp018060@zion.cs.uiuc.edu> <7D467673-881E-40C5-86E7-685A3E4BCFA3@apple.com> Message-ID: <4A779A0D.8090004@microchip.com> Bob Wilson wrote: > This patch broke 3 of the ARM dejagnu tests. I've reverted it for now. > > Fine. Let me take a look at that and get back. > On Aug 3, 2009, at 10:35 AM, Sanjiv Gupta wrote: > > >> Author: sgupta >> Date: Mon Aug 3 12:35:21 2009 >> New Revision: 77974 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=77974&view=rev >> Log: >> Allow targets to custom handle softening of results or operands >> before trying the standard stuff. >> >> Modified: >> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=77974&r1=77973&r2=77974&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp >> (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Mon >> Aug 3 12:35:21 2009 >> @@ -47,6 +47,10 @@ >> errs() << "\n"); >> SDValue R = SDValue(); >> >> + // See if the target wants to custom handle softening this result. >> + if (CustomLowerNode(N, N->getValueType(ResNo), true)) >> + return; >> + >> switch (N->getOpcode()) { >> default: >> #ifndef NDEBUG >> @@ -535,6 +539,10 @@ >> errs() << "\n"); >> SDValue Res = SDValue(); >> >> + // See if target wants to custom handle softening this operand. >> + if (CustomLowerNode(N, N->getOperand(OpNo).getValueType(), false)) >> + return false; >> + >> switch (N->getOpcode()) { >> default: >> #ifndef NDEBUG >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Mon Aug 3 21:26:59 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Aug 2009 02:26:59 -0000 Subject: [llvm-commits] [llvm] r78033 - in /llvm/trunk: lib/Bitcode/Writer/BitcodeWriter.cpp test/Bitcode/metadata.ll Message-ID: <200908040227.n742R09W004181@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 3 21:26:56 2009 New Revision: 78033 URL: http://llvm.org/viewvc/llvm-project?rev=78033&view=rev Log: Constants and Metadata share ValueList. This means they must be emitted interleaved (using appropriate BLOCK_IDs) otherwise ValuePtrs index gets out of sync. Added: llvm/trunk/test/Bitcode/metadata.ll Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78033&r1=78032&r2=78033&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Aug 3 21:26:56 2009 @@ -473,50 +473,48 @@ return Flags; } -static void WriteMDNode(const MDNode *N, +/// WriteValues - Write Constants and Metadata. +/// This function could use some refactoring help. +static void WriteValues(unsigned FirstVal, unsigned LastVal, const ValueEnumerator &VE, - BitstreamWriter &Stream, - SmallVector &Record) { - for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { - if (N->getElement(i)) { - Record.push_back(VE.getTypeID(N->getElement(i)->getType())); - Record.push_back(VE.getValueID(N->getElement(i))); - } else { - Record.push_back(VE.getTypeID(Type::VoidTy)); - Record.push_back(0); - } - } - Stream.EmitRecord(bitc::METADATA_NODE, Record, 0); - Record.clear(); -} + BitstreamWriter &Stream, bool isGlobal) { + if (FirstVal == LastVal) return; -static void WriteModuleMetadata(const ValueEnumerator &VE, - BitstreamWriter &Stream) { - const ValueEnumerator::ValueList &Vals = VE.getValues(); - bool StartedMetadataBlock = false; + // MODULE_BLOCK_ID is 0, which is not handled here. So it is OK to use + // 0 as the initializer to indicate that block is not set. + enum bitc::BlockIDs LastBlockID = bitc::MODULE_BLOCK_ID; + + unsigned AggregateAbbrev = 0; + unsigned String8Abbrev = 0; + unsigned CString7Abbrev = 0; + unsigned CString6Abbrev = 0; unsigned MDSAbbrev = 0; + SmallVector Record; - for (unsigned i = 0, e = Vals.size(); i != e; ++i) { - - if (const MDNode *N = dyn_cast(Vals[i].first)) { - if (!StartedMetadataBlock) { + + const ValueEnumerator::ValueList &Vals = VE.getValues(); + const Type *LastTy = 0; + for (unsigned i = FirstVal; i != LastVal; ++i) { + const Value *V = Vals[i].first; + if (isa(V)) { + if (LastBlockID != bitc::METADATA_BLOCK_ID) { + // Exit privious block. + if (LastBlockID != bitc::MODULE_BLOCK_ID) + Stream.ExitBlock(); + + LastBlockID = bitc::METADATA_BLOCK_ID; Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - StartedMetadataBlock = true; } - WriteMDNode(N, VE, Stream, Record); - } else if (const MDString *MDS = dyn_cast(Vals[i].first)) { - if (!StartedMetadataBlock) { - Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - + } + if (const MDString *MDS = dyn_cast(V)) { + if (MDSAbbrev == 0) { // Abbrev for METADATA_STRING. BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_STRING)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); MDSAbbrev = Stream.EmitAbbrev(Abbv); - StartedMetadataBlock = true; } - // Code: [strchar x N] const char *StrBegin = MDS->begin(); for (unsigned i = 0, e = MDS->length(); i != e; ++i) @@ -525,12 +523,21 @@ // Emit the finished record. Stream.EmitRecord(bitc::METADATA_STRING, Record, MDSAbbrev); Record.clear(); - } else if (const NamedMDNode *NMD = dyn_cast(Vals[i].first)) { - if (!StartedMetadataBlock) { - Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - StartedMetadataBlock = true; + continue; + } else if (const MDNode *N = dyn_cast(V)) { + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { + if (N->getElement(i)) { + Record.push_back(VE.getTypeID(N->getElement(i)->getType())); + Record.push_back(VE.getValueID(N->getElement(i))); + } else { + Record.push_back(VE.getTypeID(Type::VoidTy)); + Record.push_back(0); + } } - + Stream.EmitRecord(bitc::METADATA_NODE, Record, 0); + Record.clear(); + continue; + } else if (const NamedMDNode *NMD = dyn_cast(V)) { // Write name. std::string Str = NMD->getNameStr(); const char *StrBegin = Str.c_str(); @@ -538,7 +545,7 @@ Record.push_back(StrBegin[i]); Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/); Record.clear(); - + // Write named metadata elements. for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { if (NMD->getElement(i)) @@ -548,59 +555,49 @@ } Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0); Record.clear(); + continue; } - } - - if (StartedMetadataBlock) - Stream.ExitBlock(); -} -static void WriteConstants(unsigned FirstVal, unsigned LastVal, - const ValueEnumerator &VE, - BitstreamWriter &Stream, bool isGlobal) { - if (FirstVal == LastVal) return; - - Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4); + // If we need to switch block, do so now. + if (LastBlockID != bitc::CONSTANTS_BLOCK_ID) { + // Exit privious block. + if (LastBlockID != bitc::MODULE_BLOCK_ID) + Stream.ExitBlock(); + + LastBlockID = bitc::CONSTANTS_BLOCK_ID; + Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4); + // If this is a constant pool for the module, emit module-specific abbrevs. + if (isGlobal) { + // Abbrev for CST_CODE_AGGREGATE. + BitCodeAbbrev *Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); + AggregateAbbrev = Stream.EmitAbbrev(Abbv); + + // Abbrev for CST_CODE_STRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); + String8Abbrev = Stream.EmitAbbrev(Abbv); - unsigned AggregateAbbrev = 0; - unsigned String8Abbrev = 0; - unsigned CString7Abbrev = 0; - unsigned CString6Abbrev = 0; - // If this is a constant pool for the module, emit module-specific abbrevs. - if (isGlobal) { - // Abbrev for CST_CODE_AGGREGATE. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); - AggregateAbbrev = Stream.EmitAbbrev(Abbv); + // Abbrev for CST_CODE_CSTRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); + CString7Abbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for CST_CODE_STRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); - String8Abbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); - CString7Abbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); - CString6Abbrev = Stream.EmitAbbrev(Abbv); - } - - SmallVector Record; + // Abbrev for CST_CODE_CSTRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + CString6Abbrev = Stream.EmitAbbrev(Abbv); + } - const ValueEnumerator::ValueList &Vals = VE.getValues(); - const Type *LastTy = 0; - for (unsigned i = FirstVal; i != LastVal; ++i) { - const Value *V = Vals[i].first; + } if (isa(V)) continue; // If we need to switch types, do so now. @@ -802,7 +799,7 @@ // We know globalvalues have been emitted by WriteModuleInfo. for (unsigned i = 0, e = Vals.size(); i != e; ++i) { if (!isa(Vals[i].first)) { - WriteConstants(i, Vals.size(), VE, Stream, true); + WriteValues(i, Vals.size(), VE, Stream, true); return; } } @@ -1131,7 +1128,7 @@ // If there are function-local constants, emit them now. unsigned CstStart, CstEnd; VE.getFunctionConstantRange(CstStart, CstEnd); - WriteConstants(CstStart, CstEnd, VE, Stream, false); + WriteValues(CstStart, CstEnd, VE, Stream, false); // Keep a running idea of what the instruction ID is. unsigned InstID = CstEnd; @@ -1384,9 +1381,6 @@ // Emit constants. WriteModuleConstants(VE, Stream); - // Emit metadata. - WriteModuleMetadata(VE, Stream); - // Emit function bodies. for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->isDeclaration()) @@ -1397,7 +1391,7 @@ // Emit names for globals/functions etc. WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream); - + Stream.ExitBlock(); } Added: llvm/trunk/test/Bitcode/metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/metadata.ll?rev=78033&view=auto ============================================================================== --- llvm/trunk/test/Bitcode/metadata.ll (added) +++ llvm/trunk/test/Bitcode/metadata.ll Mon Aug 3 21:26:56 2009 @@ -0,0 +1,5 @@ +; RUN: llvm-as < %s | llvm-dis -f -o /dev/null + +!llvm.foo = !{!0} +!0 = metadata !{i32 42} + at my.str = internal constant [4 x i8] c"foo\00" From dpatel at apple.com Mon Aug 3 21:36:40 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Aug 2009 02:36:40 -0000 Subject: [llvm-commits] [llvm] r78034 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <200908040236.n742aesE004477@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 3 21:36:39 2009 New Revision: 78034 URL: http://llvm.org/viewvc/llvm-project?rev=78034&view=rev Log: Fix MDString Abbrev setup. Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78034&r1=78033&r2=78034&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Aug 3 21:36:39 2009 @@ -504,10 +504,6 @@ LastBlockID = bitc::METADATA_BLOCK_ID; Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - } - } - if (const MDString *MDS = dyn_cast(V)) { - if (MDSAbbrev == 0) { // Abbrev for METADATA_STRING. BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_STRING)); @@ -515,6 +511,8 @@ Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); MDSAbbrev = Stream.EmitAbbrev(Abbv); } + } + if (const MDString *MDS = dyn_cast(V)) { // Code: [strchar x N] const char *StrBegin = MDS->begin(); for (unsigned i = 0, e = MDS->length(); i != e; ++i) From dpatel at apple.com Mon Aug 3 21:54:15 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Aug 2009 02:54:15 -0000 Subject: [llvm-commits] [llvm] r78035 - /llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Message-ID: <200908040254.n742sFD3005039@zion.cs.uiuc.edu> Author: dpatel Date: Mon Aug 3 21:54:15 2009 New Revision: 78035 URL: http://llvm.org/viewvc/llvm-project?rev=78035&view=rev Log: Remove dead code. Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78035&r1=78034&r2=78035&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Aug 3 21:54:15 2009 @@ -596,8 +596,6 @@ } } - if (isa(V)) - continue; // If we need to switch types, do so now. if (V->getType() != LastTy) { LastTy = V->getType(); From isanbard at gmail.com Mon Aug 3 22:17:08 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Aug 2009 03:17:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78036 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp tree.h varasm.c Message-ID: <200908040317.n743H9n0005692@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 22:17:06 2009 New Revision: 78036 URL: http://llvm.org/viewvc/llvm-project?rev=78036&view=rev Log: Don't adorn ObjC metadata with "\1[Ll]_". This is now done in the back-end, where it should be. Declare what used to be "\1L_OBJC_*" metadata "private" and what used to be "\1l_OBJC_" linker private. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/tree.h llvm-gcc-4.2/trunk/gcc/varasm.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=78036&r1=78035&r2=78036&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Aug 3 22:17:06 2009 @@ -102,6 +102,7 @@ std::vector > StaticCtors, StaticDtors; SmallSetVector AttributeUsedGlobals; +SmallSetVector AttributeCompilerUsedGlobals; std::vector AttributeAnnotateGlobals; /// PerFunctionPasses - This is the list of cleanup passes run per-function @@ -205,6 +206,11 @@ AttributeUsedGlobals.insert(New); } + if (AttributeCompilerUsedGlobals.count(Old)) { + AttributeCompilerUsedGlobals.remove(Old); + AttributeCompilerUsedGlobals.insert(New); + } + for (unsigned i = 0, e = StaticCtors.size(); i != e; ++i) { if (StaticCtors[i].first == Old) StaticCtors[i].first = New; @@ -788,6 +794,7 @@ sys::Program::ChangeStdoutToBinary(); AttributeUsedGlobals.clear(); + AttributeCompilerUsedGlobals.clear(); timevar_pop(TV_LLVM_INIT); } @@ -843,7 +850,8 @@ if (!AttributeUsedGlobals.empty()) { std::vector AUGs; const Type *SBP= PointerType::getUnqual(Type::Int8Ty); - for (SmallSetVector::iterator AI = AttributeUsedGlobals.begin(), + for (SmallSetVector::iterator + AI = AttributeUsedGlobals.begin(), AE = AttributeUsedGlobals.end(); AI != AE; ++AI) { Constant *C = *AI; AUGs.push_back(TheFolder->CreateBitCast(C, SBP)); @@ -858,6 +866,25 @@ AttributeUsedGlobals.clear(); } + if (!AttributeCompilerUsedGlobals.empty()) { + std::vector ACUGs; + const Type *SBP= PointerType::getUnqual(Type::Int8Ty); + for (SmallSetVector::iterator + AI = AttributeCompilerUsedGlobals.begin(), + AE = AttributeCompilerUsedGlobals.end(); AI != AE; ++AI) { + Constant *C = *AI; + ACUGs.push_back(TheFolder->CreateBitCast(C, SBP)); + } + + ArrayType *AT = ArrayType::get(SBP, ACUGs.size()); + Constant *Init = ConstantArray::get(AT, ACUGs); + GlobalValue *gv = new GlobalVariable(*TheModule, AT, false, + GlobalValue::AppendingLinkage, Init, + "llvm.compiler.used"); + gv->setSection("llvm.metadata"); + AttributeCompilerUsedGlobals.clear(); + } + // Add llvm.global.annotations if (!AttributeAnnotateGlobals.empty()) { Constant *Array = ConstantArray::get( @@ -1051,6 +1078,8 @@ // A weak alias has TREE_PUBLIC set but not the other bits. if (DECL_LLVM_PRIVATE(decl)) Linkage = GlobalValue::PrivateLinkage; + else if (DECL_LLVM_LINKER_PRIVATE(decl)) + Linkage = GlobalValue::LinkerPrivateLinkage; else if (DECL_WEAK(decl)) // The user may have explicitly asked for weak linkage - ignore flag_odr. Linkage = GlobalValue::WeakAnyLinkage; @@ -1317,6 +1346,9 @@ if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS) && DECL_LLVM_PRIVATE(decl)) { Linkage = GlobalValue::PrivateLinkage; + } else if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS) + && DECL_LLVM_LINKER_PRIVATE(decl)) { + Linkage = GlobalValue::LinkerPrivateLinkage; } else if (!TREE_PUBLIC(decl)) { Linkage = GlobalValue::InternalLinkage; } else if (DECL_WEAK(decl)) { @@ -1376,8 +1408,12 @@ } // Handle used decls - if (DECL_PRESERVE_P (decl)) - AttributeUsedGlobals.insert(GV); + if (DECL_PRESERVE_P (decl)) { + if (DECL_LLVM_PRIVATE (decl)) + AttributeUsedGlobals.insert(GV); + else if (DECL_LLVM_LINKER_PRIVATE (decl)) + AttributeCompilerUsedGlobals.insert(GV); + } // Add annotate attributes for globals if (DECL_ATTRIBUTES(decl)) Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=78036&r1=78035&r2=78036&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 3 22:17:06 2009 @@ -474,6 +474,8 @@ // Compute the linkage that the function should get. if (DECL_LLVM_PRIVATE(FnDecl)) { Fn->setLinkage(Function::PrivateLinkage); + } else if (DECL_LLVM_LINKER_PRIVATE(FnDecl)) { + Fn->setLinkage(Function::LinkerPrivateLinkage); } else if (!TREE_PUBLIC(FnDecl) /*|| lang_hooks.llvm_is_in_anon(subr)*/) { Fn->setLinkage(Function::InternalLinkage); } else if (DECL_COMDAT(FnDecl)) { @@ -1995,21 +1997,21 @@ // what exception is being unwound, append a catch-all. // The representation of a catch-all is language specific. - Value *Catch_All; + Value *CatchAll; if (!lang_eh_catch_all) { // Use a "cleanup" - this should be good enough for most languages. - Catch_All = ConstantInt::get(Type::Int32Ty, 0); + CatchAll = ConstantInt::get(Type::Int32Ty, 0); } else { tree catch_all_type = lang_eh_catch_all(); if (catch_all_type == NULL_TREE) // Use a C++ style null catch-all object. - Catch_All = Constant::getNullValue( + CatchAll = Constant::getNullValue( PointerType::getUnqual(Type::Int8Ty)); else // This language has a type that catches all others. - Catch_All = Emit(catch_all_type, 0); + CatchAll = Emit(catch_all_type, 0); } - Args.push_back(Catch_All); + Args.push_back(CatchAll); } // Emit the selector call. Modified: llvm-gcc-4.2/trunk/gcc/tree.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=78036&r1=78035&r2=78036&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/tree.h (original) +++ llvm-gcc-4.2/trunk/gcc/tree.h Mon Aug 3 22:17:06 2009 @@ -2927,6 +2927,8 @@ #ifdef ENABLE_LLVM #define DECL_LLVM_PRIVATE(NODE) \ (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.llvm_private_flag) +#define DECL_LLVM_LINKER_PRIVATE(NODE) \ + (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.llvm_linker_private_flag) #endif /* LLVM LOCAL end */ @@ -3069,6 +3071,7 @@ /* LLVM LOCAL begin */ unsigned llvm_private_flag : 1; + unsigned llvm_linker_private_flag : 1; /* LLVM LOCAL end */ ENUM_BITFIELD(symbol_visibility) visibility : 2; @@ -3091,7 +3094,7 @@ unsigned block_synthesized_function : 1; /* APPLE LOCAL radar 5847976 */ unsigned block_weak : 1; - /* 4 unused bits (llvm). */ + /* 3 unused bits (llvm). */ /* APPLE LOCAL end radar 5932809 - copyable byref blocks */ /* APPLE LOCAL end radar 5732232 - blocks */ }; Modified: llvm-gcc-4.2/trunk/gcc/varasm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/varasm.c?rev=78036&r1=78035&r2=78036&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/varasm.c (original) +++ llvm-gcc-4.2/trunk/gcc/varasm.c Mon Aug 3 22:17:06 2009 @@ -755,23 +755,45 @@ void set_user_assembler_name (tree decl, const char *name) { - char *starred = alloca (strlen (name) + 2); + size_t len = strlen (name); + char *starred = alloca (len + 2); /* LLVM LOCAL begin */ #ifndef ENABLE_LLVM starred[0] = '*'; strcpy (starred + 1, name); #else - /* If the name isn't an LLVM intrinsic, add a starting '\1' character to - * indicate that the target assembler shouldn't modify the name. If it *is* - * an LLVM intrinsic name, just set the name, to support code like this: - * unsigned bswap(unsigned) __asm__("llvm.bswap"); - */ - if (name[0] != 'l' || name[1] != 'l' || name[2] != 'v' || name[3] != 'm' - || name[4] != '.') { - starred[0] = 1; - strcpy (starred + 1, name); - } else { - strcpy (starred, name); + { + /* If the name isn't an LLVM intrinsic, add a starting '\1' character to + indicate that the target assembler shouldn't modify the name. If it *is* + an LLVM intrinsic name, just set the name, to support code like this: + unsigned bswap(unsigned) __asm__("llvm.bswap"); */ + bool has_llvm_prefix = + (len > 5 && name[0] == 'l' && name[1] == 'l' && name[2] == 'v' && + name[3] == 'm' && name[4] == '.'); + + /* If the name is an OBJC metadata name, then don't prepend a '\1' character + to it. Instead, mark it as either "private" or "linker private". */ + bool has_objc_prefix = + (len > 7 && (name[0] == 'l' || name[0] == 'L') && name[1] == '_' && + ((name[2] == 'O' && name[3] == 'B' && name[4] == 'J' && name[5] == 'C') || + (name[2] == 'o' && name[3] == 'b' && name[4] == 'j' && name[5] == 'c')) && + name[6] == '_'); + + if (!has_llvm_prefix && !has_objc_prefix) { + starred[0] = 1; + strcpy (starred + 1, name); + } else { + strcpy (starred, name); + + if (has_objc_prefix) { + DECL_LLVM_PRIVATE (decl) = (name[0] == 'L'); + DECL_LLVM_LINKER_PRIVATE (decl) = (name[0] == 'l'); + + /* Remove the "[Ll]_" prefix. The LLVM assembly printer is now + intelligent enough to add the appropriate prefix to the name. */ + strcpy (starred, &name[2]); + } + } } #endif /* LLVM LOCAL end */ From eocallaghan at auroraux.org Mon Aug 3 22:30:18 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 04 Aug 2009 03:30:18 -0000 Subject: [llvm-commits] [compiler-rt] r78037 - in /compiler-rt/trunk/lib: divdc3.c divsc3.c divxc3.c int_lib.h muldc3.c mulsc3.c mulxc3.c Message-ID: <200908040330.n743UJgt006096@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Aug 3 22:30:10 2009 New Revision: 78037 URL: http://llvm.org/viewvc/llvm-project?rev=78037&view=rev Log: Refactor out common pre-processor code. Modified: compiler-rt/trunk/lib/divdc3.c compiler-rt/trunk/lib/divsc3.c compiler-rt/trunk/lib/divxc3.c compiler-rt/trunk/lib/int_lib.h compiler-rt/trunk/lib/muldc3.c compiler-rt/trunk/lib/mulsc3.c compiler-rt/trunk/lib/mulxc3.c Modified: compiler-rt/trunk/lib/divdc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divdc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/divdc3.c (original) +++ compiler-rt/trunk/lib/divdc3.c Mon Aug 3 22:30:10 2009 @@ -15,10 +15,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the quotient of (a + ib) / (c + id) double _Complex Modified: compiler-rt/trunk/lib/divsc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divsc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/divsc3.c (original) +++ compiler-rt/trunk/lib/divsc3.c Mon Aug 3 22:30:10 2009 @@ -15,10 +15,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the quotient of (a + ib) / (c + id) float _Complex Modified: compiler-rt/trunk/lib/divxc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/divxc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/divxc3.c (original) +++ compiler-rt/trunk/lib/divxc3.c Mon Aug 3 22:30:10 2009 @@ -17,10 +17,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the quotient of (a + ib) / (c + id) long double _Complex Modified: compiler-rt/trunk/lib/int_lib.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_lib.h?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/int_lib.h (original) +++ compiler-rt/trunk/lib/int_lib.h Mon Aug 3 22:30:10 2009 @@ -19,6 +19,11 @@ // Assumption: right shift of signed negative is arithmetic shift #include +#include + +#if !defined(INFINITY) && defined(HUGE_VAL) +#define INFINITY HUGE_VAL +#endif // TODO: Improve this to minimal pre-processor hackish'ness. #if defined (__SVR4) && defined (__sun) Modified: compiler-rt/trunk/lib/muldc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/muldc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/muldc3.c (original) +++ compiler-rt/trunk/lib/muldc3.c Mon Aug 3 22:30:10 2009 @@ -15,10 +15,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the product of a + ib and c + id double _Complex Modified: compiler-rt/trunk/lib/mulsc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulsc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/mulsc3.c (original) +++ compiler-rt/trunk/lib/mulsc3.c Mon Aug 3 22:30:10 2009 @@ -15,10 +15,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the product of a + ib and c + id float _Complex Modified: compiler-rt/trunk/lib/mulxc3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulxc3.c?rev=78037&r1=78036&r2=78037&view=diff ============================================================================== --- compiler-rt/trunk/lib/mulxc3.c (original) +++ compiler-rt/trunk/lib/mulxc3.c Mon Aug 3 22:30:10 2009 @@ -17,10 +17,6 @@ #include #include -#if !defined(INFINITY) && defined(HUGE_VAL) -#define INFINITY HUGE_VAL -#endif - // Returns: the product of a + ib and c + id long double _Complex From isanbard at gmail.com Mon Aug 3 22:40:55 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Aug 2009 03:40:55 -0000 Subject: [llvm-commits] [llvm] r78038 - /llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Message-ID: <200908040340.n743euGh006397@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 22:40:47 2009 New Revision: 78038 URL: http://llvm.org/viewvc/llvm-project?rev=78038&view=rev Log: XFAIL for the moment. Modified: llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Modified: llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c?rev=78038&r1=78037&r2=78038&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c (original) +++ llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Mon Aug 3 22:40:47 2009 @@ -1,5 +1,7 @@ // RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llvm-dis | \ // RUN: grep llvm.used | grep foo | grep X +// FIXME - Unxfail this when I know what's going on. +// XFAIL: * int X __attribute__((used)); int Y; From rafael.espindola at gmail.com Mon Aug 3 22:43:46 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 04 Aug 2009 03:43:46 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78039 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <200908040343.n743hlGk006477@zion.cs.uiuc.edu> Author: rafael Date: Mon Aug 3 22:43:38 2009 New Revision: 78039 URL: http://llvm.org/viewvc/llvm-project?rev=78039&view=rev Log: In C++, produce a varargs function for "T foo(...)". Fixes PR 4678 Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=78039&r1=78038&r2=78039&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 3 22:43:38 2009 @@ -415,7 +415,11 @@ // allows C functions declared as "T foo() {}" to be treated like // "T foo(void) {}" and allows us to handle functions with K&R-style // definitions correctly. - if (TYPE_ARG_TYPES(TREE_TYPE(FnDecl)) == 0) { + // Don't do this for c++. In c++ "T foo() {}" is not varargs and + // if the user typed "T foo(...)", he probably wants a varargs + // function. This also avoids a warning in instcombine. See + // llvm.org/PR4678 + if (TYPE_ARG_TYPES(TREE_TYPE(FnDecl)) == 0 && !c_dialect_cxx()) { FTy = TheTypeConverter->ConvertArgListToFnType(TREE_TYPE(FnDecl), DECL_ARGUMENTS(FnDecl), static_chain, From rafael.espindola at gmail.com Mon Aug 3 22:44:38 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 04 Aug 2009 03:44:38 -0000 Subject: [llvm-commits] [llvm] r78040 - /llvm/trunk/test/FrontendC++/2009-08-03-Varargs.cpp Message-ID: <200908040344.n743idUR006512@zion.cs.uiuc.edu> Author: rafael Date: Mon Aug 3 22:44:37 2009 New Revision: 78040 URL: http://llvm.org/viewvc/llvm-project?rev=78040&view=rev Log: Add test for PR4678 Added: llvm/trunk/test/FrontendC++/2009-08-03-Varargs.cpp Added: llvm/trunk/test/FrontendC++/2009-08-03-Varargs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-08-03-Varargs.cpp?rev=78040&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/2009-08-03-Varargs.cpp (added) +++ llvm/trunk/test/FrontendC++/2009-08-03-Varargs.cpp Mon Aug 3 22:44:37 2009 @@ -0,0 +1,4 @@ +// RUN: %llvmgxx %s -S -emit-llvm -o - | grep _Z1az\(\.\.\.\) +// PR4678 +void a(...) { +} From isanbard at gmail.com Mon Aug 3 22:46:35 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Aug 2009 03:46:35 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78041 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200908040346.n743kZMN006596@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 22:46:34 2009 New Revision: 78041 URL: http://llvm.org/viewvc/llvm-project?rev=78041&view=rev Log: Oh yeah. Not everything that is "preserved" is LLVM_PRIVATE. . . Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=78041&r1=78040&r2=78041&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Aug 3 22:46:34 2009 @@ -1409,10 +1409,10 @@ // Handle used decls if (DECL_PRESERVE_P (decl)) { - if (DECL_LLVM_PRIVATE (decl)) - AttributeUsedGlobals.insert(GV); - else if (DECL_LLVM_LINKER_PRIVATE (decl)) + if (DECL_LLVM_LINKER_PRIVATE (decl)) AttributeCompilerUsedGlobals.insert(GV); + else + AttributeUsedGlobals.insert(GV); } // Add annotate attributes for globals From isanbard at gmail.com Mon Aug 3 22:46:54 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Aug 2009 03:46:54 -0000 Subject: [llvm-commits] [llvm] r78042 - /llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Message-ID: <200908040346.n743kt1P006615@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 22:46:54 2009 New Revision: 78042 URL: http://llvm.org/viewvc/llvm-project?rev=78042&view=rev Log: Fixed now. Modified: llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Modified: llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c?rev=78042&r1=78041&r2=78042&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c (original) +++ llvm/trunk/test/FrontendC/2005-12-04-AttributeUsed.c Mon Aug 3 22:46:54 2009 @@ -1,7 +1,5 @@ // RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llvm-dis | \ // RUN: grep llvm.used | grep foo | grep X -// FIXME - Unxfail this when I know what's going on. -// XFAIL: * int X __attribute__((used)); int Y; From daniel at zuster.org Mon Aug 3 23:02:48 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 04:02:48 -0000 Subject: [llvm-commits] [llvm] r78043 - in /llvm/trunk: include/llvm/Target/TargetRegistry.h lib/Target/CBackend/CBackend.cpp lib/Target/CBackend/CTargetMachine.h lib/Target/CppBackend/CPPBackend.cpp lib/Target/CppBackend/CPPTargetMachine.h lib/Target/MSIL/MSILWriter.cpp Message-ID: <200908040402.n7442rxF007097@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 23:02:45 2009 New Revision: 78043 URL: http://llvm.org/viewvc/llvm-project?rev=78043&view=rev Log: Remove now unused Module argument to createTargetMachine. Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/CBackend/CTargetMachine.h llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegistry.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegistry.h Mon Aug 3 23:02:45 2009 @@ -23,9 +23,6 @@ // FIXME: We shouldn't need this header, but we need it until there is a // different interface to get the TargetAsmInfo. #include "llvm/Target/TargetMachine.h" -// FIXME: We shouldn't need this header, but we need it until there is a -// different interface to the target machines. -#include "llvm/Module.h" #include #include @@ -50,7 +47,6 @@ typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT); typedef TargetMachine *(*TargetMachineCtorTy)(const Target &, - const Module &, const std::string &, const std::string &); typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &, @@ -120,12 +116,16 @@ /// feature set; it should always be provided. Generally this should be /// either the target triple from the module, or the target triple of the /// host if that does not exist. - TargetMachine *createTargetMachine(const Module &M, - const std::string &Triple, + TargetMachine *createTargetMachine(const std::string &Triple, const std::string &Features) const { if (!TargetMachineCtorFn) return 0; - return TargetMachineCtorFn(*this, M, Triple, Features); + return TargetMachineCtorFn(*this, Triple, Features); + } + TargetMachine *createTargetMachine(const Module &M, + const std::string &Triple, + const std::string &Features) const { + return createTargetMachine(Triple, Features); } /// createAsmPrinter - Create a target specific assembly printer pass. @@ -149,8 +149,6 @@ }; /// TargetRegistry - Generic interface to target specific features. - // - // FIXME: Provide Target* iterator. struct TargetRegistry { class iterator { const Target *Current; @@ -327,27 +325,12 @@ } private: - static TargetMachine *Allocator(const Target &T, const Module &M, - const std::string &TT, + static TargetMachine *Allocator(const Target &T, const std::string &TT, const std::string &FS) { return new TargetMachineImpl(T, TT, FS); } }; - template - struct RegisterTargetMachineDeprecated { - RegisterTargetMachineDeprecated(Target &T) { - TargetRegistry::RegisterTargetMachine(T, &Allocator); - } - - private: - static TargetMachine *Allocator(const Target &T, const Module &M, - const std::string &TT, - const std::string &FS) { - return new TargetMachineImpl(T, M, FS); - } - }; - /// RegisterAsmPrinter - Helper template for registering a target specific /// assembly printer, for use in the target machine initialization /// function. Usage: Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Mon Aug 3 23:02:45 2009 @@ -51,7 +51,7 @@ extern "C" void LLVMInitializeCBackendTarget() { // Register the target. - RegisterTargetMachineDeprecated X(TheCBackendTarget); + RegisterTargetMachine X(TheCBackendTarget); } namespace { Modified: llvm/trunk/lib/Target/CBackend/CTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CTargetMachine.h?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CTargetMachine.h (original) +++ llvm/trunk/lib/Target/CBackend/CTargetMachine.h Mon Aug 3 23:02:45 2009 @@ -20,11 +20,8 @@ namespace llvm { struct CTargetMachine : public TargetMachine { - const TargetData DataLayout; // Calculates type size & alignment - - CTargetMachine(const Target &T, const Module &M, - const std::string &FS) - : TargetMachine(T), DataLayout(&M) {} + CTargetMachine(const Target &T, const std::string &TT, const std::string &FS) + : TargetMachine(T) {} virtual bool WantsWholeFile() const { return true; } virtual bool addPassesToEmitWholeFile(PassManager &PM, Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Aug 3 23:02:45 2009 @@ -74,7 +74,7 @@ extern "C" void LLVMInitializeCppBackendTarget() { // Register the target. - RegisterTargetMachineDeprecated X(TheCppBackendTarget); + RegisterTargetMachine X(TheCppBackendTarget); } namespace { Modified: llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h (original) +++ llvm/trunk/lib/Target/CppBackend/CPPTargetMachine.h Mon Aug 3 23:02:45 2009 @@ -22,11 +22,9 @@ class formatted_raw_ostream; struct CPPTargetMachine : public TargetMachine { - const TargetData DataLayout; // Calculates type size & alignment - - CPPTargetMachine(const Target &T, const Module &M, + CPPTargetMachine(const Target &T, const std::string &TT, const std::string &FS) - : TargetMachine(T), DataLayout(&M) {} + : TargetMachine(T) {} virtual bool WantsWholeFile() const { return true; } virtual bool addPassesToEmitWholeFile(PassManager &PM, Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=78043&r1=78042&r2=78043&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Mon Aug 3 23:02:45 2009 @@ -31,10 +31,8 @@ namespace llvm { // TargetMachine for the MSIL struct VISIBILITY_HIDDEN MSILTarget : public TargetMachine { - const TargetData DataLayout; // Calculates type size & alignment - - MSILTarget(const Target &T, const Module &M, const std::string &FS) - : TargetMachine(T), DataLayout(&M) {} + MSILTarget(const Target &T, const std::string &TT, const std::string &FS) + : TargetMachine(T) {} virtual bool WantsWholeFile() const { return true; } virtual bool addPassesToEmitWholeFile(PassManager &PM, @@ -48,7 +46,7 @@ extern "C" void LLVMInitializeMSILTarget() { // Register the target. - RegisterTargetMachineDeprecated X(TheMSILTarget); + RegisterTargetMachine X(TheMSILTarget); } bool MSILModule::runOnModule(Module &M) { From daniel at zuster.org Mon Aug 3 23:04:04 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 04:04:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78045 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <200908040404.n74445wk007161@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 23:04:04 2009 New Revision: 78045 URL: http://llvm.org/viewvc/llvm-project?rev=78045&view=rev Log: Update for LLVM API change Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=78045&r1=78044&r2=78045&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Aug 3 23:04:04 2009 @@ -474,7 +474,7 @@ LLVM_SET_SUBTARGET_FEATURES(Features); FeatureStr = Features.getString(); #endif - TheTarget = TME->createTargetMachine(*TheModule, Triple, FeatureStr); + TheTarget = TME->createTargetMachine(Triple, FeatureStr); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); TheFolder = new TargetFolder(TheTarget->getTargetData(), getGlobalContext()); From daniel at zuster.org Mon Aug 3 23:04:25 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 04:04:25 -0000 Subject: [llvm-commits] [llvm] r78046 - /llvm/trunk/include/llvm/Target/TargetRegistry.h Message-ID: <200908040404.n7444Pug007181@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 23:04:25 2009 New Revision: 78046 URL: http://llvm.org/viewvc/llvm-project?rev=78046&view=rev Log: Remove unused function. Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=78046&r1=78045&r2=78046&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegistry.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegistry.h Mon Aug 3 23:04:25 2009 @@ -122,11 +122,6 @@ return 0; return TargetMachineCtorFn(*this, Triple, Features); } - TargetMachine *createTargetMachine(const Module &M, - const std::string &Triple, - const std::string &Features) const { - return createTargetMachine(Triple, Features); - } /// createAsmPrinter - Create a target specific assembly printer pass. FunctionPass *createAsmPrinter(formatted_raw_ostream &OS, From daniel at zuster.org Mon Aug 3 23:08:40 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 04:08:40 -0000 Subject: [llvm-commits] [llvm] r78047 - in /llvm/trunk: lib/ExecutionEngine/JIT/TargetSelect.cpp lib/Target/CBackend/CBackend.cpp tools/llc/llc.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOModule.cpp Message-ID: <200908040408.n7448eSw007338@zion.cs.uiuc.edu> Author: ddunbar Date: Mon Aug 3 23:08:40 2009 New Revision: 78047 URL: http://llvm.org/viewvc/llvm-project?rev=78047&view=rev Log: No really, it's unused. Modified: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp?rev=78047&r1=78046&r2=78047&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp Mon Aug 3 23:08:40 2009 @@ -76,8 +76,7 @@ // Allocate a target... TargetMachine *Target = - TheTarget->createTargetMachine(*MP->getModule(), TheTriple.getTriple(), - FeaturesStr); + TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr); assert(Target && "Could not allocate target machine!"); return Target; } Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=78047&r1=78046&r2=78047&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Mon Aug 3 23:08:40 2009 @@ -3190,8 +3190,7 @@ if (Match) { // Per platform Target Machines don't exist, so create it; // this must be done only once. - const TargetMachine* TM = Match->createTargetMachine(*TheModule, Triple, - ""); + const TargetMachine* TM = Match->createTargetMachine(Triple, ""); TAsm = TM->getTargetAsmInfo(); } } Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=78047&r1=78046&r2=78047&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Mon Aug 3 23:08:40 2009 @@ -285,8 +285,7 @@ } std::auto_ptr - target(TheTarget->createTargetMachine(mod, TheTriple.getTriple(), - FeaturesStr)); + target(TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr)); assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=78047&r1=78046&r2=78047&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Aug 3 23:08:40 2009 @@ -322,7 +322,6 @@ Triple = sys::getHostTriple(); // create target machine from info for merged modules - Module* mergedModule = _linker.getModule(); const Target *march = TargetRegistry::lookupTarget(Triple, errMsg); if ( march == NULL ) return true; @@ -343,7 +342,7 @@ // construct LTModule, hand over ownership of module and target std::string FeatureStr = getFeatureString(Triple.c_str()); - _target = march->createTargetMachine(*mergedModule, Triple, FeatureStr); + _target = march->createTargetMachine(Triple, FeatureStr); } return false; } Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=78047&r1=78046&r2=78047&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Mon Aug 3 23:08:40 2009 @@ -162,7 +162,7 @@ // construct LTModule, hand over ownership of module and target std::string FeatureStr = getFeatureString(Triple.c_str()); - TargetMachine* target = march->createTargetMachine(*m, Triple, FeatureStr); + TargetMachine* target = march->createTargetMachine(Triple, FeatureStr); return new LTOModule(m.take(), target); } From nicholas at mxc.ca Mon Aug 3 23:08:44 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Aug 2009 21:08:44 -0700 Subject: [llvm-commits] [llvm] r77960 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOCodeGenerator.h lto.cpp In-Reply-To: References: <200908030716.n737GhAj016782@zion.cs.uiuc.edu> <352a1fb20908030859p5309772esa8fa97b38885f4c7@mail.gmail.com> Message-ID: <4A77B44C.2000702@mxc.ca> Chris Lattner wrote: > On Aug 3, 2009, at 8:59 AM, Devang Patel wrote: > >> On Mon, Aug 3, 2009 at 12:16 AM, Nick Lewycky wrote: >>> Author: nicholas >>> Date: Mon Aug 3 02:16:42 2009 >>> New Revision: 77960 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=77960&view=rev >>> Log: >>> Remove the GCC path from libLTO. This has been superceded by >>> setAssemblerPath. >>> >>> Modified: >>> llvm/trunk/tools/lto/LTOCodeGenerator.cpp >>> llvm/trunk/tools/lto/LTOCodeGenerator.h >>> llvm/trunk/tools/lto/lto.cpp >> What about lto_codegen_set_gcc_path() ? This is breaking (removing) C >> api. Is it really necessary ? > > Is anyone using it? As far as I know there's exactly two users of libLTO, the gold plugin which is in tree, and the Apple linker. The plugin started with set_gcc_path, then Apple LD added set_assembler_path, then I changed gold to use it instead. I'd like to remove set_gcc_path before anyone else starts using it, especially before we make a release with it. Nick From sabre at nondot.org Mon Aug 3 23:31:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 04:31:03 -0000 Subject: [llvm-commits] [llvm] r78048 - in /llvm/trunk: include/llvm/Value.h include/llvm/ValueSymbolTable.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Value.cpp Message-ID: <200908040431.n744V3h9008282@zion.cs.uiuc.edu> Author: lattner Date: Mon Aug 3 23:31:02 2009 New Revision: 78048 URL: http://llvm.org/viewvc/llvm-project?rev=78048&view=rev Log: switch ValueMap to using AssertingVH. This is an old patch I had laying around in a tree I forgot about. Modified: llvm/trunk/include/llvm/Value.h llvm/trunk/include/llvm/ValueSymbolTable.h llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=78048&r1=78047&r2=78048&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Mon Aug 3 23:31:02 2009 @@ -38,7 +38,7 @@ template class StringMapEntry; template class AssertingVH; -typedef StringMapEntry ValueName; +typedef StringMapEntry > ValueName; class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; Modified: llvm/trunk/include/llvm/ValueSymbolTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ValueSymbolTable.h?rev=78048&r1=78047&r2=78048&view=diff ============================================================================== --- llvm/trunk/include/llvm/ValueSymbolTable.h (original) +++ llvm/trunk/include/llvm/ValueSymbolTable.h Mon Aug 3 23:31:02 2009 @@ -17,6 +17,7 @@ #include "llvm/Value.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { template @@ -44,7 +45,7 @@ /// @{ public: /// @brief A mapping of names to values. - typedef StringMap ValueMap; + typedef StringMap > ValueMap; /// @brief An iterator over a ValueMap. typedef ValueMap::iterator iterator; Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78048&r1=78047&r2=78048&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Aug 3 23:31:02 2009 @@ -1083,7 +1083,7 @@ // VST_ENTRY: [valueid, namechar x N] // VST_BBENTRY: [bbid, namechar x N] unsigned Code; - if (isa(SI->getValue())) { + if (isa(*SI->getValue())) { Code = bitc::VST_CODE_BBENTRY; if (isChar6) AbbrevToUse = VST_BBENTRY_6_ABBREV; Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=78048&r1=78047&r2=78048&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Mon Aug 3 23:31:02 2009 @@ -57,6 +57,14 @@ } Value::~Value() { + // If this value is named, destroy the name. This should not be in a symtab + // at this point. + if (Name) + Name->Destroy(); + + // There should be no uses of this object anymore, remove it. + LeakDetector::removeGarbageObject(this); + // Notify all ValueHandles (if present) that this value is going away. if (HasValueHandle) ValueHandleBase::ValueIsDeleted(this); @@ -76,14 +84,6 @@ } #endif assert(use_empty() && "Uses remain when a value is destroyed!"); - - // If this value is named, destroy the name. This should not be in a symtab - // at this point. - if (Name) - Name->Destroy(); - - // There should be no uses of this object anymore, remove it. - LeakDetector::removeGarbageObject(this); } /// hasNUses - Return true if this Value has exactly N users. From isanbard at gmail.com Mon Aug 3 23:48:31 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Aug 2009 04:48:31 -0000 Subject: [llvm-commits] [llvm] r78051 - /llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c Message-ID: <200908040448.n744mVOm008838@zion.cs.uiuc.edu> Author: void Date: Mon Aug 3 23:48:31 2009 New Revision: 78051 URL: http://llvm.org/viewvc/llvm-project?rev=78051&view=rev Log: llvm-gcc checks the static asm variable is valid in ValidateRegisterVariable. Make this work for PPC. Modified: llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c Modified: llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c?rev=78051&r1=78050&r2=78051&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c (original) +++ llvm/trunk/test/FrontendC/2004-03-16-AsmRegisterCrash.c Mon Aug 3 23:48:31 2009 @@ -1,6 +1,10 @@ // RUN: %llvmgcc -S %s -o - | llvm-as -f -o /dev/null int foo() { +#ifdef __ppc__ + register int X __asm__("r1"); +#else register int X __asm__("ebx"); +#endif return X; } From eocallaghan at auroraux.org Mon Aug 3 23:48:38 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 04 Aug 2009 04:48:38 -0000 Subject: [llvm-commits] [compiler-rt] r78052 - /compiler-rt/trunk/www/index.html Message-ID: <200908040448.n744mdmF008855@zion.cs.uiuc.edu> Author: evocallaghan Date: Mon Aug 3 23:48:38 2009 New Revision: 78052 URL: http://llvm.org/viewvc/llvm-project?rev=78052&view=rev Log: Some compiler-rt www site improvements. Modified: compiler-rt/trunk/www/index.html Modified: compiler-rt/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/www/index.html?rev=78052&r1=78051&r2=78052&view=diff ============================================================================== --- compiler-rt/trunk/www/index.html (original) +++ compiler-rt/trunk/www/index.html Mon Aug 3 23:48:38 2009 @@ -47,14 +47,7 @@

The current feature set of compiler-rt is:

    -
  • Full support for the libgcc interfaces required by these targets: -
      -
    • Darwin i386
    • -
    • Darwin X86-64
    • -
    • Darwin PowerPC
    • -
    • Darwin PowerPC 64
    • -
  • - +
  • Full support for the libgcc interfaces on supported targets.
  • High performance hand tuned implementations of commonly used functions like __floatundidf in assembly that are dramatically faster than the libgcc implementations.
  • @@ -63,6 +56,39 @@
+

Platform Support

+ + +

Compiler-RT is known to work on the following platforms:

+ +
  • Machine Architectures: +
      +
    • i386
    • +
    • X86-64
    • +
    • PowerPC
    • +
    • PowerPC 64
    • +
  • + + + + + + + + + + + + + + + +
    OSArch
    AuroraUXAll +
    LinuxAll +
    DarwinAll +
    + +

    Source Structure

    From dpatel at apple.com Tue Aug 4 00:01:45 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Aug 2009 05:01:45 -0000 Subject: [llvm-commits] [llvm] r78053 - in /llvm/trunk: lib/Bitcode/Writer/BitcodeWriter.cpp test/Bitcode/metadata.ll Message-ID: <200908040501.n7451nag009241@zion.cs.uiuc.edu> Author: dpatel Date: Tue Aug 4 00:01:35 2009 New Revision: 78053 URL: http://llvm.org/viewvc/llvm-project?rev=78053&view=rev Log: Revert recent bitcode writer patches. Removed: llvm/trunk/test/Bitcode/metadata.ll Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78053&r1=78052&r2=78053&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Aug 4 00:01:35 2009 @@ -473,46 +473,50 @@ return Flags; } -/// WriteValues - Write Constants and Metadata. -/// This function could use some refactoring help. -static void WriteValues(unsigned FirstVal, unsigned LastVal, +static void WriteMDNode(const MDNode *N, const ValueEnumerator &VE, - BitstreamWriter &Stream, bool isGlobal) { - if (FirstVal == LastVal) return; - - // MODULE_BLOCK_ID is 0, which is not handled here. So it is OK to use - // 0 as the initializer to indicate that block is not set. - enum bitc::BlockIDs LastBlockID = bitc::MODULE_BLOCK_ID; + BitstreamWriter &Stream, + SmallVector &Record) { + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { + if (N->getElement(i)) { + Record.push_back(VE.getTypeID(N->getElement(i)->getType())); + Record.push_back(VE.getValueID(N->getElement(i))); + } else { + Record.push_back(VE.getTypeID(Type::VoidTy)); + Record.push_back(0); + } + } + Stream.EmitRecord(bitc::METADATA_NODE, Record, 0); + Record.clear(); +} - unsigned AggregateAbbrev = 0; - unsigned String8Abbrev = 0; - unsigned CString7Abbrev = 0; - unsigned CString6Abbrev = 0; +static void WriteModuleMetadata(const ValueEnumerator &VE, + BitstreamWriter &Stream) { + const ValueEnumerator::ValueList &Vals = VE.getValues(); + bool StartedMetadataBlock = false; unsigned MDSAbbrev = 0; - SmallVector Record; - - const ValueEnumerator::ValueList &Vals = VE.getValues(); - const Type *LastTy = 0; - for (unsigned i = FirstVal; i != LastVal; ++i) { - const Value *V = Vals[i].first; - if (isa(V)) { - if (LastBlockID != bitc::METADATA_BLOCK_ID) { - // Exit privious block. - if (LastBlockID != bitc::MODULE_BLOCK_ID) - Stream.ExitBlock(); - - LastBlockID = bitc::METADATA_BLOCK_ID; + for (unsigned i = 0, e = Vals.size(); i != e; ++i) { + + if (const MDNode *N = dyn_cast(Vals[i].first)) { + if (!StartedMetadataBlock) { Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + StartedMetadataBlock = true; + } + WriteMDNode(N, VE, Stream, Record); + } else if (const MDString *MDS = dyn_cast(Vals[i].first)) { + if (!StartedMetadataBlock) { + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + // Abbrev for METADATA_STRING. BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_STRING)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); MDSAbbrev = Stream.EmitAbbrev(Abbv); + StartedMetadataBlock = true; } - } - if (const MDString *MDS = dyn_cast(V)) { + // Code: [strchar x N] const char *StrBegin = MDS->begin(); for (unsigned i = 0, e = MDS->length(); i != e; ++i) @@ -521,21 +525,12 @@ // Emit the finished record. Stream.EmitRecord(bitc::METADATA_STRING, Record, MDSAbbrev); Record.clear(); - continue; - } else if (const MDNode *N = dyn_cast(V)) { - for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) { - if (N->getElement(i)) { - Record.push_back(VE.getTypeID(N->getElement(i)->getType())); - Record.push_back(VE.getValueID(N->getElement(i))); - } else { - Record.push_back(VE.getTypeID(Type::VoidTy)); - Record.push_back(0); - } + } else if (const NamedMDNode *NMD = dyn_cast(Vals[i].first)) { + if (!StartedMetadataBlock) { + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + StartedMetadataBlock = true; } - Stream.EmitRecord(bitc::METADATA_NODE, Record, 0); - Record.clear(); - continue; - } else if (const NamedMDNode *NMD = dyn_cast(V)) { + // Write name. std::string Str = NMD->getNameStr(); const char *StrBegin = Str.c_str(); @@ -543,7 +538,7 @@ Record.push_back(StrBegin[i]); Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/); Record.clear(); - + // Write named metadata elements. for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) { if (NMD->getElement(i)) @@ -553,49 +548,61 @@ } Stream.EmitRecord(bitc::METADATA_NAMED_NODE, Record, 0); Record.clear(); - continue; } + } + + if (StartedMetadataBlock) + Stream.ExitBlock(); +} - // If we need to switch block, do so now. - if (LastBlockID != bitc::CONSTANTS_BLOCK_ID) { - // Exit privious block. - if (LastBlockID != bitc::MODULE_BLOCK_ID) - Stream.ExitBlock(); - - LastBlockID = bitc::CONSTANTS_BLOCK_ID; - Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4); - // If this is a constant pool for the module, emit module-specific abbrevs. - if (isGlobal) { - // Abbrev for CST_CODE_AGGREGATE. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); - AggregateAbbrev = Stream.EmitAbbrev(Abbv); - - // Abbrev for CST_CODE_STRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); - String8Abbrev = Stream.EmitAbbrev(Abbv); +static void WriteConstants(unsigned FirstVal, unsigned LastVal, + const ValueEnumerator &VE, + BitstreamWriter &Stream, bool isGlobal) { + if (FirstVal == LastVal) return; + + Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4); - // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); - CString7Abbrev = Stream.EmitAbbrev(Abbv); + unsigned AggregateAbbrev = 0; + unsigned String8Abbrev = 0; + unsigned CString7Abbrev = 0; + unsigned CString6Abbrev = 0; + // If this is a constant pool for the module, emit module-specific abbrevs. + if (isGlobal) { + // Abbrev for CST_CODE_AGGREGATE. + BitCodeAbbrev *Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); + AggregateAbbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); - CString6Abbrev = Stream.EmitAbbrev(Abbv); - } + // Abbrev for CST_CODE_STRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); + String8Abbrev = Stream.EmitAbbrev(Abbv); + // Abbrev for CST_CODE_CSTRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); + CString7Abbrev = Stream.EmitAbbrev(Abbv); + // Abbrev for CST_CODE_CSTRING. + Abbv = new BitCodeAbbrev(); + Abbv->Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + CString6Abbrev = Stream.EmitAbbrev(Abbv); + } + + SmallVector Record; - } + const ValueEnumerator::ValueList &Vals = VE.getValues(); + const Type *LastTy = 0; + for (unsigned i = FirstVal; i != LastVal; ++i) { + const Value *V = Vals[i].first; + if (isa(V)) + continue; // If we need to switch types, do so now. if (V->getType() != LastTy) { LastTy = V->getType(); @@ -795,7 +802,7 @@ // We know globalvalues have been emitted by WriteModuleInfo. for (unsigned i = 0, e = Vals.size(); i != e; ++i) { if (!isa(Vals[i].first)) { - WriteValues(i, Vals.size(), VE, Stream, true); + WriteConstants(i, Vals.size(), VE, Stream, true); return; } } @@ -1124,7 +1131,7 @@ // If there are function-local constants, emit them now. unsigned CstStart, CstEnd; VE.getFunctionConstantRange(CstStart, CstEnd); - WriteValues(CstStart, CstEnd, VE, Stream, false); + WriteConstants(CstStart, CstEnd, VE, Stream, false); // Keep a running idea of what the instruction ID is. unsigned InstID = CstEnd; @@ -1377,6 +1384,9 @@ // Emit constants. WriteModuleConstants(VE, Stream); + // Emit metadata. + WriteModuleMetadata(VE, Stream); + // Emit function bodies. for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) if (!I->isDeclaration()) @@ -1387,7 +1397,7 @@ // Emit names for globals/functions etc. WriteValueSymbolTable(M->getValueSymbolTable(), VE, Stream); - + Stream.ExitBlock(); } Removed: llvm/trunk/test/Bitcode/metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/metadata.ll?rev=78052&view=auto ============================================================================== --- llvm/trunk/test/Bitcode/metadata.ll (original) +++ llvm/trunk/test/Bitcode/metadata.ll (removed) @@ -1,5 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis -f -o /dev/null - -!llvm.foo = !{!0} -!0 = metadata !{i32 42} - at my.str = internal constant [4 x i8] c"foo\00" From eocallaghan at auroraux.org Tue Aug 4 00:24:32 2009 From: eocallaghan at auroraux.org (Edward O'Callaghan) Date: Tue, 04 Aug 2009 05:24:32 -0000 Subject: [llvm-commits] [llvm] r78054 - /llvm/trunk/docs/GettingStarted.html Message-ID: <200908040524.n745OX6l010077@zion.cs.uiuc.edu> Author: evocallaghan Date: Tue Aug 4 00:24:28 2009 New Revision: 78054 URL: http://llvm.org/viewvc/llvm-project?rev=78054&view=rev Log: Minor www site formating improvements. Modified: llvm/trunk/docs/GettingStarted.html Modified: llvm/trunk/docs/GettingStarted.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GettingStarted.html?rev=78054&r1=78053&r2=78054&view=diff ============================================================================== --- llvm/trunk/docs/GettingStarted.html (original) +++ llvm/trunk/docs/GettingStarted.html Tue Aug 4 00:24:28 2009 @@ -226,6 +226,11 @@ GCC + Linux + amd64 + GCC + + Solaris V9 (Ultrasparc) GCC @@ -244,7 +249,6 @@ MacOS X2,9 x86 GCC - Cygwin/Win32 @@ -256,11 +260,6 @@ x861,6,8 GCC 3.4.X, binutils 2.15 - - Linux - amd64 - GCC -

    LLVM has partial support for the following platforms:

    From sabre at nondot.org Tue Aug 4 00:35:56 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 05:35:56 -0000 Subject: [llvm-commits] [llvm] r78055 - in /llvm/trunk: include/llvm/MC/SectionKind.h lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Message-ID: <200908040535.n745Zv9h010445@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 00:35:56 2009 New Revision: 78055 URL: http://llvm.org/viewvc/llvm-project?rev=78055&view=rev Log: make MergeableCString be a SectionKind "abstract class", and add new concrete versions for 1/2/4-byte mergable strings. These are not actually created yet. Modified: llvm/trunk/include/llvm/MC/SectionKind.h llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Modified: llvm/trunk/include/llvm/MC/SectionKind.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/SectionKind.h?rev=78055&r1=78054&r2=78055&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/SectionKind.h (original) +++ llvm/trunk/include/llvm/MC/SectionKind.h Tue Aug 4 00:35:56 2009 @@ -38,13 +38,20 @@ /// SectionKind are not mergeable. ReadOnly, - /// MergeableCString - This is a special section for nul-terminated - /// strings. The linker can unique the C strings, knowing their - /// semantics. Because it uniques based on the nul terminators, the - /// compiler can't put strings in this section that have embeded nuls - /// in them. - MergeableCString, + /// MergableCString - Any null-terminated string which allows merging. + /// These values are known to end in a nul value of the specified size, + /// not otherwise contain a nul value, and be mergable. This allows the + /// linker to unique the strings if it so desires. + + /// Mergeable1ByteCString - 1 byte mergable, null terminated, string. + Mergeable1ByteCString, + /// Mergeable2ByteCString - 2 byte mergable, null terminated, string. + Mergeable2ByteCString, + + /// Mergeable4ByteCString - 4 byte mergable, null terminated, string. + Mergeable4ByteCString, + /// MergeableConst - These are sections for merging fixed-length /// constants together. For example, this can be used to unique /// constant pool entries etc. @@ -119,15 +126,22 @@ bool isText() const { return K == Text; } bool isReadOnly() const { - return K == ReadOnly || K == MergeableCString || isMergeableConst(); + return K == ReadOnly || isMergeableCString() || + isMergeableConst(); } - bool isMergeableCString() const { return K == MergeableCString; } + bool isMergeableCString() const { + return K == Mergeable1ByteCString || K == Mergeable2ByteCString || + K == Mergeable4ByteCString; + } + bool isMergeable1ByteCString() const { return K == Mergeable1ByteCString; } + bool isMergeable2ByteCString() const { return K == Mergeable2ByteCString; } + bool isMergeable4ByteCString() const { return K == Mergeable4ByteCString; } + bool isMergeableConst() const { return K == MergeableConst || K == MergeableConst4 || K == MergeableConst8 || K == MergeableConst16; } - bool isMergeableConst4() const { return K == MergeableConst4; } bool isMergeableConst8() const { return K == MergeableConst8; } bool isMergeableConst16() const { return K == MergeableConst16; } @@ -177,7 +191,15 @@ static SectionKind getMetadata() { return get(Metadata); } static SectionKind getText() { return get(Text); } static SectionKind getReadOnly() { return get(ReadOnly); } - static SectionKind getMergeableCString() { return get(MergeableCString); } + static SectionKind getMergeable1ByteCString() { + return get(Mergeable1ByteCString); + } + static SectionKind getMergeable2ByteCString() { + return get(Mergeable2ByteCString); + } + static SectionKind getMergeable4ByteCString() { + return get(Mergeable4ByteCString); + } static SectionKind getMergeableConst() { return get(MergeableConst); } static SectionKind getMergeableConst4() { return get(MergeableConst4); } static SectionKind getMergeableConst8() { return get(MergeableConst8); } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=78055&r1=78054&r2=78055&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Aug 4 00:35:56 2009 @@ -905,6 +905,7 @@ getObjFileLowering().SectionForGlobal(GVar, Mang, TM); SwitchToSection(TheSection); + /// FIXME: Drive this off the section! if (C->isNullValue() && /* FIXME: Verify correct */ !GVar->hasSection() && (GVar->hasLocalLinkage() || GVar->hasExternalLinkage() || Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78055&r1=78054&r2=78055&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Aug 4 00:35:56 2009 @@ -135,8 +135,10 @@ // If initializer is a null-terminated string, put it in a "cstring" // section if the target has it. if (isConstantString(C)) - return SectionKind::getMergeableCString(); + return SectionKind::getMergeable1ByteCString(); + // FIXME: Detect 2/4 byte strings. + // Otherwise, just drop it into a mergable constant section. If we have // a section for this size, use it, otherwise use the arbitrary sized // mergable section. @@ -290,8 +292,10 @@ getOrCreateSection("\t.rodata", false, SectionKind::getReadOnly()); TLSDataSection = getOrCreateSection("\t.tdata", false, SectionKind::getThreadData()); + + // FIXME: No reason to make this. CStringSection = getOrCreateSection("\t.rodata.str", true, - SectionKind::getMergeableCString()); + SectionKind::getMergeable1ByteCString()); TLSBSSSection = getOrCreateSection("\t.tbss", false, SectionKind::getThreadBSS()); @@ -392,12 +396,16 @@ Str.push_back('x'); if (Kind.isWriteable()) Str.push_back('w'); - if (Kind.isMergeableCString() || + if (Kind.isMergeable1ByteCString() || + Kind.isMergeable2ByteCString() || + Kind.isMergeable4ByteCString() || Kind.isMergeableConst4() || Kind.isMergeableConst8() || Kind.isMergeableConst16()) Str.push_back('M'); - if (Kind.isMergeableCString()) + if (Kind.isMergeable1ByteCString() || + Kind.isMergeable2ByteCString() || + Kind.isMergeable4ByteCString()) Str.push_back('S'); if (Kind.isThreadLocal()) Str.push_back('T'); @@ -419,11 +427,15 @@ Str.append(KindStr, KindStr+strlen(KindStr)); - if (Kind.isMergeableCString()) { - // TODO: Eventually handle multiple byte character strings. For now, all - // mergable C strings are single byte. + if (Kind.isMergeable1ByteCString()) { Str.push_back(','); Str.push_back('1'); + } else if (Kind.isMergeable2ByteCString()) { + Str.push_back(','); + Str.push_back('2'); + } else if (Kind.isMergeable4ByteCString()) { + Str.push_back(','); + Str.push_back('4'); } else if (Kind.isMergeableConst4()) { Str.push_back(','); Str.push_back('4'); @@ -469,7 +481,9 @@ if (Kind.isText()) return TextSection; - if (Kind.isMergeableCString()) { + if (Kind.isMergeable1ByteCString() || + Kind.isMergeable2ByteCString() || + Kind.isMergeable4ByteCString()) { assert(CStringSection && "Should have string section prefix"); // We also need alignment here. @@ -478,9 +492,17 @@ unsigned Align = TM.getTargetData()->getPreferredAlignment(cast(GV)); - std::string Name = CStringSection->getName() + "1." + utostr(Align); - return getOrCreateSection(Name.c_str(), false, - SectionKind::getMergeableCString()); + const char *SizeSpec = "1."; + if (Kind.isMergeable2ByteCString()) + SizeSpec = "2."; + else if (Kind.isMergeable4ByteCString()) + SizeSpec = "4."; + else + assert(Kind.isMergeable1ByteCString() && "unknown string width"); + + + std::string Name = CStringSection->getName() + SizeSpec + utostr(Align); + return getOrCreateSection(Name.c_str(), false, Kind); } if (Kind.isMergeableConst()) { @@ -549,7 +571,7 @@ SectionKind::getDataRel()); CStringSection = getOrCreateSection("\t.cstring", true, - SectionKind::getMergeableCString()); + SectionKind::getMergeable1ByteCString()); FourByteConstantSection = getOrCreateSection("\t.literal4\n", true, SectionKind::getMergeableConst4()); EightByteConstantSection = getOrCreateSection("\t.literal8\n", true, @@ -660,7 +682,7 @@ } // FIXME: Alignment check should be handled by section classifier. - if (Kind.isMergeableCString()) { + if (Kind.isMergeable1ByteCString()) { Constant *C = cast(GV)->getInitializer(); const Type *Ty = cast(C->getType())->getElementType(); const TargetData &TD = *TM.getTargetData(); Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=78055&r1=78054&r2=78055&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Aug 4 00:35:56 2009 @@ -788,6 +788,7 @@ getObjFileLowering().SectionForGlobal(GVar, Mang, TM); SwitchToSection(TheSection); + // FIXME: get this stuff from section kind flags. if (C->isNullValue() && !GVar->hasSection() && // Don't put things that should go in the cstring section into "comm". !TheSection->getKind().isMergeableCString()) { From dpatel at apple.com Tue Aug 4 01:00:21 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Aug 2009 06:00:21 -0000 Subject: [llvm-commits] [llvm] r78056 - in /llvm/trunk: lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Reader/BitcodeReader.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/Bitcode/Writer/ValueEnumerator.cpp lib/Bitcode/Writer/ValueEnumerator.h test/Bitcode/metadata-2.ll test/Bitcode/metadata.ll Message-ID: <200908040600.n7460MEq011227@zion.cs.uiuc.edu> Author: dpatel Date: Tue Aug 4 01:00:18 2009 New Revision: 78056 URL: http://llvm.org/viewvc/llvm-project?rev=78056&view=rev Log: Use separate ValueList for metadata. This fixes PR4666. Added: llvm/trunk/test/Bitcode/metadata-2.ll llvm/trunk/test/Bitcode/metadata.ll Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=78056&r1=78055&r2=78056&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Aug 4 01:00:18 2009 @@ -34,6 +34,7 @@ Buffer = 0; std::vector().swap(TypeList); ValueList.clear(); + MDValueList.clear(); std::vector().swap(MAttributes); std::vector().swap(FunctionBBs); @@ -312,6 +313,41 @@ } } +void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) { + if (Idx == size()) { + push_back(V); + return; + } + + if (Idx >= size()) + resize(Idx+1); + + WeakVH &OldV = MDValuePtrs[Idx]; + if (OldV == 0) { + OldV = V; + return; + } + + // If there was a forward reference to this value, replace it. + Value *PrevVal = OldV; + OldV->replaceAllUsesWith(V); + delete PrevVal; +} + +Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { + if (Idx >= size()) + resize(Idx + 1); + + if (Value *V = MDValuePtrs[Idx]) { + assert(V->getType() == Type::MetadataTy && "Type mismatch in value table!"); + return V; + } + + // Create and return a placeholder, which will later be RAUW'd. + Value *V = new Argument(Type::MetadataTy); + MDValuePtrs[Idx] = V; + return V; +} const Type *BitcodeReader::getTypeByID(unsigned ID, bool isTypeTable) { // If the TypeID is in range, return it. @@ -700,7 +736,7 @@ } bool BitcodeReader::ParseMetadata() { - unsigned NextValueNo = ValueList.size(); + unsigned NextValueNo = MDValueList.size(); if (Stream.EnterSubBlock(bitc::METADATA_BLOCK_ID)) return Error("Malformed block record"); @@ -752,13 +788,13 @@ unsigned Size = Record.size(); SmallVector Elts; for (unsigned i = 0; i != Size; ++i) { - Value *MD = ValueList.getValueFwdRef(Record[i], Type::MetadataTy); + Value *MD = MDValueList.getValueFwdRef(Record[i]); if (MetadataBase *B = dyn_cast(MD)) Elts.push_back(B); } Value *V = NamedMDNode::Create(Name.c_str(), Elts.data(), Elts.size(), TheModule); - ValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextValueNo++); break; } case bitc::METADATA_NODE: { @@ -769,13 +805,15 @@ SmallVector Elts; for (unsigned i = 0; i != Size; i += 2) { const Type *Ty = getTypeByID(Record[i], false); - if (Ty != Type::VoidTy) + if (Ty == Type::MetadataTy) + Elts.push_back(MDValueList.getValueFwdRef(Record[i+1])); + else if (Ty != Type::VoidTy) Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty)); else Elts.push_back(NULL); } Value *V = MDNode::get(Context, &Elts[0], Elts.size()); - ValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextValueNo++); break; } case bitc::METADATA_STRING: { @@ -786,7 +824,7 @@ String[i] = Record[i]; Value *V = MDString::get(Context, StringRef(String.data(), String.size())); - ValueList.AssignValue(V, NextValueNo++); + MDValueList.AssignValue(V, NextValueNo++); break; } } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=78056&r1=78055&r2=78056&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Tue Aug 4 01:00:18 2009 @@ -86,6 +86,41 @@ void ResolveConstantForwardRefs(); }; + +//===----------------------------------------------------------------------===// +// BitcodeReaderMDValueList Class +//===----------------------------------------------------------------------===// + +class BitcodeReaderMDValueList { + std::vector MDValuePtrs; + + LLVMContext& Context; +public: + BitcodeReaderMDValueList(LLVMContext& C) : Context(C) {} + + // vector compatibility methods + unsigned size() const { return MDValuePtrs.size(); } + void resize(unsigned N) { MDValuePtrs.resize(N); } + void push_back(Value *V) { MDValuePtrs.push_back(V); } + void clear() { MDValuePtrs.clear(); } + Value *back() const { return MDValuePtrs.back(); } + void pop_back() { MDValuePtrs.pop_back(); } + bool empty() const { return MDValuePtrs.empty(); } + + Value *operator[](unsigned i) const { + assert(i < MDValuePtrs.size()); + return MDValuePtrs[i]; + } + + void shrinkTo(unsigned N) { + assert(N <= size() && "Invalid shrinkTo request!"); + MDValuePtrs.resize(N); + } + + Value *getValueFwdRef(unsigned Idx); + void AssignValue(Value *V, unsigned Idx); +}; + class BitcodeReader : public ModuleProvider { LLVMContext& Context; MemoryBuffer *Buffer; @@ -96,6 +131,7 @@ std::vector TypeList; BitcodeReaderValueList ValueList; + BitcodeReaderMDValueList MDValueList; std::vector > GlobalInits; std::vector > AliasInits; @@ -127,7 +163,7 @@ DenseMap > DeferredFunctionInfo; public: explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext& C) - : Context(C), Buffer(buffer), ErrorString(0), ValueList(C) { + : Context(C), Buffer(buffer), ErrorString(0), ValueList(C), MDValueList(C) { HasReversedFunctionsWithBodies = false; } ~BitcodeReader() { @@ -160,7 +196,10 @@ private: const Type *getTypeByID(unsigned ID, bool isTypeTable = false); Value *getFnValueByID(unsigned ID, const Type *Ty) { - return ValueList.getValueFwdRef(ID, Ty); + if (Ty == Type::MetadataTy) + return MDValueList.getValueFwdRef(ID); + else + return ValueList.getValueFwdRef(ID, Ty); } BasicBlock *getBasicBlock(unsigned ID) const { if (ID >= FunctionBBs.size()) return 0; // Invalid ID Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78056&r1=78055&r2=78056&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Aug 4 01:00:18 2009 @@ -492,7 +492,7 @@ static void WriteModuleMetadata(const ValueEnumerator &VE, BitstreamWriter &Stream) { - const ValueEnumerator::ValueList &Vals = VE.getValues(); + const ValueEnumerator::ValueList &Vals = VE.getMDValues(); bool StartedMetadataBlock = false; unsigned MDSAbbrev = 0; SmallVector Record; @@ -601,8 +601,6 @@ const Type *LastTy = 0; for (unsigned i = FirstVal; i != LastVal; ++i) { const Value *V = Vals[i].first; - if (isa(V)) - continue; // If we need to switch types, do so now. if (V->getType() != LastTy) { LastTy = V->getType(); Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=78056&r1=78055&r2=78056&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Tue Aug 4 01:00:18 2009 @@ -114,6 +114,18 @@ TypeMap[Types[i].first] = i+1; } +unsigned ValueEnumerator::getValueID(const Value *V) const { + if (isa(V)) { + ValueMapType::const_iterator I = MDValueMap.find(V); + assert(I != MDValueMap.end() && "Value not in slotcalculator!"); + return I->second-1; + } + + ValueMapType::const_iterator I = ValueMap.find(V); + assert(I != ValueMap.end() && "Value not in slotcalculator!"); + return I->second-1; +} + // Optimize constant ordering. namespace { struct CstSortPredicate { @@ -165,9 +177,51 @@ EnumerateValue(VI->getValue()); } +void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) { + // Check to see if it's already in! + unsigned &MDValueID = MDValueMap[MD]; + if (MDValueID) { + // Increment use count. + MDValues[MDValueID-1].second++; + return; + } + + // Enumerate the type of this value. + EnumerateType(MD->getType()); + + if (const MDNode *N = dyn_cast(MD)) { + MDValues.push_back(std::make_pair(MD, 1U)); + MDValueMap[MD] = MDValues.size(); + MDValueID = MDValues.size(); + for (MDNode::const_elem_iterator I = N->elem_begin(), E = N->elem_end(); + I != E; ++I) { + if (*I) + EnumerateValue(*I); + else + EnumerateType(Type::VoidTy); + } + return; + } else if (const NamedMDNode *N = dyn_cast(MD)) { + for(NamedMDNode::const_elem_iterator I = N->elem_begin(), + E = N->elem_end(); I != E; ++I) { + MetadataBase *M = *I; + EnumerateValue(M); + } + MDValues.push_back(std::make_pair(MD, 1U)); + MDValueMap[MD] = Values.size(); + return; + } + + // Add the value. + MDValues.push_back(std::make_pair(MD, 1U)); + MDValueID = MDValues.size(); +} + void ValueEnumerator::EnumerateValue(const Value *V) { assert(V->getType() != Type::VoidTy && "Can't insert void values!"); - + if (const MetadataBase *MB = dyn_cast(V)) + return EnumerateMetadata(MB); + // Check to see if it's already in! unsigned &ValueID = ValueMap[V]; if (ValueID) { @@ -207,31 +261,6 @@ } } - if (const MDNode *N = dyn_cast(V)) { - Values.push_back(std::make_pair(V, 1U)); - ValueMap[V] = Values.size(); - ValueID = Values.size(); - for (MDNode::const_elem_iterator I = N->elem_begin(), E = N->elem_end(); - I != E; ++I) { - if (*I) - EnumerateValue(*I); - else - EnumerateType(Type::VoidTy); - } - return; - } - - if (const NamedMDNode *N = dyn_cast(V)) { - for(NamedMDNode::const_elem_iterator I = N->elem_begin(), - E = N->elem_end(); I != E; ++I) { - MetadataBase *M = *I; - EnumerateValue(M); - } - Values.push_back(std::make_pair(V, 1U)); - ValueMap[V] = Values.size(); - return; - } - // Add the value. Values.push_back(std::make_pair(V, 1U)); ValueID = Values.size(); Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=78056&r1=78055&r2=78056&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original) +++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Tue Aug 4 01:00:18 2009 @@ -25,6 +25,7 @@ class BasicBlock; class Function; class Module; +class MetadataBase; class AttrListPtr; class TypeSymbolTable; class ValueSymbolTable; @@ -44,7 +45,9 @@ typedef DenseMap ValueMapType; ValueMapType ValueMap; ValueList Values; - + ValueList MDValues; + ValueMapType MDValueMap; + typedef DenseMap AttributeMapType; AttributeMapType AttributeMap; std::vector Attributes; @@ -64,12 +67,8 @@ public: ValueEnumerator(const Module *M); - unsigned getValueID(const Value *V) const { - ValueMapType::const_iterator I = ValueMap.find(V); - assert(I != ValueMap.end() && "Value not in slotcalculator!"); - return I->second-1; - } - + unsigned getValueID(const Value *V) const; + unsigned getTypeID(const Type *T) const { TypeMapType::const_iterator I = TypeMap.find(T); assert(I != TypeMap.end() && "Type not in ValueEnumerator!"); @@ -91,6 +90,7 @@ } const ValueList &getValues() const { return Values; } + const ValueList &getMDValues() const { return MDValues; } const TypeList &getTypes() const { return Types; } const std::vector &getBasicBlocks() const { return BasicBlocks; @@ -108,6 +108,7 @@ private: void OptimizeConstants(unsigned CstStart, unsigned CstEnd); + void EnumerateMetadata(const MetadataBase *MD); void EnumerateValue(const Value *V); void EnumerateType(const Type *T); void EnumerateOperandType(const Value *V); Added: llvm/trunk/test/Bitcode/metadata-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/metadata-2.ll?rev=78056&view=auto ============================================================================== --- llvm/trunk/test/Bitcode/metadata-2.ll (added) +++ llvm/trunk/test/Bitcode/metadata-2.ll Tue Aug 4 01:00:18 2009 @@ -0,0 +1,87 @@ +; RUN: llvm-as < %s | llvm-dis -f -o /dev/null + type { %object.ModuleInfo.__vtbl*, i8*, %"byte[]", %1, %"ClassInfo[]", i32, void ()*, void ()*, void ()*, i8*, void ()* } ; type %0 + type { i64, %object.ModuleInfo* } ; type %1 + type { i32, void ()* } ; type %2 + %"ClassInfo[]" = type { i64, %object.ClassInfo** } + %"Interface[]" = type { i64, %object.Interface* } + %"ModuleInfo[]" = type { i64, %object.ModuleInfo** } + %ModuleReference = type { %ModuleReference*, %object.ModuleInfo* } + %"OffsetTypeInfo[]" = type { i64, %object.OffsetTypeInfo* } + %"byte[]" = type { i64, i8* } + %object.ClassInfo = type { %object.ClassInfo.__vtbl*, i8*, %"byte[]", %"byte[]", %"void*[]", %"Interface[]", %object.ClassInfo*, i8*, i8*, i32, i8*, %"OffsetTypeInfo[]", i8*, %object.TypeInfo* } + %object.ClassInfo.__vtbl = type { %object.ClassInfo*, %"byte[]" (%object.Object*)*, i64 (%object.Object*)*, i32 (%object.Object*, %object.Object*)*, i32 (%object.Object*, %object.Object*)*, %object.Object* (%object.ClassInfo*)* } + %object.Interface = type { %object.ClassInfo*, %"void*[]", i64 } + %object.ModuleInfo = type { %object.ModuleInfo.__vtbl*, i8*, %"byte[]", %"ModuleInfo[]", %"ClassInfo[]", i32, void ()*, void ()*, void ()*, i8*, void ()* } + %object.ModuleInfo.__vtbl = type { %object.ClassInfo*, %"byte[]" (%object.Object*)*, i64 (%object.Object*)*, i32 (%object.Object*, %object.Object*)*, i32 (%object.Object*, %object.Object*)* } + %object.Object = type { %object.ModuleInfo.__vtbl*, i8* } + %object.OffsetTypeInfo = type { i64, %object.TypeInfo* } + %object.TypeInfo = type { %object.TypeInfo.__vtbl*, i8* } + %object.TypeInfo.__vtbl = type { %object.ClassInfo*, %"byte[]" (%object.Object*)*, i64 (%object.Object*)*, i32 (%object.Object*, %object.Object*)*, i32 (%object.Object*, %object.Object*)*, i64 (%object.TypeInfo*, i8*)*, i32 (%object.TypeInfo*, i8*, i8*)*, i32 (%object.TypeInfo*, i8*, i8*)*, i64 (%object.TypeInfo*)*, void (%object.TypeInfo*, i8*, i8*)*, %object.TypeInfo* (%object.TypeInfo*)*, %"byte[]" (%object.TypeInfo*)*, i32 (%object.TypeInfo*)*, %"OffsetTypeInfo[]" (%object.TypeInfo*)* } + %"void*[]" = type { i64, i8** } + at _D10ModuleInfo6__vtblZ = external constant %object.ModuleInfo.__vtbl ; <%object.ModuleInfo.__vtbl*> [#uses=1] + at .str = internal constant [20 x i8] c"tango.core.BitManip\00" ; <[20 x i8]*> [#uses=1] + at _D5tango4core8BitManip8__ModuleZ = global %0 { %object.ModuleInfo.__vtbl* @_D10ModuleInfo6__vtblZ, i8* null, %"byte[]" { i64 19, i8* getelementptr ([20 x i8]* @.str, i32 0, i32 0) }, %1 zeroinitializer, %"ClassInfo[]" zeroinitializer, i32 4, void ()* null, void ()* null, void ()* null, i8* null, void ()* null } ; <%0*> [#uses=1] + at _D5tango4core8BitManip11__moduleRefZ = internal global %ModuleReference { %ModuleReference* null, %object.ModuleInfo* bitcast (%0* @_D5tango4core8BitManip8__ModuleZ to %object.ModuleInfo*) } ; <%ModuleReference*> [#uses=2] + at _Dmodule_ref = external global %ModuleReference* ; <%ModuleReference**> [#uses=2] + at llvm.global_ctors = appending constant [1 x %2] [%2 { i32 65535, void ()* @_D5tango4core8BitManip16__moduleinfoCtorZ }] ; <[1 x %2]*> [#uses=0] + +define fastcc i32 @_D5tango4core8BitManip6popcntFkZi(i32 %x_arg) nounwind readnone { +entry: + %tmp1 = lshr i32 %x_arg, 1 ; [#uses=1] + %tmp2 = and i32 %tmp1, 1431655765 ; [#uses=1] + %tmp4 = sub i32 %x_arg, %tmp2 ; [#uses=2] + %tmp6 = lshr i32 %tmp4, 2 ; [#uses=1] + %tmp7 = and i32 %tmp6, 858993459 ; [#uses=1] + %tmp9 = and i32 %tmp4, 858993459 ; [#uses=1] + %tmp10 = add i32 %tmp7, %tmp9 ; [#uses=2] + %tmp12 = lshr i32 %tmp10, 4 ; [#uses=1] + %tmp14 = add i32 %tmp12, %tmp10 ; [#uses=1] + %tmp16 = and i32 %tmp14, 252645135 ; [#uses=2] + %tmp18 = lshr i32 %tmp16, 8 ; [#uses=1] + %tmp20 = add i32 %tmp18, %tmp16 ; [#uses=1] + %tmp22 = and i32 %tmp20, 16711935 ; [#uses=2] + %tmp24 = lshr i32 %tmp22, 16 ; [#uses=1] + %tmp26 = add i32 %tmp24, %tmp22 ; [#uses=1] + %tmp28 = and i32 %tmp26, 65535 ; [#uses=1] + ret i32 %tmp28 +} + +define fastcc i32 @_D5tango4core8BitManip7bitswapFkZk(i32 %x_arg) nounwind readnone { +entry: + %tmp1 = lshr i32 %x_arg, 1 ; [#uses=1] + %tmp2 = and i32 %tmp1, 1431655765 ; [#uses=1] + %tmp4 = shl i32 %x_arg, 1 ; [#uses=1] + %tmp5 = and i32 %tmp4, -1431655766 ; [#uses=1] + %tmp6 = or i32 %tmp2, %tmp5 ; [#uses=2] + %tmp8 = lshr i32 %tmp6, 2 ; [#uses=1] + %tmp9 = and i32 %tmp8, 858993459 ; [#uses=1] + %tmp11 = shl i32 %tmp6, 2 ; [#uses=1] + %tmp12 = and i32 %tmp11, -858993460 ; [#uses=1] + %tmp13 = or i32 %tmp9, %tmp12 ; [#uses=2] + %tmp15 = lshr i32 %tmp13, 4 ; [#uses=1] + %tmp16 = and i32 %tmp15, 252645135 ; [#uses=1] + %tmp18 = shl i32 %tmp13, 4 ; [#uses=1] + %tmp19 = and i32 %tmp18, -252645136 ; [#uses=1] + %tmp20 = or i32 %tmp16, %tmp19 ; [#uses=2] + %tmp22 = lshr i32 %tmp20, 8 ; [#uses=1] + %tmp23 = and i32 %tmp22, 16711935 ; [#uses=1] + %tmp25 = shl i32 %tmp20, 8 ; [#uses=1] + %tmp26 = and i32 %tmp25, -16711936 ; [#uses=1] + %tmp27 = or i32 %tmp23, %tmp26 ; [#uses=2] + %tmp29 = lshr i32 %tmp27, 16 ; [#uses=1] + %tmp31 = shl i32 %tmp27, 16 ; [#uses=1] + %tmp32 = or i32 %tmp29, %tmp31 ; [#uses=1] + ret i32 %tmp32 +} + +define internal void @_D5tango4core8BitManip16__moduleinfoCtorZ() nounwind { +moduleinfoCtorEntry: + %current = load %ModuleReference** @_Dmodule_ref ; <%ModuleReference*> [#uses=1] + store %ModuleReference* %current, %ModuleReference** getelementptr (%ModuleReference* @_D5tango4core8BitManip11__moduleRefZ, i32 0, i32 0) + store %ModuleReference* @_D5tango4core8BitManip11__moduleRefZ, %ModuleReference** @_Dmodule_ref + ret void +} +!llvm.ldc.classinfo._D6Object7__ClassZ = !{!0} +!llvm.ldc.classinfo._D10ModuleInfo7__ClassZ = !{!1} +!0 = metadata !{%object.Object undef, i1 false, i1 false} +!1 = metadata !{%object.ModuleInfo undef, i1 false, i1 false} Added: llvm/trunk/test/Bitcode/metadata.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/metadata.ll?rev=78056&view=auto ============================================================================== --- llvm/trunk/test/Bitcode/metadata.ll (added) +++ llvm/trunk/test/Bitcode/metadata.ll Tue Aug 4 01:00:18 2009 @@ -0,0 +1,6 @@ +; RUN: llvm-as < %s | llvm-dis -f -o /dev/null + +!llvm.foo = !{!0} +!0 = metadata !{i32 42} + at my.str = internal constant [4 x i8] c"foo\00" + From stoklund at 2pi.dk Tue Aug 4 01:05:26 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 08:05:26 +0200 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> Message-ID: On 03/08/2009, at 23.40, Evan Cheng wrote: >> Finally, clear the undef flag in MachineInstr::addRegisterKilled. >> Undef implies dead and kill implies live, so they cant both be valid. > > That's not necessary. Undef doesn't implies dead. It just means its > garbage and it has no liveness. A zombie!? I am not sure what you mean. Do you mean that a register can have three states: dead-live-undef? Or do you mean that an undef operand can be both dead or live, both are OK? Consider this replacement in lower-subregs: From: %R0 = INSERT_SUBREG %R0, %R0L, 1 To: %R0 = IMPLICIT_DEF %R0L That is what we currently do, and it works when undef implies dead. If undef implies "don't know", we need to do this instead: To: %R0 = IMPLICIT_DEF %R0 This won't work today, because the scavenger ignores all undef operands, and we would get a double-def on %R0L. We could fix the scavenger to also kill operands. But that means that would work just like did before: Kill this register, dead or alive. I am not sure is RegScavenger::backward() is used today, but I think it can only work if we stick to strict rules. What would the state of %R0 be after running backward() over an IMPLICIT_DEF like the one above? /jakob From evan.cheng at apple.com Tue Aug 4 01:06:53 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 23:06:53 -0700 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <4060CD96-A773-4622-8471-DF5BFBBCF50D@apple.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> <4060CD96-A773-4622-8471-DF5BFBBCF50D@apple.com> Message-ID: <914C6F2E-1855-473D-9F8B-981EA44FD063@apple.com> Ok. Evan On Aug 3, 2009, at 3:58 PM, Chris Lattner wrote: > > On Aug 3, 2009, at 3:25 PM, Bruno Cardoso Lopes wrote: > >>> >>> For example. It would be better to base the encoding on this flag >>> than >>> checking things like Is64BitMode, IsPIC etc. >> >> Yes, that's the right way to go. I thought about that when I >> started hacking the >> x86 code emitter, but the problem here is that I'm afraid of >> breaking JIT stuff >> and lose the focus on the elf object code emission. I would be >> happy to >> work on this clean up as a next step after elf is working, but I >> would >> prefer to >> apply this patch for now if that's ok for you. But it's your call >> then. > > Sure, makes sense to me. Evan, are you ok with this patch? > > -Chris From stoklund at 2pi.dk Tue Aug 4 01:07:31 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 08:07:31 +0200 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> Message-ID: On 02/08/2009, at 21.52, Eli Friedman wrote: > On Sun, Aug 2, 2009 at 12:18 PM, Jakob Stoklund > Olesen wrote: >> The generated code looks like this: >> >> %reg1032 = MOVENCC_z %reg1031 >> %reg1032 = BITTGL %reg1032, 0 >> >> In this case a kill flag is also added to BITTGL, and >> TwoAddressInstructionPass fails to remove it again. Probably because >> it is expecting SSA code as input? > > AFAIK, all virtual registers are supposed to be SSA until the > two-address pass runs. I will have to create a new vreg in copyRegToReg then. Is there some way of knowing if we are before or after the two-address pass? From evan.cheng at apple.com Tue Aug 4 01:08:37 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 23:08:37 -0700 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: <200908031151.22285.dag@cray.com> References: <200907301710.32176.dag@cray.com> <200908031151.22285.dag@cray.com> Message-ID: <0CA98A62-A2A6-4705-916A-6D78396DE38E@apple.com> I am really not crazy about it especially since it has such a generic name Dump.h. But it's not a big deal. Evan On Aug 3, 2009, at 9:51 AM, David Greene wrote: > On Saturday 01 August 2009 19:57, Evan Cheng wrote: >> Do we really need Dump.h? Since it's Machine specific, perhaps it's >> ok >> just put it in MachineFunction.h? > > But it gets used by MachineBasicBlock and MachineInstr too. > > -Dave > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Aug 4 01:11:16 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 23:11:16 -0700 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <38a0d8450908021953ld211ee2y426145b3b4312443@mail.gmail.com> Message-ID: <6CD0A61D-FC64-4622-9FB8-F9BF540FF2D6@apple.com> I don't think even Intel knows which is which. Worst opcode names ever. Evan On Aug 2, 2009, at 8:03 PM, Eli Friedman wrote: > On Sun, Aug 2, 2009 at 7:53 PM, Rafael > Espindola wrote: >>> AFAIK, MMX_MOVD64from64rr was originally written as "movd" for >>> compatibility reasons; why are you changing it? >> >> Because it is supposed to move 64 bits. movd is 32 bits, right? >> >> I checked with gcc 4.3 and it uses movq. > > Really? I get two movd's for the following testcase: > > #include > long long a(__m64 x) { return _mm_cvtm64_si64(x); } > __m64 b(long long x) { return _mm_cvtsi64_m64(x); } > > -Eli > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Aug 4 01:13:43 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 23:13:43 -0700 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> Message-ID: <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> On Aug 3, 2009, at 11:07 PM, Jakob Stoklund Olesen wrote: > > On 02/08/2009, at 21.52, Eli Friedman wrote: > >> On Sun, Aug 2, 2009 at 12:18 PM, Jakob Stoklund >> Olesen wrote: >>> The generated code looks like this: >>> >>> %reg1032 = MOVENCC_z %reg1031 >>> %reg1032 = BITTGL %reg1032, 0 >>> >>> In this case a kill flag is also added to BITTGL, and >>> TwoAddressInstructionPass fails to remove it again. Probably because >>> it is expecting SSA code as input? >> >> AFAIK, all virtual registers are supposed to be SSA until the >> two-address pass runs. > > I will have to create a new vreg in copyRegToReg then. Sorry, I am still missing some details. Is MOVENCC_z the move instruction being inserted? Why do you need to introduce a VR then? > > Is there some way of knowing if we are before or after the two-address > pass? No. Evan > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Aug 4 01:19:57 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 3 Aug 2009 23:19:57 -0700 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> Message-ID: <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> On Aug 3, 2009, at 11:05 PM, Jakob Stoklund Olesen wrote: > > On 03/08/2009, at 23.40, Evan Cheng wrote: > >>> Finally, clear the undef flag in MachineInstr::addRegisterKilled. >>> Undef implies dead and kill implies live, so they cant both be >>> valid. >> >> That's not necessary. Undef doesn't implies dead. It just means its >> garbage and it has no liveness. > > A zombie!? > > I am not sure what you mean. > Do you mean that a register can have three states: dead-live-undef? > Or do you mean that an undef operand can be both dead or live, both > are OK? Undef operands are "don't care". :-) It would have been cleaner to have an Undef machineoperand rather than a register machineoperand that's undef. But we still need to assign registers to them so the instructions can be translated to machine code. > > Consider this replacement in lower-subregs: > > From: %R0 = INSERT_SUBREG %R0, %R0L, 1 > To: %R0 = IMPLICIT_DEF %R0L > > That is what we currently do, and it works when undef implies dead. If > undef implies "don't know", we need to do this instead: > > To: %R0 = IMPLICIT_DEF %R0 > > This won't work today, because the scavenger ignores all undef > operands, and we would get a double-def on %R0L. We could fix the > scavenger to also kill operands. But that means that > would work just like did before: Kill this > register, dead or alive. I see. subreg lowering could have just remove the undef marker. What my comment meant was addRegisterKilled really didn't have to unset the undef marker. It needed to be removed in this special case. I think a cleaner solution would have been to introduce a target specific instruction KILL that just kills a register. But that's future work. > > I am not sure is RegScavenger::backward() is used today, but I think > it can only work if we stick to strict rules. What would the state of > %R0 be after running backward() over an IMPLICIT_DEF like the one > above? I agree in this case the undef marker must be removed. The only argument who should remove it. Evan > > /jakob > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Tue Aug 4 01:20:34 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 08:20:34 +0200 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> Message-ID: <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> On 04/08/2009, at 08.13, Evan Cheng wrote: > > On Aug 3, 2009, at 11:07 PM, Jakob Stoklund Olesen wrote: > >> >> On 02/08/2009, at 21.52, Eli Friedman wrote: >> >>> On Sun, Aug 2, 2009 at 12:18 PM, Jakob Stoklund >>> Olesen wrote: >>>> The generated code looks like this: >>>> >>>> %reg1032 = MOVENCC_z %reg1031 >>>> %reg1032 = BITTGL %reg1032, 0 >>>> >>>> In this case a kill flag is also added to BITTGL, and >>>> TwoAddressInstructionPass fails to remove it again. Probably >>>> because >>>> it is expecting SSA code as input? >>> >>> AFAIK, all virtual registers are supposed to be SSA until the >>> two-address pass runs. >> >> I will have to create a new vreg in copyRegToReg then. > > Sorry, I am still missing some details. Is MOVENCC_z the move > instruction being inserted? Why do you need to introduce a VR then? No, copyRegToReg inserts both instructions. It cannot do the move in just one instruction. From anton at korobeynikov.info Tue Aug 4 01:44:41 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 4 Aug 2009 10:44:41 +0400 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> Message-ID: Hello, Jakob > No, copyRegToReg inserts both instructions. It cannot do the move in > just one instruction. Why don't use a pseudo instruction for now? I found it's the only way to go when one wants, e.g. to copy regpairs via 2 reg-reg moves. Too many code assumes that the last instruction being inserted is a 'real move' and all others are just some unimportant stuff. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From stoklund at 2pi.dk Tue Aug 4 01:54:23 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 08:54:23 +0200 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> Message-ID: <785AA75A-4BAF-4C8C-9264-B8A292F88F85@2pi.dk> On 04/08/2009, at 08.44, Anton Korobeynikov wrote: > Hello, Jakob > >> No, copyRegToReg inserts both instructions. It cannot do the move in >> just one instruction. > Why don't use a pseudo instruction for now? I found it's the only way > to go when one wants, e.g. to copy regpairs via 2 reg-reg moves. Too > many code assumes that the last instruction being inserted is a 'real > move' and all others are just some unimportant stuff. That would work. In your case, have you tried adding imp-def/imp-use operands of the real super register? Take a look at BlackfinRegisterInfo::loadConstant where an i32 constant is loaded into a register by loading the two halves with i16 constants. From anton at korobeynikov.info Tue Aug 4 02:04:11 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 4 Aug 2009 11:04:11 +0400 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: <785AA75A-4BAF-4C8C-9264-B8A292F88F85@2pi.dk> References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> <785AA75A-4BAF-4C8C-9264-B8A292F88F85@2pi.dk> Message-ID: Hello, Jakob > In your case, have you tried adding imp-def/imp-use operands of the > real super register? Yes. Afair, some codes really assumes that only 1 instruction is issued by copyRegToReg. See, e.g. LowerSubregInstructionsPass::LowerExtract and around. There were other places, I don't remember offhand, but basically some codes expects that copyRegToReg can issue multiple instructions (mostly DAG lowering stuff) and others - not. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From evan.cheng at apple.com Tue Aug 4 03:34:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 08:34:49 -0000 Subject: [llvm-commits] [llvm] r78057 - /llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Message-ID: <200908040834.n748YsZB023213@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 03:34:18 2009 New Revision: 78057 URL: http://llvm.org/viewvc/llvm-project?rev=78057&view=rev Log: Thumb2 does not have ib (increment before) and da (decrement after) forms of ldm / stm. Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=78057&r1=78056&r2=78057&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Tue Aug 4 03:34:18 2009 @@ -176,13 +176,19 @@ ARM_AM::AMSubMode Mode = ARM_AM::ia; bool isAM4 = isi32Load(Opcode) || isi32Store(Opcode); - if (isAM4 && Offset == 4) + if (isAM4 && Offset == 4) { + if (isThumb2) + // Thumb2 does not support ldmib / stmib. + return false; Mode = ARM_AM::ib; - else if (isAM4 && Offset == -4 * (int)NumRegs + 4) + } else if (isAM4 && Offset == -4 * (int)NumRegs + 4) { + if (isThumb2) + // Thumb2 does not support ldmda / stmda. + return false; Mode = ARM_AM::da; - else if (isAM4 && Offset == -4 * (int)NumRegs) + } else if (isAM4 && Offset == -4 * (int)NumRegs) { Mode = ARM_AM::db; - else if (Offset != 0) { + } else if (Offset != 0) { // If starting offset isn't zero, insert a MI to materialize a new base. // But only do so if it is cost effective, i.e. merging more than two // loads / stores. From nicolas.geoffray at lip6.fr Tue Aug 4 05:33:53 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 12:33:53 +0200 Subject: [llvm-commits] [llvm] r77706 - in /llvm/trunk: include/llvm/Support/Annotation.h lib/Support/Annotation.cpp In-Reply-To: <1ED15384-C3EE-4FD7-9ECA-041D11C0973D@apple.com> References: <200907311836.n6VIaP2r014052@zion.cs.uiuc.edu> <4A76A75C.4040509@lip6.fr> <0BECC467-15D3-4E73-8085-BE55E8A4133B@apple.com> <4A7718D5.50604@lip6.fr> <1ED15384-C3EE-4FD7-9ECA-041D11C0973D@apple.com> Message-ID: <4A780E91.7060400@lip6.fr> Hi Dan, Dan Gohman wrote: > What if you put a map member in your ModuleProvider subclass? > Yes, that's what I will end up doing. By doing so, I must change lots of things in vmkit, as I was tolerating functions of different modules to call each other directly. This prevents using the verifier, but works fine otherwise! But that's just me being lazy :) > That shouldn't require any locking beyond whatever is already > present to protect the Module itself. Indeed. Nice catch. > Does vmkit assign contexts > to Functions when the Module is created? If so, all of the map's > allocation would happen at the same time, and materializeFunction > calls wouldn't see any additional allocations. > Not really, functions are created lazily, so new functions may be created after creation of the context. Thanks for having thought about it! Nicolas > Dan > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From asl at math.spbu.ru Tue Aug 4 05:47:33 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 04 Aug 2009 10:47:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78058 - /llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm Message-ID: <200908041047.n74Alb0n032760@zion.cs.uiuc.edu> Author: asl Date: Tue Aug 4 05:47:10 2009 New Revision: 78058 URL: http://llvm.org/viewvc/llvm-project?rev=78058&view=rev Log: Unbreak thumb version of the routine Modified: llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm Modified: llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm?rev=78058&r1=78057&r2=78058&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/lib1funcs.asm Tue Aug 4 05:47:10 2009 @@ -1264,7 +1264,8 @@ .code 32 FUNC_START div0 - stmfd sp!, {r1, lr} + /* LLVM LOCAL mainline */ + do_push {r1, lr} mov r0, #SIGFPE bl SYM(raise) __PLT__ /* APPLE LOCAL ARM MACH assembler */ From asl at math.spbu.ru Tue Aug 4 06:13:03 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 04 Aug 2009 11:13:03 -0000 Subject: [llvm-commits] [llvm] r78059 - /llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Message-ID: <200908041113.n74BD5a7001030@zion.cs.uiuc.edu> Author: asl Date: Tue Aug 4 06:12:51 2009 New Revision: 78059 URL: http://llvm.org/viewvc/llvm-project?rev=78059&view=rev Log: Fix a typo - this unbreaks llvm-gcc build on arm Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h?rev=78059&r1=78058&r2=78059&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Tue Aug 4 06:12:51 2009 @@ -25,10 +25,10 @@ // That will allow not treating these as "directives". if (TM.getSubtarget().isAAPCS_ABI()) { StaticCtorSection = - getOrCreateSection("\t.section .init_array,\"aw\",%init_array", false, + getOrCreateSection(".init_array,\"aw\",%init_array", false, SectionKind::getDataRel()); StaticDtorSection = - getOrCreateSection("\t.section .fini_array,\"aw\",%fini_array", false, + getOrCreateSection(".fini_array,\"aw\",%fini_array", false, SectionKind::getDataRel()); } } From asl at math.spbu.ru Tue Aug 4 06:18:49 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 04 Aug 2009 11:18:49 -0000 Subject: [llvm-commits] [llvm] r78060 - /llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Message-ID: <200908041118.n74BIqSs001194@zion.cs.uiuc.edu> Author: asl Date: Tue Aug 4 06:18:31 2009 New Revision: 78060 URL: http://llvm.org/viewvc/llvm-project?rev=78060&view=rev Log: Ooops, I was too fast to commit the wrong fix :( Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Modified: llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h?rev=78060&r1=78059&r2=78060&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetObjectFile.h Tue Aug 4 06:18:31 2009 @@ -25,10 +25,10 @@ // That will allow not treating these as "directives". if (TM.getSubtarget().isAAPCS_ABI()) { StaticCtorSection = - getOrCreateSection(".init_array,\"aw\",%init_array", false, + getOrCreateSection("\t.section .init_array,\"aw\",%init_array", true, SectionKind::getDataRel()); StaticDtorSection = - getOrCreateSection(".fini_array,\"aw\",%fini_array", false, + getOrCreateSection("\t.section .fini_array,\"aw\",%fini_array", true, SectionKind::getDataRel()); } } From asl at math.spbu.ru Tue Aug 4 06:32:30 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Tue, 04 Aug 2009 11:32:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78061 - /llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h Message-ID: <200908041132.n74BWX0H001791@zion.cs.uiuc.edu> Author: asl Date: Tue Aug 4 06:32:20 2009 New Revision: 78061 URL: http://llvm.org/viewvc/llvm-project?rev=78061&view=rev Log: Use proper variant of swi instruction, since syscall number is passed in r7 register Modified: llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h?rev=78061&r1=78060&r2=78061&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/linux-eabi.h Tue Aug 4 06:32:20 2009 @@ -79,7 +79,7 @@ register unsigned long _end __asm ("a2") = (unsigned long) (END); \ register unsigned long _flg __asm ("a3") = 0; \ register unsigned long _scno __asm ("r7") = 0xf0002; \ - __asm __volatile ("swi 0x9f0002 @ sys_cacheflush" \ + __asm __volatile ("swi 0 @ sys_cacheflush" \ : "=r" (_beg) \ : "0" (_beg), "r" (_end), "r" (_flg), "r" (_scno)); \ } From aaronngray.lists at googlemail.com Tue Aug 4 07:22:12 2009 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Tue, 4 Aug 2009 13:22:12 +0100 Subject: [llvm-commits] [PATCH] x86 code emitter improvements for object files In-Reply-To: <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> References: <275e64e40907311603k11679adeybd7aa160739b1908@mail.gmail.com> <0C952180-94F8-475D-88ED-8EF214A9D02B@apple.com> <275e64e40908031525i6ceeb331kf20b8393a1fc3918@mail.gmail.com> Message-ID: <9719867c0908040522o2e8c5986y9d8cdb2fa6b99c76@mail.gmail.com> 2009/8/3 Bruno Cardoso Lopes > On Mon, Aug 3, 2009 at 4:00 PM, Chris Lattner wrote: > Yes, that's the right way to go. I thought about that when I started > hacking the > x86 code emitter, but the problem here is that I'm afraid of breaking JIT > stuff > and lose the focus on the elf object code emission. I would be happy to > work on this clean up as a next step after elf is working, but I would > prefer to > apply this patch for now if that's ok for you. But it's your call then. > Tests out fine on my diag program. Thanks, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090804/f2305fc7/attachment.html From dag at cray.com Tue Aug 4 08:46:35 2009 From: dag at cray.com (David Greene) Date: Tue, 4 Aug 2009 08:46:35 -0500 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: <0CA98A62-A2A6-4705-916A-6D78396DE38E@apple.com> References: <200907301710.32176.dag@cray.com> <200908031151.22285.dag@cray.com> <0CA98A62-A2A6-4705-916A-6D78396DE38E@apple.com> Message-ID: <200908040846.35455.dag@cray.com> On Tuesday 04 August 2009 01:08, Evan Cheng wrote: > I am really not crazy about it especially since it has such a generic > name Dump.h. But it's not a big deal. I'm open to a better naming. I'm not particulrly fond of Dump.h either. -Dave From dag at cray.com Tue Aug 4 08:50:19 2009 From: dag at cray.com (David Greene) Date: Tue, 4 Aug 2009 08:50:19 -0500 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <38a0d8450908022033w46f17d6dy2f403ad3c1624653@mail.gmail.com> Message-ID: <200908040850.19860.dag@cray.com> On Monday 03 August 2009 00:08, Eli Friedman wrote: > On Sun, Aug 2, 2009 at 8:33 PM, Rafael Espindola wrote: > >> I don't see any connection between the way it's written and for the > >> assembler and the way the JIT deals with it. ?And you still haven't > >> addressed the issue, which is that I'm pretty sure it was done for > >> compatibility reasons. ?If you don't know anything about that, I would > >> suggest switching it back to movd. > > > > Do you know what we are trying to be compatible with? > > I looked it up; we are trying to be compatible with OS X. See > http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011849.html . This *still* isn't fixed? This is a real problem. movq is the right thing to use for rr instructions. Why can't anyone fix the broken Leopard assembler? -Dave From dag at cray.com Tue Aug 4 08:50:55 2009 From: dag at cray.com (David Greene) Date: Tue, 4 Aug 2009 08:50:55 -0500 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: <6CD0A61D-FC64-4622-9FB8-F9BF540FF2D6@apple.com> References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <6CD0A61D-FC64-4622-9FB8-F9BF540FF2D6@apple.com> Message-ID: <200908040850.55556.dag@cray.com> On Tuesday 04 August 2009 01:11, Evan Cheng wrote: > I don't think even Intel knows which is which. Worst opcode names ever. Actually, you can thank AMD for that one. Stupid, stupid, stupid! -Dave From dag at cray.com Tue Aug 4 08:54:03 2009 From: dag at cray.com (David Greene) Date: Tue, 4 Aug 2009 08:54:03 -0500 Subject: [llvm-commits] [llvm] r77940 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrMMX.td test/CodeGen/X86/2009-08-02-mmx-scalar-to-vector.ll test/CodeGen/X86/mmx-bitcast-to-i64.ll In-Reply-To: <200908040850.19860.dag@cray.com> References: <200908030245.n732jZ5E007719@zion.cs.uiuc.edu> <200908040850.19860.dag@cray.com> Message-ID: <200908040854.04070.dag@cray.com> On Tuesday 04 August 2009 08:50, David Greene wrote: > On Monday 03 August 2009 00:08, Eli Friedman wrote: > > On Sun, Aug 2, 2009 at 8:33 PM, Rafael Espindola > > wrote: > > >> I don't see any connection between the way it's written and for the > > >> assembler and the way the JIT deals with it. ?And you still haven't > > >> addressed the issue, which is that I'm pretty sure it was done for > > >> compatibility reasons. ?If you don't know anything about that, I would > > >> suggest switching it back to movd. > > > > > > Do you know what we are trying to be compatible with? > > > > I looked it up; we are trying to be compatible with OS X. See > > http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-December/011849.html . > > This *still* isn't fixed? > > This is a real problem. movq is the right thing to use for rr > instructions. Actually, the problem is with mr and rm variants because the assembler can't know to move 64 bits without a rex prefix. -Dave From stoklund at chora.dk Tue Aug 4 03:24:35 2009 From: stoklund at chora.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 10:24:35 +0200 Subject: [llvm-commits] [PATCH] Accidental on two-address operand References: <0CF6B5E2-8826-4AA5-93FF-C30E2D5166A7@apple.com> <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> <785AA75A-4BAF-4C8C-9264-B8A292F88F85@2pi.dk> Message-ID: <87iqh4rnp8.fsf@chora.dk> Anton Korobeynikov writes: > Hello, Jakob > >> In your case, have you tried adding imp-def/imp-use operands of the >> real super register? > Yes. Afair, some codes really assumes that only 1 instruction is > issued by copyRegToReg. See, e.g. > LowerSubregInstructionsPass::LowerExtract and around. Yes, there is some dubious code around there. I am looking into it. > There were other > places, I don't remember offhand, but basically some codes expects > that copyRegToReg can issue multiple instructions (mostly DAG lowering > stuff) and others - not. LowerSubregInstructionsPass currently assumes that the source register is being used, and the destination register is being defined by the copyRegToReg instructions. It may also add implicit operands to the last instruction emitted - that may be a bit dubious come to think of it. If it doesn't work with multiple copy instructions, that is a bug IMHO. /jakob From stoklund at chora.dk Tue Aug 4 04:13:46 2009 From: stoklund at chora.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 11:13:46 +0200 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> Message-ID: <87eirsrlf9.fsf@chora.dk> Evan Cheng writes: > On Aug 3, 2009, at 11:05 PM, Jakob Stoklund Olesen wrote: > >> >> On 03/08/2009, at 23.40, Evan Cheng wrote: >> >>>> Finally, clear the undef flag in MachineInstr::addRegisterKilled. >>>> Undef implies dead and kill implies live, so they cant both be >>>> valid. >>> >>> That's not necessary. Undef doesn't implies dead. It just means its >>> garbage and it has no liveness. >> >> A zombie!? >> >> I am not sure what you mean. >> Do you mean that a register can have three states: dead-live-undef? >> Or do you mean that an undef operand can be both dead or live, both >> are OK? > > Undef operands are "don't care". :-) It would have been cleaner to > have an Undef machineoperand rather than a register machineoperand > that's undef. But we still need to assign registers to them so the > instructions can be translated to machine code. OK, here is the example that caused me to make that change: llvm-as < Blackfin/i8mem.ll | Debug/bin/llc -march=bfin -debug We have this code: %R0 = LOAD32p_8z %P0, Mem:LD(1,1) [i8_l + 0] %R0L = EXTRACT_SUBREG %R0, 1 %R0 = INSERT_SUBREG %R0, %R0L, 1 The code is stupid because of missing Blackfin peepholes. Please ignore that. It should be correct. Now look what happens without my fix: ********** LOWERING SUBREG INSTRS ********** ********** Function: i8_ls subreg: CONVERTING: %R0L = EXTRACT_SUBREG %R0, 1 subreg: eliminated! subreg: killed here: %R0 = INSERT_SUBREG %R0, %R0L, 1 LowerExtract moves the %R0 flag to the INSERT_SUBREG below. Because INSERT_SUBREG is a two-addr instruction, the kill flag on %R0 is implicit. (I fixed that last week). Then: subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 subreg: %R0 = IMPLICIT_DEF %R0L And that is wrong because LowerInsert assumed %R0 was dead. We get a double-def of %R0. When the flag is removed by MachineInstr::addRegisterKilled, we get this instead: subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 subreg: eliminated! Which is correct. With your semantics for , I think we would need to do this: subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 subreg: %R0 = IMPLICIT_DEF %R0 This won't work now because the regscavenger ignores all operands, and we still get the double-def assert. That can be fixed, of course. Note that if we do this, %R0 means "kill %R0, dead or alive". That is what you wanted to avoid, I think. It also means that RegScavenger::backward probably can't work properly - Would %R0 be dead or alive after running backwards over %R0? Could we make it work with stricter semantics? Let "undef implies dead" be the rule? Then this: %R0 = IMPLICIT_DEF would essentially mean the same as this: %R0 = IMPLICIT_DEF And this: %R0 = INSERT_SUBREG %R0, %R0L, 1 would require %R0 to be dead. I think that could work, but there may be issues in livevars that I don't understand. Strict semantics makes it a lot easier to reason about register liveness when transforming the code in LowerSubregs and other places. From stoklund at chora.dk Tue Aug 4 05:12:12 2009 From: stoklund at chora.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 12:12:12 +0200 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> Message-ID: <87ab2fsxab.fsf@chora.dk> Evan Cheng writes: > I agree in this case the undef marker must be removed. The only > argument who should remove it. Actually, this is a bad example because LowerExtract's behaviour is wrong for another reason. Consider this code: %R0L = EXTRACT_SUBREG %R0, 1 %R0H = MOVE16i 12345 %P0 = STORE16_inc %P0, %R0H %P0 = STORE16_inc %P0, %R0L LowerExtract eliminates EXTRACT_SUBREG and moves the %R0 flag to the last instruction (where %R0L is killed): %R0H = MOVE16i 12345 %P0 = STORE16_inc %P0, %R0H %P0 = STORE16_inc %P0, %R0L, %R0 This means that the live range of %R0 has been extended with two instructions, and we get a double-def when defining the other subregister %R0H. I'll see if I can produce a test case. There is still an issue with the semantics. Look at this: %R0 = INSERT_SUBREG %R0, %R1H, 1 LowerInsert replaces it with %R0L = COPY16 %R1H, %R0, %R0 Should there be an %R0 or not? If %R0 is live it is required. If %R0 is dead it would be illegal. There are two choices: 1) We allow %R0 with "soft semantics". 2) We require "undef implies dead" so we can remove the . From c-d.hailfinger.devel.2006 at gmx.net Tue Aug 4 09:31:36 2009 From: c-d.hailfinger.devel.2006 at gmx.net (Carl-Daniel Hailfinger) Date: Tue, 04 Aug 2009 16:31:36 +0200 Subject: [llvm-commits] [PATCH] clang: Add 32/64bit library search paths for Linux Message-ID: <4A784648.6050609@gmx.net> Linux distributions have various library search paths which vary across distributions. /lib and /usr/lib/ are either 32 bit or 64 bit, depending on whether you run something from the Debian family or openSUSE/RedHat family. /lib32 and /usr/lib32 exist in some distributions (usually those which have /lib for 64 bit code, e.g. Debian on x86_64). /lib64 and /usr/lib64 exist in other distributions (usually those which have /lib for 32 bit code, e.g. openSUSE on x86_64). Add all those paths to the default clang library search path. This fixes Bug 4140 for x86-64 non-Debian distributions and for 32 bit compilation on x86-64 Debian. This is my first patch, so I appreciate feedback about what I can improve. The patch is against cfe trunk. Regards, Carl-Daniel -- http://www.hailfinger.org/ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: clang_lib_searchpath_3264bit.diff Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20090804/3769eceb/attachment.pl From brukman+llvm at gmail.com Tue Aug 4 10:47:38 2009 From: brukman+llvm at gmail.com (Misha Brukman) Date: Tue, 04 Aug 2009 15:47:38 -0000 Subject: [llvm-commits] [llvm] r78065 - /llvm/trunk/utils/crosstool/create-snapshots.sh Message-ID: <200908041547.n74FlfYB009567@zion.cs.uiuc.edu> Author: brukman Date: Tue Aug 4 10:47:18 2009 New Revision: 78065 URL: http://llvm.org/viewvc/llvm-project?rev=78065&view=rev Log: * Use "svn export" instead of "svn co" and avoid cleaning up .svn dirs * Use "svn info" to get last revision in repo, will get matching tarballs * Now run "svn -q" since "svn info" tells us the revision number Modified: llvm/trunk/utils/crosstool/create-snapshots.sh Modified: llvm/trunk/utils/crosstool/create-snapshots.sh URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/crosstool/create-snapshots.sh?rev=78065&r1=78064&r2=78065&view=diff ============================================================================== --- llvm/trunk/utils/crosstool/create-snapshots.sh (original) +++ llvm/trunk/utils/crosstool/create-snapshots.sh Tue Aug 4 10:47:18 2009 @@ -11,31 +11,31 @@ set -o nounset set -o errexit -readonly REV="${1:-HEAD}" +readonly LLVM_PROJECT_SVN="http://llvm.org/svn/llvm-project" -runOnModule() { +getLatestRevisionFromSVN() { + svn info ${LLVM_PROJECT_SVN} | egrep ^Revision | sed 's/^Revision: //' +} + +readonly REV="${1:-$(getLatestRevisionFromSVN)}" + +createTarballFromSVN() { local module=$1 local log="${module}.log" - echo "Running: svn co -r ${REV} ${module}; log in ${log}" - svn co -r ${REV} http://llvm.org/svn/llvm-project/${module}/trunk ${module} \ - > ${log} 2>&1 - - # Delete all the ".svn" dirs; they take quite a lot of space. - echo "Cleaning up .svn dirs" - find ${module} -type d -name \.svn -print0 | xargs -0 /bin/rm -rf + echo "Running: svn export -r ${REV} ${module}; log in ${log}" + svn -q export -r ${REV} ${LLVM_PROJECT_SVN}/${module}/trunk \ + ${module} > ${log} 2>&1 # Create "module-revision.tar.bz2" packages from the SVN checkout dirs. - local revision=$(grep "Checked out revision" ${log} | \ - sed 's/[^0-9]\+\([0-9]\+\)[^0-9]\+/\1/') - local tarball="${module}-${revision}.tar.bz2" + local tarball="${module}-${REV}.tar.bz2" echo "Creating tarball: ${tarball}" tar cjf ${tarball} ${module} - echo "Cleaning SVN checkout dir ${module}" + echo "Cleaning up '${module}'" rm -rf ${module} ${log} } for module in "llvm" "llvm-gcc-4.2"; do - runOnModule ${module} + createTarballFromSVN ${module} done From anton at korobeynikov.info Tue Aug 4 11:02:55 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 4 Aug 2009 20:02:55 +0400 Subject: [llvm-commits] [PATCH] Accidental on two-address operand In-Reply-To: <87iqh4rnp8.fsf@chora.dk> References: <141B2004-5734-4F38-8FAE-D48C8BAA3D67@apple.com> <474EE964-F4A4-4EB2-BB19-5FB33E81B310@2pi.dk> <785AA75A-4BAF-4C8C-9264-B8A292F88F85@2pi.dk> <87iqh4rnp8.fsf@chora.dk> Message-ID: Hello, Jakob > LowerSubregInstructionsPass currently assumes that the source register > is being used, and the destination register is being defined by the > copyRegToReg instructions. It may also add implicit operands to the last > instruction emitted - that may be a bit dubious come to think of it. Yeah, that's not true for the code emitted for regpairs. E.g. on systemz 64bit regpair is formed from low 32 bits of 2 consecutive registers, so one 64 bit move should be turned into 2 32 bit moves... -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From bob.wilson at apple.com Tue Aug 4 11:06:41 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 4 Aug 2009 09:06:41 -0700 Subject: [llvm-commits] [llvm] r78025 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h ARMInstrNEON.td In-Reply-To: <4B0840D7-EB4A-470F-B8A3-28F7C6404010@apple.com> References: <200908040036.n740aHAn000672@zion.cs.uiuc.edu> <4B0840D7-EB4A-470F-B8A3-28F7C6404010@apple.com> Message-ID: <2248FEDC-254C-46E4-B385-04F421421281@apple.com> On Aug 3, 2009, at 6:21 PM, Evan Cheng wrote: > On Aug 3, 2009, at 5:36 PM, Bob Wilson wrote: > >> >> +static SDValue LowerNeonVLDIntrinsic(SDValue Op, SelectionDAG &DAG, >> + unsigned Opcode, unsigned >> NumVecs) { >> + SDNode *Node = Op.getNode(); >> + MVT VT = Node->getValueType(0); >> + DebugLoc dl = Op.getDebugLoc(); >> + >> + if (!VT.is64BitVector()) >> + return SDValue(); // unimplemented >> + >> + SDValue Ops[] = { Node->getOperand(0), >> + Node->getOperand(1) }; >> + SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); >> + SDValue Result = DAG.getNode(Opcode, dl, Tys, Ops, 2); >> + >> + static const unsigned VLDRegs[] = { >> + ARM::D0, ARM::D1, ARM::D2, ARM::D3 >> + }; > > Is this a temporary solution? Perhaps we want to do a post-isel pre- > allocation pass to be a little bit smarter about what registers to > pre- > allocate to? I was just doing it that way because you told me to do that (e.g., http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090706/080830.html ). When we talked about it in person, it was my understanding that your plan was to do something very simple when legalizing the intrinsics and then later on we would investigate smarter solutions. However, having gotten this far with it , I am not very happy with allocating the registers during isel lowering. The CopyToReg and CopyFromReg nodes are a hassle, and taking the next step of generating machine instructions seems like it will be even more awkward. I'm going to try adding a post-isel pre-allocation pass, as you suggest. Take 3. From sabre at nondot.org Tue Aug 4 11:13:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 16:13:10 -0000 Subject: [llvm-commits] [llvm] r78066 - in /llvm/trunk: lib/Target/TargetLoweringObjectFile.cpp test/CodeGen/X86/global-sections.ll Message-ID: <200908041613.n74GDB0O010342@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 11:13:09 2009 New Revision: 78066 URL: http://llvm.org/viewvc/llvm-project?rev=78066&view=rev Log: Add support emiting for 2/4 byte mergable strings to the ".rodata.str*" section on ELF targets. Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/test/CodeGen/X86/global-sections.ll Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78066&r1=78065&r2=78066&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Aug 4 11:13:09 2009 @@ -79,18 +79,33 @@ return true; } -static bool isConstantString(const Constant *C) { +/// IsNullTerminatedString - Return true if the specified constant (which is +/// known to have a type that is an array of 1/2/4 byte elements) ends with a +/// nul value and contains no other nuls in it. +static bool IsNullTerminatedString(const Constant *C) { + const ArrayType *ATy = cast(C->getType()); + // First check: is we have constant array of i8 terminated with zero - const ConstantArray *CVA = dyn_cast(C); - // Check, if initializer is a null-terminated string - if (CVA && CVA->isCString()) + if (const ConstantArray *CVA = dyn_cast(C)) { + if (ATy->getNumElements() == 0) return false; + + ConstantInt *Null = + dyn_cast(CVA->getOperand(ATy->getNumElements()-1)); + if (Null == 0 || Null->getZExtValue() != 0) + return false; // Not null terminated. + + // Verify that the null doesn't occur anywhere else in the string. + for (unsigned i = 0, e = ATy->getNumElements()-1; i != e; ++i) + // Reject constantexpr elements etc. + if (!isa(CVA->getOperand(i)) || + CVA->getOperand(i) == Null) + return false; return true; + } // Another possibility: [1 x i8] zeroinitializer if (isa(C)) - if (const ArrayType *Ty = dyn_cast(C->getType())) - return (Ty->getElementType() == Type::Int8Ty && - Ty->getNumElements() == 1); + return ATy->getNumElements() == 1; return false; } @@ -133,11 +148,23 @@ default: llvm_unreachable("unknown relocation info kind"); case Constant::NoRelocation: // If initializer is a null-terminated string, put it in a "cstring" - // section if the target has it. - if (isConstantString(C)) - return SectionKind::getMergeable1ByteCString(); - - // FIXME: Detect 2/4 byte strings. + // section of the right width. + if (const ArrayType *ATy = dyn_cast(C->getType())) { + if (const IntegerType *ITy = + dyn_cast(ATy->getElementType())) { + if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 || + ITy->getBitWidth() == 32) && + IsNullTerminatedString(C)) { + if (ITy->getBitWidth() == 8) + return SectionKind::getMergeable1ByteCString(); + if (ITy->getBitWidth() == 16) + return SectionKind::getMergeable2ByteCString(); + + assert(ITy->getBitWidth() == 32 && "Unknown width"); + return SectionKind::getMergeable4ByteCString(); + } + } + } // Otherwise, just drop it into a mergable constant section. If we have // a section for this size, use it, otherwise use the arbitrary sized Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=78066&r1=78065&r2=78066&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original) +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Tue Aug 4 11:13:09 2009 @@ -85,3 +85,39 @@ ; DARWIN:_G6: ; DARWIN: .ascii "\001" + + at G7 = constant [10 x i8] c"abcdefghi\00" + +; DARWIN: .cstring +; DARWIN: .globl _G7 +; DARWIN: _G7: +; DARWIN: .asciz "abcdefghi" + +; LINUX: .section .rodata.str1.1,"aMS", at progbits,1 +; LINUX: .globl G7 +; LINUX: G7: +; LINUX: .asciz "abcdefghi" + + + at G8 = constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ] + +; DARWIN: .const +; DARWIN: .globl _G8 +; DARWIN: _G8: + +; LINUX: .section .rodata.str2.2,"aMS", at progbits,2 +; LINUX: .globl G8 +; LINUX:G8: + + at G9 = constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ] + +; ARWIN: .const [[ already in const section]] +; DARWIN: .globl _G9 +; DARWIN: _G9: + +; LINUX: .section .rodata.str4.4,"aMS", at progbits,4 +; LINUX: .globl G9 +; LINUX:G9 + + + From sabre at nondot.org Tue Aug 4 11:19:51 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 16:19:51 -0000 Subject: [llvm-commits] [llvm] r78067 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/Target/TargetLoweringObjectFile.cpp Message-ID: <200908041619.n74GJpjf010652@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 11:19:50 2009 New Revision: 78067 URL: http://llvm.org/viewvc/llvm-project?rev=78067&view=rev Log: fix a fixme: don't create an explicit "CStringSection" for ELF, it is just being used as a prefix, so forward substitute it directly. Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78067&r1=78066&r2=78067&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Tue Aug 4 11:19:50 2009 @@ -187,8 +187,6 @@ /// const MCSection *TLSBSSSection; // Defaults to ".tbss". - const MCSection *CStringSection; - const MCSection *DataRelSection; const MCSection *DataRelLocalSection; const MCSection *DataRelROSection; Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78067&r1=78066&r2=78067&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Aug 4 11:19:50 2009 @@ -320,10 +320,6 @@ TLSDataSection = getOrCreateSection("\t.tdata", false, SectionKind::getThreadData()); - // FIXME: No reason to make this. - CStringSection = getOrCreateSection("\t.rodata.str", true, - SectionKind::getMergeable1ByteCString()); - TLSBSSSection = getOrCreateSection("\t.tbss", false, SectionKind::getThreadBSS()); @@ -511,7 +507,6 @@ if (Kind.isMergeable1ByteCString() || Kind.isMergeable2ByteCString() || Kind.isMergeable4ByteCString()) { - assert(CStringSection && "Should have string section prefix"); // We also need alignment here. // FIXME: this is getting the alignment of the character, not the @@ -519,16 +514,16 @@ unsigned Align = TM.getTargetData()->getPreferredAlignment(cast(GV)); - const char *SizeSpec = "1."; + const char *SizeSpec = ".rodata.str1."; if (Kind.isMergeable2ByteCString()) - SizeSpec = "2."; + SizeSpec = ".rodata.str2."; else if (Kind.isMergeable4ByteCString()) - SizeSpec = "4."; + SizeSpec = ".rodata.str4."; else assert(Kind.isMergeable1ByteCString() && "unknown string width"); - std::string Name = CStringSection->getName() + SizeSpec + utostr(Align); + std::string Name = SizeSpec + utostr(Align); return getOrCreateSection(Name.c_str(), false, Kind); } From sabre at nondot.org Tue Aug 4 11:27:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 16:27:17 -0000 Subject: [llvm-commits] [llvm] r78068 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/Target/TargetLoweringObjectFile.cpp test/CodeGen/X86/global-sections.ll Message-ID: <200908041627.n74GRHsI010937@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 11:27:13 2009 New Revision: 78068 URL: http://llvm.org/viewvc/llvm-project?rev=78068&view=rev Log: enhance codegen to put 16-bit character strings into the __TEXT,__ustring section on darwin. Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/test/CodeGen/X86/global-sections.ll Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=78068&r1=78067&r2=78068&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Tue Aug 4 11:27:13 2009 @@ -224,6 +224,7 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile { const MCSection *CStringSection; + const MCSection *UStringSection; const MCSection *TextCoalSection; const MCSection *ConstTextCoalSection; const MCSection *ConstDataCoalSection; Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=78068&r1=78067&r2=78068&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Tue Aug 4 11:27:13 2009 @@ -593,11 +593,13 @@ SectionKind::getDataRel()); CStringSection = getOrCreateSection("\t.cstring", true, - SectionKind::getMergeable1ByteCString()); + SectionKind::getMergeable1ByteCString()); + UStringSection = getOrCreateSection("__TEXT,__ustring", false, + SectionKind::getMergeable2ByteCString()); FourByteConstantSection = getOrCreateSection("\t.literal4\n", true, - SectionKind::getMergeableConst4()); + SectionKind::getMergeableConst4()); EightByteConstantSection = getOrCreateSection("\t.literal8\n", true, - SectionKind::getMergeableConst8()); + SectionKind::getMergeableConst8()); // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back // to using it in -static mode. @@ -704,18 +706,15 @@ } // FIXME: Alignment check should be handled by section classifier. - if (Kind.isMergeable1ByteCString()) { - Constant *C = cast(GV)->getInitializer(); - const Type *Ty = cast(C->getType())->getElementType(); - const TargetData &TD = *TM.getTargetData(); - unsigned Size = TD.getTypeAllocSize(Ty); - if (Size) { - unsigned Align = TD.getPreferredAlignment(cast(GV)); - if (Align <= 32) + if (Kind.isMergeable1ByteCString() || + Kind.isMergeable2ByteCString()) { + if (TM.getTargetData()->getPreferredAlignment( + cast(GV)) < 32) { + if (Kind.isMergeable1ByteCString()) return CStringSection; + assert(Kind.isMergeable2ByteCString()); + return UStringSection; } - - return ReadOnlySection; } if (Kind.isMergeableConst()) { @@ -725,11 +724,10 @@ return EightByteConstantSection; if (Kind.isMergeableConst16() && SixteenByteConstantSection) return SixteenByteConstantSection; - return ReadOnlySection; // .const } - - // FIXME: ROData -> const in -static mode that is relocatable but they happen - // by the static linker. Why not mergeable? + + // Otherwise, if it is readonly, but not something we can specially optimize, + // just drop it in .const. if (Kind.isReadOnly()) return ReadOnlySection; Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=78068&r1=78067&r2=78068&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original) +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Tue Aug 4 11:27:13 2009 @@ -101,7 +101,7 @@ @G8 = constant [4 x i16] [ i16 1, i16 2, i16 3, i16 0 ] -; DARWIN: .const +; DARWIN: .section __TEXT,__ustring ; DARWIN: .globl _G8 ; DARWIN: _G8: @@ -111,7 +111,7 @@ @G9 = constant [4 x i32] [ i32 1, i32 2, i32 3, i32 0 ] -; ARWIN: .const [[ already in const section]] +; DARWIN: .const ; DARWIN: .globl _G9 ; DARWIN: _G9: From daniel at zuster.org Tue Aug 4 11:46:39 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 16:46:39 -0000 Subject: [llvm-commits] [llvm] r78070 - /llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Message-ID: <200908041646.n74GklEZ011568@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Aug 4 11:46:12 2009 New Revision: 78070 URL: http://llvm.org/viewvc/llvm-project?rev=78070&view=rev Log: Avoid compiler warning (in -Asserts mode) Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=78070&r1=78069&r2=78070&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Tue Aug 4 11:46:12 2009 @@ -1616,6 +1616,8 @@ SDVTList Tys = DAG.getVTList(MVT::i8, MVT::Flag); switch (Op.getOpcode()) { + default: + assert (0 && "Opcode unknown."); case ISD::SUBE: return DAG.getNode(Op.getOpcode(), dl, Tys, NewVal, Op.getOperand(1), Op.getOperand(2)); @@ -1626,8 +1628,6 @@ case ISD::SUB: return DAG.getNode(Op.getOpcode(), dl, MVT::i8, NewVal, Op.getOperand(1)); break; - default: - assert (0 && "Opcode unknown."); } } From evan.cheng at apple.com Tue Aug 4 11:52:46 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 16:52:46 -0000 Subject: [llvm-commits] [llvm] r78072 - in /llvm/trunk: lib/CodeGen/RegisterScavenging.cpp test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll Message-ID: <200908041652.n74GqlLH011826@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 11:52:44 2009 New Revision: 78072 URL: http://llvm.org/viewvc/llvm-project?rev=78072&view=rev Log: Fix PR4528. This scavenger assertion is too strict. The two-address value is killed by another operand. There is probably a better fix. Either 1) scavenger can look at other operands, or 2) livevariables can be smarter about kill markers. Patches welcome. Added: llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=78072&r1=78071&r2=78072&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Tue Aug 4 11:52:44 2009 @@ -267,7 +267,8 @@ unsigned UseIdx; if (MI->isRegTiedToUseOperand(Idx, &UseIdx) && !MI->getOperand(UseIdx).isUndef()) { - assert(isUsed(Reg) && "Using an undefined register!"); + assert(!MI->getOperand(UseIdx).isKill() && + "Using an undefined register!"); continue; } Added: llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll?rev=78072&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert.ll Tue Aug 4 11:52:44 2009 @@ -0,0 +1,25 @@ +; RUN: llvm-as < %s | llc -mtriple=armv6-elf +; PR4528 + +define arm_aapcscc i32 @file_read_actor(i32 %desc, i32 %page, i32 %offset, i32 %size) nounwind optsize { +entry: + br i1 undef, label %fault_in_pages_writeable.exit, label %bb5.i + +bb5.i: ; preds = %entry + %asmtmp.i = tail call i32 asm sideeffect "1:\09strbt\09$1,[$2]\0A2:\0A\09.section .fixup,\22ax\22\0A\09.align\092\0A3:\09mov\09$0, $3\0A\09b\092b\0A\09.previous\0A\09.section __ex_table,\22a\22\0A\09.align\093\0A\09.long\091b, 3b\0A\09.previous", "=r,r,r,i,0,~{cc}"(i8 0, i32 undef, i32 -14, i32 0) nounwind ; [#uses=1] + br label %fault_in_pages_writeable.exit + +fault_in_pages_writeable.exit: ; preds = %bb5.i, %entry + %0 = phi i32 [ 0, %entry ], [ %asmtmp.i, %bb5.i ] ; [#uses=1] + %1 = icmp eq i32 %0, 0 ; [#uses=1] + br i1 %1, label %bb2, label %bb3 + +bb2: ; preds = %fault_in_pages_writeable.exit + unreachable + +bb3: ; preds = %fault_in_pages_writeable.exit + %2 = tail call arm_aapcscc i32 @__copy_to_user(i8* undef, i8* undef, i32 undef) nounwind ; [#uses=0] + unreachable +} + +declare arm_aapcscc i32 @__copy_to_user(i8*, i8*, i32) From kremenek at apple.com Tue Aug 4 11:56:06 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 4 Aug 2009 09:56:06 -0700 Subject: [llvm-commits] [PATCH] clang: Add 32/64bit library search paths for Linux In-Reply-To: <4A784648.6050609@gmx.net> References: <4A784648.6050609@gmx.net> Message-ID: <99BA01F3-B628-4615-8C24-61CE4DC196DB@apple.com> Hi Carl-Daniel, The place to send clang patches is cfe-commits, not llvm-commits. Please resend your email to that list. Cheers, Ted On Aug 4, 2009, at 7:31 AM, Carl-Daniel Hailfinger wrote: > Linux distributions have various library search paths which vary > across > distributions. /lib and /usr/lib/ are either 32 bit or 64 bit, > depending > on whether you run something from the Debian family or openSUSE/RedHat > family. > /lib32 and /usr/lib32 exist in some distributions (usually those which > have /lib for 64 bit code, e.g. Debian on x86_64). > /lib64 and /usr/lib64 exist in other distributions (usually those > which > have /lib for 32 bit code, e.g. openSUSE on x86_64). > > Add all those paths to the default clang library search path. > > This fixes Bug 4140 for x86-64 non-Debian distributions and for 32 bit > compilation on x86-64 Debian. > > This is my first patch, so I appreciate feedback about what I can > improve. > > The patch is against cfe trunk. > > Regards, > Carl-Daniel > > -- > http://www.hailfinger.org/ > > < > clang_lib_searchpath_3264bit.diff > >_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From kremenek at apple.com Tue Aug 4 11:59:13 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 04 Aug 2009 16:59:13 -0000 Subject: [llvm-commits] [llvm] r78073 - /llvm/tags/checker/checker-0.215/ Message-ID: <200908041659.n74GxGD7012219@zion.cs.uiuc.edu> Author: kremenek Date: Tue Aug 4 11:58:39 2009 New Revision: 78073 URL: http://llvm.org/viewvc/llvm-project?rev=78073&view=rev Log: Removing checker-0.215. Removed: llvm/tags/checker/checker-0.215/ From dgregor at apple.com Tue Aug 4 12:04:54 2009 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 04 Aug 2009 17:04:54 -0000 Subject: [llvm-commits] [llvm] r78076 - /llvm/trunk/include/llvm/Support/type_traits.h Message-ID: <200908041704.n74H4sRg012443@zion.cs.uiuc.edu> Author: dgregor Date: Tue Aug 4 12:04:52 2009 New Revision: 78076 URL: http://llvm.org/viewvc/llvm-project?rev=78076&view=rev Log: Add some type traits that are used for Clang's statically-checked canonical types. Modified: llvm/trunk/include/llvm/Support/type_traits.h Modified: llvm/trunk/include/llvm/Support/type_traits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=78076&r1=78075&r2=78076&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/type_traits.h (original) +++ llvm/trunk/include/llvm/Support/type_traits.h Tue Aug 4 12:04:52 2009 @@ -49,6 +49,33 @@ enum { value = sizeof(char) == sizeof(dont_use::is_class_helper(0)) }; }; + +// enable_if_c - Enable/disable a template based on a metafunction +template +struct enable_if_c { + typedef T type; +}; + +template struct enable_if_c { }; + +// enable_if - Enable/disable a template based on a metafunction +template +struct enable_if : public enable_if_c { }; + +namespace dont_use { + template char base_of_helper(const volatile Base*); + template double base_of_helper(...); +} + +/// is_base_of - Metafunction to determine whether one type is a base class of +/// (or identical to) another type. +template +struct is_base_of { + static const bool value + = is_class::value && is_class::value && + sizeof(char) == sizeof(dont_use::base_of_helper((Derived*)0)); +}; + } #endif From kremenek at apple.com Tue Aug 4 12:06:21 2009 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 04 Aug 2009 17:06:21 -0000 Subject: [llvm-commits] [llvm] r78078 - /llvm/tags/checker/checker-0.215/ Message-ID: <200908041706.n74H6L9X012502@zion.cs.uiuc.edu> Author: kremenek Date: Tue Aug 4 12:06:19 2009 New Revision: 78078 URL: http://llvm.org/viewvc/llvm-project?rev=78078&view=rev Log: Tagging checker-0.215. Added: llvm/tags/checker/checker-0.215/ - copied from r78077, llvm/trunk/ From evan.cheng at apple.com Tue Aug 4 12:31:47 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 4 Aug 2009 10:31:47 -0700 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: <87eirsrlf9.fsf@chora.dk> References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> <87eirsrlf9.fsf@chora.dk> Message-ID: <5B3E9460-BBBB-4715-A7F6-EA2454C51A6C@apple.com> On Aug 4, 2009, at 2:13 AM, Jakob Stoklund Olesen wrote: > Evan Cheng writes: > >> On Aug 3, 2009, at 11:05 PM, Jakob Stoklund Olesen wrote: >> >>> >>> On 03/08/2009, at 23.40, Evan Cheng wrote: >>> >>>>> Finally, clear the undef flag in MachineInstr::addRegisterKilled. >>>>> Undef implies dead and kill implies live, so they cant both be >>>>> valid. >>>> >>>> That's not necessary. Undef doesn't implies dead. It just means its >>>> garbage and it has no liveness. >>> >>> A zombie!? >>> >>> I am not sure what you mean. >>> Do you mean that a register can have three states: dead-live-undef? >>> Or do you mean that an undef operand can be both dead or live, both >>> are OK? >> >> Undef operands are "don't care". :-) It would have been cleaner to >> have an Undef machineoperand rather than a register machineoperand >> that's undef. But we still need to assign registers to them so the >> instructions can be translated to machine code. > > OK, here is the example that caused me to make that change: > > llvm-as < Blackfin/i8mem.ll | Debug/bin/llc -march=bfin -debug > > We have this code: > > %R0 = LOAD32p_8z %P0, Mem:LD(1,1) [i8_l + 0] > %R0L = EXTRACT_SUBREG %R0, 1 > %R0 = INSERT_SUBREG %R0, %R0L, 1 > > The code is stupid because of missing Blackfin peepholes. Please > ignore > that. It should be correct. > > Now look what happens without my fix: > > ********** LOWERING SUBREG INSTRS ********** > ********** Function: i8_ls > subreg: CONVERTING: %R0L = EXTRACT_SUBREG %R0, 1 > subreg: eliminated! > subreg: killed here: %R0 = INSERT_SUBREG %R0, > %R0L, 1 > > LowerExtract moves the %R0 flag to the INSERT_SUBREG > below. Because INSERT_SUBREG is a two-addr instruction, the kill > flag on > %R0 is implicit. (I fixed that last week). > > Then: > > subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 > subreg: %R0 = IMPLICIT_DEF %R0L > > And that is wrong because LowerInsert assumed %R0 was dead. We get a > double-def of %R0. > > When the flag is removed by MachineInstr::addRegisterKilled, > we > get this instead: > > subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 > subreg: eliminated! > > Which is correct. > > With your semantics for , I think we would need to do this: > > subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 > subreg: %R0 = IMPLICIT_DEF %R0 > > This won't work now because the regscavenger ignores all > operands, and we still get the double-def assert. That can be fixed, > of > course. I agree not removing the here is correct. We need a way to model r0 is killed before the def. > > Note that if we do this, %R0 means "kill %R0, dead or > alive". That is what you wanted to avoid, I think. It also means that > RegScavenger::backward probably can't work properly - Would %R0 be > dead > or alive after running backwards over %R0? There isn't a client for backward() right now so I am not too concerned about it. But in this case, it would assume R0 is not-live. > > > Could we make it work with stricter semantics? Let "undef implies > dead" > be the rule? Then this: > > %R0 = IMPLICIT_DEF > > would essentially mean the same as this: > > %R0 = IMPLICIT_DEF > > And this: > > %R0 = INSERT_SUBREG %R0, %R0L, 1 > > would require %R0 to be dead. I think that could work, but there may > be > issues in livevars that I don't understand. I am very hesitant to change the semantics. That will break a lot of assumptions in the register allocator. I think the current approach of having subreg lowering pass insert the right instructions to model "kill" is enough. Is it not? Evan > > Strict semantics makes it a lot easier to reason about register > liveness > when transforming the code in LowerSubregs and other places. > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From devang.patel at gmail.com Tue Aug 4 12:43:07 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 4 Aug 2009 10:43:07 -0700 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: <200908040846.35455.dag@cray.com> References: <200907301710.32176.dag@cray.com> <200908031151.22285.dag@cray.com> <0CA98A62-A2A6-4705-916A-6D78396DE38E@apple.com> <200908040846.35455.dag@cray.com> Message-ID: <352a1fb20908041043r55606e95l8a363b95f4320277@mail.gmail.com> On Tue, Aug 4, 2009 at 6:46 AM, David Greene wrote: > On Tuesday 04 August 2009 01:08, Evan Cheng wrote: >> I am really not crazy about it especially since it has such a generic >> name Dump.h. But it's not a big deal. > > I'm open to a better naming. ?I'm not particulrly fond of Dump.h either. Since you ask, how about AsmPrefixPrinter.h ? :) - Devang From clattner at apple.com Tue Aug 4 12:44:45 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 4 Aug 2009 10:44:45 -0700 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: <200908040846.35455.dag@cray.com> References: <200907301710.32176.dag@cray.com> <200908031151.22285.dag@cray.com> <0CA98A62-A2A6-4705-916A-6D78396DE38E@apple.com> <200908040846.35455.dag@cray.com> Message-ID: On Aug 4, 2009, at 6:46 AM, David Greene wrote: > On Tuesday 04 August 2009 01:08, Evan Cheng wrote: >> I am really not crazy about it especially since it has such a generic >> name Dump.h. But it's not a big deal. > > I'm open to a better naming. I'm not particulrly fond of Dump.h > either. I still don't understand why you need a general "prefix printer" mechanism, instead of just doing a simple helper function in the liveintervals code. -Chris From clattner at apple.com Tue Aug 4 12:48:08 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 4 Aug 2009 10:48:08 -0700 Subject: [llvm-commits] [llvm] r77740 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-04-17-tls-fast.ll test/CodeGen/X86/tls1-pic.ll test/CodeGen/X86/tls2-pic.ll test/CodeGen/X86/tls3-pic.ll test/CodeGen/X86/tls4-pic.ll utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <200908031836.51123.dag@cray.com> References: <200907312157.n6VLvAKm021365@zion.cs.uiuc.edu> <200908031705.59956.dag@cray.com> <200908031711.30871.dag@cray.com> <200908031836.51123.dag@cray.com> Message-ID: On Aug 3, 2009, at 4:36 PM, David Greene wrote: > On Monday 03 August 2009 17:11, David Greene wrote: > >> >> AsmWriterEmitter no longer emits tabs into the AsmStrs because of >> this. So >> you're right, all this ugly complexity can go away. Hmm...except >> this >> probably doesn't work for "pd" suffixed mnemonics as I pointed out >> earlier. >> So there's a bug here. I'll figure that out. > > I've got a fix for this and a cleanup to boot. Testing now, will > apply > probably tomorrow. Thank you Dave, I really prefer that this change (the comment formatting stuff for operands) get settled before many more patches go in. I can only keep track of so many outstanding issues at a time. Once it is "right" I can stop fretting about it :) Thanks again for working on this, it seems like the solution is converging to a really really nice place. -Chris From david_goodwin at apple.com Tue Aug 4 12:53:37 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 04 Aug 2009 17:53:37 -0000 Subject: [llvm-commits] [llvm] r78081 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMInstrVFP.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h test/CodeGen/ARM/fadds.ll test/CodeGen/ARM/fdivs.ll test/CodeGen/ARM/fmacs.ll test/CodeGen/ARM/fmscs.ll test/CodeGen/ARM/fmuls.ll test/CodeGen/ARM/fnmacs.ll test/CodeGen/ARM/fnmscs.ll test/CodeGen/ARM/fnmuls.ll test/CodeGen/ARM/fsubs.ll Message-ID: <200908041753.n74HrpTA014069@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Aug 4 12:53:06 2009 New Revision: 78081 URL: http://llvm.org/viewvc/llvm-project?rev=78081&view=rev Log: Initial support for single-precision FP using NEON. Added "neonfp" attribute to enable. Added patterns for some binary FP operations. Added: llvm/trunk/test/CodeGen/ARM/fadds.ll llvm/trunk/test/CodeGen/ARM/fdivs.ll llvm/trunk/test/CodeGen/ARM/fmacs.ll llvm/trunk/test/CodeGen/ARM/fmscs.ll llvm/trunk/test/CodeGen/ARM/fmuls.ll llvm/trunk/test/CodeGen/ARM/fnmacs.ll llvm/trunk/test/CodeGen/ARM/fnmscs.ll llvm/trunk/test/CodeGen/ARM/fnmuls.ll llvm/trunk/test/CodeGen/ARM/fsubs.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMInstrVFP.td llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Tue Aug 4 12:53:06 2009 @@ -32,6 +32,9 @@ "ARM v6t2">; def ArchV7A : SubtargetFeature<"v7a", "ARMArchVersion", "V7A", "ARM v7A">; +def FeatureNEONFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP", + "true", + "Use NEON for single-precision FP">; def FeatureVFP2 : SubtargetFeature<"vfp2", "ARMFPUType", "VFPv2", "Enable VFP2 instructions">; def FeatureVFP3 : SubtargetFeature<"vfp3", "ARMFPUType", "VFPv3", Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Aug 4 12:53:06 2009 @@ -1080,6 +1080,14 @@ let Inst{11-8} = 0b1010; } +// Single precision, binary if no NEON +// Same as ASbI except not available if NEON is enabled +class ASbIn opcod, dag oops, dag iops, string opc, + string asm, list pattern> + : ASbI { + list Predicates = [HasVFP2,DontUseNEONForFP]; +} + // VFP conversion instructions class AVConv1I opcod1, bits<4> opcod2, bits<4> opcod3, dag oops, dag iops, string opc, string asm, list pattern> @@ -1220,3 +1228,9 @@ class NVDup opcod1, bits<4> opcod2, bits<2> opcod3, dag oops, dag iops, string opc, string asm, list pattern> : NVLaneOp; + +// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON +// for single-precision FP. +class NEONFPPat : Pat { + list Predicates = [HasNEON,UseNEONForFP]; +} Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Aug 4 12:53:06 2009 @@ -104,6 +104,8 @@ def HasVFP2 : Predicate<"Subtarget->hasVFP2()">; def HasVFP3 : Predicate<"Subtarget->hasVFP3()">; def HasNEON : Predicate<"Subtarget->hasNEON()">; +def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">; +def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">; def IsThumb : Predicate<"Subtarget->isThumb()">; def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">; def IsThumb2 : Predicate<"Subtarget->isThumb2()">; Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Aug 4 12:53:06 2009 @@ -283,6 +283,13 @@ let isCommutable = Commutable; } +// Basic 3-register operations, scalar single-precision +class N3VDs + : NEONFPPat<(f32 (OpNode SPR:$a, SPR:$b)), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; + // Basic 3-register intrinsics, both double- and quad-register. class N3VDInt op21_20, bits<4> op11_8, bit op4, string OpcodeStr, ValueType ResTy, ValueType OpTy, @@ -319,6 +326,15 @@ [(set QPR:$dst, (Ty (OpNode QPR:$src1, (Ty (MulOp QPR:$src2, QPR:$src3)))))]>; +// Multiply-Add/Sub operations, scalar single-precision +class N3VDMulOps + : NEONFPPat<(f32 (OpNode SPR:$acc, + (f32 (MulNode SPR:$a, SPR:$b)))), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$acc, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0), + (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$b, arm_ssubreg_0)), + arm_ssubreg_0)>; + // Neon 3-argument intrinsics, both double- and quad-register. // The destination register is also used as the first source operand register. class N3VDInt3 op21_20, bits<4> op11_8, bit op4, @@ -886,6 +902,9 @@ // VRADDHN : Vector Rounding Add and Narrow Returning High Half (D = Q + Q) defm VRADDHN : N3VNInt_HSD<1,1,0b0100,0, "vraddhn.i", int_arm_neon_vraddhn, 1>; +// Vector Add Operations used for single-precision FP +def : N3VDs; + // Vector Multiply Operations. // VMUL : Vector Multiply (integer, polynomial and floating-point) @@ -908,6 +927,9 @@ // VQDMULL : Vector Saturating Doubling Multiply Long (Q = D * D) defm VQDMULL : N3VLInt_HS<0,1,0b1101,0, "vqdmull.s", int_arm_neon_vqdmull, 1>; +// Vector Multiply Operations used for single-precision FP +def : N3VDs; + // Vector Multiply-Accumulate and Multiply-Subtract Operations. // VMLA : Vector Multiply Accumulate (integer and floating-point) @@ -929,6 +951,9 @@ // VQDMLSL : Vector Saturating Doubling Multiply Subtract Long (Q -= D * D) defm VQDMLSL : N3VLInt3_HS<0, 1, 0b1011, 0, "vqdmlsl.s", int_arm_neon_vqdmlsl>; +// Vector Multiply-Accumulate/Subtract used for single-precision FP +def : N3VDMulOps; + // Vector Subtract Operations. // VSUB : Vector Subtract (integer and floating-point) @@ -952,6 +977,9 @@ // VRSUBHN : Vector Rounding Subtract and Narrow Returning High Half (D=Q-Q) defm VRSUBHN : N3VNInt_HSD<1,1,0b0110,0, "vrsubhn.i", int_arm_neon_vrsubhn, 0>; +// Vector Sub Operations used for single-precision FP +def : N3VDs; + // Vector Comparisons. // VCEQ : Vector Compare Equal Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Aug 4 12:53:06 2009 @@ -98,9 +98,9 @@ "faddd", " $dst, $a, $b", [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>; -def FADDS : ASbI<0b11100011, (outs SPR:$dst), (ins SPR:$a, SPR:$b), - "fadds", " $dst, $a, $b", - [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>; +def FADDS : ASbIn<0b11100011, (outs SPR:$dst), (ins SPR:$a, SPR:$b), + "fadds", " $dst, $a, $b", + [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>; // These are encoded as unary instructions. let Defs = [FPSCR] in { @@ -125,9 +125,9 @@ "fmuld", " $dst, $a, $b", [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>; -def FMULS : ASbI<0b11100010, (outs SPR:$dst), (ins SPR:$a, SPR:$b), - "fmuls", " $dst, $a, $b", - [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>; +def FMULS : ASbIn<0b11100010, (outs SPR:$dst), (ins SPR:$a, SPR:$b), + "fmuls", " $dst, $a, $b", + [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>; def FNMULD : ADbI<0b11100010, (outs DPR:$dst), (ins DPR:$a, DPR:$b), "fnmuld", " $dst, $a, $b", @@ -154,9 +154,9 @@ let Inst{6} = 1; } -def FSUBS : ASbI<0b11100011, (outs SPR:$dst), (ins SPR:$a, SPR:$b), - "fsubs", " $dst, $a, $b", - [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]> { +def FSUBS : ASbIn<0b11100011, (outs SPR:$dst), (ins SPR:$a, SPR:$b), + "fsubs", " $dst, $a, $b", + [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]> { let Inst{6} = 1; } @@ -317,10 +317,10 @@ [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>, RegConstraint<"$dstin = $dst">; -def FMACS : ASbI<0b11100000, (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b), - "fmacs", " $dst, $a, $b", - [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>, - RegConstraint<"$dstin = $dst">; +def FMACS : ASbIn<0b11100000, (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b), + "fmacs", " $dst, $a, $b", + [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>, + RegConstraint<"$dstin = $dst">; def FMSCD : ADbI<0b11100001, (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b), "fmscd", " $dst, $a, $b", @@ -339,8 +339,8 @@ let Inst{6} = 1; } -def FNMACS : ASbI<0b11100000, (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b), - "fnmacs", " $dst, $a, $b", +def FNMACS : ASbIn<0b11100000, (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b), + "fnmacs", " $dst, $a, $b", [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>, RegConstraint<"$dstin = $dst"> { let Inst{6} = 1; Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Tue Aug 4 12:53:06 2009 @@ -25,6 +25,7 @@ bool isThumb) : ARMArchVersion(V4T) , ARMFPUType(None) + , UseNEONForSinglePrecisionFP(false) , IsThumb(isThumb) , ThumbMode(Thumb1) , IsR9Reserved(ReserveR9) Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=78081&r1=78080&r2=78081&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Tue Aug 4 12:53:06 2009 @@ -42,6 +42,9 @@ /// ARMFPUType - Floating Point Unit type. ARMFPEnum ARMFPUType; + /// UseNEONForSinglePrecisionFP - if NEON is available use for FP + bool UseNEONForSinglePrecisionFP; + /// IsThumb - True if we are in thumb mode, false if in ARM mode. bool IsThumb; @@ -98,7 +101,9 @@ bool hasVFP2() const { return ARMFPUType >= VFPv2; } bool hasVFP3() const { return ARMFPUType >= VFPv3; } bool hasNEON() const { return ARMFPUType >= NEON; } - + bool useNEONForSinglePrecisionFP() const { + return hasNEON() && UseNEONForSinglePrecisionFP; } + bool isTargetDarwin() const { return TargetType == isDarwin; } bool isTargetELF() const { return TargetType == isELF; } Added: llvm/trunk/test/CodeGen/ARM/fadds.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fadds.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fadds.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fadds.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fadds\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vadd.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fadds\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %0 = fadd float %a, %b + ret float %0 +} + Added: llvm/trunk/test/CodeGen/ARM/fdivs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fdivs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fdivs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fdivs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fdivs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fdivs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fdivs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %0 = fdiv float %a, %b + ret float %0 +} + Added: llvm/trunk/test/CodeGen/ARM/fmacs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fmacs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fmacs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fmacs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vmla.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %acc, float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fadd float %acc, %0 + ret float %1 +} + Added: llvm/trunk/test/CodeGen/ARM/fmscs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fmscs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fmscs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fmscs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %acc, float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fsub float %0, %acc + ret float %1 +} + Added: llvm/trunk/test/CodeGen/ARM/fmuls.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fmuls.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fmuls.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fmuls.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vmul.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %0 = fmul float %a, %b + ret float %0 +} + Added: llvm/trunk/test/CodeGen/ARM/fnmacs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmacs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmacs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fnmacs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,12 @@ +; XFAIL: * +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vmls.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %acc, float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fsub float %acc, %0 + ret float %1 +} + Added: llvm/trunk/test/CodeGen/ARM/fnmscs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmscs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmscs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fnmscs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,13 @@ +; XFAIL: * +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %acc, float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fsub float 0.0, %0 + %2 = fsub float %1, %acc + ret float %2 +} + Added: llvm/trunk/test/CodeGen/ARM/fnmuls.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmuls.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmuls.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fnmuls.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,12 @@ +; XFAIL: * +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fsub float 0.0, %0 + ret float %1 +} + Added: llvm/trunk/test/CodeGen/ARM/fsubs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fsubs.ll?rev=78081&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fsubs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fsubs.ll Tue Aug 4 12:53:06 2009 @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fsubs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vsub.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fsubs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %0 = fsub float %a, %b + ret float %0 +} + From sanjiv.gupta at microchip.com Tue Aug 4 12:59:29 2009 From: sanjiv.gupta at microchip.com (Sanjiv Gupta) Date: Tue, 04 Aug 2009 17:59:29 -0000 Subject: [llvm-commits] [llvm] r78082 - /llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Message-ID: <200908041759.n74HxVQm014227@zion.cs.uiuc.edu> Author: sgupta Date: Tue Aug 4 12:59:16 2009 New Revision: 78082 URL: http://llvm.org/viewvc/llvm-project?rev=78082&view=rev Log: Legalize i64 store operations generated by inst-combine. Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Modified: llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp?rev=78082&r1=78081&r2=78082&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp Tue Aug 4 12:59:16 2009 @@ -253,6 +253,7 @@ setOperationAction(ISD::STORE, MVT::i8, Legal); setOperationAction(ISD::STORE, MVT::i16, Custom); setOperationAction(ISD::STORE, MVT::i32, Custom); + setOperationAction(ISD::STORE, MVT::i64, Custom); setOperationAction(ISD::ADDE, MVT::i8, Custom); setOperationAction(ISD::ADDC, MVT::i8, Custom); @@ -593,8 +594,25 @@ getChain(Store3), getChain(Store4)); return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, RetLo, RetHi); - } - else { + } else if (ValueType == MVT::i64) { + SDValue SrcLo, SrcHi; + GetExpandedParts(Src, DAG, SrcLo, SrcHi); + SDValue ChainLo = Chain, ChainHi = Chain; + if (Chain.getOpcode() == ISD::TokenFactor) { + ChainLo = Chain.getOperand(0); + ChainHi = Chain.getOperand(1); + } + SDValue Store1 = DAG.getStore(ChainLo, dl, SrcLo, Ptr, NULL, + 0 + StoreOffset); + + Ptr = DAG.getNode(ISD::ADD, dl, Ptr.getValueType(), Ptr, + DAG.getConstant(4, Ptr.getValueType())); + SDValue Store2 = DAG.getStore(ChainHi, dl, SrcHi, Ptr, NULL, + 1 + StoreOffset); + + return DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Store1, + Store2); + } else { assert (0 && "value type not supported"); return SDValue(); } From david_goodwin at apple.com Tue Aug 4 13:12:11 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 04 Aug 2009 18:12:11 -0000 Subject: [llvm-commits] [llvm] r78083 - in /llvm/trunk/test/CodeGen/ARM: fnmscs.ll fnmuls.ll Message-ID: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Aug 4 13:11:59 2009 New Revision: 78083 URL: http://llvm.org/viewvc/llvm-project?rev=78083&view=rev Log: Improve tests. Modified: llvm/trunk/test/CodeGen/ARM/fnmscs.ll llvm/trunk/test/CodeGen/ARM/fnmuls.ll Modified: llvm/trunk/test/CodeGen/ARM/fnmscs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmscs.ll?rev=78083&r1=78082&r2=78083&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmscs.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fnmscs.ll Tue Aug 4 13:11:59 2009 @@ -1,9 +1,9 @@ ; XFAIL: * -; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 -define float @test(float %acc, float %a, float %b) { +define float @test1(float %acc, float %a, float %b) { entry: %0 = fmul float %a, %b %1 = fsub float 0.0, %0 @@ -11,3 +11,11 @@ ret float %2 } +define float @test2(float %acc, float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fmul float -1.0, %0 + %2 = fsub float %1, %acc + ret float %2 +} + Modified: llvm/trunk/test/CodeGen/ARM/fnmuls.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmuls.ll?rev=78083&r1=78082&r2=78083&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmuls.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fnmuls.ll Tue Aug 4 13:11:59 2009 @@ -1,12 +1,19 @@ ; XFAIL: * -; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmuls\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 -define float @test(float %a, float %b) { +define float @test1(float %a, float %b) { entry: %0 = fmul float %a, %b %1 = fsub float 0.0, %0 ret float %1 } +define float @test2(float %a, float %b) { +entry: + %0 = fmul float %a, %b + %1 = fmul float -1.0, %0 + ret float %1 +} + From anton at korobeynikov.info Tue Aug 4 13:15:55 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 4 Aug 2009 22:15:55 +0400 Subject: [llvm-commits] [llvm] r78083 - in /llvm/trunk/test/CodeGen/ARM: fnmscs.ll fnmuls.ll In-Reply-To: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> References: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> Message-ID: Hi, David > -; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 > -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 > -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 > +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 > +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 > +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 Why don't use FileCheck for this? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From david_goodwin at apple.com Tue Aug 4 13:26:17 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 4 Aug 2009 11:26:17 -0700 Subject: [llvm-commits] [llvm] r78083 - in /llvm/trunk/test/CodeGen/ARM: fnmscs.ll fnmuls.ll In-Reply-To: References: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> Message-ID: Where is the documentation for FileCheck? On Aug 4, 2009, at 11:15 AM, Anton Korobeynikov wrote: > Hi, David > >> -; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs >> \\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >> -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep - >> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >> -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep - >> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >> +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs >> \\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 >> +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep - >> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 >> +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep - >> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 > Why don't use FileCheck for this? > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State > University > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Tue Aug 4 13:44:20 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 4 Aug 2009 11:44:20 -0700 Subject: [llvm-commits] [llvm] r78083 - in /llvm/trunk/test/CodeGen/ARM: fnmscs.ll fnmuls.ll In-Reply-To: References: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> Message-ID: On Aug 4, 2009, at 11:26 AM, David Goodwin wrote: > Where is the documentation for FileCheck? I still need to write the docs unfortunately. Basically it does a grep for a prefix (defaulting to "CHECK:") and verifies that the strings occur, and in order. Take a look at CodeGen/ arm/mul_const.ll for a simple example. It also defaults to canonicalizing horizontal whitespace, so you don't have to do an exact match on tabs and spaces. One annoying current limitation is that it doesn't support regex's yet. -Chris > > On Aug 4, 2009, at 11:15 AM, Anton Korobeynikov wrote: > >> Hi, David >> >>> -; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs >>> \\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >>> -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep - >>> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >>> -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep - >>> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 >>> +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmscs >>> \\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 >>> +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep - >>> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 >>> +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep - >>> E {fnmscs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 >> Why don't use FileCheck for this? >> >> -- >> With best regards, Anton Korobeynikov >> Faculty of Mathematics and Mechanics, Saint Petersburg State >> University >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From david_goodwin at apple.com Tue Aug 4 13:45:01 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 04 Aug 2009 18:45:01 -0000 Subject: [llvm-commits] [llvm] r78085 - in /llvm/trunk: lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMInstrVFP.td test/CodeGen/ARM/fnmacs.ll Message-ID: <200908041845.n74IjBN0015695@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Aug 4 13:44:29 2009 New Revision: 78085 URL: http://llvm.org/viewvc/llvm-project?rev=78085&view=rev Log: Match common pattern for FNMAC. Add NEON SP support. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMInstrVFP.td llvm/trunk/test/CodeGen/ARM/fnmacs.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78085&r1=78084&r2=78085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Aug 4 13:44:29 2009 @@ -953,6 +953,7 @@ // Vector Multiply-Accumulate/Subtract used for single-precision FP def : N3VDMulOps; +def : N3VDMulOps; // Vector Subtract Operations. Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=78085&r1=78084&r2=78085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Aug 4 13:44:29 2009 @@ -346,6 +346,11 @@ let Inst{6} = 1; } +def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, DPR:$b)), + (FNMACD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>; +def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)), + (FNMACS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>; + def FNMSCD : ADbI<0b11100001, (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b), "fnmscd", " $dst, $a, $b", [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>, Modified: llvm/trunk/test/CodeGen/ARM/fnmacs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmacs.ll?rev=78085&r1=78084&r2=78085&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmacs.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fnmacs.ll Tue Aug 4 13:44:29 2009 @@ -1,4 +1,3 @@ -; XFAIL: * ; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 ; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vmls.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 ; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnmacs\\W*s\[0-9\]+,\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 From clattner at apple.com Tue Aug 4 13:45:30 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 4 Aug 2009 11:45:30 -0700 Subject: [llvm-commits] [llvm] r78083 - in /llvm/trunk/test/CodeGen/ARM: fnmscs.ll fnmuls.ll In-Reply-To: References: <200908041812.n74ICFSh014698@zion.cs.uiuc.edu> Message-ID: On Aug 4, 2009, at 11:44 AM, Chris Lattner wrote: > > On Aug 4, 2009, at 11:26 AM, David Goodwin wrote: > >> Where is the documentation for FileCheck? > > I still need to write the docs unfortunately. > > Basically it does a grep for a prefix (defaulting to "CHECK:") and > verifies that the strings occur, and in order. Take a look at > CodeGen/ > arm/mul_const.ll for a simple example. It also defaults to > canonicalizing horizontal whitespace, so you don't have to do an exact > match on tabs and spaces. > > One annoying current limitation is that it doesn't support regex's > yet. Oh, one really nice thing about it is that it lets you merge multiple tiny .ll files into larger ones, which run faster. For example, see CodeGen/X86/sse41.ll -Chris From evan.cheng at apple.com Tue Aug 4 13:46:22 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 18:46:22 -0000 Subject: [llvm-commits] [llvm] r78086 - in /llvm/trunk: lib/Target/ARM/ARMRegisterInfo.td test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll Message-ID: <200908041846.n74IkN32015737@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 13:46:17 2009 New Revision: 78086 URL: http://llvm.org/viewvc/llvm-project?rev=78086&view=rev Log: In thumb mode, r7 is used as frame register. This fixes pr4681. Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=78086&r1=78085&r2=78086&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Tue Aug 4 13:46:17 2009 @@ -160,6 +160,13 @@ ARM::R4, ARM::R5, ARM::R6, ARM::R8, ARM::R10,ARM::R11, ARM::R7 }; + // FP is R7, R9 is available as callee-saved register. + // This is used by non-Darwin platform in Thumb mode. + static const unsigned ARM_GPR_AO_5[] = { + ARM::R0, ARM::R1, ARM::R2, ARM::R3, + ARM::R12,ARM::LR, + ARM::R4, ARM::R5, ARM::R6, + ARM::R8, ARM::R9, ARM::R10,ARM::R11,ARM::R7 }; GPRClass::iterator GPRClass::allocation_order_begin(const MachineFunction &MF) const { @@ -173,6 +180,8 @@ } else { if (Subtarget.isR9Reserved()) return ARM_GPR_AO_2; + else if (Subtarget.isThumb()) + return ARM_GPR_AO_5; else return ARM_GPR_AO_1; } @@ -193,6 +202,8 @@ } else { if (Subtarget.isR9Reserved()) I = ARM_GPR_AO_2 + (sizeof(ARM_GPR_AO_2)/sizeof(unsigned)); + else if (Subtarget.isThumb()) + I = ARM_GPR_AO_5 + (sizeof(ARM_GPR_AO_5)/sizeof(unsigned)); else I = ARM_GPR_AO_1 + (sizeof(ARM_GPR_AO_1)/sizeof(unsigned)); } Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll?rev=78086&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-08-04-CoalescerAssert.ll Tue Aug 4 13:46:17 2009 @@ -0,0 +1,29 @@ +; RUN: llvm-as < %s | llc -mtriple=thumbv7-none-linux-gnueabi +; PR4681 + + %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } + %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 } + at .str2 = external constant [30 x i8], align 1 ; <[30 x i8]*> [#uses=1] + +define arm_aapcscc i32 @__mf_heuristic_check(i32 %ptr, i32 %ptr_high) nounwind { +entry: + br i1 undef, label %bb1, label %bb + +bb: ; preds = %entry + unreachable + +bb1: ; preds = %entry + br i1 undef, label %bb9, label %bb2 + +bb2: ; preds = %bb1 + %0 = call i8* @llvm.frameaddress(i32 0) ; [#uses=1] + %1 = call arm_aapcscc i32 (%struct.FILE*, i8*, ...)* @fprintf(%struct.FILE* noalias undef, i8* noalias getelementptr ([30 x i8]* @.str2, i32 0, i32 0), i8* %0, i8* null) nounwind ; [#uses=0] + unreachable + +bb9: ; preds = %bb1 + ret i32 undef +} + +declare i8* @llvm.frameaddress(i32) nounwind readnone + +declare arm_aapcscc i32 @fprintf(%struct.FILE* noalias nocapture, i8* noalias nocapture, ...) nounwind From stoklund at 2pi.dk Tue Aug 4 14:01:48 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 21:01:48 +0200 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: <5B3E9460-BBBB-4715-A7F6-EA2454C51A6C@apple.com> References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> <87eirsrlf9.fsf@chora.dk> <5B3E9460-BBBB-4715-A7F6-EA2454C51A6C@apple.com> Message-ID: On 04/08/2009, at 19.31, Evan Cheng wrote: > I am very hesitant to change the semantics. That will break a lot of > assumptions in the register allocator. I think the current approach of > having subreg lowering pass insert the right instructions to model > "kill" is enough. Is it not? You are probably right. I am still struggling to completely understand the semantics. We will almost certainly need to insert fake instructions that only change flags. I am using IMPLICIT_DEF for that now, but it should probably be replaced by a new ALTER_LIFE or something. [...] >>> Undef operands are "don't care". :-) It would have been cleaner to >>> have an Undef machineoperand rather than a register machineoperand >>> that's undef. But we still need to assign registers to them so the >>> instructions can be translated to machine code. Ok, so if I understand you correctly, the actual register doesn't really matter. It is only there so we produce valid machine code and the only restriction is that the register class must be correct. And of course there are two-address constraints. If that is correct, we could write an undef operand as %UNDEF. Like this: %R0 = INSERT_SUBREG %UNDEF, %R0L, 1 This makes sense to me. Note that in this case %R0 must be dead. Not because it is referenced by an , but because it is not killed before being defined. MachineInstr::addRegisterKilled() should not remove the flag. It should completely skip the undef operand, just like the regscavenger does. The flags and should not be allowed at the same time. It is nonsensical. Am I on the right track? From alenhar2 at cs.uiuc.edu Tue Aug 4 14:06:35 2009 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 04 Aug 2009 19:06:35 -0000 Subject: [llvm-commits] [poolalloc] r78087 - /poolalloc/trunk/include/dsa/DSNode.h Message-ID: <200908041906.n74J6jwA016348@zion.cs.uiuc.edu> Author: alenhar2 Date: Tue Aug 4 14:06:07 2009 New Revision: 78087 URL: http://llvm.org/viewvc/llvm-project?rev=78087&view=rev Log: remove unnecesarry member Modified: poolalloc/trunk/include/dsa/DSNode.h Modified: poolalloc/trunk/include/dsa/DSNode.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=78087&r1=78086&r2=78087&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSNode.h (original) +++ poolalloc/trunk/include/dsa/DSNode.h Tue Aug 4 14:06:07 2009 @@ -426,8 +426,6 @@ static DSNode *createSentinel() { return new DSNode(0,0); } static void destroySentinel(DSNode *N) { delete N; } - //static DSNode *createNode(const DSNode &V) { return new DSNode(V); } - void addNodeToList(DSNode *NTy) {} void removeNodeFromList(DSNode *NTy) {} From alenhar2 at cs.uiuc.edu Tue Aug 4 14:09:04 2009 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 04 Aug 2009 19:09:04 -0000 Subject: [llvm-commits] [poolalloc] r78088 - in /poolalloc/trunk/lib/DSA: BottomUpClosure.cpp CallTargets.cpp DataStructure.cpp DataStructureStats.cpp Local.cpp Printer.cpp StdLibPass.cpp TopDownClosure.cpp Message-ID: <200908041909.n74J97fh016428@zion.cs.uiuc.edu> Author: alenhar2 Date: Tue Aug 4 14:08:49 2009 New Revision: 78088 URL: http://llvm.org/viewvc/llvm-project?rev=78088&view=rev Log: make build against head Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp poolalloc/trunk/lib/DSA/CallTargets.cpp poolalloc/trunk/lib/DSA/DataStructure.cpp poolalloc/trunk/lib/DSA/DataStructureStats.cpp poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/DSA/Printer.cpp poolalloc/trunk/lib/DSA/StdLibPass.cpp poolalloc/trunk/lib/DSA/TopDownClosure.cpp Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Aug 4 14:08:49 2009 @@ -20,6 +20,8 @@ #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FormattedStream.h" + using namespace llvm; namespace { @@ -52,15 +54,15 @@ calculateGraphs(MainFunc, Stack, NextID, ValMap); CloneAuxIntoGlobal(getDSGraph(*MainFunc)); } else { - DOUT << debugname << ": No 'main' function found!\n"; + DEBUG(ferrs() << debugname << ": No 'main' function found!\n"); } // Calculate the graphs for any functions that are unreachable from main... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration() && !hasDSGraph(*I)) { if (MainFunc) - DOUT << debugname << ": Function unreachable from main: " - << I->getName() << "\n"; + DEBUG(ferrs() << debugname << ": Function unreachable from main: " + << I->getName() << "\n"); calculateGraphs(I, Stack, NextID, ValMap); // Calculate all graphs. CloneAuxIntoGlobal(getDSGraph(*I)); } @@ -261,14 +263,14 @@ // If this is a new SCC, process it now. if (Stack.back() == F) { // Special case the single "SCC" case here. - DOUT << "Visiting single node SCC #: " << MyID << " fn: " - << F->getName() << "\n"; + DEBUG(ferrs() << "Visiting single node SCC #: " << MyID << " fn: " + << F->getName() << "\n"); Stack.pop_back(); - DOUT << " [BU] Calculating graph for: " << F->getName()<< "\n"; + DEBUG(ferrs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); calculateGraph(Graph); - DOUT << " [BU] Done inlining: " << F->getName() << " [" - << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size() - << "]\n"; + DEBUG(ferrs() << " [BU] Done inlining: " << F->getName() << " [" + << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size() + << "]\n"); if (MaxSCC < 1) MaxSCC = 1; @@ -295,7 +297,7 @@ ResolvedFuncs.resize(uid - ResolvedFuncs.begin()); if (ResolvedFuncs.size() || NewCalleeFuncs.size()) { - DOUT << "Recalculating " << F->getName() << " due to new knowledge\n"; + DEBUG(ferrs() << "Recalculating " << F->getName() << " due to new knowledge\n"); ValMap.erase(F); return calculateGraphs(F, Stack, NextID, ValMap); } else { @@ -339,8 +341,8 @@ } Stack.pop_back(); - DOUT << "Calculating graph for SCC #: " << MyID << " of size: " - << SCCSize << "\n"; + DEBUG(ferrs() << "Calculating graph for SCC #: " << MyID << " of size: " + << SCCSize << "\n"); // Compute the Max SCC Size. if (MaxSCC < SCCSize) @@ -352,9 +354,9 @@ // Now that we have one big happy family, resolve all of the call sites in // the graph... calculateGraph(SCCGraph); - DOUT << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() - << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n" - << "DONE with SCC #: " << MyID << "\n"; + DEBUG(ferrs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() + << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n" + << "DONE with SCC #: " << MyID << "\n"); // We never have to revisit "SCC" processed functions... //propagate incomplete call nodes @@ -471,28 +473,30 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline DEBUG(GI->AssertGraphOK(); GI->getGlobalsGraph()->AssertGraphOK()); - DOUT << " Inlining graph for " << Callee->getName() - << "[" << GI->getGraphSize() << "+" - << GI->getAuxFunctionCalls().size() << "] into '" - << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" - << Graph->getAuxFunctionCalls().size() << "]\n"; + DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + << "[" << GI->getGraphSize() << "+" + << GI->getAuxFunctionCalls().size() << "] into '" + << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" + << Graph->getAuxFunctionCalls().size() << "]\n"); Graph->mergeInGraph(CS, *Callee, *GI, DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes| (isComplete?0:DSGraph::DontCloneAuxCallNodes)); ++NumInlines; DEBUG(Graph->AssertGraphOK();); } else if (CalledFuncs.size() > 1) { - DEBUG(std::cerr << "In Fns: " << Graph->getFunctionNames() << "\n"); - DEBUG(std::cerr << " calls " << CalledFuncs.size() + DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(ferrs() << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(std::cerr << " Fns ="); + DEBUG(ferrs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) - if (NumPrinted++ < 8) DOUT << " " << (*I)->getName(); - DOUT << "\n"; + if (NumPrinted++ < 8) { + DEBUG(ferrs() << " " << (*I)->getName()); + } + DEBUG(ferrs() << "\n"); if (!isComplete) { for (unsigned x = 0; x < CalledFuncs.size(); ) @@ -543,17 +547,17 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DOUT << "***\n*** RECYCLED GRAPH ***\n***\n"; + DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DOUT << " Inlining multi callee graph " - << "[" << GI->getGraphSize() << "+" - << GI->getAuxFunctionCalls().size() << "] into '" - << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" - << Graph->getAuxFunctionCalls().size() << "]\n"; + DEBUG(ferrs() << " Inlining multi callee graph " + << "[" << GI->getGraphSize() << "+" + << GI->getAuxFunctionCalls().size() << "] into '" + << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" + << Graph->getAuxFunctionCalls().size() << "]\n"); Graph->mergeInGraph(CS, IndCallGraph.second, *GI, DSGraph::StripAllocaBit | @@ -618,26 +622,28 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline if (GI == Graph) continue; - DOUT << " Inlining graph for " << Callee->getName() - << "[" << GI->getGraphSize() << "+" - << GI->getAuxFunctionCalls().size() << "] into '" - << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" - << Graph->getAuxFunctionCalls().size() << "]\n"; + DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + << "[" << GI->getGraphSize() << "+" + << GI->getAuxFunctionCalls().size() << "] into '" + << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" + << Graph->getAuxFunctionCalls().size() << "]\n"); Graph->mergeInGraph(CS, *Callee, *GI, DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes); ++NumInlines; } else { - DEBUG(std::cerr << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); DEBUG(std::cerr << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(std::cerr << " Fns ="); + DEBUG(ferrs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) - if (NumPrinted++ < 8) DOUT << " " << (*I)->getName(); - DOUT << "\n"; + if (NumPrinted++ < 8) { + DEBUG(ferrs() << " " << (*I)->getName()); + } + DEBUG(ferrs() << "\n"); for (unsigned x = 0; x < CalledFuncs.size(); ) if (!hasDSGraph(*CalledFuncs[x])) @@ -690,18 +696,17 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DOUT << "***\n*** RECYCLED GRAPH ***\n***\n"; + DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG( - DOUT << " Inlining multi callee graph " + DEBUG(ferrs() << " Inlining multi callee graph " << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" - << Graph->getAuxFunctionCalls().size() << "]\n"; ); + << Graph->getAuxFunctionCalls().size() << "]\n" ); Graph->mergeInGraph(CS, IndCallGraph.second, *GI, DSGraph::StripAllocaBit | Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CallTargets.cpp (original) +++ poolalloc/trunk/lib/DSA/CallTargets.cpp Tue Aug 4 14:08:49 2009 @@ -24,7 +24,7 @@ #include "dsa/CallTargets.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Streams.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Constants.h" #include using namespace llvm; @@ -74,11 +74,11 @@ } if (N->isCompleteNode() && !IndMap[cs].size()) { ++CompleteEmpty; - cerr << "Call site empty: '" - << cs.getInstruction()->getName() - << "' In '" - << cs.getInstruction()->getParent()->getParent()->getName() - << "'\n"; + DEBUG(ferrs() << "Call site empty: '" + << cs.getInstruction()->getName() + << "' In '" + << cs.getInstruction()->getParent()->getParent()->getName() + << "'\n"); } } } else { @@ -100,13 +100,13 @@ O << "* "; CallSite cs = ii->first; cs.getInstruction()->dump(); - O << cs.getInstruction()->getParent()->getParent()->getName() << " " - << cs.getInstruction()->getName() << " "; + O << cs.getInstruction()->getParent()->getParent()->getNameStr() << " " + << cs.getInstruction()->getNameStr() << " "; } O << ii->first.getInstruction() << ":"; for (std::vector::const_iterator i = ii->second.begin(), e = ii->second.end(); i != e; ++i) { - O << " " << (*i)->getName(); + O << " " << (*i)->getNameStr(); } O << "\n"; } Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Aug 4 14:08:49 2009 @@ -1426,7 +1426,7 @@ std::string Return; for (DSGraph::retnodes_iterator I = retnodes_begin(); I != retnodes_end(); ++I) - Return += I->first->getName() + " "; + Return += I->first->getNameStr() + " "; Return.erase(Return.end()-1, Return.end()); // Remove last space character return Return; } Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Tue Aug 4 14:08:49 2009 @@ -20,6 +20,8 @@ #include "llvm/Support/Streams.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FormattedStream.h" + #include using namespace llvm; @@ -94,19 +96,21 @@ if (Callees.size() > 0) { totalNumCallees += Callees.size(); ++numIndirectCalls; - } else - cerr << "WARNING: No callee in Function '" << F.getName() - << "' at call: \n" - << *I->getCallSite().getInstruction(); + } else { + DEBUG(ferrs() << "WARNING: No callee in Function '" + << F.getNameStr() << "' at call: \n" + << *I->getCallSite().getInstruction()); + } } TotalNumCallees += totalNumCallees; NumIndirectCalls += numIndirectCalls; - if (numIndirectCalls) - cout << " In function " << F.getName() << ": " - << (totalNumCallees / (double) numIndirectCalls) - << " average callees per indirect call\n"; + if (numIndirectCalls) { + DEBUG(ferrs() << " In function " << F.getName() << ": " + << (totalNumCallees / (double) numIndirectCalls) + << " average callees per indirect call\n"); + } } DSNode *DSGraphStats::getNodeForValue(Value *V) { Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Tue Aug 4 14:08:49 2009 @@ -23,6 +23,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/DenseSet.h" @@ -249,7 +250,7 @@ NH = getValueDest(*(cast(C)->getAliasee())); return 0; } else { - llvm::cerr << "Unknown constant: " << *C << std::endl; + DEBUG(ferrs() << "Unknown constant: " << *C << "\n"); assert(0 && "Unknown constant type!"); } N = createNode(); // just create a shadow node @@ -486,9 +487,9 @@ } else { // Variable index into a node. We must merge all of the elements of the // sequential type here. - if (isa(STy)) - cerr << "Pointer indexing not handled yet!\n"; - else { + if (isa(STy)) { + DEBUG(ferrs() << "Pointer indexing not handled yet!\n"); + } else { const ArrayType *ATy = cast(STy); unsigned ElSize = TD.getTypeAllocSize(CurTy); DSNode *N = Value.getNode(); @@ -535,8 +536,9 @@ if (IGEP->getParent()->getParent()->getName() == "alloc_vfsmnt") { if (G.getPoolDescriptorsMap().count(N) != 0) - if (G.getPoolDescriptorsMap()[N]) - std::cerr << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"; + if (G.getPoolDescriptorsMap()[N]) { + DEBUG(ferrs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"); + } } } #endif @@ -695,7 +697,7 @@ return true; } - cerr << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"; + DEBUG(ferrs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); assert(0 && "Unhandled intrinsic"); return false; } @@ -726,7 +728,7 @@ if (!isa(Callee)) { CalleeNode = getValueDest(*Callee).getNode(); if (CalleeNode == 0) { - cerr << "WARNING: Program is calling through a null pointer?\n"<< *I; + DEBUG(ferrs() << "WARNING: Program is calling through a null pointer?\n" << *I); return; // Calling a null pointer? } } Modified: poolalloc/trunk/lib/DSA/Printer.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Printer.cpp (original) +++ poolalloc/trunk/lib/DSA/Printer.cpp Tue Aug 4 14:08:49 2009 @@ -24,7 +24,7 @@ #include "llvm/Support/Streams.h" #include "llvm/ADT/Statistic.h" #include "llvm/Config/config.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FormattedStream.h" #include #include #include @@ -190,7 +190,7 @@ if (G->getReturnNodes().size() == 1) Label = "returning"; else - Label = I->first->getName() + " ret node"; + Label = I->first->getNameStr() + " ret node"; // Output the return node... GW.emitSimpleNode((void*)I->first, "plaintext=circle", Label); @@ -295,17 +295,17 @@ if (I->getName() == "main" || !OnlyPrintMain) { const Function *SCCFn = Gr->retnodes_begin()->first; if (&*I == SCCFn) { - Gr->writeGraphToFile(O, Prefix+I->getName()); + Gr->writeGraphToFile(O, Prefix+I->getNameStr()); } else { IsDuplicateGraph = true; // Don't double count node/call nodes. - O << "Didn't write '" << Prefix+I->getName() - << ".dot' - Graph already emitted to '" << Prefix+SCCFn->getName() + O << "Didn't write '" << Prefix+I->getNameStr() + << ".dot' - Graph already emitted to '" << Prefix+SCCFn->getNameStr() << "\n"; } } else { const Function *SCCFn = Gr->retnodes_begin()->first; if (&*I == SCCFn) { - O << "Skipped Writing '" << Prefix+I->getName() << ".dot'... [" + O << "Skipped Writing '" << Prefix+I->getNameStr() << ".dot'... [" << Gr->getGraphSize() << "+" << NumCalls << "]\n"; } else { IsDuplicateGraph = true; // Don't double count node/call nodes. @@ -343,13 +343,13 @@ void DataStructures::dumpCallGraph() const { for( ActualCalleesTy::const_iterator ii = ActualCallees.begin(), ee = ActualCallees.end(); ii != ee; ++ii) { - if (ii->first) cerr << ii->first->getParent()->getParent()->getName() << " "; - cerr << ii->first << ": ["; + if (ii->first) ferrs() << ii->first->getParent()->getParent()->getName() << " "; + ferrs() << ii->first << ": ["; for (callee_iterator cbi = ii->second.begin(), cbe = ii->second.end(); cbi != cbe; ++cbi) { - cerr << (*cbi)->getName() << " "; + ferrs() << (*cbi)->getName() << " "; } - cerr << "]\n"; + ferrs() << "]\n"; if (ii->first) ii->first->dump(); } } Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Aug 4 14:08:49 2009 @@ -20,6 +20,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" #include #include "llvm/Module.h" @@ -182,7 +183,8 @@ if (CI->getOperand(0) == F) { DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); //delete the call - DOUT << "Removing " << F->getName() << " from " << CI->getParent()->getParent()->getName() << "\n"; + DEBUG(ferrs() << "Removing " << F->getNameStr() << " from " + << CI->getParent()->getParent()->getNameStr() << "\n"); Graph->removeFunctionCalls(*F); } } Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=78088&r1=78087&r2=78088&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Tue Aug 4 14:08:49 2009 @@ -20,6 +20,7 @@ #include "llvm/DerivedTypes.h" #include "dsa/DSGraph.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" #include "llvm/ADT/Statistic.h" using namespace llvm; @@ -197,7 +198,8 @@ RC.getClonedNH(GG->getNodeForValue(*GI)); } - DOUT << "[TD] Inlining callers into '" << DSG->getFunctionNames() << "'\n"; + DEBUG(ferrs() << "[TD] Inlining callers into '" + << DSG->getFunctionNames() << "'\n"); // Iteratively inline caller graphs into this graph. while (!EdgesFromCaller.empty()) { @@ -213,13 +215,16 @@ do { const DSCallSite &CS = *EdgesFromCaller.back().CS; const Function &CF = *EdgesFromCaller.back().CalledFunction; - DOUT << " [TD] Inlining graph into Fn '" << CF.getName() << "' from "; - if (CallerGraph->getReturnNodes().empty()) - DOUT << "SYNTHESIZED INDIRECT GRAPH"; - else - DOUT << "Fn '" << CS.getCallSite().getInstruction()-> - getParent()->getParent()->getName() << "'"; - DOUT << ": " << CF.getFunctionType()->getNumParams() << " args\n"; + DEBUG(ferrs() << " [TD] Inlining graph into Fn '" + << CF.getNameStr() << "' from "); + if (CallerGraph->getReturnNodes().empty()) { + DEBUG(ferrs() << "SYNTHESIZED INDIRECT GRAPH"); + } else { + DEBUG(ferrs() << "Fn '" << CS.getCallSite().getInstruction()-> + getParent()->getParent()->getNameStr() << "'"); + } + DEBUG(ferrs() << ": " << CF.getFunctionType()->getNumParams() + << " args\n"); // Get the formal argument and return nodes for the called function and // merge them with the cloned subgraph. @@ -334,8 +339,8 @@ // If we already have this graph, recycle it. if (IndCallRecI != IndCallMap.end() && IndCallRecI->first == Callees) { - DOUT << " [TD] *** Reuse of indcall graph for " << Callees.size() - << " callees!\n"; + DEBUG(ferrs() << " [TD] *** Reuse of indcall graph for " << Callees.size() + << " callees!\n"); IndCallGraph = IndCallRecI->second; } else { // Otherwise, create a new DSGraph to represent this. From stoklund at 2pi.dk Tue Aug 4 14:17:29 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 19:17:29 -0000 Subject: [llvm-commits] [llvm] r78089 - /llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Message-ID: <200908041917.n74JHXH6016675@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 14:16:55 2009 New Revision: 78089 URL: http://llvm.org/viewvc/llvm-project?rev=78089&view=rev Log: Most flags are reserved registers on Blackfin. The only exception is CC. Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp?rev=78089&r1=78088&r2=78089&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Tue Aug 4 14:16:55 2009 @@ -63,6 +63,17 @@ BlackfinRegisterInfo::getReservedRegs(const MachineFunction &MF) const { using namespace BF; BitVector Reserved(getNumRegs()); + Reserved.set(AZ); + Reserved.set(AN); + Reserved.set(AQ); + Reserved.set(AC0); + Reserved.set(AC1); + Reserved.set(AV0); + Reserved.set(AV0S); + Reserved.set(AV1); + Reserved.set(AV1S); + Reserved.set(V); + Reserved.set(VS); Reserved.set(L0); Reserved.set(L1); Reserved.set(L2); From stoklund at 2pi.dk Tue Aug 4 14:18:03 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 19:18:03 -0000 Subject: [llvm-commits] [llvm] r78090 - /llvm/trunk/lib/CodeGen/MachineVerifier.cpp Message-ID: <200908041918.n74JI36T016706@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 14:18:01 2009 New Revision: 78090 URL: http://llvm.org/viewvc/llvm-project?rev=78090&view=rev Log: Enforce stricter rules in machine code verifier. Implicit operands no longer get a free pass: Imp-use requires a live register and imp-def requires a dead register. There is also no special rule allowing redefinition of a sub-register when the super-register is live. The super register must have imp-kill+imp-def operands instead. Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=78090&r1=78089&r2=78090&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Tue Aug 4 14:18:01 2009 @@ -88,14 +88,6 @@ RV.push_back(*R); } - // Does RS contain any super-registers of Reg? - bool anySuperRegisters(const RegSet &RS, unsigned Reg) { - for (const unsigned *R = TRI->getSuperRegisters(Reg); *R; R++) - if (RS.count(*R)) - return true; - return false; - } - struct BBInfo { // Is this MBB reachable from the MF entry point? bool reachable; @@ -151,7 +143,7 @@ DenseMap MBBInfoMap; bool isReserved(unsigned Reg) { - return Reg < regsReserved.size() && regsReserved[Reg]; + return Reg < regsReserved.size() && regsReserved.test(Reg); } void visitMachineFunctionBefore(); @@ -287,6 +279,16 @@ MachineVerifier::visitMachineFunctionBefore() { regsReserved = TRI->getReservedRegs(*MF); + + // A sub-register of a reserved register is also reserved + for (int Reg = regsReserved.find_first(); Reg>=0; + Reg = regsReserved.find_next(Reg)) { + for (const unsigned *Sub = TRI->getSubRegisters(Reg); *Sub; ++Sub) { + // FIXME: This should probably be: + // assert(regsReserved.test(*Sub) && "Non-reserved sub-register"); + regsReserved.set(*Sub); + } + } markReachable(&MF->front()); } @@ -364,9 +366,8 @@ MI->getOperand(defIdx).getReg() == Reg) addRegWithSubRegs(regsKilled, Reg); } - // Explicit use of a dead register. - // A register use marked is OK. - if (!MO->isImplicit() && !MO->isUndef() && !regsLive.count(Reg)) { + // Use of a dead register. A register use marked is OK. + if (!MO->isUndef() && !regsLive.count(Reg)) { if (TargetRegisterInfo::isPhysicalRegister(Reg)) { // Reserved registers may be used even when 'dead'. if (!isReserved(Reg)) @@ -385,10 +386,7 @@ } else { // Register defined. // TODO: verify that earlyclobber ops are not used. - if (MO->isImplicit()) - addRegWithSubRegs(regsImpDefined, Reg); - else - addRegWithSubRegs(regsDefined, Reg); + addRegWithSubRegs(regsDefined, Reg); if (MO->isDead()) addRegWithSubRegs(regsDead, Reg); @@ -462,10 +460,7 @@ E = regsDefined.end(); I != E; ++I) { if (regsLive.count(*I)) { if (TargetRegisterInfo::isPhysicalRegister(*I)) { - // We allow double defines to physical registers with live - // super-registers. - if (!allowPhysDoubleDefs && !isReserved(*I) && - !anySuperRegisters(regsLive, *I)) { + if (!allowPhysDoubleDefs && !isReserved(*I)) { report("Redefining a live physical register", MI); *OS << "Register " << TRI->getName(*I) << " was defined but already live.\n"; From alenhar2 at cs.uiuc.edu Tue Aug 4 14:34:15 2009 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Tue, 04 Aug 2009 19:34:15 -0000 Subject: [llvm-commits] [poolalloc] r78091 - in /poolalloc/trunk/lib/DSA: BottomUpClosure.cpp CallTargets.cpp DataStructureStats.cpp Local.cpp Printer.cpp StdLibPass.cpp TopDownClosure.cpp Message-ID: <200908041934.n74JYKss017263@zion.cs.uiuc.edu> Author: alenhar2 Date: Tue Aug 4 14:33:52 2009 New Revision: 78091 URL: http://llvm.org/viewvc/llvm-project?rev=78091&view=rev Log: wrong output Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp poolalloc/trunk/lib/DSA/CallTargets.cpp poolalloc/trunk/lib/DSA/DataStructureStats.cpp poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/DSA/Printer.cpp poolalloc/trunk/lib/DSA/StdLibPass.cpp poolalloc/trunk/lib/DSA/TopDownClosure.cpp Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Aug 4 14:33:52 2009 @@ -54,14 +54,14 @@ calculateGraphs(MainFunc, Stack, NextID, ValMap); CloneAuxIntoGlobal(getDSGraph(*MainFunc)); } else { - DEBUG(ferrs() << debugname << ": No 'main' function found!\n"); + DEBUG(errs() << debugname << ": No 'main' function found!\n"); } // Calculate the graphs for any functions that are unreachable from main... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration() && !hasDSGraph(*I)) { if (MainFunc) - DEBUG(ferrs() << debugname << ": Function unreachable from main: " + DEBUG(errs() << debugname << ": Function unreachable from main: " << I->getName() << "\n"); calculateGraphs(I, Stack, NextID, ValMap); // Calculate all graphs. CloneAuxIntoGlobal(getDSGraph(*I)); @@ -263,12 +263,12 @@ // If this is a new SCC, process it now. if (Stack.back() == F) { // Special case the single "SCC" case here. - DEBUG(ferrs() << "Visiting single node SCC #: " << MyID << " fn: " + DEBUG(errs() << "Visiting single node SCC #: " << MyID << " fn: " << F->getName() << "\n"); Stack.pop_back(); - DEBUG(ferrs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); + DEBUG(errs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); calculateGraph(Graph); - DEBUG(ferrs() << " [BU] Done inlining: " << F->getName() << " [" + DEBUG(errs() << " [BU] Done inlining: " << F->getName() << " [" << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size() << "]\n"); @@ -297,7 +297,7 @@ ResolvedFuncs.resize(uid - ResolvedFuncs.begin()); if (ResolvedFuncs.size() || NewCalleeFuncs.size()) { - DEBUG(ferrs() << "Recalculating " << F->getName() << " due to new knowledge\n"); + DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n"); ValMap.erase(F); return calculateGraphs(F, Stack, NextID, ValMap); } else { @@ -341,7 +341,7 @@ } Stack.pop_back(); - DEBUG(ferrs() << "Calculating graph for SCC #: " << MyID << " of size: " + DEBUG(errs() << "Calculating graph for SCC #: " << MyID << " of size: " << SCCSize << "\n"); // Compute the Max SCC Size. @@ -354,7 +354,7 @@ // Now that we have one big happy family, resolve all of the call sites in // the graph... calculateGraph(SCCGraph); - DEBUG(ferrs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() + DEBUG(errs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n" << "DONE with SCC #: " << MyID << "\n"); @@ -473,7 +473,7 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline DEBUG(GI->AssertGraphOK(); GI->getGlobalsGraph()->AssertGraphOK()); - DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + DEBUG(errs() << " Inlining graph for " << Callee->getName() << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -484,19 +484,19 @@ ++NumInlines; DEBUG(Graph->AssertGraphOK();); } else if (CalledFuncs.size() > 1) { - DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); - DEBUG(ferrs() << " calls " << CalledFuncs.size() + DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(errs() << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(ferrs() << " Fns ="); + DEBUG(errs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) if (NumPrinted++ < 8) { - DEBUG(ferrs() << " " << (*I)->getName()); + DEBUG(errs() << " " << (*I)->getName()); } - DEBUG(ferrs() << "\n"); + DEBUG(errs() << "\n"); if (!isComplete) { for (unsigned x = 0; x < CalledFuncs.size(); ) @@ -547,13 +547,13 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); + DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG(ferrs() << " Inlining multi callee graph " + DEBUG(errs() << " Inlining multi callee graph " << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -622,7 +622,7 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline if (GI == Graph) continue; - DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + DEBUG(errs() << " Inlining graph for " << Callee->getName() << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -631,19 +631,19 @@ DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes); ++NumInlines; } else { - DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n"); DEBUG(std::cerr << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(ferrs() << " Fns ="); + DEBUG(errs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) if (NumPrinted++ < 8) { - DEBUG(ferrs() << " " << (*I)->getName()); + DEBUG(errs() << " " << (*I)->getName()); } - DEBUG(ferrs() << "\n"); + DEBUG(errs() << "\n"); for (unsigned x = 0; x < CalledFuncs.size(); ) if (!hasDSGraph(*CalledFuncs[x])) @@ -696,13 +696,13 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); + DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG(ferrs() << " Inlining multi callee graph " + DEBUG(errs() << " Inlining multi callee graph " << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CallTargets.cpp (original) +++ poolalloc/trunk/lib/DSA/CallTargets.cpp Tue Aug 4 14:33:52 2009 @@ -74,7 +74,7 @@ } if (N->isCompleteNode() && !IndMap[cs].size()) { ++CompleteEmpty; - DEBUG(ferrs() << "Call site empty: '" + DEBUG(errs() << "Call site empty: '" << cs.getInstruction()->getName() << "' In '" << cs.getInstruction()->getParent()->getParent()->getName() Modified: poolalloc/trunk/lib/DSA/DataStructureStats.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructureStats.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructureStats.cpp Tue Aug 4 14:33:52 2009 @@ -97,7 +97,7 @@ totalNumCallees += Callees.size(); ++numIndirectCalls; } else { - DEBUG(ferrs() << "WARNING: No callee in Function '" + DEBUG(errs() << "WARNING: No callee in Function '" << F.getNameStr() << "' at call: \n" << *I->getCallSite().getInstruction()); } @@ -107,7 +107,7 @@ NumIndirectCalls += numIndirectCalls; if (numIndirectCalls) { - DEBUG(ferrs() << " In function " << F.getName() << ": " + DEBUG(errs() << " In function " << F.getName() << ": " << (totalNumCallees / (double) numIndirectCalls) << " average callees per indirect call\n"); } Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Tue Aug 4 14:33:52 2009 @@ -250,7 +250,7 @@ NH = getValueDest(*(cast(C)->getAliasee())); return 0; } else { - DEBUG(ferrs() << "Unknown constant: " << *C << "\n"); + DEBUG(errs() << "Unknown constant: " << *C << "\n"); assert(0 && "Unknown constant type!"); } N = createNode(); // just create a shadow node @@ -488,7 +488,7 @@ // Variable index into a node. We must merge all of the elements of the // sequential type here. if (isa(STy)) { - DEBUG(ferrs() << "Pointer indexing not handled yet!\n"); + DEBUG(errs() << "Pointer indexing not handled yet!\n"); } else { const ArrayType *ATy = cast(STy); unsigned ElSize = TD.getTypeAllocSize(CurTy); @@ -537,7 +537,7 @@ { if (G.getPoolDescriptorsMap().count(N) != 0) if (G.getPoolDescriptorsMap()[N]) { - DEBUG(ferrs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"); + DEBUG(errs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"); } } } @@ -697,7 +697,7 @@ return true; } - DEBUG(ferrs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); + DEBUG(errs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); assert(0 && "Unhandled intrinsic"); return false; } @@ -728,7 +728,7 @@ if (!isa(Callee)) { CalleeNode = getValueDest(*Callee).getNode(); if (CalleeNode == 0) { - DEBUG(ferrs() << "WARNING: Program is calling through a null pointer?\n" << *I); + DEBUG(errs() << "WARNING: Program is calling through a null pointer?\n" << *I); return; // Calling a null pointer? } } Modified: poolalloc/trunk/lib/DSA/Printer.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Printer.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Printer.cpp (original) +++ poolalloc/trunk/lib/DSA/Printer.cpp Tue Aug 4 14:33:52 2009 @@ -343,13 +343,13 @@ void DataStructures::dumpCallGraph() const { for( ActualCalleesTy::const_iterator ii = ActualCallees.begin(), ee = ActualCallees.end(); ii != ee; ++ii) { - if (ii->first) ferrs() << ii->first->getParent()->getParent()->getName() << " "; - ferrs() << ii->first << ": ["; + if (ii->first) errs() << ii->first->getParent()->getParent()->getName() << " "; + errs() << ii->first << ": ["; for (callee_iterator cbi = ii->second.begin(), cbe = ii->second.end(); cbi != cbe; ++cbi) { - ferrs() << (*cbi)->getName() << " "; + errs() << (*cbi)->getName() << " "; } - ferrs() << "]\n"; + errs() << "]\n"; if (ii->first) ii->first->dump(); } } Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Aug 4 14:33:52 2009 @@ -183,7 +183,7 @@ if (CI->getOperand(0) == F) { DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); //delete the call - DEBUG(ferrs() << "Removing " << F->getNameStr() << " from " + DEBUG(errs() << "Removing " << F->getNameStr() << " from " << CI->getParent()->getParent()->getNameStr() << "\n"); Graph->removeFunctionCalls(*F); } Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=78091&r1=78090&r2=78091&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Tue Aug 4 14:33:52 2009 @@ -198,7 +198,7 @@ RC.getClonedNH(GG->getNodeForValue(*GI)); } - DEBUG(ferrs() << "[TD] Inlining callers into '" + DEBUG(errs() << "[TD] Inlining callers into '" << DSG->getFunctionNames() << "'\n"); // Iteratively inline caller graphs into this graph. @@ -215,15 +215,15 @@ do { const DSCallSite &CS = *EdgesFromCaller.back().CS; const Function &CF = *EdgesFromCaller.back().CalledFunction; - DEBUG(ferrs() << " [TD] Inlining graph into Fn '" + DEBUG(errs() << " [TD] Inlining graph into Fn '" << CF.getNameStr() << "' from "); if (CallerGraph->getReturnNodes().empty()) { - DEBUG(ferrs() << "SYNTHESIZED INDIRECT GRAPH"); + DEBUG(errs() << "SYNTHESIZED INDIRECT GRAPH"); } else { - DEBUG(ferrs() << "Fn '" << CS.getCallSite().getInstruction()-> + DEBUG(errs() << "Fn '" << CS.getCallSite().getInstruction()-> getParent()->getParent()->getNameStr() << "'"); } - DEBUG(ferrs() << ": " << CF.getFunctionType()->getNumParams() + DEBUG(errs() << ": " << CF.getFunctionType()->getNumParams() << " args\n"); // Get the formal argument and return nodes for the called function and @@ -339,7 +339,7 @@ // If we already have this graph, recycle it. if (IndCallRecI != IndCallMap.end() && IndCallRecI->first == Callees) { - DEBUG(ferrs() << " [TD] *** Reuse of indcall graph for " << Callees.size() + DEBUG(errs() << " [TD] *** Reuse of indcall graph for " << Callees.size() << " callees!\n"); IndCallGraph = IndCallRecI->second; } else { From evan.cheng at apple.com Tue Aug 4 14:36:49 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 4 Aug 2009 12:36:49 -0700 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> <87eirsrlf9.fsf@chora.dk> <5B3E9460-BBBB-4715-A7F6-EA2454C51A6C@apple.com> Message-ID: <05BD81A1-6059-4509-B50B-1A54DD4CB5D8@apple.com> On Aug 4, 2009, at 12:01 PM, Jakob Stoklund Olesen wrote: > > On 04/08/2009, at 19.31, Evan Cheng wrote: >> I am very hesitant to change the semantics. That will break a lot of >> assumptions in the register allocator. I think the current approach >> of >> having subreg lowering pass insert the right instructions to model >> "kill" is enough. Is it not? > > You are probably right. I am still struggling to completely understand > the semantics. > > We will almost certainly need to insert fake instructions that only > change flags. I am using IMPLICIT_DEF for that now, but it should > probably be replaced by a new ALTER_LIFE or something. I suggest KILL. It's easy to understand. > > [...] > >>>> Undef operands are "don't care". :-) It would have been cleaner to >>>> have an Undef machineoperand rather than a register machineoperand >>>> that's undef. But we still need to assign registers to them so the >>>> instructions can be translated to machine code. > > Ok, so if I understand you correctly, the actual register doesn't > really matter. It is only there so we produce valid machine code and > the only restriction is that the register class must be correct. And > of course there are two-address constraints. Yep. > > If that is correct, we could write an undef operand as %UNDEF. Like > this: > > %R0 = INSERT_SUBREG %UNDEF, %R0L, 1 Right. > > This makes sense to me. Note that in this case %R0 must be dead. Not > because it is referenced by an , but because it is not killed > before being defined. Yep. > > MachineInstr::addRegisterKilled() should not remove the flag. > It should completely skip the undef operand, just like the > regscavenger does. Ok. > > The flags and should not be allowed at the same time. > It is nonsensical. Yes, that would be nice because it makes the instructions easier to read. I thought about changing the machine instruction printer to just print instead of %r0. > > Am I on the right track? Very much so! Thanks for working on this. Evan > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Tue Aug 4 15:01:54 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 20:01:54 -0000 Subject: [llvm-commits] [llvm] r78093 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll test/CodeGen/X86/stack-color-with-reg.ll Message-ID: <200908042002.n74K20iY018093@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 15:01:11 2009 New Revision: 78093 URL: http://llvm.org/viewvc/llvm-project?rev=78093&view=rev Log: LowerSubregsInstructionPass::LowerExtract should not extend the live range of registers. When LowerExtract eliminates an EXTRACT_SUBREG with a kill flag, it moves the kill flag to the place where the sub-register is killed. This can accidentally overlap with the use of a sibling sub-register, and we have trouble. In the test case we have this code: Live Ins: %R0 %R1 %R2 %R2L = EXTRACT_SUBREG %R2, 1 %R2H = LOAD16fi , 0, Mem:LD(2,4) [FixedStack-1 + 0] %R1L = EXTRACT_SUBREG %R1, 1 %R0L = EXTRACT_SUBREG %R0, 1 %R0H = ADD16 %R2H, %R2L, %AZ, %AN, %AC0, %V, %VS subreg: CONVERTING: %R2L = EXTRACT_SUBREG %R2, 1 subreg: eliminated! subreg: killed here: %R0H = ADD16 %R2H, %R2L, %R2, %AZ, %AN, %AC0, %V, %VS The kill flag on %R2 is moved to the last instruction, and the live range overlaps with the definition of %R2H: *** Bad machine code: Redefining a live physical register *** - function: f - basic block: 0x18358c0 (#0) - instruction: %R2H = LOAD16fi , 0, Mem:LD(2,4) [FixedStack-1 + 0] Register R2H was defined but already live. The fix is to replace EXTRACT_SUBREG with IMPLICIT_DEF instead of eliminating it completely: subreg: CONVERTING: %R2L = EXTRACT_SUBREG %R2, 1 subreg: replace by: %R2L = IMPLICIT_DEF %R2 Note that these IMPLICIT_DEF instructions survive to the asm output. It is necessary to fix the stack-color-with-reg test case because of that. Added: llvm/trunk/test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=78093&r1=78092&r2=78093&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original) +++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Tue Aug 4 15:01:11 2009 @@ -103,7 +103,7 @@ MachineFunction &MF = *MBB->getParent(); const TargetRegisterInfo &TRI = *MF.getTarget().getRegisterInfo(); const TargetInstrInfo &TII = *MF.getTarget().getInstrInfo(); - + assert(MI->getOperand(0).isReg() && MI->getOperand(0).isDef() && MI->getOperand(1).isReg() && MI->getOperand(1).isUse() && MI->getOperand(2).isImm() && "Malformed extract_subreg"); @@ -117,23 +117,20 @@ "Extract supperg source must be a physical register"); assert(TargetRegisterInfo::isPhysicalRegister(DstReg) && "Extract destination must be in a physical register"); - + DOUT << "subreg: CONVERTING: " << *MI; if (SrcReg == DstReg) { - // No need to insert an identify copy instruction. + // No need to insert an identity copy instruction. + if (MI->getOperand(1).isKill()) { + // We must make sure the super-register gets killed.Replace the + // instruction with IMPLICIT_DEF. + MI->setDesc(TII.get(TargetInstrInfo::IMPLICIT_DEF)); + MI->RemoveOperand(2); // SubIdx + DOUT << "subreg: replace by: " << *MI; + return true; + } DOUT << "subreg: eliminated!"; - // Find the kill of the destination register's live range, and insert - // a kill of the source register at that point. - if (MI->getOperand(1).isKill() && !MI->getOperand(0).isDead()) - for (MachineBasicBlock::iterator MII = - next(MachineBasicBlock::iterator(MI)); - MII != MBB->end(); ++MII) - if (MII->killsRegister(DstReg, &TRI)) { - MII->addRegisterKilled(SuperReg, &TRI, /*AddIfNotFound=*/true); - DOUT << "\nsubreg: killed here: " << *MII; - break; - } } else { // Insert copy const TargetRegisterClass *TRCS = TRI.getPhysicalRegisterRegClass(DstReg); Added: llvm/trunk/test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll?rev=78093&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll (added) +++ llvm/trunk/test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll Tue Aug 4 15:01:11 2009 @@ -0,0 +1,15 @@ +; RUN: llvm-as < %s | llc -march=bfin -join-liveintervals=0 -verify-machineinstrs + +; Provoke an error in LowerSubregsPass::LowerExtract where the live range of a +; super-register is illegally extended. + +define i16 @f(i16 %x1, i16 %x2, i16 %x3, i16 %x4) { + %y1 = add i16 %x1, 1 + %y2 = add i16 %x2, 2 + %y3 = add i16 %x3, 3 + %y4 = add i16 %x4, 4 + %z12 = add i16 %y1, %y2 + %z34 = add i16 %y3, %y4 + %p = add i16 %z12, %z34 + ret i16 %p +} Modified: llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll?rev=78093&r1=78092&r2=78093&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll (original) +++ llvm/trunk/test/CodeGen/X86/stack-color-with-reg.ll Tue Aug 4 15:01:11 2009 @@ -1,7 +1,7 @@ ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t ; RUN: grep stackcoloring %t | grep "loads eliminated" ; RUN: grep stackcoloring %t | grep "stack slot refs replaced with reg refs" | grep 5 -; RUN: grep asm-printer %t | grep 175 +; RUN: grep asm-printer %t | grep 180 type { [62 x %struct.Bitvec*] } ; type %0 type { i8* } ; type %1 From stoklund at 2pi.dk Tue Aug 4 15:09:37 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 20:09:37 -0000 Subject: [llvm-commits] [llvm] r78095 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200908042009.n74K9hCH018333@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 15:09:25 2009 New Revision: 78095 URL: http://llvm.org/viewvc/llvm-project?rev=78095&view=rev Log: Don't tamper with operands in MachineInstr::addRegisterKilled. For an undef operand, MO.getReg() is meaningless and we should not use it. Undef operands should be skipped entirely. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=78095&r1=78094&r2=78095&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Tue Aug 4 15:09:25 2009 @@ -1030,7 +1030,7 @@ SmallVector DeadOps; for (unsigned i = 0, e = getNumOperands(); i != e; ++i) { MachineOperand &MO = getOperand(i); - if (!MO.isReg() || !MO.isUse()) + if (!MO.isReg() || !MO.isUse() || MO.isUndef()) continue; unsigned Reg = MO.getReg(); if (!Reg) @@ -1041,8 +1041,6 @@ if (MO.isKill()) // The register is already marked kill. return true; - // This operand can no longer be undef since Reg is live-in. - MO.setIsUndef(false); if (isPhysReg && isRegTiedToDefOperand(i)) // Two-address uses of physregs must not be marked kill. return true; From sabre at nondot.org Tue Aug 4 15:09:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 20:09:45 -0000 Subject: [llvm-commits] [llvm] r78096 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/TargetAsmInfo.cpp lib/Target/X86/X86TargetAsmInfo.cpp Message-ID: <200908042009.n74K9mpI018352@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 15:09:41 2009 New Revision: 78096 URL: http://llvm.org/viewvc/llvm-project?rev=78096&view=rev Log: rip out SectionEndDirectiveSuffix support, only uses by the masm backend. If anyone cares about masm in the future, we'll have semantic sections it can hang off of. Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/TargetAsmInfo.cpp llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=78096&r1=78095&r2=78096&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Tue Aug 4 15:09:41 2009 @@ -198,10 +198,6 @@ /// directive for data sections. const char *DataSectionStartSuffix; // Defaults to "". - /// SectionEndDirectiveSuffix - If non-null, the asm printer will close each - /// section with the section name and this suffix printed. - const char *SectionEndDirectiveSuffix;// Defaults to null. - /// JumpTableDirective - if non-null, the directive to emit before a jump /// table. const char *JumpTableDirective; @@ -454,9 +450,6 @@ const char *getDataSectionStartSuffix() const { return DataSectionStartSuffix; } - const char *getSectionEndDirectiveSuffix() const { - return SectionEndDirectiveSuffix; - } const char *getGlobalDirective() const { return GlobalDirective; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=78096&r1=78095&r2=78096&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Aug 4 15:09:41 2009 @@ -90,10 +90,6 @@ // If we're already in this section, we're done. if (CurrentSection == NS) return; - // Close the current section, if applicable. - if (NS != 0 && TAI->getSectionEndDirectiveSuffix()) - O << NS->getName() << TAI->getSectionEndDirectiveSuffix() << '\n'; - CurrentSection = NS; if (NS != 0) { Modified: llvm/trunk/lib/Target/TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetAsmInfo.cpp?rev=78096&r1=78095&r2=78096&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetAsmInfo.cpp Tue Aug 4 15:09:41 2009 @@ -57,7 +57,6 @@ SwitchToSectionDirective = "\t.section\t"; TextSectionStartSuffix = ""; DataSectionStartSuffix = ""; - SectionEndDirectiveSuffix = 0; JumpTableDirective = 0; GlobalDirective = "\t.globl\t"; SetDirective = 0; Modified: llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp?rev=78096&r1=78095&r2=78096&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetAsmInfo.cpp Tue Aug 4 15:09:41 2009 @@ -134,7 +134,6 @@ SwitchToSectionDirective = ""; TextSectionStartSuffix = "\tSEGMENT PARA 'CODE'"; DataSectionStartSuffix = "\tSEGMENT PARA 'DATA'"; - SectionEndDirectiveSuffix = "\tends\n"; } // Instantiate default implementation. From stoklund at 2pi.dk Tue Aug 4 15:15:39 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 4 Aug 2009 22:15:39 +0200 Subject: [llvm-commits] [llvm] r77989 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp lib/CodeGen/MachineInstr.cpp test/CodeGen/ARM/2009-08-02-RegScavengerAssert-Neon.ll In-Reply-To: <05BD81A1-6059-4509-B50B-1A54DD4CB5D8@apple.com> References: <200908032008.n73K8goN023448@zion.cs.uiuc.edu> <85AC6E8F-168F-441E-B591-59C3B543F6EE@apple.com> <87eirsrlf9.fsf@chora.dk> <5B3E9460-BBBB-4715-A7F6-EA2454C51A6C@apple.com> <05BD81A1-6059-4509-B50B-1A54DD4CB5D8@apple.com> Message-ID: On 04/08/2009, at 21.36, Evan Cheng wrote: >> We will almost certainly need to insert fake instructions that only >> change flags. I am using IMPLICIT_DEF for that now, but it should >> probably be replaced by a new ALTER_LIFE or something. > > I suggest KILL. It's easy to understand. ALTER_LIFE is silly, but the instruction can also make registers live: subreg: CONVERTING: %R2L = EXTRACT_SUBREG %R2, 1 subreg: replace by: %R2L = IMPLICIT_DEF %R2 subreg: CONVERTING: %R0 = INSERT_SUBREG %R0, %R0L, 1 subreg: replace by: %R0 = IMPLICIT_DEF %R0L [...] >> Am I on the right track? > > Very much so! Thanks for working on this. Woot! Finally. From resistor at mac.com Tue Aug 4 15:25:25 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Aug 2009 20:25:25 -0000 Subject: [llvm-commits] [llvm] r78097 - in /llvm/trunk: include/llvm/LLVMContext.h lib/VMCore/Constants.cpp lib/VMCore/LLVMContextImpl.cpp lib/VMCore/LLVMContextImpl.h Message-ID: <200908042025.n74KPVti018779@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 15:25:11 2009 New Revision: 78097 URL: http://llvm.org/viewvc/llvm-project?rev=78097&view=rev Log: Privatize the last bit of Constant-creation state. Modified: llvm/trunk/include/llvm/LLVMContext.h llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/LLVMContextImpl.cpp llvm/trunk/lib/VMCore/LLVMContextImpl.h Modified: llvm/trunk/include/llvm/LLVMContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=78097&r1=78096&r2=78097&view=diff ============================================================================== --- llvm/trunk/include/llvm/LLVMContext.h (original) +++ llvm/trunk/include/llvm/LLVMContext.h Tue Aug 4 15:25:11 2009 @@ -52,21 +52,9 @@ /// infrastructure, including the type and constant uniquing tables. /// LLVMContext itself provides no locking guarantees, so you should be careful /// to have one context per thread. -class LLVMContext { +struct LLVMContext { LLVMContextImpl* pImpl; - friend class ConstantInt; - friend class ConstantFP; - friend class ConstantStruct; - friend class ConstantArray; - friend class ConstantVector; - friend class ConstantAggregateZero; - friend class MDNode; - friend class MDString; - friend class ConstantPointerNull; - friend class UndefValue; - friend class ConstantExpr; -public: LLVMContext(); ~LLVMContext(); }; Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=78097&r1=78096&r2=78097&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Aug 4 15:25:11 2009 @@ -603,290 +603,6 @@ return get(std::vector(Vals, Vals+NumVals)); } - -namespace llvm { -// We declare several classes private to this file, so use an anonymous -// namespace -namespace { - -/// UnaryConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement unary constant exprs. -class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } - UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { - Op<0>() = C; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// BinaryConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement binary constant exprs. -class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { - Op<0>() = C1; - Op<1>() = C2; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// SelectConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement select constant exprs. -class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ExtractElementConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// extractelement constant exprs. -class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - ExtractElementConstantExpr(Constant *C1, Constant *C2) - : ConstantExpr(cast(C1->getType())->getElementType(), - Instruction::ExtractElement, &Op<0>(), 2) { - Op<0>() = C1; - Op<1>() = C2; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// InsertElementConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// insertelement constant exprs. -class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C1->getType(), Instruction::InsertElement, - &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ShuffleVectorConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// shufflevector constant exprs. -class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(VectorType::get( - cast(C1->getType())->getElementType(), - cast(C3->getType())->getNumElements()), - Instruction::ShuffleVector, - &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ExtractValueConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// extractvalue constant exprs. -class VISIBILITY_HIDDEN ExtractValueConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } - ExtractValueConstantExpr(Constant *Agg, - const SmallVector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1), - Indices(IdxList) { - Op<0>() = Agg; - } - - /// Indices - These identify which value to extract. - const SmallVector Indices; - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// InsertValueConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// insertvalue constant exprs. -class VISIBILITY_HIDDEN InsertValueConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 2); - } - InsertValueConstantExpr(Constant *Agg, Constant *Val, - const SmallVector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2), - Indices(IdxList) { - Op<0>() = Agg; - Op<1>() = Val; - } - - /// Indices - These identify the position for the insertion. - const SmallVector Indices; - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - - -/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is -/// used behind the scenes to implement getelementpr constant exprs. -class VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr { - GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, - const Type *DestTy); -public: - static GetElementPtrConstantExpr *Create(Constant *C, - const std::vector&IdxList, - const Type *DestTy) { - return - new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -// CompareConstantExpr - This class is private to Constants.cpp, and is used -// behind the scenes to implement ICmp and FCmp constant expressions. This is -// needed in order to store the predicate value for these instructions. -struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - unsigned short predicate; - CompareConstantExpr(const Type *ty, Instruction::OtherOps opc, - unsigned short pred, Constant* LHS, Constant* RHS) - : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) { - Op<0>() = LHS; - Op<1>() = RHS; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -} // end anonymous namespace - -template <> -struct OperandTraits : FixedNumOperandTraits<1> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<1> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) - -template <> -struct OperandTraits : VariadicOperandTraits<1> { -}; - -GetElementPtrConstantExpr::GetElementPtrConstantExpr - (Constant *C, - const std::vector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::GetElementPtr, - OperandTraits::op_end(this) - - (IdxList.size()+1), - IdxList.size()+1) { - OperandList[0] = C; - for (unsigned i = 0, E = IdxList.size(); i != E; ++i) - OperandList[i+1] = IdxList[i]; -} - -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) - - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) - - -} // End llvm namespace - - // Utility function for determining if a ConstantExpr is a CastOp or not. This // can't be inline because we don't want to #include Instruction.h into // Constant.h @@ -1264,134 +980,6 @@ //---- ConstantExpr::get() implementations... // -namespace { - -struct ExprMapKeyType { - typedef SmallVector IndexList; - - ExprMapKeyType(unsigned opc, - const std::vector &ops, - unsigned short pred = 0, - const IndexList &inds = IndexList()) - : opcode(opc), predicate(pred), operands(ops), indices(inds) {} - uint16_t opcode; - uint16_t predicate; - std::vector operands; - IndexList indices; - bool operator==(const ExprMapKeyType& that) const { - return this->opcode == that.opcode && - this->predicate == that.predicate && - this->operands == that.operands && - this->indices == that.indices; - } - bool operator<(const ExprMapKeyType & that) const { - return this->opcode < that.opcode || - (this->opcode == that.opcode && this->predicate < that.predicate) || - (this->opcode == that.opcode && this->predicate == that.predicate && - this->operands < that.operands) || - (this->opcode == that.opcode && this->predicate == that.predicate && - this->operands == that.operands && this->indices < that.indices); - } - - bool operator!=(const ExprMapKeyType& that) const { - return !(*this == that); - } -}; - -} - -namespace llvm { - template<> - struct ConstantCreator { - static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V, - unsigned short pred = 0) { - if (Instruction::isCast(V.opcode)) - return new UnaryConstantExpr(V.opcode, V.operands[0], Ty); - if ((V.opcode >= Instruction::BinaryOpsBegin && - V.opcode < Instruction::BinaryOpsEnd)) - return new BinaryConstantExpr(V.opcode, V.operands[0], V.operands[1]); - if (V.opcode == Instruction::Select) - return new SelectConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::ExtractElement) - return new ExtractElementConstantExpr(V.operands[0], V.operands[1]); - if (V.opcode == Instruction::InsertElement) - return new InsertElementConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::ShuffleVector) - return new ShuffleVectorConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::InsertValue) - return new InsertValueConstantExpr(V.operands[0], V.operands[1], - V.indices, Ty); - if (V.opcode == Instruction::ExtractValue) - return new ExtractValueConstantExpr(V.operands[0], V.indices, Ty); - if (V.opcode == Instruction::GetElementPtr) { - std::vector IdxList(V.operands.begin()+1, V.operands.end()); - return GetElementPtrConstantExpr::Create(V.operands[0], IdxList, Ty); - } - - // The compare instructions are weird. We have to encode the predicate - // value and it is combined with the instruction opcode by multiplying - // the opcode by one hundred. We must decode this to get the predicate. - if (V.opcode == Instruction::ICmp) - return new CompareConstantExpr(Ty, Instruction::ICmp, V.predicate, - V.operands[0], V.operands[1]); - if (V.opcode == Instruction::FCmp) - return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, - V.operands[0], V.operands[1]); - llvm_unreachable("Invalid ConstantExpr!"); - return 0; - } - }; - - template<> - struct ConvertConstantType { - static void convert(ConstantExpr *OldC, const Type *NewTy) { - Constant *New; - switch (OldC->getOpcode()) { - case Instruction::Trunc: - case Instruction::ZExt: - case Instruction::SExt: - case Instruction::FPTrunc: - case Instruction::FPExt: - case Instruction::UIToFP: - case Instruction::SIToFP: - case Instruction::FPToUI: - case Instruction::FPToSI: - case Instruction::PtrToInt: - case Instruction::IntToPtr: - case Instruction::BitCast: - New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), - NewTy); - break; - case Instruction::Select: - New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), - OldC->getOperand(1), - OldC->getOperand(2)); - break; - default: - assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && - OldC->getOpcode() < Instruction::BinaryOpsEnd); - New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), - OldC->getOperand(1)); - break; - case Instruction::GetElementPtr: - // Make everyone now use a constant of the new type... - std::vector Idx(OldC->op_begin()+1, OldC->op_end()); - New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), - &Idx[0], Idx.size()); - break; - } - - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } - }; -} // end namespace llvm - - static ExprMapKeyType getValType(ConstantExpr *CE) { std::vector Operands; Operands.reserve(CE->getNumOperands()); @@ -1403,9 +991,6 @@ CE->getIndices() : SmallVector()); } -static ManagedStatic > ExprConstants; - /// This is a utility function to handle folding of casts and lookup of the /// cast in the ExprConstants map. It is used by the various get* methods below. static inline Constant *getFoldedCast( @@ -1415,12 +1000,14 @@ if (Constant *FC = ConstantFoldCastInstruction(Ty->getContext(), opc, C, Ty)) return FC; + LLVMContextImpl *pImpl = Ty->getContext().pImpl; + // Look up the constant in the table first to ensure uniqueness std::vector argVec(1, C); ExprMapKeyType Key(opc, argVec); // Implicitly locked. - return ExprConstants->getOrCreate(Ty, Key); + return pImpl->ExprConstants.getOrCreate(Ty, Key); } Constant *ConstantExpr::getCast(unsigned oc, Constant *C, const Type *Ty) { @@ -1663,8 +1250,10 @@ std::vector argVec(1, C1); argVec.push_back(C2); ExprMapKeyType Key(Opcode, argVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getCompareTy(unsigned short predicate, @@ -1796,8 +1385,10 @@ argVec[2] = V2; ExprMapKeyType Key(Instruction::Select, argVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C, @@ -1822,8 +1413,10 @@ ArgVec.push_back(cast(Idxs[i])); const ExprMapKeyType Key(Instruction::GetElementPtr, ArgVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs, @@ -1859,8 +1452,10 @@ // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::ICmp, ArgVec, pred); + LLVMContextImpl *pImpl = LHS->getType()->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(Type::Int1Ty, Key); + return pImpl->ExprConstants.getOrCreate(Type::Int1Ty, Key); } Constant * @@ -1879,8 +1474,10 @@ // Get the key type with both the opcode and predicate const ExprMapKeyType Key(Instruction::FCmp, ArgVec, pred); + LLVMContextImpl *pImpl = LHS->getType()->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(Type::Int1Ty, Key); + return pImpl->ExprConstants.getOrCreate(Type::Int1Ty, Key); } Constant *ConstantExpr::getExtractElementTy(const Type *ReqTy, Constant *Val, @@ -1893,8 +1490,10 @@ ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::ExtractElement,ArgVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getExtractElement(Constant *Val, Constant *Idx) { @@ -1917,8 +1516,10 @@ ArgVec.push_back(Idx); const ExprMapKeyType Key(Instruction::InsertElement,ArgVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getInsertElement(Constant *Val, Constant *Elt, @@ -1943,8 +1544,10 @@ ArgVec.push_back(Mask); const ExprMapKeyType Key(Instruction::ShuffleVector,ArgVec); + LLVMContextImpl *pImpl = ReqTy->getContext().pImpl; + // Implicitly locked. - return ExprConstants->getOrCreate(ReqTy, Key); + return pImpl->ExprConstants.getOrCreate(ReqTy, Key); } Constant *ConstantExpr::getShuffleVector(Constant *V1, Constant *V2, @@ -2113,7 +1716,8 @@ // void ConstantExpr::destroyConstant() { // Implicitly locked. - ExprConstants->remove(this); + LLVMContextImpl *pImpl = getType()->getContext().pImpl; + pImpl->ExprConstants.remove(this); destroyConstantImpl(); } Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=78097&r1=78096&r2=78097&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Tue Aug 4 15:25:11 2009 @@ -21,3 +21,16 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C) : Context(C), TheTrueVal(0), TheFalseVal(0) { } + +GetElementPtrConstantExpr::GetElementPtrConstantExpr + (Constant *C, + const std::vector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::GetElementPtr, + OperandTraits::op_end(this) + - (IdxList.size()+1), + IdxList.size()+1) { + OperandList[0] = C; + for (unsigned i = 0, E = IdxList.size(); i != E; ++i) + OperandList[i+1] = IdxList[i]; +} \ No newline at end of file Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78097&r1=78096&r2=78097&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug 4 15:25:11 2009 @@ -18,6 +18,8 @@ #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" +#include "llvm/Operator.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/System/Mutex.h" @@ -34,6 +36,297 @@ template struct ConstantTraits; + +/// UnaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement unary constant exprs. +class UnaryConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 1); + } + UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) + : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { + Op<0>() = C; + } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// BinaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement binary constant exprs. +class BinaryConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) + : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { + Op<0>() = C1; + Op<1>() = C2; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// SelectConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement select constant exprs. +class SelectConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ExtractElementConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// extractelement constant exprs. +class ExtractElementConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + ExtractElementConstantExpr(Constant *C1, Constant *C2) + : ConstantExpr(cast(C1->getType())->getElementType(), + Instruction::ExtractElement, &Op<0>(), 2) { + Op<0>() = C1; + Op<1>() = C2; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// InsertElementConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// insertelement constant exprs. +class InsertElementConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(C1->getType(), Instruction::InsertElement, + &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ShuffleVectorConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// shufflevector constant exprs. +class ShuffleVectorConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(VectorType::get( + cast(C1->getType())->getElementType(), + cast(C3->getType())->getNumElements()), + Instruction::ShuffleVector, + &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ExtractValueConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// extractvalue constant exprs. +class ExtractValueConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 1); + } + ExtractValueConstantExpr(Constant *Agg, + const SmallVector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1), + Indices(IdxList) { + Op<0>() = Agg; + } + + /// Indices - These identify which value to extract. + const SmallVector Indices; + + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// InsertValueConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// insertvalue constant exprs. +class InsertValueConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 2); + } + InsertValueConstantExpr(Constant *Agg, Constant *Val, + const SmallVector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2), + Indices(IdxList) { + Op<0>() = Agg; + Op<1>() = Val; + } + + /// Indices - These identify the position for the insertion. + const SmallVector Indices; + + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + + +/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is +/// used behind the scenes to implement getelementpr constant exprs. +class GetElementPtrConstantExpr : public ConstantExpr { + GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, + const Type *DestTy); +public: + static GetElementPtrConstantExpr *Create(Constant *C, + const std::vector&IdxList, + const Type *DestTy) { + return + new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +// CompareConstantExpr - This class is private to Constants.cpp, and is used +// behind the scenes to implement ICmp and FCmp constant expressions. This is +// needed in order to store the predicate value for these instructions. +struct CompareConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + unsigned short predicate; + CompareConstantExpr(const Type *ty, Instruction::OtherOps opc, + unsigned short pred, Constant* LHS, Constant* RHS) + : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) { + Op<0>() = LHS; + Op<1>() = RHS; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) + +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) + + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) + +struct ExprMapKeyType { + typedef SmallVector IndexList; + + ExprMapKeyType(unsigned opc, + const std::vector &ops, + unsigned short pred = 0, + const IndexList &inds = IndexList()) + : opcode(opc), predicate(pred), operands(ops), indices(inds) {} + uint16_t opcode; + uint16_t predicate; + std::vector operands; + IndexList indices; + bool operator==(const ExprMapKeyType& that) const { + return this->opcode == that.opcode && + this->predicate == that.predicate && + this->operands == that.operands && + this->indices == that.indices; + } + bool operator<(const ExprMapKeyType & that) const { + return this->opcode < that.opcode || + (this->opcode == that.opcode && this->predicate < that.predicate) || + (this->opcode == that.opcode && this->predicate == that.predicate && + this->operands < that.operands) || + (this->opcode == that.opcode && this->predicate == that.predicate && + this->operands == that.operands && this->indices < that.indices); + } + + bool operator!=(const ExprMapKeyType& that) const { + return !(*this == that); + } +}; + // The number of operands for each ConstantCreator::create method is // determined by the ConstantTraits template. // ConstantCreator - A class that is used to create constants by @@ -42,26 +335,115 @@ // constant. // template -struct VISIBILITY_HIDDEN ConstantTraits< std::vector > { +struct ConstantTraits< std::vector > { static unsigned uses(const std::vector& v) { return v.size(); } }; template -struct VISIBILITY_HIDDEN ConstantCreator { +struct ConstantCreator { static ConstantClass *create(const TypeClass *Ty, const ValType &V) { return new(ConstantTraits::uses(V)) ConstantClass(Ty, V); } }; template -struct VISIBILITY_HIDDEN ConvertConstantType { +struct ConvertConstantType { static void convert(ConstantClass *OldC, const TypeClass *NewTy) { llvm_unreachable("This type cannot be converted!"); } }; +template<> +struct ConstantCreator { + static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V, + unsigned short pred = 0) { + if (Instruction::isCast(V.opcode)) + return new UnaryConstantExpr(V.opcode, V.operands[0], Ty); + if ((V.opcode >= Instruction::BinaryOpsBegin && + V.opcode < Instruction::BinaryOpsEnd)) + return new BinaryConstantExpr(V.opcode, V.operands[0], V.operands[1]); + if (V.opcode == Instruction::Select) + return new SelectConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::ExtractElement) + return new ExtractElementConstantExpr(V.operands[0], V.operands[1]); + if (V.opcode == Instruction::InsertElement) + return new InsertElementConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::ShuffleVector) + return new ShuffleVectorConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::InsertValue) + return new InsertValueConstantExpr(V.operands[0], V.operands[1], + V.indices, Ty); + if (V.opcode == Instruction::ExtractValue) + return new ExtractValueConstantExpr(V.operands[0], V.indices, Ty); + if (V.opcode == Instruction::GetElementPtr) { + std::vector IdxList(V.operands.begin()+1, V.operands.end()); + return GetElementPtrConstantExpr::Create(V.operands[0], IdxList, Ty); + } + + // The compare instructions are weird. We have to encode the predicate + // value and it is combined with the instruction opcode by multiplying + // the opcode by one hundred. We must decode this to get the predicate. + if (V.opcode == Instruction::ICmp) + return new CompareConstantExpr(Ty, Instruction::ICmp, V.predicate, + V.operands[0], V.operands[1]); + if (V.opcode == Instruction::FCmp) + return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, + V.operands[0], V.operands[1]); + llvm_unreachable("Invalid ConstantExpr!"); + return 0; + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantExpr *OldC, const Type *NewTy) { + Constant *New; + switch (OldC->getOpcode()) { + case Instruction::Trunc: + case Instruction::ZExt: + case Instruction::SExt: + case Instruction::FPTrunc: + case Instruction::FPExt: + case Instruction::UIToFP: + case Instruction::SIToFP: + case Instruction::FPToUI: + case Instruction::FPToSI: + case Instruction::PtrToInt: + case Instruction::IntToPtr: + case Instruction::BitCast: + New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), + NewTy); + break; + case Instruction::Select: + New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), + OldC->getOperand(1), + OldC->getOperand(2)); + break; + default: + assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && + OldC->getOpcode() < Instruction::BinaryOpsEnd); + New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), + OldC->getOperand(1)); + break; + case Instruction::GetElementPtr: + // Make everyone now use a constant of the new type... + std::vector Idx(OldC->op_begin()+1, OldC->op_end()); + New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), + &Idx[0], Idx.size()); + break; + } + + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + // ConstantAggregateZero does not take extra "value" argument... template struct ConstantCreator { @@ -458,7 +840,7 @@ static bool isPod() { return false; } }; -class LLVMContextImpl { +struct LLVMContextImpl { sys::SmartRWMutex ConstantsLock; typedef DenseMap UndefValueConstants; + ValueMap ExprConstants; + LLVMContext &Context; ConstantInt *TheTrueVal; ConstantInt *TheFalseVal; + LLVMContextImpl(LLVMContext &C); +private: LLVMContextImpl(); LLVMContextImpl(const LLVMContextImpl&); - - friend class ConstantInt; - friend class ConstantFP; - friend class ConstantStruct; - friend class ConstantArray; - friend class ConstantVector; - friend class ConstantAggregateZero; - friend class MDNode; - friend class MDString; - friend class ConstantPointerNull; - friend class UndefValue; -public: - LLVMContextImpl(LLVMContext &C); }; } From dag at cray.com Tue Aug 4 16:55:22 2009 From: dag at cray.com (David Greene) Date: Tue, 4 Aug 2009 16:55:22 -0500 Subject: [llvm-commits] [PATCH] Dump with LI Indices In-Reply-To: References: <200907301710.32176.dag@cray.com> <200908040846.35455.dag@cray.com> Message-ID: <200908041655.22914.dag@cray.com> On Tuesday 04 August 2009 12:44, Chris Lattner wrote: > On Aug 4, 2009, at 6:46 AM, David Greene wrote: > > On Tuesday 04 August 2009 01:08, Evan Cheng wrote: > >> I am really not crazy about it especially since it has such a generic > >> name Dump.h. But it's not a big deal. > > > > I'm open to a better naming. I'm not particulrly fond of Dump.h > > either. > > I still don't understand why you need a general "prefix printer" > mechanism, instead of just doing a simple helper function in the > liveintervals code. How would you do a helper function? Remember, dumps happen lots of places before and after LiveIntervals has run. Are you suggesting that the MachineFunction and MachineBasicBlock dump routines call directly into LiveIntervals? If so, then we'll need a flag to tell the dump routines to *not* do that. That seems less clean to me. -Dave From deeppatel1987 at gmail.com Tue Aug 4 17:20:14 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 4 Aug 2009 22:20:14 +0000 Subject: [llvm-commits] [llvm] r78081 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMInstrVFP.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMS Message-ID: <305d6f60908041520t3346d13cgc238229dcc82741a@mail.gmail.com> Have you done any benchmarking that suggests that this is a win? The docs we have for the Cortex-A9 suggest that NEON operations have longer latency than VFP ops. (I don't have the A8 docs to compare with.) deep On Tue, Aug 4, 2009 at 5:53 PM, David Goodwin wrote: > Author: david_goodwin > Date: Tue Aug ?4 12:53:06 2009 > New Revision: 78081 > > URL: http://llvm.org/viewvc/llvm-project?rev=78081&view=rev > Log: > Initial support for single-precision FP using NEON. Added "neonfp" attribute to enable. Added patterns for some binary FP operations. From gohman at apple.com Tue Aug 4 17:29:58 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 4 Aug 2009 15:29:58 -0700 Subject: [llvm-commits] [llvm] r78048 - in /llvm/trunk: include/llvm/Value.h include/llvm/ValueSymbolTable.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Value.cpp In-Reply-To: <200908040431.n744V3h9008282@zion.cs.uiuc.edu> References: <200908040431.n744V3h9008282@zion.cs.uiuc.edu> Message-ID: <93C933D6-2A1E-43B3-A26F-7B5A2395F286@apple.com> On Aug 3, 2009, at 9:31 PM, Chris Lattner wrote: > Author: lattner > Date: Mon Aug 3 23:31:02 2009 > New Revision: 78048 > > URL: http://llvm.org/viewvc/llvm-project?rev=78048&view=rev > Log: > switch ValueMap to using AssertingVH. This is an old patch I had > laying > around in a tree I forgot about. Hi Chris, This has the property of causing LLVM's public ABI to be non-trivially sensitive to NDEBUG. If clients aren't built with NDEBUG set to what it's set to in the LLVM build they're linking with, the results are very bad and very hard to diagnose. I think this is too heavy a burden to put on clients. Dan From resistor at mac.com Tue Aug 4 17:41:51 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Aug 2009 22:41:51 -0000 Subject: [llvm-commits] [llvm] r78115 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Assembly/ include/llvm/Bitcode/ include/llvm/CodeGen/ include/llvm/Debugger/ include/llvm/Support/ include/llvm/Transforms/Utils/ lib/Archive/ lib/AsmParser/ lib/Bitcode/Reader/ lib/VMCore/ tools/bugpoint/ tools/llvm-db/ Message-ID: <200908042241.n74MfuJc023650@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 17:41:48 2009 New Revision: 78115 URL: http://llvm.org/viewvc/llvm-project?rev=78115&view=rev Log: Factor some of the constants+context related code out into a separate header, to make LLVMContextImpl.h not hideous. Also, fix some MSVC compile errors. Removed: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/include/llvm/Analysis/SparsePropagation.h llvm/trunk/include/llvm/Analysis/ValueTracking.h llvm/trunk/include/llvm/Assembly/Parser.h llvm/trunk/include/llvm/BasicBlock.h llvm/trunk/include/llvm/Bitcode/Archive.h llvm/trunk/include/llvm/Bitcode/ReaderWriter.h llvm/trunk/include/llvm/CodeGen/ValueTypes.h llvm/trunk/include/llvm/Constant.h llvm/trunk/include/llvm/Constants.h llvm/trunk/include/llvm/Debugger/Debugger.h llvm/trunk/include/llvm/Function.h llvm/trunk/include/llvm/GlobalVariable.h llvm/trunk/include/llvm/InstrTypes.h llvm/trunk/include/llvm/Instruction.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/include/llvm/Intrinsics.h llvm/trunk/include/llvm/LLVMContext.h llvm/trunk/include/llvm/Linker.h llvm/trunk/include/llvm/Metadata.h llvm/trunk/include/llvm/Module.h llvm/trunk/include/llvm/Support/TargetFolder.h llvm/trunk/include/llvm/Transforms/Utils/Cloning.h llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h llvm/trunk/include/llvm/Value.h llvm/trunk/lib/Archive/ArchiveInternals.h llvm/trunk/lib/AsmParser/LLLexer.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h llvm/trunk/lib/VMCore/ConstantFold.h llvm/trunk/lib/VMCore/LLVMContext.cpp llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/tools/bugpoint/BugDriver.h llvm/trunk/tools/llvm-db/CLIDebugger.h Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Tue Aug 4 17:41:48 2009 @@ -22,7 +22,7 @@ class TargetData; class Function; class Type; - class LLVMContext; + struct LLVMContext; /// ConstantFoldInstruction - Attempt to constant fold the specified /// instruction. If successful, the constant result is returned, if not, null Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Aug 4 17:41:48 2009 @@ -40,7 +40,7 @@ class DebugLoc; struct DebugLocTracker; class Instruction; - class LLVMContext; + struct LLVMContext; class DIDescriptor { protected: Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Tue Aug 4 17:41:48 2009 @@ -40,7 +40,7 @@ class Type; class ScalarEvolution; class TargetData; - class LLVMContext; + struct LLVMContext; class Loop; class LoopInfo; class Operator; Modified: llvm/trunk/include/llvm/Analysis/SparsePropagation.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/SparsePropagation.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/SparsePropagation.h (original) +++ llvm/trunk/include/llvm/Analysis/SparsePropagation.h Tue Aug 4 17:41:48 2009 @@ -31,7 +31,7 @@ class BasicBlock; class Function; class SparseSolver; - class LLVMContext; + struct LLVMContext; template class SmallVectorImpl; Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original) +++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ class Instruction; class APInt; class TargetData; - class LLVMContext; + struct LLVMContext; /// ComputeMaskedBits - Determine which of the bits specified in Mask are /// known to be either zero or one and return them in the KnownZero/KnownOne Modified: llvm/trunk/include/llvm/Assembly/Parser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/Parser.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/Parser.h (original) +++ llvm/trunk/include/llvm/Assembly/Parser.h Tue Aug 4 17:41:48 2009 @@ -21,7 +21,7 @@ class Module; class SMDiagnostic; class raw_ostream; -class LLVMContext; +struct LLVMContext; /// This function is the main interface to the LLVM Assembly Parser. It parses /// an ASCII file that (presumably) contains LLVM Assembly code. It returns a Modified: llvm/trunk/include/llvm/BasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/BasicBlock.h (original) +++ llvm/trunk/include/llvm/BasicBlock.h Tue Aug 4 17:41:48 2009 @@ -22,7 +22,7 @@ namespace llvm { class TerminatorInst; -class LLVMContext; +struct LLVMContext; template<> struct ilist_traits : public SymbolTableListTraits { Modified: llvm/trunk/include/llvm/Bitcode/Archive.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Archive.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/Archive.h (original) +++ llvm/trunk/include/llvm/Bitcode/Archive.h Tue Aug 4 17:41:48 2009 @@ -32,7 +32,7 @@ class Module; // From VMCore class Archive; // Declared below class ArchiveMemberHeader; // Internal implementation class -class LLVMContext; // Global data +struct LLVMContext; // Global data /// This class is the main class manipulated by users of the Archive class. It /// holds information about one member of the Archive. It is also the element Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original) +++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ class MemoryBuffer; class ModulePass; class BitstreamWriter; - class LLVMContext; + struct LLVMContext; class raw_ostream; /// getBitcodeModuleProvider - Read the header of the specified bitcode buffer Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ValueTypes.h (original) +++ llvm/trunk/include/llvm/CodeGen/ValueTypes.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ namespace llvm { class Type; - class LLVMContext; + struct LLVMContext; struct MVT { // MVT = Machine Value Type public: Modified: llvm/trunk/include/llvm/Constant.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constant.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constant.h (original) +++ llvm/trunk/include/llvm/Constant.h Tue Aug 4 17:41:48 2009 @@ -20,7 +20,7 @@ class APInt; template class SmallVectorImpl; - class LLVMContext; + struct LLVMContext; /// This is an important base class in LLVM. It provides the common facilities /// of all constant values in an LLVM program. A constant is a value that is Modified: llvm/trunk/include/llvm/Constants.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Constants.h (original) +++ llvm/trunk/include/llvm/Constants.h Tue Aug 4 17:41:48 2009 @@ -231,7 +231,7 @@ APFloat Val; void *operator new(size_t, unsigned);// DO NOT IMPLEMENT ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT - friend class LLVMContextImpl; + friend struct LLVMContextImpl; protected: ConstantFP(const Type *Ty, const APFloat& V); protected: Modified: llvm/trunk/include/llvm/Debugger/Debugger.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Debugger/Debugger.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Debugger/Debugger.h (original) +++ llvm/trunk/include/llvm/Debugger/Debugger.h Tue Aug 4 17:41:48 2009 @@ -20,7 +20,7 @@ namespace llvm { class Module; class InferiorProcess; - class LLVMContext; + struct LLVMContext; /// Debugger class - This class implements the LLVM source-level debugger. /// This allows clients to handle the user IO processing without having to Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Tue Aug 4 17:41:48 2009 @@ -26,7 +26,7 @@ namespace llvm { class FunctionType; -class LLVMContext; +struct LLVMContext; // Traits for intrusive list of basic blocks... template<> struct ilist_traits Modified: llvm/trunk/include/llvm/GlobalVariable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/GlobalVariable.h (original) +++ llvm/trunk/include/llvm/GlobalVariable.h Tue Aug 4 17:41:48 2009 @@ -28,7 +28,7 @@ class Module; class Constant; -class LLVMContext; +struct LLVMContext; template class SymbolTableListTraits; Modified: llvm/trunk/include/llvm/InstrTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InstrTypes.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/InstrTypes.h (original) +++ llvm/trunk/include/llvm/InstrTypes.h Tue Aug 4 17:41:48 2009 @@ -22,7 +22,7 @@ namespace llvm { -class LLVMContext; +struct LLVMContext; //===----------------------------------------------------------------------===// // TerminatorInst Class Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Tue Aug 4 17:41:48 2009 @@ -20,7 +20,7 @@ namespace llvm { -class LLVMContext; +struct LLVMContext; template class SymbolTableListTraits; Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Tue Aug 4 17:41:48 2009 @@ -29,7 +29,7 @@ class ConstantInt; class ConstantRange; class APInt; -class LLVMContext; +struct LLVMContext; //===----------------------------------------------------------------------===// // AllocationInst Class Modified: llvm/trunk/include/llvm/Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.h (original) +++ llvm/trunk/include/llvm/Intrinsics.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ class Type; class FunctionType; class Function; -class LLVMContext; +struct LLVMContext; class Module; class AttrListPtr; Modified: llvm/trunk/include/llvm/LLVMContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/LLVMContext.h (original) +++ llvm/trunk/include/llvm/LLVMContext.h Tue Aug 4 17:41:48 2009 @@ -34,7 +34,7 @@ class ConstantVector; class FunctionType; class IntegerType; -class LLVMContextImpl; +struct LLVMContextImpl; class MDNode; class MDString; class OpaqueType; Modified: llvm/trunk/include/llvm/Linker.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Linker.h (original) +++ llvm/trunk/include/llvm/Linker.h Tue Aug 4 17:41:48 2009 @@ -21,7 +21,7 @@ namespace llvm { class Module; -class LLVMContext; +struct LLVMContext; /// This class provides the core functionality of linking in LLVM. It retains a /// Module object which is the composite of the modules and libraries linked Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Tue Aug 4 17:41:48 2009 @@ -27,7 +27,7 @@ namespace llvm { class Constant; -class LLVMContext; +struct LLVMContext; //===----------------------------------------------------------------------===// // MetadataBase - A base class for MDNode, MDString and NamedMDNode. @@ -206,7 +206,7 @@ class NamedMDNode : public MetadataBase, public ilist_node { friend class SymbolTableListTraits; - friend class LLVMContextImpl; + friend struct LLVMContextImpl; NamedMDNode(const NamedMDNode &); // DO NOT IMPLEMENT void *operator new(size_t, unsigned); // DO NOT IMPLEMENT Modified: llvm/trunk/include/llvm/Module.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Module.h (original) +++ llvm/trunk/include/llvm/Module.h Tue Aug 4 17:41:48 2009 @@ -26,7 +26,7 @@ class GlobalValueRefMap; // Used by ConstantVals.cpp class FunctionType; -class LLVMContext; +struct LLVMContext; template<> struct ilist_traits : public SymbolTableListTraits { Modified: llvm/trunk/include/llvm/Support/TargetFolder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetFolder.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TargetFolder.h (original) +++ llvm/trunk/include/llvm/Support/TargetFolder.h Tue Aug 4 17:41:48 2009 @@ -25,7 +25,7 @@ namespace llvm { class TargetData; -class LLVMContext; +struct LLVMContext; /// TargetFolder - Create constants with target dependent folding. class TargetFolder { Modified: llvm/trunk/include/llvm/Transforms/Utils/Cloning.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Cloning.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Cloning.h Tue Aug 4 17:41:48 2009 @@ -38,7 +38,7 @@ class TargetData; class Loop; class LoopInfo; -class LLVMContext; +struct LLVMContext; /// CloneModule - Return an exact copy of the specified module /// Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Tue Aug 4 17:41:48 2009 @@ -27,7 +27,7 @@ class AllocaInst; class ConstantExpr; class TargetData; -class LLVMContext; +struct LLVMContext; struct DbgInfoIntrinsic; template class SmallVectorImpl; Modified: llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/PromoteMemToReg.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ class DominatorTree; class DominanceFrontier; class AliasSetTracker; -class LLVMContext; +struct LLVMContext; /// isAllocaPromotable - Return true if this alloca is legal for promotion. /// This is true if there are only loads and stores to the alloca... Modified: llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/ValueMapper.h Tue Aug 4 17:41:48 2009 @@ -20,7 +20,7 @@ namespace llvm { class Value; class Instruction; - class LLVMContext; + struct LLVMContext; typedef DenseMap ValueMapTy; Value *MapValue(const Value *V, ValueMapTy &VM, LLVMContext &Context); Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Tue Aug 4 17:41:48 2009 @@ -42,7 +42,7 @@ class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; -class LLVMContext; +struct LLVMContext; //===----------------------------------------------------------------------===// // Value Class Modified: llvm/trunk/lib/Archive/ArchiveInternals.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveInternals.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/Archive/ArchiveInternals.h (original) +++ llvm/trunk/lib/Archive/ArchiveInternals.h Tue Aug 4 17:41:48 2009 @@ -31,7 +31,7 @@ namespace llvm { - class LLVMContext; + struct LLVMContext; /// The ArchiveMemberHeader structure is used internally for bitcode /// archives. Modified: llvm/trunk/lib/AsmParser/LLLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.h (original) +++ llvm/trunk/lib/AsmParser/LLLexer.h Tue Aug 4 17:41:48 2009 @@ -24,7 +24,7 @@ class MemoryBuffer; class Type; class SMDiagnostic; - class LLVMContext; + struct LLVMContext; class LLLexer { const char *CurPtr; Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.h Tue Aug 4 17:41:48 2009 @@ -26,7 +26,7 @@ namespace llvm { class MemoryBuffer; - class LLVMContext; + struct LLVMContext; //===----------------------------------------------------------------------===// // BitcodeReaderValueList Class Modified: llvm/trunk/lib/VMCore/ConstantFold.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/ConstantFold.h (original) +++ llvm/trunk/lib/VMCore/ConstantFold.h Tue Aug 4 17:41:48 2009 @@ -23,7 +23,7 @@ class Value; class Constant; class Type; - class LLVMContext; + struct LLVMContext; // Constant fold various types of instruction... Constant *ConstantFoldCastInstruction( Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContext.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Aug 4 17:41:48 2009 @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // This file implements LLVMContext, as a wrapper around the opaque -// class LLVMContextImpl. +// struct LLVMContextImpl. // //===----------------------------------------------------------------------===// @@ -29,5 +29,18 @@ return *GlobalContext; } -LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { } +LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { } LLVMContext::~LLVMContext() { delete pImpl; } + +GetElementPtrConstantExpr::GetElementPtrConstantExpr + (Constant *C, + const std::vector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::GetElementPtr, + OperandTraits::op_end(this) + - (IdxList.size()+1), + IdxList.size()+1) { + OperandList[0] = C; + for (unsigned i = 0, E = IdxList.size(); i != E; ++i) + OperandList[i+1] = IdxList[i]; +} Removed: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=78114&view=auto ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (removed) @@ -1,36 +0,0 @@ -//===--------------- LLVMContextImpl.cpp - Implementation ------*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements LLVMContextImpl, the opaque implementation -// of LLVMContext. -// -//===----------------------------------------------------------------------===// - -#include "LLVMContextImpl.h" -#include "llvm/Constants.h" -#include "llvm/DerivedTypes.h" -#include "llvm/LLVMContext.h" -#include "llvm/Metadata.h" -using namespace llvm; - -LLVMContextImpl::LLVMContextImpl(LLVMContext &C) : - Context(C), TheTrueVal(0), TheFalseVal(0) { } - -GetElementPtrConstantExpr::GetElementPtrConstantExpr - (Constant *C, - const std::vector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::GetElementPtr, - OperandTraits::op_end(this) - - (IdxList.size()+1), - IdxList.size()+1) { - OperandList[0] = C; - for (unsigned i = 0, E = IdxList.size(); i != E; ++i) - OperandList[i+1] = IdxList[i]; -} \ No newline at end of file Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug 4 17:41:48 2009 @@ -15,776 +15,25 @@ #ifndef LLVM_LLVMCONTEXT_IMPL_H #define LLVM_LLVMCONTEXT_IMPL_H +#include "ConstantsContext.h" #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/Instructions.h" -#include "llvm/Operator.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/System/Mutex.h" #include "llvm/System/RWMutex.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/StringMap.h" -#include #include namespace llvm { -template -struct ConstantTraits; - - -/// UnaryConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement unary constant exprs. -class UnaryConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } - UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { - Op<0>() = C; - } - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// BinaryConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement binary constant exprs. -class BinaryConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { - Op<0>() = C1; - Op<1>() = C2; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// SelectConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement select constant exprs. -class SelectConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ExtractElementConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// extractelement constant exprs. -class ExtractElementConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - ExtractElementConstantExpr(Constant *C1, Constant *C2) - : ConstantExpr(cast(C1->getType())->getElementType(), - Instruction::ExtractElement, &Op<0>(), 2) { - Op<0>() = C1; - Op<1>() = C2; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// InsertElementConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// insertelement constant exprs. -class InsertElementConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C1->getType(), Instruction::InsertElement, - &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ShuffleVectorConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// shufflevector constant exprs. -class ShuffleVectorConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly three operands - void *operator new(size_t s) { - return User::operator new(s, 3); - } - ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(VectorType::get( - cast(C1->getType())->getElementType(), - cast(C3->getType())->getNumElements()), - Instruction::ShuffleVector, - &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// ExtractValueConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// extractvalue constant exprs. -class ExtractValueConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 1); - } - ExtractValueConstantExpr(Constant *Agg, - const SmallVector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1), - Indices(IdxList) { - Op<0>() = Agg; - } - - /// Indices - These identify which value to extract. - const SmallVector Indices; - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -/// InsertValueConstantExpr - This class is private to -/// Constants.cpp, and is used behind the scenes to implement -/// insertvalue constant exprs. -class InsertValueConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT -public: - // allocate space for exactly one operand - void *operator new(size_t s) { - return User::operator new(s, 2); - } - InsertValueConstantExpr(Constant *Agg, Constant *Val, - const SmallVector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2), - Indices(IdxList) { - Op<0>() = Agg; - Op<1>() = Val; - } - - /// Indices - These identify the position for the insertion. - const SmallVector Indices; - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - - -/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is -/// used behind the scenes to implement getelementpr constant exprs. -class GetElementPtrConstantExpr : public ConstantExpr { - GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, - const Type *DestTy); -public: - static GetElementPtrConstantExpr *Create(Constant *C, - const std::vector&IdxList, - const Type *DestTy) { - return - new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -// CompareConstantExpr - This class is private to Constants.cpp, and is used -// behind the scenes to implement ICmp and FCmp constant expressions. This is -// needed in order to store the predicate value for these instructions. -struct CompareConstantExpr : public ConstantExpr { - void *operator new(size_t, unsigned); // DO NOT IMPLEMENT - // allocate space for exactly two operands - void *operator new(size_t s) { - return User::operator new(s, 2); - } - unsigned short predicate; - CompareConstantExpr(const Type *ty, Instruction::OtherOps opc, - unsigned short pred, Constant* LHS, Constant* RHS) - : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) { - Op<0>() = LHS; - Op<1>() = RHS; - } - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); -}; - -template <> -struct OperandTraits : FixedNumOperandTraits<1> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<3> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<1> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) - -template <> -struct OperandTraits : VariadicOperandTraits<1> { -}; - -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) - - -template <> -struct OperandTraits : FixedNumOperandTraits<2> { -}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) - -struct ExprMapKeyType { - typedef SmallVector IndexList; - - ExprMapKeyType(unsigned opc, - const std::vector &ops, - unsigned short pred = 0, - const IndexList &inds = IndexList()) - : opcode(opc), predicate(pred), operands(ops), indices(inds) {} - uint16_t opcode; - uint16_t predicate; - std::vector operands; - IndexList indices; - bool operator==(const ExprMapKeyType& that) const { - return this->opcode == that.opcode && - this->predicate == that.predicate && - this->operands == that.operands && - this->indices == that.indices; - } - bool operator<(const ExprMapKeyType & that) const { - return this->opcode < that.opcode || - (this->opcode == that.opcode && this->predicate < that.predicate) || - (this->opcode == that.opcode && this->predicate == that.predicate && - this->operands < that.operands) || - (this->opcode == that.opcode && this->predicate == that.predicate && - this->operands == that.operands && this->indices < that.indices); - } - - bool operator!=(const ExprMapKeyType& that) const { - return !(*this == that); - } -}; - -// The number of operands for each ConstantCreator::create method is -// determined by the ConstantTraits template. -// ConstantCreator - A class that is used to create constants by -// ValueMap*. This class should be partially specialized if there is -// something strange that needs to be done to interface to the ctor for the -// constant. -// -template -struct ConstantTraits< std::vector > { - static unsigned uses(const std::vector& v) { - return v.size(); - } -}; - -template -struct ConstantCreator { - static ConstantClass *create(const TypeClass *Ty, const ValType &V) { - return new(ConstantTraits::uses(V)) ConstantClass(Ty, V); - } -}; - -template -struct ConvertConstantType { - static void convert(ConstantClass *OldC, const TypeClass *NewTy) { - llvm_unreachable("This type cannot be converted!"); - } -}; - -template<> -struct ConstantCreator { - static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V, - unsigned short pred = 0) { - if (Instruction::isCast(V.opcode)) - return new UnaryConstantExpr(V.opcode, V.operands[0], Ty); - if ((V.opcode >= Instruction::BinaryOpsBegin && - V.opcode < Instruction::BinaryOpsEnd)) - return new BinaryConstantExpr(V.opcode, V.operands[0], V.operands[1]); - if (V.opcode == Instruction::Select) - return new SelectConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::ExtractElement) - return new ExtractElementConstantExpr(V.operands[0], V.operands[1]); - if (V.opcode == Instruction::InsertElement) - return new InsertElementConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::ShuffleVector) - return new ShuffleVectorConstantExpr(V.operands[0], V.operands[1], - V.operands[2]); - if (V.opcode == Instruction::InsertValue) - return new InsertValueConstantExpr(V.operands[0], V.operands[1], - V.indices, Ty); - if (V.opcode == Instruction::ExtractValue) - return new ExtractValueConstantExpr(V.operands[0], V.indices, Ty); - if (V.opcode == Instruction::GetElementPtr) { - std::vector IdxList(V.operands.begin()+1, V.operands.end()); - return GetElementPtrConstantExpr::Create(V.operands[0], IdxList, Ty); - } - - // The compare instructions are weird. We have to encode the predicate - // value and it is combined with the instruction opcode by multiplying - // the opcode by one hundred. We must decode this to get the predicate. - if (V.opcode == Instruction::ICmp) - return new CompareConstantExpr(Ty, Instruction::ICmp, V.predicate, - V.operands[0], V.operands[1]); - if (V.opcode == Instruction::FCmp) - return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, - V.operands[0], V.operands[1]); - llvm_unreachable("Invalid ConstantExpr!"); - return 0; - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantExpr *OldC, const Type *NewTy) { - Constant *New; - switch (OldC->getOpcode()) { - case Instruction::Trunc: - case Instruction::ZExt: - case Instruction::SExt: - case Instruction::FPTrunc: - case Instruction::FPExt: - case Instruction::UIToFP: - case Instruction::SIToFP: - case Instruction::FPToUI: - case Instruction::FPToSI: - case Instruction::PtrToInt: - case Instruction::IntToPtr: - case Instruction::BitCast: - New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), - NewTy); - break; - case Instruction::Select: - New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), - OldC->getOperand(1), - OldC->getOperand(2)); - break; - default: - assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && - OldC->getOpcode() < Instruction::BinaryOpsEnd); - New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), - OldC->getOperand(1)); - break; - case Instruction::GetElementPtr: - // Make everyone now use a constant of the new type... - std::vector Idx(OldC->op_begin()+1, OldC->op_end()); - New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), - &Idx[0], Idx.size()); - break; - } - - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -// ConstantAggregateZero does not take extra "value" argument... -template -struct ConstantCreator { - static ConstantAggregateZero *create(const Type *Ty, const ValType &V){ - return new ConstantAggregateZero(Ty); - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantVector *OldC, const VectorType *NewTy) { - // Make everyone now use a constant of the new type... - std::vector C; - for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) - C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantVector::get(NewTy, C); - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantAggregateZero *OldC, const Type *NewTy) { - // Make everyone now use a constant of the new type... - Constant *New = ConstantAggregateZero::get(NewTy); - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantArray *OldC, const ArrayType *NewTy) { - // Make everyone now use a constant of the new type... - std::vector C; - for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) - C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantArray::get(NewTy, C); - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantStruct *OldC, const StructType *NewTy) { - // Make everyone now use a constant of the new type... - std::vector C; - for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) - C.push_back(cast(OldC->getOperand(i))); - Constant *New = ConstantStruct::get(NewTy, C); - assert(New != OldC && "Didn't replace constant??"); - - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -// ConstantPointerNull does not take extra "value" argument... -template -struct ConstantCreator { - static ConstantPointerNull *create(const PointerType *Ty, const ValType &V){ - return new ConstantPointerNull(Ty); - } -}; - -template<> -struct ConvertConstantType { - static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) { - // Make everyone now use a constant of the new type... - Constant *New = ConstantPointerNull::get(NewTy); - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -// UndefValue does not take extra "value" argument... -template -struct ConstantCreator { - static UndefValue *create(const Type *Ty, const ValType &V) { - return new UndefValue(Ty); - } -}; - -template<> -struct ConvertConstantType { - static void convert(UndefValue *OldC, const Type *NewTy) { - // Make everyone now use a constant of the new type. - Constant *New = UndefValue::get(NewTy); - assert(New != OldC && "Didn't replace constant??"); - OldC->uncheckedReplaceAllUsesWith(New); - OldC->destroyConstant(); // This constant is now dead, destroy it. - } -}; - -template -class ValueMap : public AbstractTypeUser { -public: - typedef std::pair MapKey; - typedef std::map MapTy; - typedef std::map InverseMapTy; - typedef std::map AbstractTypeMapTy; -private: - /// Map - This is the main map from the element descriptor to the Constants. - /// This is the primary way we avoid creating two of the same shape - /// constant. - MapTy Map; - - /// InverseMap - If "HasLargeKey" is true, this contains an inverse mapping - /// from the constants to their element in Map. This is important for - /// removal of constants from the array, which would otherwise have to scan - /// through the map with very large keys. - InverseMapTy InverseMap; - - /// AbstractTypeMap - Map for abstract type constants. - /// - AbstractTypeMapTy AbstractTypeMap; - - /// ValueMapLock - Mutex for this map. - sys::SmartMutex ValueMapLock; - -public: - // NOTE: This function is not locked. It is the caller's responsibility - // to enforce proper synchronization. - typename MapTy::iterator map_end() { return Map.end(); } - - /// InsertOrGetItem - Return an iterator for the specified element. - /// If the element exists in the map, the returned iterator points to the - /// entry and Exists=true. If not, the iterator points to the newly - /// inserted entry and returns Exists=false. Newly inserted entries have - /// I->second == 0, and should be filled in. - /// NOTE: This function is not locked. It is the caller's responsibility - // to enforce proper synchronization. - typename MapTy::iterator InsertOrGetItem(std::pair - &InsertVal, - bool &Exists) { - std::pair IP = Map.insert(InsertVal); - Exists = !IP.second; - return IP.first; - } - -private: - typename MapTy::iterator FindExistingElement(ConstantClass *CP) { - if (HasLargeKey) { - typename InverseMapTy::iterator IMI = InverseMap.find(CP); - assert(IMI != InverseMap.end() && IMI->second != Map.end() && - IMI->second->second == CP && - "InverseMap corrupt!"); - return IMI->second; - } - - typename MapTy::iterator I = - Map.find(MapKey(static_cast(CP->getRawType()), - getValType(CP))); - if (I == Map.end() || I->second != CP) { - // FIXME: This should not use a linear scan. If this gets to be a - // performance problem, someone should look at this. - for (I = Map.begin(); I != Map.end() && I->second != CP; ++I) - /* empty */; - } - return I; - } - - ConstantClass* Create(const TypeClass *Ty, const ValType &V, - typename MapTy::iterator I) { - ConstantClass* Result = - ConstantCreator::create(Ty, V); - - assert(Result->getType() == Ty && "Type specified is not correct!"); - I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); - - if (HasLargeKey) // Remember the reverse mapping if needed. - InverseMap.insert(std::make_pair(Result, I)); - - // If the type of the constant is abstract, make sure that an entry - // exists for it in the AbstractTypeMap. - if (Ty->isAbstract()) { - typename AbstractTypeMapTy::iterator TI = - AbstractTypeMap.find(Ty); - - if (TI == AbstractTypeMap.end()) { - // Add ourselves to the ATU list of the type. - cast(Ty)->addAbstractTypeUser(this); - - AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); - } - } - - return Result; - } -public: - - /// getOrCreate - Return the specified constant from the map, creating it if - /// necessary. - ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { - sys::SmartScopedLock Lock(ValueMapLock); - MapKey Lookup(Ty, V); - ConstantClass* Result = 0; - - typename MapTy::iterator I = Map.find(Lookup); - // Is it in the map? - if (I != Map.end()) - Result = static_cast(I->second); - - if (!Result) { - // If no preexisting value, create one now... - Result = Create(Ty, V, I); - } - - return Result; - } - - void remove(ConstantClass *CP) { - sys::SmartScopedLock Lock(ValueMapLock); - typename MapTy::iterator I = FindExistingElement(CP); - assert(I != Map.end() && "Constant not found in constant table!"); - assert(I->second == CP && "Didn't find correct element?"); - - if (HasLargeKey) // Remember the reverse mapping if needed. - InverseMap.erase(CP); - - // Now that we found the entry, make sure this isn't the entry that - // the AbstractTypeMap points to. - const TypeClass *Ty = static_cast(I->first.first); - if (Ty->isAbstract()) { - assert(AbstractTypeMap.count(Ty) && - "Abstract type not in AbstractTypeMap?"); - typename MapTy::iterator &ATMEntryIt = AbstractTypeMap[Ty]; - if (ATMEntryIt == I) { - // Yes, we are removing the representative entry for this type. - // See if there are any other entries of the same type. - typename MapTy::iterator TmpIt = ATMEntryIt; - - // First check the entry before this one... - if (TmpIt != Map.begin()) { - --TmpIt; - if (TmpIt->first.first != Ty) // Not the same type, move back... - ++TmpIt; - } - - // If we didn't find the same type, try to move forward... - if (TmpIt == ATMEntryIt) { - ++TmpIt; - if (TmpIt == Map.end() || TmpIt->first.first != Ty) - --TmpIt; // No entry afterwards with the same type - } - - // If there is another entry in the map of the same abstract type, - // update the AbstractTypeMap entry now. - if (TmpIt != ATMEntryIt) { - ATMEntryIt = TmpIt; - } else { - // Otherwise, we are removing the last instance of this type - // from the table. Remove from the ATM, and from user list. - cast(Ty)->removeAbstractTypeUser(this); - AbstractTypeMap.erase(Ty); - } - } - } - - Map.erase(I); - } - - - /// MoveConstantToNewSlot - If we are about to change C to be the element - /// specified by I, update our internal data structures to reflect this - /// fact. - /// NOTE: This function is not locked. It is the responsibility of the - /// caller to enforce proper synchronization if using this method. - void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) { - // First, remove the old location of the specified constant in the map. - typename MapTy::iterator OldI = FindExistingElement(C); - assert(OldI != Map.end() && "Constant not found in constant table!"); - assert(OldI->second == C && "Didn't find correct element?"); - - // If this constant is the representative element for its abstract type, - // update the AbstractTypeMap so that the representative element is I. - if (C->getType()->isAbstract()) { - typename AbstractTypeMapTy::iterator ATI = - AbstractTypeMap.find(C->getType()); - assert(ATI != AbstractTypeMap.end() && - "Abstract type not in AbstractTypeMap?"); - if (ATI->second == OldI) - ATI->second = I; - } - - // Remove the old entry from the map. - Map.erase(OldI); - - // Update the inverse map so that we know that this constant is now - // located at descriptor I. - if (HasLargeKey) { - assert(I->second == C && "Bad inversemap entry!"); - InverseMap[C] = I; - } - } - - void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { - sys::SmartScopedLock Lock(ValueMapLock); - typename AbstractTypeMapTy::iterator I = - AbstractTypeMap.find(cast(OldTy)); - - assert(I != AbstractTypeMap.end() && - "Abstract type not in AbstractTypeMap?"); - - // Convert a constant at a time until the last one is gone. The last one - // leaving will remove() itself, causing the AbstractTypeMapEntry to be - // eliminated eventually. - do { - ConvertConstantType::convert( - static_cast(I->second->second), - cast(NewTy)); - - I = AbstractTypeMap.find(cast(OldTy)); - } while (I != AbstractTypeMap.end()); - } - - // If the type became concrete without being refined to any other existing - // type, we just remove ourselves from the ATU list. - void typeBecameConcrete(const DerivedType *AbsTy) { - AbsTy->removeAbstractTypeUser(this); - } - - void dump() const { - DOUT << "Constant.cpp: ValueMap\n"; - } -}; - class ConstantInt; class ConstantFP; class MDString; class MDNode; -class LLVMContext; +struct LLVMContext; class Type; class Value; @@ -844,11 +93,11 @@ sys::SmartRWMutex ConstantsLock; typedef DenseMap IntMapTy; + DenseMapAPIntKeyInfo> IntMapTy; IntMapTy IntConstants; typedef DenseMap FPMapTy; + DenseMapAPFloatKeyInfo> FPMapTy; FPMapTy FPConstants; StringMap MDStringCache; @@ -875,14 +124,10 @@ ValueMap ExprConstants; - LLVMContext &Context; ConstantInt *TheTrueVal; ConstantInt *TheFalseVal; - LLVMContextImpl(LLVMContext &C); -private: - LLVMContextImpl(); - LLVMContextImpl(const LLVMContextImpl&); + LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { } }; } Modified: llvm/trunk/tools/bugpoint/BugDriver.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/BugDriver.h (original) +++ llvm/trunk/tools/bugpoint/BugDriver.h Tue Aug 4 17:41:48 2009 @@ -30,7 +30,7 @@ class BasicBlock; class AbstractInterpreter; class Instruction; -class LLVMContext; +struct LLVMContext; class DebugCrashes; Modified: llvm/trunk/tools/llvm-db/CLIDebugger.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-db/CLIDebugger.h?rev=78115&r1=78114&r2=78115&view=diff ============================================================================== --- llvm/trunk/tools/llvm-db/CLIDebugger.h (original) +++ llvm/trunk/tools/llvm-db/CLIDebugger.h Tue Aug 4 17:41:48 2009 @@ -24,7 +24,7 @@ struct SourceLanguage; class ProgramInfo; class RuntimeInfo; - class LLVMContext; + struct LLVMContext; /// CLIDebugger - This class implements the command line interface for the /// LLVM debugger. From evan.cheng at apple.com Tue Aug 4 17:23:23 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 22:23:23 -0000 Subject: [llvm-commits] [llvm] r78113 - /llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll Message-ID: <200908042223.n74MNap9022864@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 17:22:58 2009 New Revision: 78113 URL: http://llvm.org/viewvc/llvm-project?rev=78113&view=rev Log: Fix test. Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll?rev=78113&r1=78112&r2=78113&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll Tue Aug 4 17:22:58 2009 @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s @X = external global [0 x i32] ; <[0 x i32]*> [#uses=5] From sabre at nondot.org Tue Aug 4 16:13:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 21:13:16 -0000 Subject: [llvm-commits] [llvm] r78103 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200908042113.n74LDNAM020289@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 16:12:08 2009 New Revision: 78103 URL: http://llvm.org/viewvc/llvm-project?rev=78103&view=rev Log: remove a random reference to subtarget. Even without this, we still get "intel syntax" instructions from llc with -x86-asm-syntax=intel Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=78103&r1=78102&r2=78103&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Aug 4 16:12:08 2009 @@ -29,8 +29,6 @@ } const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const { - if (Subtarget.isFlavorIntel()) - return new X86WinTargetAsmInfo(*this); switch (Subtarget.TargetType) { default: llvm_unreachable("unknown subtarget type"); case X86Subtarget::isDarwin: From stoklund at 2pi.dk Tue Aug 4 16:29:33 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 21:29:33 -0000 Subject: [llvm-commits] [llvm] r78106 - /llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Message-ID: <200908042129.n74LTacY020906@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 16:29:11 2009 New Revision: 78106 URL: http://llvm.org/viewvc/llvm-project?rev=78106&view=rev Log: Don't give implicit machine operands special treatment in the register scavenger. Imp-def is *not* allowed to redefine a live register. Imp-use is *not* allowed to use a dead register. Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=78106&r1=78105&r2=78106&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Tue Aug 4 16:29:11 2009 @@ -226,7 +226,7 @@ const MachineOperand MO = *UseMOs[i].first; unsigned Reg = MO.getReg(); - assert((MO.isImplicit() || isUsed(Reg)) && "Using an undefined register!"); + assert(isUsed(Reg) && "Using an undefined register!"); if (MO.isKill() && !isReserved(Reg)) { KillRegs.set(Reg); @@ -276,10 +276,7 @@ if (RedefinesSuperRegPart(MI, MO, TRI)) continue; - // Implicit def is allowed to "re-define" any register. Similarly, - // implicitly defined registers can be clobbered. - assert((MO.isImplicit() || isReserved(Reg) || isUnused(Reg) || - isSuperRegUsed(Reg) || + assert((isReserved(Reg) || isUnused(Reg) || isSuperRegUsed(Reg) || isLiveInButUnusedBefore(Reg, MI, MBB, TRI, MRI)) && "Re-defining a live register!"); setUsed(Reg); From mrs at apple.com Tue Aug 4 16:27:34 2009 From: mrs at apple.com (Mike Stump) Date: Tue, 04 Aug 2009 21:27:34 -0000 Subject: [llvm-commits] [llvm] r78105 - in /llvm/trunk/lib/Target/Blackfin: AsmPrinter/CMakeLists.txt TargetInfo/CMakeLists.txt Message-ID: <200908042127.n74LRjfN020792@zion.cs.uiuc.edu> Author: mrs Date: Tue Aug 4 16:27:06 2009 New Revision: 78105 URL: http://llvm.org/viewvc/llvm-project?rev=78105&view=rev Log: Restlyize to match other targets, fixes cmake build to boot. Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt Modified: llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt?rev=78105&r1=78104&r2=78105&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Blackfin/AsmPrinter/CMakeLists.txt Tue Aug 4 16:27:06 2009 @@ -1,4 +1,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -add_llvm_library(LLVMBlackfinAsmPrinter BlackfinAsmPrinter.cpp) + +add_llvm_library(LLVMBlackfinAsmPrinter BlackfinAsmPrinter.cpp + ) add_dependencies(LLVMBlackfinAsmPrinter BlackfinCodeGenTable_gen) Modified: llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt?rev=78105&r1=78104&r2=78105&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Blackfin/TargetInfo/CMakeLists.txt Tue Aug 4 16:27:06 2009 @@ -1,4 +1,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -add_llvm_library(LLVMBlackfinInfo BlackfinTargetInfo.cpp) + +add_llvm_library(LLVMBlackfinInfo BlackfinTargetInfo.cpp + ) + add_dependencies(LLVMBlackfinInfo BlackfinCodeGenTable_gen) From bob.wilson at apple.com Tue Aug 4 16:39:48 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 21:39:48 -0000 Subject: [llvm-commits] [llvm] r78109 - in /llvm/trunk/lib/Target/ARM: ARMInstrNEON.td AsmPrinter/ARMAsmPrinter.cpp Message-ID: <200908042139.n74LdxHk021347@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 16:39:33 2009 New Revision: 78109 URL: http://llvm.org/viewvc/llvm-project?rev=78109&view=rev Log: Replace dregsingle operand modifier with explicit escaped curly brackets. For other VLDn and VSTn operations, we need to list the multiple registers explicitly anyway, so there's no point in special-casing this one usage. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78109&r1=78108&r2=78109&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Aug 4 16:39:33 2009 @@ -142,7 +142,7 @@ // VLD1 : Vector Load (multiple single elements) class VLD1D : NLdSt<(outs DPR:$dst), (ins addrmode6:$addr), - !strconcat(OpcodeStr, "\t${dst:dregsingle}, $addr"), + !strconcat(OpcodeStr, "\t\\{$dst\\}, $addr"), [(set DPR:$dst, (Ty (IntOp addrmode6:$addr)))]>; class VLD1Q : NLdSt<(outs QPR:$dst), (ins addrmode6:$addr), @@ -164,7 +164,7 @@ // VST1 : Vector Store (multiple single elements) class VST1D : NLdSt<(outs), (ins addrmode6:$addr, DPR:$src), - !strconcat(OpcodeStr, "\t${src:dregsingle}, $addr"), + !strconcat(OpcodeStr, "\t\\{$src\\}, $addr"), [(IntOp addrmode6:$addr, (Ty DPR:$src))]>; class VST1Q : NLdSt<(outs), (ins addrmode6:$addr, QPR:$src), Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78109&r1=78108&r2=78109&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Aug 4 16:39:33 2009 @@ -348,8 +348,6 @@ O << '{' << TRI->getAsmName(DRegLo) << ',' << TRI->getAsmName(DRegHi) << '}'; - } else if (Modifier && strcmp(Modifier, "dregsingle") == 0) { - O << '{' << TRI->getAsmName(Reg) << '}'; } else { O << TRI->getAsmName(Reg); } From stoklund at 2pi.dk Tue Aug 4 16:30:38 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Aug 2009 21:30:38 -0000 Subject: [llvm-commits] [llvm] r78107 - in /llvm/trunk: lib/CodeGen/RegisterScavenging.cpp test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll Message-ID: <200908042130.n74LUdpB020949@zion.cs.uiuc.edu> Author: stoklund Date: Tue Aug 4 16:30:30 2009 New Revision: 78107 URL: http://llvm.org/viewvc/llvm-project?rev=78107&view=rev Log: Clean up the handling of two-address operands in RegScavenger. This fixes PR4528. Added: llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=78107&r1=78106&r2=78107&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Tue Aug 4 16:30:30 2009 @@ -224,11 +224,13 @@ BitVector KillRegs(NumPhysRegs); for (unsigned i = 0, e = UseMOs.size(); i != e; ++i) { const MachineOperand MO = *UseMOs[i].first; + unsigned Idx = UseMOs[i].second; unsigned Reg = MO.getReg(); assert(isUsed(Reg) && "Using an undefined register!"); - if (MO.isKill() && !isReserved(Reg)) { + // Two-address operands implicitly kill. + if ((MO.isKill() || MI->isRegTiedToDefOperand(Idx)) && !isReserved(Reg)) { KillRegs.set(Reg); // Mark sub-registers as used. @@ -251,8 +253,6 @@ for (unsigned i = 0, e = NumECs + NumDefs; i != e; ++i) { const MachineOperand &MO = (i < NumECs) ? *EarlyClobberMOs[i].first : *DefMOs[i-NumECs].first; - unsigned Idx = (i < NumECs) - ? EarlyClobberMOs[i].second : DefMOs[i-NumECs].second; unsigned Reg = MO.getReg(); if (MO.isUndef()) continue; @@ -263,15 +263,6 @@ continue; } - // Skip two-address destination operand. - unsigned UseIdx; - if (MI->isRegTiedToUseOperand(Idx, &UseIdx) && - !MI->getOperand(UseIdx).isUndef()) { - assert(!MI->getOperand(UseIdx).isKill() && - "Using an undefined register!"); - continue; - } - // Skip if this is merely redefining part of a super-register. if (RedefinesSuperRegPart(MI, MO, TRI)) continue; Added: llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll?rev=78107&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-08-04-RegScavengerAssert-2.ll Tue Aug 4 16:30:30 2009 @@ -0,0 +1,33 @@ +; RUN: llvm-as < %s | llc -mtriple=armv6-elf +; PR4528 + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:64" +target triple = "armv6-elf" + +define arm_aapcscc i32 @file_read_actor(i32* nocapture %desc, i32* %page, i32 %offset, i32 %size) nounwind optsize { +entry: + br i1 undef, label %fault_in_pages_writeable.exit, label %bb5.i + +bb5.i: ; preds = %entry + %asmtmp.i = tail call i32 asm sideeffect "1:\09strbt\09$1,[$2]\0A2:\0A\09.section .fixup,\22ax\22\0A\09.align\092\0A3:\09mov\09$0, $3\0A\09b\092b\0A\09.previous\0A\09.section __ex_table,\22a\22\0A\09.align\093\0A\09.long\091b, 3b\0A\09.previous", "=r,r,r,i,0,~{cc}"(i8 0, i32 undef, i32 -14, i32 0) nounwind ; [#uses=1] + %0 = icmp eq i32 %asmtmp.i, 0 ; [#uses=1] + br i1 %0, label %bb6.i, label %fault_in_pages_writeable.exit + +bb6.i: ; preds = %bb5.i + br i1 undef, label %fault_in_pages_writeable.exit, label %bb7.i + +bb7.i: ; preds = %bb6.i + unreachable + +fault_in_pages_writeable.exit: ; preds = %bb6.i, %bb5.i, %entry + br i1 undef, label %bb2, label %bb3 + +bb2: ; preds = %fault_in_pages_writeable.exit + unreachable + +bb3: ; preds = %fault_in_pages_writeable.exit + %1 = tail call arm_aapcscc i32 @__copy_to_user(i8* undef, i8* undef, i32 undef) nounwind ; [#uses=0] + unreachable +} + +declare arm_aapcscc i32 @__copy_to_user(i8*, i8*, i32) From evan.cheng at apple.com Tue Aug 4 16:13:16 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 21:13:16 -0000 Subject: [llvm-commits] [llvm] r78104 - in /llvm/trunk: lib/Target/ARM/ARMLoadStoreOptimizer.cpp lib/Target/ARM/ARMTargetMachine.cpp lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp test/CodeGen/Thumb2/thumb2-ldm.ll Message-ID: <200908042113.n74LDSdA020296@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 16:12:13 2009 New Revision: 78104 URL: http://llvm.org/viewvc/llvm-project?rev=78104&view=rev Log: Enable load / store multiple pass for Thumb2. It's not using ldrd / strd yet. Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=78104&r1=78103&r2=78104&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Tue Aug 4 16:12:13 2009 @@ -615,12 +615,15 @@ return false; bool isDPR = NewOpc == ARM::FLDMD || NewOpc == ARM::FSTMD; - unsigned Offset = isAM5 - ? ARM_AM::getAM5Opc((AddSub == ARM_AM::sub) ? ARM_AM::db : ARM_AM::ia, - true, isDPR ? 2 : 1) - : (isAM2 - ? ARM_AM::getAM2Opc(AddSub, Bytes, ARM_AM::no_shift) - : Bytes); + unsigned Offset = 0; + if (isAM5) + Offset = ARM_AM::getAM5Opc((AddSub == ARM_AM::sub) + ? ARM_AM::db + : ARM_AM::ia, true, (isDPR ? 2 : 1)); + else if (isAM2) + Offset = ARM_AM::getAM2Opc(AddSub, Bytes, ARM_AM::no_shift); + else + Offset = AddSub == ARM_AM::sub ? -Bytes : Bytes; if (isLd) { if (isAM5) // FLDMS, FLDMD Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=78104&r1=78103&r2=78104&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Tue Aug 4 16:12:13 2009 @@ -101,8 +101,9 @@ bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - // FIXME: temporarily disabling load / store optimization pass for Thumb mode. - if (OptLevel != CodeGenOpt::None && !DisableLdStOpti && !Subtarget.isThumb()) + // FIXME: temporarily disabling load / store optimization pass for Thumb1 mode. + if (OptLevel != CodeGenOpt::None && !DisableLdStOpti && + !Subtarget.isThumb1Only()) PM.add(createARMLoadStoreOptimizationPass()); if (OptLevel != CodeGenOpt::None && Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78104&r1=78103&r2=78104&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Aug 4 16:12:13 2009 @@ -599,6 +599,7 @@ // FIXME bool isLDM = (MI->getOpcode() == ARM::LDM || MI->getOpcode() == ARM::LDM_RET || + MI->getOpcode() == ARM::t2LDM || MI->getOpcode() == ARM::t2LDM_RET); O << ARM_AM::getAMSubModeAltStr(Mode, isLDM); } else Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll?rev=78104&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ldm.ll Tue Aug 4 16:12:13 2009 @@ -0,0 +1,40 @@ +; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | FileCheck %s + + at X = external global [0 x i32] ; <[0 x i32]*> [#uses=5] + +define i32 @t1() { +; CHECK: t1: +; CHECK: stmfd sp!, {r7, lr} +; CHECK: ldmfd sp!, {r7, pc} + %tmp = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 0) ; [#uses=1] + %tmp3 = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 1) ; [#uses=1] + %tmp4 = tail call i32 @f1( i32 %tmp, i32 %tmp3 ) ; [#uses=1] + ret i32 %tmp4 +} + +define i32 @t2() { +; CHECK: t2: +; CHECK: stmfd sp!, {r7, lr} +; CHECK: ldmia +; CHECK: ldmfd sp!, {r7, pc} + %tmp = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 2) ; [#uses=1] + %tmp3 = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 3) ; [#uses=1] + %tmp5 = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 4) ; [#uses=1] + %tmp6 = tail call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 ) ; [#uses=1] + ret i32 %tmp6 +} + +define i32 @t3() { +; CHECK: t3: +; CHECK: stmfd sp!, {r7, lr} +; CHECK: ldmfd sp!, {r7, pc} + %tmp = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 1) ; [#uses=1] + %tmp3 = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 2) ; [#uses=1] + %tmp5 = load i32* getelementptr ([0 x i32]* @X, i32 0, i32 3) ; [#uses=1] + %tmp6 = tail call i32 @f2( i32 %tmp, i32 %tmp3, i32 %tmp5 ) ; [#uses=1] + ret i32 %tmp6 +} + +declare i32 @f1(i32, i32) + +declare i32 @f2(i32, i32, i32) From bob.wilson at apple.com Tue Aug 4 17:02:25 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 22:02:25 -0000 Subject: [llvm-commits] [llvm] r78111 - in /llvm/trunk/test/CodeGen/ARM: vabal.ll vabdl.ll vacge.ll Message-ID: <200908042202.n74M2Uw6022120@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 17:01:41 2009 New Revision: 78111 URL: http://llvm.org/viewvc/llvm-project?rev=78111&view=rev Log: Convert more Neon tests to use FileCheck. Modified: llvm/trunk/test/CodeGen/ARM/vabal.ll llvm/trunk/test/CodeGen/ARM/vabdl.ll llvm/trunk/test/CodeGen/ARM/vacge.ll Modified: llvm/trunk/test/CodeGen/ARM/vabal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vabal.ll?rev=78111&r1=78110&r2=78111&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vabal.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vabal.ll Tue Aug 4 17:01:41 2009 @@ -1,12 +1,8 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vabal\\.s8} %t | count 1 -; RUN: grep {vabal\\.s16} %t | count 1 -; RUN: grep {vabal\\.s32} %t | count 1 -; RUN: grep {vabal\\.u8} %t | count 1 -; RUN: grep {vabal\\.u16} %t | count 1 -; RUN: grep {vabal\\.u32} %t | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <8 x i16> @vabals8(<8 x i16>* %A, <8 x i8>* %B, <8 x i8>* %C) nounwind { +;CHECK: vabals8: +;CHECK: vabal.s8 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i8>* %B %tmp3 = load <8 x i8>* %C @@ -15,6 +11,8 @@ } define <4 x i32> @vabals16(<4 x i32>* %A, <4 x i16>* %B, <4 x i16>* %C) nounwind { +;CHECK: vabals16: +;CHECK: vabal.s16 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i16>* %B %tmp3 = load <4 x i16>* %C @@ -23,6 +21,8 @@ } define <2 x i64> @vabals32(<2 x i64>* %A, <2 x i32>* %B, <2 x i32>* %C) nounwind { +;CHECK: vabals32: +;CHECK: vabal.s32 %tmp1 = load <2 x i64>* %A %tmp2 = load <2 x i32>* %B %tmp3 = load <2 x i32>* %C @@ -31,6 +31,8 @@ } define <8 x i16> @vabalu8(<8 x i16>* %A, <8 x i8>* %B, <8 x i8>* %C) nounwind { +;CHECK: vabalu8: +;CHECK: vabal.u8 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i8>* %B %tmp3 = load <8 x i8>* %C @@ -39,6 +41,8 @@ } define <4 x i32> @vabalu16(<4 x i32>* %A, <4 x i16>* %B, <4 x i16>* %C) nounwind { +;CHECK: vabalu16: +;CHECK: vabal.u16 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i16>* %B %tmp3 = load <4 x i16>* %C @@ -47,6 +51,8 @@ } define <2 x i64> @vabalu32(<2 x i64>* %A, <2 x i32>* %B, <2 x i32>* %C) nounwind { +;CHECK: vabalu32: +;CHECK: vabal.u32 %tmp1 = load <2 x i64>* %A %tmp2 = load <2 x i32>* %B %tmp3 = load <2 x i32>* %C Modified: llvm/trunk/test/CodeGen/ARM/vabdl.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vabdl.ll?rev=78111&r1=78110&r2=78111&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vabdl.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vabdl.ll Tue Aug 4 17:01:41 2009 @@ -1,12 +1,8 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vabdl\\.s8} %t | count 1 -; RUN: grep {vabdl\\.s16} %t | count 1 -; RUN: grep {vabdl\\.s32} %t | count 1 -; RUN: grep {vabdl\\.u8} %t | count 1 -; RUN: grep {vabdl\\.u16} %t | count 1 -; RUN: grep {vabdl\\.u32} %t | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <8 x i16> @vabdls8(<8 x i8>* %A, <8 x i8>* %B) nounwind { +;CHECK: vabdls8: +;CHECK: vabdl.s8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = call <8 x i16> @llvm.arm.neon.vabdls.v8i16(<8 x i8> %tmp1, <8 x i8> %tmp2) @@ -14,6 +10,8 @@ } define <4 x i32> @vabdls16(<4 x i16>* %A, <4 x i16>* %B) nounwind { +;CHECK: vabdls16: +;CHECK: vabdl.s16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = call <4 x i32> @llvm.arm.neon.vabdls.v4i32(<4 x i16> %tmp1, <4 x i16> %tmp2) @@ -21,6 +19,8 @@ } define <2 x i64> @vabdls32(<2 x i32>* %A, <2 x i32>* %B) nounwind { +;CHECK: vabdls32: +;CHECK: vabdl.s32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = call <2 x i64> @llvm.arm.neon.vabdls.v2i64(<2 x i32> %tmp1, <2 x i32> %tmp2) @@ -28,6 +28,8 @@ } define <8 x i16> @vabdlu8(<8 x i8>* %A, <8 x i8>* %B) nounwind { +;CHECK: vabdlu8: +;CHECK: vabdl.u8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = call <8 x i16> @llvm.arm.neon.vabdlu.v8i16(<8 x i8> %tmp1, <8 x i8> %tmp2) @@ -35,6 +37,8 @@ } define <4 x i32> @vabdlu16(<4 x i16>* %A, <4 x i16>* %B) nounwind { +;CHECK: vabdlu16: +;CHECK: vabdl.u16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = call <4 x i32> @llvm.arm.neon.vabdlu.v4i32(<4 x i16> %tmp1, <4 x i16> %tmp2) @@ -42,6 +46,8 @@ } define <2 x i64> @vabdlu32(<2 x i32>* %A, <2 x i32>* %B) nounwind { +;CHECK: vabdlu32: +;CHECK: vabdl.u32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = call <2 x i64> @llvm.arm.neon.vabdlu.v2i64(<2 x i32> %tmp1, <2 x i32> %tmp2) Modified: llvm/trunk/test/CodeGen/ARM/vacge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vacge.ll?rev=78111&r1=78110&r2=78111&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vacge.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vacge.ll Tue Aug 4 17:01:41 2009 @@ -1,7 +1,8 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vacge\\.f32} %t | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <2 x i32> @vacgef32(<2 x float>* %A, <2 x float>* %B) nounwind { +;CHECK: vacgef32: +;CHECK: vacge.f32 %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B %tmp3 = call <2 x i32> @llvm.arm.neon.vacged(<2 x float> %tmp1, <2 x float> %tmp2) @@ -9,6 +10,8 @@ } define <4 x i32> @vacgeQf32(<4 x float>* %A, <4 x float>* %B) nounwind { +;CHECK: vacgeQf32: +;CHECK: vacge.f32 %tmp1 = load <4 x float>* %A %tmp2 = load <4 x float>* %B %tmp3 = call <4 x i32> @llvm.arm.neon.vacgeq(<4 x float> %tmp1, <4 x float> %tmp2) From bob.wilson at apple.com Tue Aug 4 16:34:34 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 21:34:34 -0000 Subject: [llvm-commits] [llvm] r78108 - in /llvm/trunk/test/CodeGen/ARM: vaba.ll vabd.ll vabs.ll Message-ID: <200908042134.n74LYuEx021119@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 16:33:22 2009 New Revision: 78108 URL: http://llvm.org/viewvc/llvm-project?rev=78108&view=rev Log: Convert a few Neon tests to use FileCheck. Modified: llvm/trunk/test/CodeGen/ARM/vaba.ll llvm/trunk/test/CodeGen/ARM/vabd.ll llvm/trunk/test/CodeGen/ARM/vabs.ll Modified: llvm/trunk/test/CodeGen/ARM/vaba.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vaba.ll?rev=78108&r1=78107&r2=78108&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vaba.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vaba.ll Tue Aug 4 16:33:22 2009 @@ -1,12 +1,8 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vaba\\.s8} %t | count 2 -; RUN: grep {vaba\\.s16} %t | count 2 -; RUN: grep {vaba\\.s32} %t | count 2 -; RUN: grep {vaba\\.u8} %t | count 2 -; RUN: grep {vaba\\.u16} %t | count 2 -; RUN: grep {vaba\\.u32} %t | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <8 x i8> @vabas8(<8 x i8>* %A, <8 x i8>* %B, <8 x i8>* %C) nounwind { +;CHECK: vabas8: +;CHECK: vaba.s8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = load <8 x i8>* %C @@ -15,6 +11,8 @@ } define <4 x i16> @vabas16(<4 x i16>* %A, <4 x i16>* %B, <4 x i16>* %C) nounwind { +;CHECK: vabas16: +;CHECK: vaba.s16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = load <4 x i16>* %C @@ -23,6 +21,8 @@ } define <2 x i32> @vabas32(<2 x i32>* %A, <2 x i32>* %B, <2 x i32>* %C) nounwind { +;CHECK: vabas32: +;CHECK: vaba.s32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = load <2 x i32>* %C @@ -31,6 +31,8 @@ } define <8 x i8> @vabau8(<8 x i8>* %A, <8 x i8>* %B, <8 x i8>* %C) nounwind { +;CHECK: vabau8: +;CHECK: vaba.u8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = load <8 x i8>* %C @@ -39,6 +41,8 @@ } define <4 x i16> @vabau16(<4 x i16>* %A, <4 x i16>* %B, <4 x i16>* %C) nounwind { +;CHECK: vabau16: +;CHECK: vaba.u16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = load <4 x i16>* %C @@ -47,6 +51,8 @@ } define <2 x i32> @vabau32(<2 x i32>* %A, <2 x i32>* %B, <2 x i32>* %C) nounwind { +;CHECK: vabau32: +;CHECK: vaba.u32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = load <2 x i32>* %C @@ -55,6 +61,8 @@ } define <16 x i8> @vabaQs8(<16 x i8>* %A, <16 x i8>* %B, <16 x i8>* %C) nounwind { +;CHECK: vabaQs8: +;CHECK: vaba.s8 %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = load <16 x i8>* %C @@ -63,6 +71,8 @@ } define <8 x i16> @vabaQs16(<8 x i16>* %A, <8 x i16>* %B, <8 x i16>* %C) nounwind { +;CHECK: vabaQs16: +;CHECK: vaba.s16 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = load <8 x i16>* %C @@ -71,6 +81,8 @@ } define <4 x i32> @vabaQs32(<4 x i32>* %A, <4 x i32>* %B, <4 x i32>* %C) nounwind { +;CHECK: vabaQs32: +;CHECK: vaba.s32 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = load <4 x i32>* %C @@ -79,6 +91,8 @@ } define <16 x i8> @vabaQu8(<16 x i8>* %A, <16 x i8>* %B, <16 x i8>* %C) nounwind { +;CHECK: vabaQu8: +;CHECK: vaba.u8 %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = load <16 x i8>* %C @@ -87,6 +101,8 @@ } define <8 x i16> @vabaQu16(<8 x i16>* %A, <8 x i16>* %B, <8 x i16>* %C) nounwind { +;CHECK: vabaQu16: +;CHECK: vaba.u16 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = load <8 x i16>* %C @@ -95,6 +111,8 @@ } define <4 x i32> @vabaQu32(<4 x i32>* %A, <4 x i32>* %B, <4 x i32>* %C) nounwind { +;CHECK: vabaQu32: +;CHECK: vaba.u32 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = load <4 x i32>* %C Modified: llvm/trunk/test/CodeGen/ARM/vabd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vabd.ll?rev=78108&r1=78107&r2=78108&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vabd.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vabd.ll Tue Aug 4 16:33:22 2009 @@ -1,13 +1,8 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vabd\\.s8} %t | count 2 -; RUN: grep {vabd\\.s16} %t | count 2 -; RUN: grep {vabd\\.s32} %t | count 2 -; RUN: grep {vabd\\.u8} %t | count 2 -; RUN: grep {vabd\\.u16} %t | count 2 -; RUN: grep {vabd\\.u32} %t | count 2 -; RUN: grep {vabd\\.f32} %t | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <8 x i8> @vabds8(<8 x i8>* %A, <8 x i8>* %B) nounwind { +;CHECK: vabds8: +;CHECK: vabd.s8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = call <8 x i8> @llvm.arm.neon.vabds.v8i8(<8 x i8> %tmp1, <8 x i8> %tmp2) @@ -15,6 +10,8 @@ } define <4 x i16> @vabds16(<4 x i16>* %A, <4 x i16>* %B) nounwind { +;CHECK: vabds16: +;CHECK: vabd.s16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = call <4 x i16> @llvm.arm.neon.vabds.v4i16(<4 x i16> %tmp1, <4 x i16> %tmp2) @@ -22,6 +19,8 @@ } define <2 x i32> @vabds32(<2 x i32>* %A, <2 x i32>* %B) nounwind { +;CHECK: vabds32: +;CHECK: vabd.s32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = call <2 x i32> @llvm.arm.neon.vabds.v2i32(<2 x i32> %tmp1, <2 x i32> %tmp2) @@ -29,6 +28,8 @@ } define <8 x i8> @vabdu8(<8 x i8>* %A, <8 x i8>* %B) nounwind { +;CHECK: vabdu8: +;CHECK: vabd.u8 %tmp1 = load <8 x i8>* %A %tmp2 = load <8 x i8>* %B %tmp3 = call <8 x i8> @llvm.arm.neon.vabdu.v8i8(<8 x i8> %tmp1, <8 x i8> %tmp2) @@ -36,6 +37,8 @@ } define <4 x i16> @vabdu16(<4 x i16>* %A, <4 x i16>* %B) nounwind { +;CHECK: vabdu16: +;CHECK: vabd.u16 %tmp1 = load <4 x i16>* %A %tmp2 = load <4 x i16>* %B %tmp3 = call <4 x i16> @llvm.arm.neon.vabdu.v4i16(<4 x i16> %tmp1, <4 x i16> %tmp2) @@ -43,6 +46,8 @@ } define <2 x i32> @vabdu32(<2 x i32>* %A, <2 x i32>* %B) nounwind { +;CHECK: vabdu32: +;CHECK: vabd.u32 %tmp1 = load <2 x i32>* %A %tmp2 = load <2 x i32>* %B %tmp3 = call <2 x i32> @llvm.arm.neon.vabdu.v2i32(<2 x i32> %tmp1, <2 x i32> %tmp2) @@ -50,6 +55,8 @@ } define <2 x float> @vabdf32(<2 x float>* %A, <2 x float>* %B) nounwind { +;CHECK: vabdf32: +;CHECK: vabd.f32 %tmp1 = load <2 x float>* %A %tmp2 = load <2 x float>* %B %tmp3 = call <2 x float> @llvm.arm.neon.vabdf.v2f32(<2 x float> %tmp1, <2 x float> %tmp2) @@ -57,6 +64,8 @@ } define <16 x i8> @vabdQs8(<16 x i8>* %A, <16 x i8>* %B) nounwind { +;CHECK: vabdQs8: +;CHECK: vabd.s8 %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = call <16 x i8> @llvm.arm.neon.vabds.v16i8(<16 x i8> %tmp1, <16 x i8> %tmp2) @@ -64,6 +73,8 @@ } define <8 x i16> @vabdQs16(<8 x i16>* %A, <8 x i16>* %B) nounwind { +;CHECK: vabdQs16: +;CHECK: vabd.s16 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = call <8 x i16> @llvm.arm.neon.vabds.v8i16(<8 x i16> %tmp1, <8 x i16> %tmp2) @@ -71,6 +82,8 @@ } define <4 x i32> @vabdQs32(<4 x i32>* %A, <4 x i32>* %B) nounwind { +;CHECK: vabdQs32: +;CHECK: vabd.s32 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = call <4 x i32> @llvm.arm.neon.vabds.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp2) @@ -78,6 +91,8 @@ } define <16 x i8> @vabdQu8(<16 x i8>* %A, <16 x i8>* %B) nounwind { +;CHECK: vabdQu8: +;CHECK: vabd.u8 %tmp1 = load <16 x i8>* %A %tmp2 = load <16 x i8>* %B %tmp3 = call <16 x i8> @llvm.arm.neon.vabdu.v16i8(<16 x i8> %tmp1, <16 x i8> %tmp2) @@ -85,6 +100,8 @@ } define <8 x i16> @vabdQu16(<8 x i16>* %A, <8 x i16>* %B) nounwind { +;CHECK: vabdQu16: +;CHECK: vabd.u16 %tmp1 = load <8 x i16>* %A %tmp2 = load <8 x i16>* %B %tmp3 = call <8 x i16> @llvm.arm.neon.vabdu.v8i16(<8 x i16> %tmp1, <8 x i16> %tmp2) @@ -92,6 +109,8 @@ } define <4 x i32> @vabdQu32(<4 x i32>* %A, <4 x i32>* %B) nounwind { +;CHECK: vabdQu32: +;CHECK: vabd.u32 %tmp1 = load <4 x i32>* %A %tmp2 = load <4 x i32>* %B %tmp3 = call <4 x i32> @llvm.arm.neon.vabdu.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp2) @@ -99,6 +118,8 @@ } define <4 x float> @vabdQf32(<4 x float>* %A, <4 x float>* %B) nounwind { +;CHECK: vabdQf32: +;CHECK: vabd.f32 %tmp1 = load <4 x float>* %A %tmp2 = load <4 x float>* %B %tmp3 = call <4 x float> @llvm.arm.neon.vabdf.v4f32(<4 x float> %tmp1, <4 x float> %tmp2) Modified: llvm/trunk/test/CodeGen/ARM/vabs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vabs.ll?rev=78108&r1=78107&r2=78108&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vabs.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vabs.ll Tue Aug 4 16:33:22 2009 @@ -1,52 +1,64 @@ -; RUN: llvm-as < %s | llc -march=arm -mattr=+neon > %t -; RUN: grep {vabs\\.s8} %t | count 2 -; RUN: grep {vabs\\.s16} %t | count 2 -; RUN: grep {vabs\\.s32} %t | count 2 -; RUN: grep {vabs\\.f32} %t | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon | FileCheck %s define <8 x i8> @vabss8(<8 x i8>* %A) nounwind { +;CHECK: vabss8: +;CHECK: vabs.s8 %tmp1 = load <8 x i8>* %A %tmp2 = call <8 x i8> @llvm.arm.neon.vabs.v8i8(<8 x i8> %tmp1) ret <8 x i8> %tmp2 } define <4 x i16> @vabss16(<4 x i16>* %A) nounwind { +;CHECK: vabss16: +;CHECK: vabs.s16 %tmp1 = load <4 x i16>* %A %tmp2 = call <4 x i16> @llvm.arm.neon.vabs.v4i16(<4 x i16> %tmp1) ret <4 x i16> %tmp2 } define <2 x i32> @vabss32(<2 x i32>* %A) nounwind { +;CHECK: vabss32: +;CHECK: vabs.s32 %tmp1 = load <2 x i32>* %A %tmp2 = call <2 x i32> @llvm.arm.neon.vabs.v2i32(<2 x i32> %tmp1) ret <2 x i32> %tmp2 } define <2 x float> @vabsf32(<2 x float>* %A) nounwind { +;CHECK: vabsf32: +;CHECK: vabs.f32 %tmp1 = load <2 x float>* %A %tmp2 = call <2 x float> @llvm.arm.neon.vabsf.v2f32(<2 x float> %tmp1) ret <2 x float> %tmp2 } define <16 x i8> @vabsQs8(<16 x i8>* %A) nounwind { +;CHECK: vabsQs8: +;CHECK: vabs.s8 %tmp1 = load <16 x i8>* %A %tmp2 = call <16 x i8> @llvm.arm.neon.vabs.v16i8(<16 x i8> %tmp1) ret <16 x i8> %tmp2 } define <8 x i16> @vabsQs16(<8 x i16>* %A) nounwind { +;CHECK: vabsQs16: +;CHECK: vabs.s16 %tmp1 = load <8 x i16>* %A %tmp2 = call <8 x i16> @llvm.arm.neon.vabs.v8i16(<8 x i16> %tmp1) ret <8 x i16> %tmp2 } define <4 x i32> @vabsQs32(<4 x i32>* %A) nounwind { +;CHECK: vabsQs32: +;CHECK: vabs.s32 %tmp1 = load <4 x i32>* %A %tmp2 = call <4 x i32> @llvm.arm.neon.vabs.v4i32(<4 x i32> %tmp1) ret <4 x i32> %tmp2 } define <4 x float> @vabsQf32(<4 x float>* %A) nounwind { +;CHECK: vabsQf32: +;CHECK: vabs.f32 %tmp1 = load <4 x float>* %A %tmp2 = call <4 x float> @llvm.arm.neon.vabsf.v4f32(<4 x float> %tmp1) ret <4 x float> %tmp2 From daniel at zuster.org Tue Aug 4 15:32:49 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 20:32:49 -0000 Subject: [llvm-commits] [llvm] r78098 - /llvm/trunk/lib/System/Unix/Program.inc Message-ID: <200908042033.n74KX6ph019002@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Aug 4 15:32:25 2009 New Revision: 78098 URL: http://llvm.org/viewvc/llvm-project?rev=78098&view=rev Log: When exec() fails, return 127 instead of errno; the parent process has no way to distinguish that the result is errno, so it can't use it to provide more information about the error (it also exposes the numeric value of errno). Modified: llvm/trunk/lib/System/Unix/Program.inc Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=78098&r1=78097&r2=78098&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Tue Aug 4 15:32:25 2009 @@ -197,12 +197,12 @@ // Execute! if (envp != 0) - execve (path.c_str(), (char**)args, (char**)envp); + execve(path.c_str(), (char**)args, (char**)envp); else - execv (path.c_str(), (char**)args); + execv(path.c_str(), (char**)args); // If the execve() failed, we should exit and let the parent pick up // our non-zero exit status. - exit (errno); + exit(127); } // Parent process: Break out of the switch to do our processing. From daniel at zuster.org Tue Aug 4 15:36:56 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Aug 2009 20:36:56 -0000 Subject: [llvm-commits] [llvm] r78099 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <200908042037.n74Kb02i019127@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Aug 4 15:36:45 2009 New Revision: 78099 URL: http://llvm.org/viewvc/llvm-project?rev=78099&view=rev Log: TableGen / AsmMatcher: Tweaks to avoid generating completely bogus match functions. - Fix variant flattening when the variant embeds an operand reference. - Ignore instructions which reference an operand multiple times (e.g., "xorb $dst, $dst"), and operands which have extra flags (e.g., "$dst:subreg32"). Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=78099&r1=78098&r2=78099&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Aug 4 15:36:45 2009 @@ -29,23 +29,40 @@ std::string Res = ""; for (;;) { - // Add the prefix until the next '{', and split out the contents in the - // braces. - std::pair Inner, Split = Cur.split('{'); - - Res += Split.first; - if (Split.second.empty()) + // Find the start of the next variant string. + size_t VariantsStart = 0; + for (size_t e = Cur.size(); VariantsStart != e; ++VariantsStart) + if (Cur[VariantsStart] == '{' && + (VariantsStart == 0 || Cur[VariantsStart-1] != '$')) + break; + + // Add the prefix to the result. + Res += Cur.slice(0, VariantsStart); + if (VariantsStart == Cur.size()) break; - Inner = Split.second.split('}'); + ++VariantsStart; // Skip the '{'. + + // Scan to the end of the variants string. + size_t VariantsEnd = VariantsStart; + unsigned NestedBraces = 1; + for (size_t e = Cur.size(); VariantsEnd != e; ++VariantsEnd) { + if (Cur[VariantsEnd] == '}') { + if (--NestedBraces == 0) + break; + } else if (Cur[VariantsEnd] == '{') + ++NestedBraces; + } // Select the Nth variant (or empty). - StringRef Selection = Inner.first; + StringRef Selection = Cur.slice(VariantsStart, VariantsEnd); for (unsigned i = 0; i != N; ++i) Selection = Selection.split('|').second; Res += Selection.split('|').first; - Cur = Inner.second; + assert(VariantsEnd != Cur.size() && + "Unterminated variants in assembly string!"); + Cur = Cur.substr(VariantsEnd + 1); } return Res; @@ -128,6 +145,12 @@ if (Form->getValue()->getAsString() == "Pseudo") continue; + // Ignore "PHI" node. + // + // FIXME: This is also a hack. + if (it->first == "PHI") + continue; + // Ignore instructions with no .s string. // // FIXME: What are these? @@ -138,12 +161,6 @@ if (StringRef(CGI.AsmString).startswith("lock")) continue; - // FIXME: Hack. -#if 0 - if (1 && it->first != "SUB8mr") - continue; -#endif - std::string Flattened = FlattenVariants(CGI.AsmString, 0); SmallVector Tokens; @@ -167,9 +184,50 @@ } }); - // FIXME: Ignore non-literal tokens. - if (std::find(Tokens[0].begin(), Tokens[0].end(), '$') != Tokens[0].end()) + // FIXME: Ignore prefixes with non-literal tokens. + if (std::find(Tokens[0].begin(), Tokens[0].end(), '$') != Tokens[0].end()) { + DEBUG({ + errs() << "warning: '" << it->first << "': " + << "ignoring non-literal token '" << Tokens[0] << "', \n"; + }); + continue; + } + + // Ignore instructions with subreg specifiers, these are always fake + // instructions for simplifying codegen. + // + // FIXME: Is this true? + // + // Also, we ignore instructions which reference the operand multiple times; + // this implies a constraint we would not currently honor. These are + // currently always fake instructions for simplifying codegen. + // + // FIXME: Encode this assumption in the .td, so we can error out here. + std::set OperandNames; + unsigned HasSubreg = 0, HasDuplicate = 0; + for (unsigned i = 1, e = Tokens.size(); i < e; ++i) { + if (Tokens[i][0] == '$' && + std::find(Tokens[i].begin(), + Tokens[i].end(), ':') != Tokens[i].end()) + HasSubreg = i; + if (Tokens[i][0] == '$' && !OperandNames.insert(Tokens[i]).second) + HasDuplicate = i; + } + if (HasSubreg) { + DEBUG({ + errs() << "warning: '" << it->first << "': " + << "ignoring instruction; operand with subreg attribute '" + << Tokens[HasSubreg] << "', \n"; + }); continue; + } else if (HasDuplicate) { + DEBUG({ + errs() << "warning: '" << it->first << "': " + << "ignoring instruction; tied operand '" + << Tokens[HasSubreg] << "', \n"; + }); + continue; + } std::string FnName = "Match_" + Target.getName() + "_Inst_" + it->first; MatchFns.push_back(FnName); From david_goodwin at apple.com Tue Aug 4 15:39:11 2009 From: david_goodwin at apple.com (David Goodwin) Date: Tue, 04 Aug 2009 20:39:11 -0000 Subject: [llvm-commits] [llvm] r78101 - in /llvm/trunk: lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/ARMInstrVFP.td test/CodeGen/ARM/fabss.ll test/CodeGen/ARM/fnegs.ll Message-ID: <200908042039.n74KdHpp019215@zion.cs.uiuc.edu> Author: david_goodwin Date: Tue Aug 4 15:39:05 2009 New Revision: 78101 URL: http://llvm.org/viewvc/llvm-project?rev=78101&view=rev Log: Add NEON single-precision FP support for fabs and fneg. Added: llvm/trunk/test/CodeGen/ARM/fabss.ll llvm/trunk/test/CodeGen/ARM/fnegs.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=78101&r1=78100&r2=78101&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Aug 4 15:39:05 2009 @@ -1071,6 +1071,14 @@ let Inst{7-4} = opcod3; } +// Single precision, unary if no NEON +// Same as ASuI except not available if NEON is enabled +class ASuIn opcod1, bits<4> opcod2, bits<4> opcod3, dag oops, dag iops, + string opc, string asm, list pattern> + : ASuI { + list Predicates = [HasVFP2,DontUseNEONForFP]; +} + // Single precision, binary class ASbI opcod, dag oops, dag iops, string opc, string asm, list pattern> Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78101&r1=78100&r2=78101&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Aug 4 15:39:05 2009 @@ -246,6 +246,12 @@ (ins QPR:$src), !strconcat(OpcodeStr, "\t$dst, $src"), "", [(set QPR:$dst, (ResTy (IntOp (OpTy QPR:$src))))]>; +// Basic 2-register operations, scalar single-precision +class N2VDInts + : NEONFPPat<(f32 (OpNode SPR:$a)), + (EXTRACT_SUBREG (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$a, arm_ssubreg_0)), + arm_ssubreg_0)>; + // Narrow 2-register intrinsics. class N2VNInt op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16, bits<5> op11_7, bit op6, bit op4, @@ -1338,6 +1344,7 @@ v2f32, v2f32, int_arm_neon_vabsf>; def VABSfq : N2VQInt<0b11, 0b11, 0b10, 0b01, 0b01110, 0, "vabs.f32", v4f32, v4f32, int_arm_neon_vabsf>; +def : N2VDInts; // VQABS : Vector Saturating Absolute Value defm VQABS : N2VInt_QHS<0b11, 0b11, 0b00, 0b01110, 0, "vqabs.s", @@ -1372,6 +1379,7 @@ def VNEGf32q : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 1, 0, (outs QPR:$dst), (ins QPR:$src), "vneg.f32\t$dst, $src", "", [(set QPR:$dst, (v4f32 (fneg QPR:$src)))]>; +def : N2VDInts; def : Pat<(v8i8 (vneg_conv DPR:$src)), (VNEGs8d DPR:$src)>; def : Pat<(v4i16 (vneg_conv DPR:$src)), (VNEGs16d DPR:$src)>; Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=78101&r1=78100&r2=78101&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Aug 4 15:39:05 2009 @@ -168,9 +168,9 @@ "fabsd", " $dst, $a", [(set DPR:$dst, (fabs DPR:$a))]>; -def FABSS : ASuI<0b11101011, 0b0000, 0b1100, (outs SPR:$dst), (ins SPR:$a), - "fabss", " $dst, $a", - [(set SPR:$dst, (fabs SPR:$a))]>; +def FABSS : ASuIn<0b11101011, 0b0000, 0b1100, (outs SPR:$dst), (ins SPR:$a), + "fabss", " $dst, $a", + [(set SPR:$dst, (fabs SPR:$a))]>; let Defs = [FPSCR] in { def FCMPEZD : ADuI<0b11101011, 0b0101, 0b1100, (outs), (ins DPR:$a), @@ -208,9 +208,9 @@ "fnegd", " $dst, $a", [(set DPR:$dst, (fneg DPR:$a))]>; -def FNEGS : ASuI<0b11101011, 0b0001, 0b0100, (outs SPR:$dst), (ins SPR:$a), - "fnegs", " $dst, $a", - [(set SPR:$dst, (fneg SPR:$a))]>; +def FNEGS : ASuIn<0b11101011, 0b0001, 0b0100, (outs SPR:$dst), (ins SPR:$a), + "fnegs", " $dst, $a", + [(set SPR:$dst, (fneg SPR:$a))]>; def FSQRTD : ADuI<0b11101011, 0b0001, 0b1100, (outs DPR:$dst), (ins DPR:$a), "fsqrtd", " $dst, $a", Added: llvm/trunk/test/CodeGen/ARM/fabss.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fabss.ll?rev=78101&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fabss.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fabss.ll Tue Aug 4 15:39:05 2009 @@ -0,0 +1,13 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fabss\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vabs.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 1 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fabss\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 1 + +define float @test(float %a, float %b) { +entry: + %dum = fadd float %a, %b + %0 = tail call float @fabsf(float %dum) + %dum1 = fadd float %0, %b + ret float %dum1 +} + +declare float @fabsf(float) Added: llvm/trunk/test/CodeGen/ARM/fnegs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnegs.ll?rev=78101&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnegs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fnegs.ll Tue Aug 4 15:39:05 2009 @@ -0,0 +1,23 @@ +; RUN: llvm-as < %s | llc -march=arm -mattr=+vfp2 | grep -E {fnegs\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,+neonfp | grep -E {vneg.f32\\W*d\[0-9\]+,\\W*d\[0-9\]+} | count 2 +; RUN: llvm-as < %s | llc -march=arm -mattr=+neon,-neonfp | grep -E {fnegs\\W*s\[0-9\]+,\\W*s\[0-9\]+} | count 2 + +define float @test1(float* %a) { +entry: + %0 = load float* %a, align 4 ; [#uses=2] + %1 = fsub float -0.000000e+00, %0 ; [#uses=2] + %2 = fpext float %1 to double ; [#uses=1] + %3 = fcmp olt double %2, 1.234000e+00 ; [#uses=1] + %retval = select i1 %3, float %1, float %0 ; [#uses=1] + ret float %retval +} + +define float @test2(float* %a) { +entry: + %0 = load float* %a, align 4 ; [#uses=2] + %1 = fmul float -1.000000e+00, %0 ; [#uses=2] + %2 = fpext float %1 to double ; [#uses=1] + %3 = fcmp olt double %2, 1.234000e+00 ; [#uses=1] + %retval = select i1 %3, float %1, float %0 ; [#uses=1] + ret float %retval +} From resistor at mac.com Tue Aug 4 17:55:52 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Aug 2009 22:55:52 -0000 Subject: [llvm-commits] [llvm] r78116 - /llvm/trunk/lib/VMCore/ConstantsContext.h Message-ID: <200908042255.n74Mtsje024274@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 17:55:26 2009 New Revision: 78116 URL: http://llvm.org/viewvc/llvm-project?rev=78116&view=rev Log: It helps if I remember to actually add the file... Added: llvm/trunk/lib/VMCore/ConstantsContext.h Added: llvm/trunk/lib/VMCore/ConstantsContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantsContext.h?rev=78116&view=auto ============================================================================== --- llvm/trunk/lib/VMCore/ConstantsContext.h (added) +++ llvm/trunk/lib/VMCore/ConstantsContext.h Tue Aug 4 17:55:26 2009 @@ -0,0 +1,774 @@ +//===---------------- ConstantsContext.h - Implementation ------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines various helper methods and classes used by +// LLVMContextImpl for creating and managing constants. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CONSTANTSCONTEXT_H +#define LLVM_CONSTANTSCONTEXT_H + +#include "llvm/Instructions.h" +#include "llvm/Operator.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/System/Mutex.h" +#include "llvm/System/RWMutex.h" +#include + +namespace llvm { +template +struct ConstantTraits; + +/// UnaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement unary constant exprs. +class UnaryConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 1); + } + UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) + : ConstantExpr(Ty, Opcode, &Op<0>(), 1) { + Op<0>() = C; + } + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// BinaryConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement binary constant exprs. +class BinaryConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) + : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) { + Op<0>() = C1; + Op<1>() = C2; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// SelectConstantExpr - This class is private to Constants.cpp, and is used +/// behind the scenes to implement select constant exprs. +class SelectConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ExtractElementConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// extractelement constant exprs. +class ExtractElementConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + ExtractElementConstantExpr(Constant *C1, Constant *C2) + : ConstantExpr(cast(C1->getType())->getElementType(), + Instruction::ExtractElement, &Op<0>(), 2) { + Op<0>() = C1; + Op<1>() = C2; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// InsertElementConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// insertelement constant exprs. +class InsertElementConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(C1->getType(), Instruction::InsertElement, + &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ShuffleVectorConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// shufflevector constant exprs. +class ShuffleVectorConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly three operands + void *operator new(size_t s) { + return User::operator new(s, 3); + } + ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3) + : ConstantExpr(VectorType::get( + cast(C1->getType())->getElementType(), + cast(C3->getType())->getNumElements()), + Instruction::ShuffleVector, + &Op<0>(), 3) { + Op<0>() = C1; + Op<1>() = C2; + Op<2>() = C3; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// ExtractValueConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// extractvalue constant exprs. +class ExtractValueConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 1); + } + ExtractValueConstantExpr(Constant *Agg, + const SmallVector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1), + Indices(IdxList) { + Op<0>() = Agg; + } + + /// Indices - These identify which value to extract. + const SmallVector Indices; + + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +/// InsertValueConstantExpr - This class is private to +/// Constants.cpp, and is used behind the scenes to implement +/// insertvalue constant exprs. +class InsertValueConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT +public: + // allocate space for exactly one operand + void *operator new(size_t s) { + return User::operator new(s, 2); + } + InsertValueConstantExpr(Constant *Agg, Constant *Val, + const SmallVector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2), + Indices(IdxList) { + Op<0>() = Agg; + Op<1>() = Val; + } + + /// Indices - These identify the position for the insertion. + const SmallVector Indices; + + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + + +/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is +/// used behind the scenes to implement getelementpr constant exprs. +class GetElementPtrConstantExpr : public ConstantExpr { + GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, + const Type *DestTy); +public: + static GetElementPtrConstantExpr *Create(Constant *C, + const std::vector&IdxList, + const Type *DestTy) { + return + new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy); + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +// CompareConstantExpr - This class is private to Constants.cpp, and is used +// behind the scenes to implement ICmp and FCmp constant expressions. This is +// needed in order to store the predicate value for these instructions. +struct CompareConstantExpr : public ConstantExpr { + void *operator new(size_t, unsigned); // DO NOT IMPLEMENT + // allocate space for exactly two operands + void *operator new(size_t s) { + return User::operator new(s, 2); + } + unsigned short predicate; + CompareConstantExpr(const Type *ty, Instruction::OtherOps opc, + unsigned short pred, Constant* LHS, Constant* RHS) + : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) { + Op<0>() = LHS; + Op<1>() = RHS; + } + /// Transparently provide more efficient getOperand methods. + DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); +}; + +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertElementConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<3> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ShuffleVectorConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<1> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ExtractValueConstantExpr, Value) + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InsertValueConstantExpr, Value) + +template <> +struct OperandTraits : VariadicOperandTraits<1> { +}; + +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value) + + +template <> +struct OperandTraits : FixedNumOperandTraits<2> { +}; +DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value) + +struct ExprMapKeyType { + typedef SmallVector IndexList; + + ExprMapKeyType(unsigned opc, + const std::vector &ops, + unsigned short pred = 0, + const IndexList &inds = IndexList()) + : opcode(opc), predicate(pred), operands(ops), indices(inds) {} + uint16_t opcode; + uint16_t predicate; + std::vector operands; + IndexList indices; + bool operator==(const ExprMapKeyType& that) const { + return this->opcode == that.opcode && + this->predicate == that.predicate && + this->operands == that.operands && + this->indices == that.indices; + } + bool operator<(const ExprMapKeyType & that) const { + return this->opcode < that.opcode || + (this->opcode == that.opcode && this->predicate < that.predicate) || + (this->opcode == that.opcode && this->predicate == that.predicate && + this->operands < that.operands) || + (this->opcode == that.opcode && this->predicate == that.predicate && + this->operands == that.operands && this->indices < that.indices); + } + + bool operator!=(const ExprMapKeyType& that) const { + return !(*this == that); + } +}; + +// The number of operands for each ConstantCreator::create method is +// determined by the ConstantTraits template. +// ConstantCreator - A class that is used to create constants by +// ValueMap*. This class should be partially specialized if there is +// something strange that needs to be done to interface to the ctor for the +// constant. +// +template +struct ConstantTraits< std::vector > { + static unsigned uses(const std::vector& v) { + return v.size(); + } +}; + +template +struct ConstantCreator { + static ConstantClass *create(const TypeClass *Ty, const ValType &V) { + return new(ConstantTraits::uses(V)) ConstantClass(Ty, V); + } +}; + +template +struct ConvertConstantType { + static void convert(ConstantClass *OldC, const TypeClass *NewTy) { + llvm_unreachable("This type cannot be converted!"); + } +}; + +template<> +struct ConstantCreator { + static ConstantExpr *create(const Type *Ty, const ExprMapKeyType &V, + unsigned short pred = 0) { + if (Instruction::isCast(V.opcode)) + return new UnaryConstantExpr(V.opcode, V.operands[0], Ty); + if ((V.opcode >= Instruction::BinaryOpsBegin && + V.opcode < Instruction::BinaryOpsEnd)) + return new BinaryConstantExpr(V.opcode, V.operands[0], V.operands[1]); + if (V.opcode == Instruction::Select) + return new SelectConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::ExtractElement) + return new ExtractElementConstantExpr(V.operands[0], V.operands[1]); + if (V.opcode == Instruction::InsertElement) + return new InsertElementConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::ShuffleVector) + return new ShuffleVectorConstantExpr(V.operands[0], V.operands[1], + V.operands[2]); + if (V.opcode == Instruction::InsertValue) + return new InsertValueConstantExpr(V.operands[0], V.operands[1], + V.indices, Ty); + if (V.opcode == Instruction::ExtractValue) + return new ExtractValueConstantExpr(V.operands[0], V.indices, Ty); + if (V.opcode == Instruction::GetElementPtr) { + std::vector IdxList(V.operands.begin()+1, V.operands.end()); + return GetElementPtrConstantExpr::Create(V.operands[0], IdxList, Ty); + } + + // The compare instructions are weird. We have to encode the predicate + // value and it is combined with the instruction opcode by multiplying + // the opcode by one hundred. We must decode this to get the predicate. + if (V.opcode == Instruction::ICmp) + return new CompareConstantExpr(Ty, Instruction::ICmp, V.predicate, + V.operands[0], V.operands[1]); + if (V.opcode == Instruction::FCmp) + return new CompareConstantExpr(Ty, Instruction::FCmp, V.predicate, + V.operands[0], V.operands[1]); + llvm_unreachable("Invalid ConstantExpr!"); + return 0; + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantExpr *OldC, const Type *NewTy) { + Constant *New; + switch (OldC->getOpcode()) { + case Instruction::Trunc: + case Instruction::ZExt: + case Instruction::SExt: + case Instruction::FPTrunc: + case Instruction::FPExt: + case Instruction::UIToFP: + case Instruction::SIToFP: + case Instruction::FPToUI: + case Instruction::FPToSI: + case Instruction::PtrToInt: + case Instruction::IntToPtr: + case Instruction::BitCast: + New = ConstantExpr::getCast(OldC->getOpcode(), OldC->getOperand(0), + NewTy); + break; + case Instruction::Select: + New = ConstantExpr::getSelectTy(NewTy, OldC->getOperand(0), + OldC->getOperand(1), + OldC->getOperand(2)); + break; + default: + assert(OldC->getOpcode() >= Instruction::BinaryOpsBegin && + OldC->getOpcode() < Instruction::BinaryOpsEnd); + New = ConstantExpr::getTy(NewTy, OldC->getOpcode(), OldC->getOperand(0), + OldC->getOperand(1)); + break; + case Instruction::GetElementPtr: + // Make everyone now use a constant of the new type... + std::vector Idx(OldC->op_begin()+1, OldC->op_end()); + New = ConstantExpr::getGetElementPtrTy(NewTy, OldC->getOperand(0), + &Idx[0], Idx.size()); + break; + } + + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +// ConstantAggregateZero does not take extra "value" argument... +template +struct ConstantCreator { + static ConstantAggregateZero *create(const Type *Ty, const ValType &V){ + return new ConstantAggregateZero(Ty); + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantVector *OldC, const VectorType *NewTy) { + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) + C.push_back(cast(OldC->getOperand(i))); + Constant *New = ConstantVector::get(NewTy, C); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantAggregateZero *OldC, const Type *NewTy) { + // Make everyone now use a constant of the new type... + Constant *New = ConstantAggregateZero::get(NewTy); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantArray *OldC, const ArrayType *NewTy) { + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) + C.push_back(cast(OldC->getOperand(i))); + Constant *New = ConstantArray::get(NewTy, C); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantStruct *OldC, const StructType *NewTy) { + // Make everyone now use a constant of the new type... + std::vector C; + for (unsigned i = 0, e = OldC->getNumOperands(); i != e; ++i) + C.push_back(cast(OldC->getOperand(i))); + Constant *New = ConstantStruct::get(NewTy, C); + assert(New != OldC && "Didn't replace constant??"); + + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +// ConstantPointerNull does not take extra "value" argument... +template +struct ConstantCreator { + static ConstantPointerNull *create(const PointerType *Ty, const ValType &V){ + return new ConstantPointerNull(Ty); + } +}; + +template<> +struct ConvertConstantType { + static void convert(ConstantPointerNull *OldC, const PointerType *NewTy) { + // Make everyone now use a constant of the new type... + Constant *New = ConstantPointerNull::get(NewTy); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +// UndefValue does not take extra "value" argument... +template +struct ConstantCreator { + static UndefValue *create(const Type *Ty, const ValType &V) { + return new UndefValue(Ty); + } +}; + +template<> +struct ConvertConstantType { + static void convert(UndefValue *OldC, const Type *NewTy) { + // Make everyone now use a constant of the new type. + Constant *New = UndefValue::get(NewTy); + assert(New != OldC && "Didn't replace constant??"); + OldC->uncheckedReplaceAllUsesWith(New); + OldC->destroyConstant(); // This constant is now dead, destroy it. + } +}; + +template +class ValueMap : public AbstractTypeUser { +public: + typedef std::pair MapKey; + typedef std::map MapTy; + typedef std::map InverseMapTy; + typedef std::map AbstractTypeMapTy; +private: + /// Map - This is the main map from the element descriptor to the Constants. + /// This is the primary way we avoid creating two of the same shape + /// constant. + MapTy Map; + + /// InverseMap - If "HasLargeKey" is true, this contains an inverse mapping + /// from the constants to their element in Map. This is important for + /// removal of constants from the array, which would otherwise have to scan + /// through the map with very large keys. + InverseMapTy InverseMap; + + /// AbstractTypeMap - Map for abstract type constants. + /// + AbstractTypeMapTy AbstractTypeMap; + + /// ValueMapLock - Mutex for this map. + sys::SmartMutex ValueMapLock; + +public: + // NOTE: This function is not locked. It is the caller's responsibility + // to enforce proper synchronization. + typename MapTy::iterator map_end() { return Map.end(); } + + /// InsertOrGetItem - Return an iterator for the specified element. + /// If the element exists in the map, the returned iterator points to the + /// entry and Exists=true. If not, the iterator points to the newly + /// inserted entry and returns Exists=false. Newly inserted entries have + /// I->second == 0, and should be filled in. + /// NOTE: This function is not locked. It is the caller's responsibility + // to enforce proper synchronization. + typename MapTy::iterator InsertOrGetItem(std::pair + &InsertVal, + bool &Exists) { + std::pair IP = Map.insert(InsertVal); + Exists = !IP.second; + return IP.first; + } + +private: + typename MapTy::iterator FindExistingElement(ConstantClass *CP) { + if (HasLargeKey) { + typename InverseMapTy::iterator IMI = InverseMap.find(CP); + assert(IMI != InverseMap.end() && IMI->second != Map.end() && + IMI->second->second == CP && + "InverseMap corrupt!"); + return IMI->second; + } + + typename MapTy::iterator I = + Map.find(MapKey(static_cast(CP->getRawType()), + getValType(CP))); + if (I == Map.end() || I->second != CP) { + // FIXME: This should not use a linear scan. If this gets to be a + // performance problem, someone should look at this. + for (I = Map.begin(); I != Map.end() && I->second != CP; ++I) + /* empty */; + } + return I; + } + + ConstantClass* Create(const TypeClass *Ty, const ValType &V, + typename MapTy::iterator I) { + ConstantClass* Result = + ConstantCreator::create(Ty, V); + + assert(Result->getType() == Ty && "Type specified is not correct!"); + I = Map.insert(I, std::make_pair(MapKey(Ty, V), Result)); + + if (HasLargeKey) // Remember the reverse mapping if needed. + InverseMap.insert(std::make_pair(Result, I)); + + // If the type of the constant is abstract, make sure that an entry + // exists for it in the AbstractTypeMap. + if (Ty->isAbstract()) { + typename AbstractTypeMapTy::iterator TI = + AbstractTypeMap.find(Ty); + + if (TI == AbstractTypeMap.end()) { + // Add ourselves to the ATU list of the type. + cast(Ty)->addAbstractTypeUser(this); + + AbstractTypeMap.insert(TI, std::make_pair(Ty, I)); + } + } + + return Result; + } +public: + + /// getOrCreate - Return the specified constant from the map, creating it if + /// necessary. + ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { + sys::SmartScopedLock Lock(ValueMapLock); + MapKey Lookup(Ty, V); + ConstantClass* Result = 0; + + typename MapTy::iterator I = Map.find(Lookup); + // Is it in the map? + if (I != Map.end()) + Result = static_cast(I->second); + + if (!Result) { + // If no preexisting value, create one now... + Result = Create(Ty, V, I); + } + + return Result; + } + + void remove(ConstantClass *CP) { + sys::SmartScopedLock Lock(ValueMapLock); + typename MapTy::iterator I = FindExistingElement(CP); + assert(I != Map.end() && "Constant not found in constant table!"); + assert(I->second == CP && "Didn't find correct element?"); + + if (HasLargeKey) // Remember the reverse mapping if needed. + InverseMap.erase(CP); + + // Now that we found the entry, make sure this isn't the entry that + // the AbstractTypeMap points to. + const TypeClass *Ty = static_cast(I->first.first); + if (Ty->isAbstract()) { + assert(AbstractTypeMap.count(Ty) && + "Abstract type not in AbstractTypeMap?"); + typename MapTy::iterator &ATMEntryIt = AbstractTypeMap[Ty]; + if (ATMEntryIt == I) { + // Yes, we are removing the representative entry for this type. + // See if there are any other entries of the same type. + typename MapTy::iterator TmpIt = ATMEntryIt; + + // First check the entry before this one... + if (TmpIt != Map.begin()) { + --TmpIt; + if (TmpIt->first.first != Ty) // Not the same type, move back... + ++TmpIt; + } + + // If we didn't find the same type, try to move forward... + if (TmpIt == ATMEntryIt) { + ++TmpIt; + if (TmpIt == Map.end() || TmpIt->first.first != Ty) + --TmpIt; // No entry afterwards with the same type + } + + // If there is another entry in the map of the same abstract type, + // update the AbstractTypeMap entry now. + if (TmpIt != ATMEntryIt) { + ATMEntryIt = TmpIt; + } else { + // Otherwise, we are removing the last instance of this type + // from the table. Remove from the ATM, and from user list. + cast(Ty)->removeAbstractTypeUser(this); + AbstractTypeMap.erase(Ty); + } + } + } + + Map.erase(I); + } + + + /// MoveConstantToNewSlot - If we are about to change C to be the element + /// specified by I, update our internal data structures to reflect this + /// fact. + /// NOTE: This function is not locked. It is the responsibility of the + /// caller to enforce proper synchronization if using this method. + void MoveConstantToNewSlot(ConstantClass *C, typename MapTy::iterator I) { + // First, remove the old location of the specified constant in the map. + typename MapTy::iterator OldI = FindExistingElement(C); + assert(OldI != Map.end() && "Constant not found in constant table!"); + assert(OldI->second == C && "Didn't find correct element?"); + + // If this constant is the representative element for its abstract type, + // update the AbstractTypeMap so that the representative element is I. + if (C->getType()->isAbstract()) { + typename AbstractTypeMapTy::iterator ATI = + AbstractTypeMap.find(C->getType()); + assert(ATI != AbstractTypeMap.end() && + "Abstract type not in AbstractTypeMap?"); + if (ATI->second == OldI) + ATI->second = I; + } + + // Remove the old entry from the map. + Map.erase(OldI); + + // Update the inverse map so that we know that this constant is now + // located at descriptor I. + if (HasLargeKey) { + assert(I->second == C && "Bad inversemap entry!"); + InverseMap[C] = I; + } + } + + void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) { + sys::SmartScopedLock Lock(ValueMapLock); + typename AbstractTypeMapTy::iterator I = + AbstractTypeMap.find(cast(OldTy)); + + assert(I != AbstractTypeMap.end() && + "Abstract type not in AbstractTypeMap?"); + + // Convert a constant at a time until the last one is gone. The last one + // leaving will remove() itself, causing the AbstractTypeMapEntry to be + // eliminated eventually. + do { + ConvertConstantType::convert( + static_cast(I->second->second), + cast(NewTy)); + + I = AbstractTypeMap.find(cast(OldTy)); + } while (I != AbstractTypeMap.end()); + } + + // If the type became concrete without being refined to any other existing + // type, we just remove ourselves from the ATU list. + void typeBecameConcrete(const DerivedType *AbsTy) { + AbsTy->removeAbstractTypeUser(this); + } + + void dump() const { + DOUT << "Constant.cpp: ValueMap\n"; + } +}; + +} + +#endif From stuart at apple.com Tue Aug 4 17:59:10 2009 From: stuart at apple.com (Stuart Hastings) Date: Tue, 04 Aug 2009 22:59:10 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78117 - /llvm-gcc-4.2/trunk/build_gcc Message-ID: <200908042259.n74MxDBU024393@zion.cs.uiuc.edu> Author: stuart Date: Tue Aug 4 17:58:56 2009 New Revision: 78117 URL: http://llvm.org/viewvc/llvm-project?rev=78117&view=rev Log: Revert r76083. Modified: llvm-gcc-4.2/trunk/build_gcc Modified: llvm-gcc-4.2/trunk/build_gcc URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/build_gcc?rev=78117&r1=78116&r2=78117&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/build_gcc (original) +++ llvm-gcc-4.2/trunk/build_gcc Tue Aug 4 17:58:56 2009 @@ -179,11 +179,8 @@ # APPLE LOCAL end ARM # LLVM LOCAL begin -# If we can find an LLVM-GCC, prefer it. -export CC=/Developer/usr/bin/llvm-gcc -if [ ! -x $CC ] ; then unset CC ; fi -export CXX=/Developer/usr/bin/llvm-g++ -if [ ! -x $CXX ] ; then unset CXX ; fi +# If the user has CC set in their environment unset it now +unset CC # LLVM LOCAL end ######################################## From benny.kra at googlemail.com Tue Aug 4 18:02:57 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 04 Aug 2009 23:02:57 -0000 Subject: [llvm-commits] [llvm] r78118 - /llvm/trunk/lib/VMCore/CMakeLists.txt Message-ID: <200908042302.n74N2whm024597@zion.cs.uiuc.edu> Author: d0k Date: Tue Aug 4 18:02:53 2009 New Revision: 78118 URL: http://llvm.org/viewvc/llvm-project?rev=78118&view=rev Log: Update CMakeLists. Modified: llvm/trunk/lib/VMCore/CMakeLists.txt Modified: llvm/trunk/lib/VMCore/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=78118&r1=78117&r2=78118&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/CMakeLists.txt (original) +++ llvm/trunk/lib/VMCore/CMakeLists.txt Tue Aug 4 18:02:53 2009 @@ -14,7 +14,6 @@ Instructions.cpp IntrinsicInst.cpp LLVMContext.cpp - LLVMContextImpl.cpp LeakDetector.cpp Mangler.cpp Metadata.cpp From sabre at nondot.org Tue Aug 4 18:07:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 04 Aug 2009 23:07:18 -0000 Subject: [llvm-commits] [llvm] r78119 - in /llvm/trunk: include/llvm/Value.h include/llvm/ValueSymbolTable.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Value.cpp Message-ID: <200908042307.n74N7Nav025051@zion.cs.uiuc.edu> Author: lattner Date: Tue Aug 4 18:07:12 2009 New Revision: 78119 URL: http://llvm.org/viewvc/llvm-project?rev=78119&view=rev Log: revert r78048, it isn't worth using assertingvh here. Modified: llvm/trunk/include/llvm/Value.h llvm/trunk/include/llvm/ValueSymbolTable.h llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/VMCore/Value.cpp Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=78119&r1=78118&r2=78119&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Tue Aug 4 18:07:12 2009 @@ -38,7 +38,7 @@ template class StringMapEntry; template class AssertingVH; -typedef StringMapEntry > ValueName; +typedef StringMapEntry ValueName; class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; Modified: llvm/trunk/include/llvm/ValueSymbolTable.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ValueSymbolTable.h?rev=78119&r1=78118&r2=78119&view=diff ============================================================================== --- llvm/trunk/include/llvm/ValueSymbolTable.h (original) +++ llvm/trunk/include/llvm/ValueSymbolTable.h Tue Aug 4 18:07:12 2009 @@ -17,7 +17,6 @@ #include "llvm/Value.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/ValueHandle.h" namespace llvm { template @@ -45,7 +44,7 @@ /// @{ public: /// @brief A mapping of names to values. - typedef StringMap > ValueMap; + typedef StringMap ValueMap; /// @brief An iterator over a ValueMap. typedef ValueMap::iterator iterator; Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=78119&r1=78118&r2=78119&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original) +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Aug 4 18:07:12 2009 @@ -1088,7 +1088,7 @@ // VST_ENTRY: [valueid, namechar x N] // VST_BBENTRY: [bbid, namechar x N] unsigned Code; - if (isa(*SI->getValue())) { + if (isa(SI->getValue())) { Code = bitc::VST_CODE_BBENTRY; if (isChar6) AbbrevToUse = VST_BBENTRY_6_ABBREV; Modified: llvm/trunk/lib/VMCore/Value.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=78119&r1=78118&r2=78119&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Value.cpp (original) +++ llvm/trunk/lib/VMCore/Value.cpp Tue Aug 4 18:07:12 2009 @@ -57,14 +57,6 @@ } Value::~Value() { - // If this value is named, destroy the name. This should not be in a symtab - // at this point. - if (Name) - Name->Destroy(); - - // There should be no uses of this object anymore, remove it. - LeakDetector::removeGarbageObject(this); - // Notify all ValueHandles (if present) that this value is going away. if (HasValueHandle) ValueHandleBase::ValueIsDeleted(this); @@ -84,6 +76,14 @@ } #endif assert(use_empty() && "Uses remain when a value is destroyed!"); + + // If this value is named, destroy the name. This should not be in a symtab + // at this point. + if (Name) + Name->Destroy(); + + // There should be no uses of this object anymore, remove it. + LeakDetector::removeGarbageObject(this); } /// hasNUses - Return true if this Value has exactly N users. From clattner at apple.com Tue Aug 4 18:10:15 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 4 Aug 2009 16:10:15 -0700 Subject: [llvm-commits] [llvm] r78048 - in /llvm/trunk: include/llvm/Value.h include/llvm/ValueSymbolTable.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Value.cpp In-Reply-To: <93C933D6-2A1E-43B3-A26F-7B5A2395F286@apple.com> References: <200908040431.n744V3h9008282@zion.cs.uiuc.edu> <93C933D6-2A1E-43B3-A26F-7B5A2395F286@apple.com> Message-ID: <13D9A47B-4039-45A1-AFB4-342D14734F32@apple.com> On Aug 4, 2009, at 3:29 PM, Dan Gohman wrote: > On Aug 3, 2009, at 9:31 PM, Chris Lattner wrote: >> Author: lattner >> Date: Mon Aug 3 23:31:02 2009 >> New Revision: 78048 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=78048&view=rev >> Log: >> switch ValueMap to using AssertingVH. This is an old patch I had >> laying >> around in a tree I forgot about. > > Hi Chris, > > This has the property of causing LLVM's public ABI to be non-trivially > sensitive to NDEBUG. If clients aren't built with NDEBUG set to what > it's set to in the LLVM build they're linking with, the results are > very bad and very hard to diagnose. I think this is too heavy a > burden to put on clients. I'm not really very sympathetic to that... there are so many ways that people will already get burned if they do that, it isn't funny. Also, the build system splits out assert and non-assert builds, so it is unlikely to happen. However, I don't really have a strong opinion and don't think it adds much value, so I reverted it. -Chris From gohman at apple.com Tue Aug 4 18:16:08 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 04 Aug 2009 23:16:08 -0000 Subject: [llvm-commits] [llvm] r78120 - /llvm/trunk/lib/System/Unix/Program.inc Message-ID: <200908042316.n74NGBGa025329@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 18:15:49 2009 New Revision: 78120 URL: http://llvm.org/viewvc/llvm-project?rev=78120&view=rev Log: Follow Unix behavior and return 127 if the command is not found, and 126 if it is not executable. Modified: llvm/trunk/lib/System/Unix/Program.inc Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=78120&r1=78119&r2=78120&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Tue Aug 4 18:15:49 2009 @@ -202,7 +202,7 @@ execv(path.c_str(), (char**)args); // If the execve() failed, we should exit and let the parent pick up // our non-zero exit status. - exit(127); + exit(errno == ENOENT ? 127 : 126); } // Parent process: Break out of the switch to do our processing. From gohman at apple.com Tue Aug 4 18:24:02 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 04 Aug 2009 23:24:02 -0000 Subject: [llvm-commits] [llvm] r78121 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <200908042324.n74NO8MT025580@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 18:23:56 2009 New Revision: 78121 URL: http://llvm.org/viewvc/llvm-project?rev=78121&view=rev Log: Check for !isa instead of isa. This matches what the comment says, and it avoids spurious BitCast instructions for Argument values. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=78121&r1=78120&r2=78121&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Aug 4 18:23:56 2009 @@ -1637,7 +1637,7 @@ // do this by forcing a BitCast (noop cast) to be inserted into the // preheader in this case. if (!fitsInAddressMode(Base, getAccessType(Inst), TLI, false) && - !isa(BaseV)) { + isa(BaseV)) { // We want this constant emitted into the preheader! This is just // using cast as a copy so BitCast (no-op cast) is appropriate BaseV = new BitCastInst(BaseV, BaseV->getType(), "preheaderinsert", From resistor at mac.com Tue Aug 4 18:33:07 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Aug 2009 23:33:07 -0000 Subject: [llvm-commits] [llvm] r78122 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp TypesContext.h Message-ID: <200908042333.n74NXDIW025877@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 18:33:01 2009 New Revision: 78122 URL: http://llvm.org/viewvc/llvm-project?rev=78122&view=rev Log: Begin the process of privatizing the type uniquing tables. No API changes yet, but there will be in the near future. Added: llvm/trunk/lib/VMCore/TypesContext.h Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78122&r1=78121&r2=78122&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug 4 18:33:01 2009 @@ -16,6 +16,7 @@ #define LLVM_LLVMCONTEXT_IMPL_H #include "ConstantsContext.h" +#include "TypesContext.h" #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" @@ -127,6 +128,8 @@ ConstantInt *TheTrueVal; ConstantInt *TheFalseVal; + TypeMap ArrayTypes; + LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { } }; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=78122&r1=78121&r2=78122&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Aug 4 18:33:01 2009 @@ -11,9 +11,12 @@ // //===----------------------------------------------------------------------===// +#include "LLVMContextImpl.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" +#include "llvm/LLVMContext.h" +#include "llvm/Metadata.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SCCIterator.h" @@ -696,295 +699,10 @@ return false; } -/// getSubElementHash - Generate a hash value for all of the SubType's of this -/// type. The hash value is guaranteed to be zero if any of the subtypes are -/// an opaque type. Otherwise we try to mix them in as well as possible, but do -/// not look at the subtype's subtype's. -static unsigned getSubElementHash(const Type *Ty) { - unsigned HashVal = 0; - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) { - HashVal *= 32; - const Type *SubTy = I->get(); - HashVal += SubTy->getTypeID(); - switch (SubTy->getTypeID()) { - default: break; - case Type::OpaqueTyID: return 0; // Opaque -> hash = 0 no matter what. - case Type::IntegerTyID: - HashVal ^= (cast(SubTy)->getBitWidth() << 3); - break; - case Type::FunctionTyID: - HashVal ^= cast(SubTy)->getNumParams()*2 + - cast(SubTy)->isVarArg(); - break; - case Type::ArrayTyID: - HashVal ^= cast(SubTy)->getNumElements(); - break; - case Type::VectorTyID: - HashVal ^= cast(SubTy)->getNumElements(); - break; - case Type::StructTyID: - HashVal ^= cast(SubTy)->getNumElements(); - break; - case Type::PointerTyID: - HashVal ^= cast(SubTy)->getAddressSpace(); - break; - } - } - return HashVal ? HashVal : 1; // Do not return zero unless opaque subty. -} - -//===----------------------------------------------------------------------===// -// Derived Type Factory Functions -//===----------------------------------------------------------------------===// - -namespace llvm { -class TypeMapBase { -protected: - /// TypesByHash - Keep track of types by their structure hash value. Note - /// that we only keep track of types that have cycles through themselves in - /// this map. - /// - std::multimap TypesByHash; - -public: - ~TypeMapBase() { - // PATypeHolder won't destroy non-abstract types. - // We can't destroy them by simply iterating, because - // they may contain references to each-other. -#if 0 - for (std::multimap::iterator I - = TypesByHash.begin(), E = TypesByHash.end(); I != E; ++I) { - Type *Ty = const_cast(I->second.Ty); - I->second.destroy(); - // We can't invoke destroy or delete, because the type may - // contain references to already freed types. - // So we have to destruct the object the ugly way. - if (Ty) { - Ty->AbstractTypeUsers.clear(); - static_cast(Ty)->Type::~Type(); - operator delete(Ty); - } - } -#endif - } - - void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { - std::multimap::iterator I = - TypesByHash.lower_bound(Hash); - for (; I != TypesByHash.end() && I->first == Hash; ++I) { - if (I->second == Ty) { - TypesByHash.erase(I); - return; - } - } - - // This must be do to an opaque type that was resolved. Switch down to hash - // code of zero. - assert(Hash && "Didn't find type entry!"); - RemoveFromTypesByHash(0, Ty); - } - - /// TypeBecameConcrete - When Ty gets a notification that TheType just became - /// concrete, drop uses and make Ty non-abstract if we should. - void TypeBecameConcrete(DerivedType *Ty, const DerivedType *TheType) { - // If the element just became concrete, remove 'ty' from the abstract - // type user list for the type. Do this for as many times as Ty uses - // OldType. - for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); - I != E; ++I) - if (I->get() == TheType) - TheType->removeAbstractTypeUser(Ty); - - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! Note that this - // may send out notifications to AbstractTypeUsers that types become - // concrete. - if (Ty->isAbstract()) - Ty->PromoteAbstractToConcrete(); - } -}; -} - - -// TypeMap - Make sure that only one instance of a particular type may be -// created on any given run of the compiler... note that this involves updating -// our map if an abstract type gets refined somehow. -// -namespace llvm { -template -class TypeMap : public TypeMapBase { - std::map Map; -public: - typedef typename std::map::iterator iterator; - ~TypeMap() { print("ON EXIT"); } - - inline TypeClass *get(const ValType &V) { - iterator I = Map.find(V); - return I != Map.end() ? cast((Type*)I->second.get()) : 0; - } - - inline void add(const ValType &V, TypeClass *Ty) { - Map.insert(std::make_pair(V, Ty)); - - // If this type has a cycle, remember it. - TypesByHash.insert(std::make_pair(ValType::hashTypeStructure(Ty), Ty)); - print("add"); - } - - /// RefineAbstractType - This method is called after we have merged a type - /// with another one. We must now either merge the type away with - /// some other type or reinstall it in the map with it's new configuration. - void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType, - const Type *NewType) { -#ifdef DEBUG_MERGE_TYPES - DOUT << "RefineAbstractType(" << (void*)OldType << "[" << *OldType - << "], " << (void*)NewType << " [" << *NewType << "])\n"; -#endif - - // Otherwise, we are changing one subelement type into another. Clearly the - // OldType must have been abstract, making us abstract. - assert(Ty->isAbstract() && "Refining a non-abstract type!"); - assert(OldType != NewType); - - // Make a temporary type holder for the type so that it doesn't disappear on - // us when we erase the entry from the map. - PATypeHolder TyHolder = Ty; - - // The old record is now out-of-date, because one of the children has been - // updated. Remove the obsolete entry from the map. - unsigned NumErased = Map.erase(ValType::get(Ty)); - assert(NumErased && "Element not found!"); NumErased = NumErased; - - // Remember the structural hash for the type before we start hacking on it, - // in case we need it later. - unsigned OldTypeHash = ValType::hashTypeStructure(Ty); - - // Find the type element we are refining... and change it now! - for (unsigned i = 0, e = Ty->getNumContainedTypes(); i != e; ++i) - if (Ty->ContainedTys[i] == OldType) - Ty->ContainedTys[i] = NewType; - unsigned NewTypeHash = ValType::hashTypeStructure(Ty); - - // If there are no cycles going through this node, we can do a simple, - // efficient lookup in the map, instead of an inefficient nasty linear - // lookup. - if (!TypeHasCycleThroughItself(Ty)) { - typename std::map::iterator I; - bool Inserted; - - tie(I, Inserted) = Map.insert(std::make_pair(ValType::get(Ty), Ty)); - if (!Inserted) { - // Refined to a different type altogether? - RemoveFromTypesByHash(OldTypeHash, Ty); - - // We already have this type in the table. Get rid of the newly refined - // type. - TypeClass *NewTy = cast((Type*)I->second.get()); - Ty->unlockedRefineAbstractTypeTo(NewTy); - return; - } - } else { - // Now we check to see if there is an existing entry in the table which is - // structurally identical to the newly refined type. If so, this type - // gets refined to the pre-existing type. - // - std::multimap::iterator I, E, Entry; - tie(I, E) = TypesByHash.equal_range(NewTypeHash); - Entry = E; - for (; I != E; ++I) { - if (I->second == Ty) { - // Remember the position of the old type if we see it in our scan. - Entry = I; - } else { - if (TypesEqual(Ty, I->second)) { - TypeClass *NewTy = cast((Type*)I->second.get()); - - // Remove the old entry form TypesByHash. If the hash values differ - // now, remove it from the old place. Otherwise, continue scanning - // withing this hashcode to reduce work. - if (NewTypeHash != OldTypeHash) { - RemoveFromTypesByHash(OldTypeHash, Ty); - } else { - if (Entry == E) { - // Find the location of Ty in the TypesByHash structure if we - // haven't seen it already. - while (I->second != Ty) { - ++I; - assert(I != E && "Structure doesn't contain type??"); - } - Entry = I; - } - TypesByHash.erase(Entry); - } - Ty->unlockedRefineAbstractTypeTo(NewTy); - return; - } - } - } - - // If there is no existing type of the same structure, we reinsert an - // updated record into the map. - Map.insert(std::make_pair(ValType::get(Ty), Ty)); - } - - // If the hash codes differ, update TypesByHash - if (NewTypeHash != OldTypeHash) { - RemoveFromTypesByHash(OldTypeHash, Ty); - TypesByHash.insert(std::make_pair(NewTypeHash, Ty)); - } - - // If the type is currently thought to be abstract, rescan all of our - // subtypes to see if the type has just become concrete! Note that this - // may send out notifications to AbstractTypeUsers that types become - // concrete. - if (Ty->isAbstract()) - Ty->PromoteAbstractToConcrete(); - } - - void print(const char *Arg) const { -#ifdef DEBUG_MERGE_TYPES - DOUT << "TypeMap<>::" << Arg << " table contents:\n"; - unsigned i = 0; - for (typename std::map::const_iterator I - = Map.begin(), E = Map.end(); I != E; ++I) - DOUT << " " << (++i) << ". " << (void*)I->second.get() << " " - << *I->second.get() << "\n"; -#endif - } - - void dump() const { print("dump output"); } -}; -} - - //===----------------------------------------------------------------------===// // Function Type Factory and Value Class... // -//===----------------------------------------------------------------------===// -// Integer Type Factory... -// -namespace llvm { -class IntegerValType { - uint32_t bits; -public: - IntegerValType(uint16_t numbits) : bits(numbits) {} - - static IntegerValType get(const IntegerType *Ty) { - return IntegerValType(Ty->getBitWidth()); - } - - static unsigned hashTypeStructure(const IntegerType *Ty) { - return (unsigned)Ty->getBitWidth(); - } - - inline bool operator<(const IntegerValType &IVT) const { - return bits < IVT.bits; - } -}; -} - static ManagedStatic > IntegerTypes; const IntegerType *IntegerType::get(unsigned NumBits) { @@ -1030,36 +748,6 @@ return APInt::getAllOnesValue(getBitWidth()); } -// FunctionValType - Define a class to hold the key that goes into the TypeMap -// -namespace llvm { -class FunctionValType { - const Type *RetTy; - std::vector ArgTypes; - bool isVarArg; -public: - FunctionValType(const Type *ret, const std::vector &args, - bool isVA) : RetTy(ret), ArgTypes(args), isVarArg(isVA) {} - - static FunctionValType get(const FunctionType *FT); - - static unsigned hashTypeStructure(const FunctionType *FT) { - unsigned Result = FT->getNumParams()*2 + FT->isVarArg(); - return Result; - } - - inline bool operator<(const FunctionValType &MTV) const { - if (RetTy < MTV.RetTy) return true; - if (RetTy > MTV.RetTy) return false; - if (isVarArg < MTV.isVarArg) return true; - if (isVarArg > MTV.isVarArg) return false; - if (ArgTypes < MTV.ArgTypes) return true; - if (ArgTypes > MTV.ArgTypes) return false; - return false; - } -}; -} - // Define the actual map itself now... static ManagedStatic > FunctionTypes; @@ -1096,46 +784,21 @@ return FT; } -//===----------------------------------------------------------------------===// -// Array Type Factory... -// -namespace llvm { -class ArrayValType { - const Type *ValTy; - uint64_t Size; -public: - ArrayValType(const Type *val, uint64_t sz) : ValTy(val), Size(sz) {} - - static ArrayValType get(const ArrayType *AT) { - return ArrayValType(AT->getElementType(), AT->getNumElements()); - } - - static unsigned hashTypeStructure(const ArrayType *AT) { - return (unsigned)AT->getNumElements(); - } - - inline bool operator<(const ArrayValType &MTV) const { - if (Size < MTV.Size) return true; - return Size == MTV.Size && ValTy < MTV.ValTy; - } -}; -} - -static ManagedStatic > ArrayTypes; - ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) { assert(ElementType && "Can't get array of types!"); assert(isValidElementType(ElementType) && "Invalid type for array element!"); ArrayValType AVT(ElementType, NumElements); ArrayType *AT = 0; + + LLVMContextImpl *pImpl = ElementType->getContext().pImpl; sys::SmartScopedLock L(*TypeMapLock); - AT = ArrayTypes->get(AVT); + AT = pImpl->ArrayTypes.get(AVT); if (!AT) { // Value not found. Derive a new type! - ArrayTypes->add(AVT, AT = new ArrayType(ElementType, NumElements)); + pImpl->ArrayTypes.add(AVT, AT = new ArrayType(ElementType, NumElements)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *AT << "\n"; @@ -1155,32 +818,6 @@ return true; } - -//===----------------------------------------------------------------------===// -// Vector Type Factory... -// -namespace llvm { -class VectorValType { - const Type *ValTy; - unsigned Size; -public: - VectorValType(const Type *val, int sz) : ValTy(val), Size(sz) {} - - static VectorValType get(const VectorType *PT) { - return VectorValType(PT->getElementType(), PT->getNumElements()); - } - - static unsigned hashTypeStructure(const VectorType *PT) { - return PT->getNumElements(); - } - - inline bool operator<(const VectorValType &MTV) const { - if (Size < MTV.Size) return true; - return Size == MTV.Size && ValTy < MTV.ValTy; - } -}; -} - static ManagedStatic > VectorTypes; VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { @@ -1213,37 +850,6 @@ // Struct Type Factory... // -namespace llvm { -// StructValType - Define a class to hold the key that goes into the TypeMap -// -class StructValType { - std::vector ElTypes; - bool packed; -public: - StructValType(const std::vector &args, bool isPacked) - : ElTypes(args), packed(isPacked) {} - - static StructValType get(const StructType *ST) { - std::vector ElTypes; - ElTypes.reserve(ST->getNumElements()); - for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) - ElTypes.push_back(ST->getElementType(i)); - - return StructValType(ElTypes, ST->isPacked()); - } - - static unsigned hashTypeStructure(const StructType *ST) { - return ST->getNumElements(); - } - - inline bool operator<(const StructValType &STV) const { - if (ElTypes < STV.ElTypes) return true; - else if (ElTypes > STV.ElTypes) return false; - else return (int)packed < (int)STV.packed; - } -}; -} - static ManagedStatic > StructTypes; StructType *StructType::get(const std::vector &ETypes, @@ -1295,30 +901,6 @@ // Pointer Type Factory... // -// PointerValType - Define a class to hold the key that goes into the TypeMap -// -namespace llvm { -class PointerValType { - const Type *ValTy; - unsigned AddressSpace; -public: - PointerValType(const Type *val, unsigned as) : ValTy(val), AddressSpace(as) {} - - static PointerValType get(const PointerType *PT) { - return PointerValType(PT->getElementType(), PT->getAddressSpace()); - } - - static unsigned hashTypeStructure(const PointerType *PT) { - return getSubElementHash(PT); - } - - bool operator<(const PointerValType &MTV) const { - if (AddressSpace < MTV.AddressSpace) return true; - return AddressSpace == MTV.AddressSpace && ValTy < MTV.ValTy; - } -}; -} - static ManagedStatic > PointerTypes; PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) { @@ -1533,11 +1115,13 @@ // void ArrayType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - ArrayTypes->RefineAbstractType(this, OldType, NewType); + LLVMContextImpl *pImpl = OldType->getContext().pImpl; + pImpl->ArrayTypes.RefineAbstractType(this, OldType, NewType); } void ArrayType::typeBecameConcrete(const DerivedType *AbsTy) { - ArrayTypes->TypeBecameConcrete(this, AbsTy); + LLVMContextImpl *pImpl = AbsTy->getContext().pImpl; + pImpl->ArrayTypes.TypeBecameConcrete(this, AbsTy); } // refineAbstractType - Called when a contained type is found to be more Added: llvm/trunk/lib/VMCore/TypesContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/TypesContext.h?rev=78122&view=auto ============================================================================== --- llvm/trunk/lib/VMCore/TypesContext.h (added) +++ llvm/trunk/lib/VMCore/TypesContext.h Tue Aug 4 18:33:01 2009 @@ -0,0 +1,426 @@ +//===-------------------- TypesContext.h - Implementation ------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines various helper methods and classes used by +// LLVMContextImpl for creating and managing types. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TYPESCONTEXT_H +#define LLVM_TYPESCONTEXT_H + +#include "llvm/ADT/STLExtras.h" +#include + + +//===----------------------------------------------------------------------===// +// Derived Type Factory Functions +//===----------------------------------------------------------------------===// +namespace llvm { + +/// getSubElementHash - Generate a hash value for all of the SubType's of this +/// type. The hash value is guaranteed to be zero if any of the subtypes are +/// an opaque type. Otherwise we try to mix them in as well as possible, but do +/// not look at the subtype's subtype's. +static unsigned getSubElementHash(const Type *Ty) { + unsigned HashVal = 0; + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + I != E; ++I) { + HashVal *= 32; + const Type *SubTy = I->get(); + HashVal += SubTy->getTypeID(); + switch (SubTy->getTypeID()) { + default: break; + case Type::OpaqueTyID: return 0; // Opaque -> hash = 0 no matter what. + case Type::IntegerTyID: + HashVal ^= (cast(SubTy)->getBitWidth() << 3); + break; + case Type::FunctionTyID: + HashVal ^= cast(SubTy)->getNumParams()*2 + + cast(SubTy)->isVarArg(); + break; + case Type::ArrayTyID: + HashVal ^= cast(SubTy)->getNumElements(); + break; + case Type::VectorTyID: + HashVal ^= cast(SubTy)->getNumElements(); + break; + case Type::StructTyID: + HashVal ^= cast(SubTy)->getNumElements(); + break; + case Type::PointerTyID: + HashVal ^= cast(SubTy)->getAddressSpace(); + break; + } + } + return HashVal ? HashVal : 1; // Do not return zero unless opaque subty. +} + +//===----------------------------------------------------------------------===// +// Integer Type Factory... +// +class IntegerValType { + uint32_t bits; +public: + IntegerValType(uint16_t numbits) : bits(numbits) {} + + static IntegerValType get(const IntegerType *Ty) { + return IntegerValType(Ty->getBitWidth()); + } + + static unsigned hashTypeStructure(const IntegerType *Ty) { + return (unsigned)Ty->getBitWidth(); + } + + inline bool operator<(const IntegerValType &IVT) const { + return bits < IVT.bits; + } +}; + +// PointerValType - Define a class to hold the key that goes into the TypeMap +// +class PointerValType { + const Type *ValTy; + unsigned AddressSpace; +public: + PointerValType(const Type *val, unsigned as) : ValTy(val), AddressSpace(as) {} + + static PointerValType get(const PointerType *PT) { + return PointerValType(PT->getElementType(), PT->getAddressSpace()); + } + + static unsigned hashTypeStructure(const PointerType *PT) { + return getSubElementHash(PT); + } + + bool operator<(const PointerValType &MTV) const { + if (AddressSpace < MTV.AddressSpace) return true; + return AddressSpace == MTV.AddressSpace && ValTy < MTV.ValTy; + } +}; + +//===----------------------------------------------------------------------===// +// Array Type Factory... +// +class ArrayValType { + const Type *ValTy; + uint64_t Size; +public: + ArrayValType(const Type *val, uint64_t sz) : ValTy(val), Size(sz) {} + + static ArrayValType get(const ArrayType *AT) { + return ArrayValType(AT->getElementType(), AT->getNumElements()); + } + + static unsigned hashTypeStructure(const ArrayType *AT) { + return (unsigned)AT->getNumElements(); + } + + inline bool operator<(const ArrayValType &MTV) const { + if (Size < MTV.Size) return true; + return Size == MTV.Size && ValTy < MTV.ValTy; + } +}; + +//===----------------------------------------------------------------------===// +// Vector Type Factory... +// +class VectorValType { + const Type *ValTy; + unsigned Size; +public: + VectorValType(const Type *val, int sz) : ValTy(val), Size(sz) {} + + static VectorValType get(const VectorType *PT) { + return VectorValType(PT->getElementType(), PT->getNumElements()); + } + + static unsigned hashTypeStructure(const VectorType *PT) { + return PT->getNumElements(); + } + + inline bool operator<(const VectorValType &MTV) const { + if (Size < MTV.Size) return true; + return Size == MTV.Size && ValTy < MTV.ValTy; + } +}; + +// StructValType - Define a class to hold the key that goes into the TypeMap +// +class StructValType { + std::vector ElTypes; + bool packed; +public: + StructValType(const std::vector &args, bool isPacked) + : ElTypes(args), packed(isPacked) {} + + static StructValType get(const StructType *ST) { + std::vector ElTypes; + ElTypes.reserve(ST->getNumElements()); + for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i) + ElTypes.push_back(ST->getElementType(i)); + + return StructValType(ElTypes, ST->isPacked()); + } + + static unsigned hashTypeStructure(const StructType *ST) { + return ST->getNumElements(); + } + + inline bool operator<(const StructValType &STV) const { + if (ElTypes < STV.ElTypes) return true; + else if (ElTypes > STV.ElTypes) return false; + else return (int)packed < (int)STV.packed; + } +}; + +// FunctionValType - Define a class to hold the key that goes into the TypeMap +// +class FunctionValType { + const Type *RetTy; + std::vector ArgTypes; + bool isVarArg; +public: + FunctionValType(const Type *ret, const std::vector &args, + bool isVA) : RetTy(ret), ArgTypes(args), isVarArg(isVA) {} + + static FunctionValType get(const FunctionType *FT); + + static unsigned hashTypeStructure(const FunctionType *FT) { + unsigned Result = FT->getNumParams()*2 + FT->isVarArg(); + return Result; + } + + inline bool operator<(const FunctionValType &MTV) const { + if (RetTy < MTV.RetTy) return true; + if (RetTy > MTV.RetTy) return false; + if (isVarArg < MTV.isVarArg) return true; + if (isVarArg > MTV.isVarArg) return false; + if (ArgTypes < MTV.ArgTypes) return true; + if (ArgTypes > MTV.ArgTypes) return false; + return false; + } +}; + +class TypeMapBase { +protected: + /// TypesByHash - Keep track of types by their structure hash value. Note + /// that we only keep track of types that have cycles through themselves in + /// this map. + /// + std::multimap TypesByHash; + +public: + ~TypeMapBase() { + // PATypeHolder won't destroy non-abstract types. + // We can't destroy them by simply iterating, because + // they may contain references to each-other. +#if 0 + for (std::multimap::iterator I + = TypesByHash.begin(), E = TypesByHash.end(); I != E; ++I) { + Type *Ty = const_cast(I->second.Ty); + I->second.destroy(); + // We can't invoke destroy or delete, because the type may + // contain references to already freed types. + // So we have to destruct the object the ugly way. + if (Ty) { + Ty->AbstractTypeUsers.clear(); + static_cast(Ty)->Type::~Type(); + operator delete(Ty); + } + } +#endif + } + + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { + std::multimap::iterator I = + TypesByHash.lower_bound(Hash); + for (; I != TypesByHash.end() && I->first == Hash; ++I) { + if (I->second == Ty) { + TypesByHash.erase(I); + return; + } + } + + // This must be do to an opaque type that was resolved. Switch down to hash + // code of zero. + assert(Hash && "Didn't find type entry!"); + RemoveFromTypesByHash(0, Ty); + } + + /// TypeBecameConcrete - When Ty gets a notification that TheType just became + /// concrete, drop uses and make Ty non-abstract if we should. + void TypeBecameConcrete(DerivedType *Ty, const DerivedType *TheType) { + // If the element just became concrete, remove 'ty' from the abstract + // type user list for the type. Do this for as many times as Ty uses + // OldType. + for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); + I != E; ++I) + if (I->get() == TheType) + TheType->removeAbstractTypeUser(Ty); + + // If the type is currently thought to be abstract, rescan all of our + // subtypes to see if the type has just become concrete! Note that this + // may send out notifications to AbstractTypeUsers that types become + // concrete. + if (Ty->isAbstract()) + Ty->PromoteAbstractToConcrete(); + } +}; + +// TypeMap - Make sure that only one instance of a particular type may be +// created on any given run of the compiler... note that this involves updating +// our map if an abstract type gets refined somehow. +// +template +class TypeMap : public TypeMapBase { + std::map Map; +public: + typedef typename std::map::iterator iterator; + ~TypeMap() { print("ON EXIT"); } + + inline TypeClass *get(const ValType &V) { + iterator I = Map.find(V); + return I != Map.end() ? cast((Type*)I->second.get()) : 0; + } + + inline void add(const ValType &V, TypeClass *Ty) { + Map.insert(std::make_pair(V, Ty)); + + // If this type has a cycle, remember it. + TypesByHash.insert(std::make_pair(ValType::hashTypeStructure(Ty), Ty)); + print("add"); + } + + /// RefineAbstractType - This method is called after we have merged a type + /// with another one. We must now either merge the type away with + /// some other type or reinstall it in the map with it's new configuration. + void RefineAbstractType(TypeClass *Ty, const DerivedType *OldType, + const Type *NewType) { +#ifdef DEBUG_MERGE_TYPES + DOUT << "RefineAbstractType(" << (void*)OldType << "[" << *OldType + << "], " << (void*)NewType << " [" << *NewType << "])\n"; +#endif + + // Otherwise, we are changing one subelement type into another. Clearly the + // OldType must have been abstract, making us abstract. + assert(Ty->isAbstract() && "Refining a non-abstract type!"); + assert(OldType != NewType); + + // Make a temporary type holder for the type so that it doesn't disappear on + // us when we erase the entry from the map. + PATypeHolder TyHolder = Ty; + + // The old record is now out-of-date, because one of the children has been + // updated. Remove the obsolete entry from the map. + unsigned NumErased = Map.erase(ValType::get(Ty)); + assert(NumErased && "Element not found!"); NumErased = NumErased; + + // Remember the structural hash for the type before we start hacking on it, + // in case we need it later. + unsigned OldTypeHash = ValType::hashTypeStructure(Ty); + + // Find the type element we are refining... and change it now! + for (unsigned i = 0, e = Ty->getNumContainedTypes(); i != e; ++i) + if (Ty->ContainedTys[i] == OldType) + Ty->ContainedTys[i] = NewType; + unsigned NewTypeHash = ValType::hashTypeStructure(Ty); + + // If there are no cycles going through this node, we can do a simple, + // efficient lookup in the map, instead of an inefficient nasty linear + // lookup. + if (!TypeHasCycleThroughItself(Ty)) { + typename std::map::iterator I; + bool Inserted; + + tie(I, Inserted) = Map.insert(std::make_pair(ValType::get(Ty), Ty)); + if (!Inserted) { + // Refined to a different type altogether? + RemoveFromTypesByHash(OldTypeHash, Ty); + + // We already have this type in the table. Get rid of the newly refined + // type. + TypeClass *NewTy = cast((Type*)I->second.get()); + Ty->unlockedRefineAbstractTypeTo(NewTy); + return; + } + } else { + // Now we check to see if there is an existing entry in the table which is + // structurally identical to the newly refined type. If so, this type + // gets refined to the pre-existing type. + // + std::multimap::iterator I, E, Entry; + tie(I, E) = TypesByHash.equal_range(NewTypeHash); + Entry = E; + for (; I != E; ++I) { + if (I->second == Ty) { + // Remember the position of the old type if we see it in our scan. + Entry = I; + } else { + if (TypesEqual(Ty, I->second)) { + TypeClass *NewTy = cast((Type*)I->second.get()); + + // Remove the old entry form TypesByHash. If the hash values differ + // now, remove it from the old place. Otherwise, continue scanning + // withing this hashcode to reduce work. + if (NewTypeHash != OldTypeHash) { + RemoveFromTypesByHash(OldTypeHash, Ty); + } else { + if (Entry == E) { + // Find the location of Ty in the TypesByHash structure if we + // haven't seen it already. + while (I->second != Ty) { + ++I; + assert(I != E && "Structure doesn't contain type??"); + } + Entry = I; + } + TypesByHash.erase(Entry); + } + Ty->unlockedRefineAbstractTypeTo(NewTy); + return; + } + } + } + + // If there is no existing type of the same structure, we reinsert an + // updated record into the map. + Map.insert(std::make_pair(ValType::get(Ty), Ty)); + } + + // If the hash codes differ, update TypesByHash + if (NewTypeHash != OldTypeHash) { + RemoveFromTypesByHash(OldTypeHash, Ty); + TypesByHash.insert(std::make_pair(NewTypeHash, Ty)); + } + + // If the type is currently thought to be abstract, rescan all of our + // subtypes to see if the type has just become concrete! Note that this + // may send out notifications to AbstractTypeUsers that types become + // concrete. + if (Ty->isAbstract()) + Ty->PromoteAbstractToConcrete(); + } + + void print(const char *Arg) const { +#ifdef DEBUG_MERGE_TYPES + DOUT << "TypeMap<>::" << Arg << " table contents:\n"; + unsigned i = 0; + for (typename std::map::const_iterator I + = Map.begin(), E = Map.end(); I != E; ++I) + DOUT << " " << (++i) << ". " << (void*)I->second.get() << " " + << *I->second.get() << "\n"; +#endif + } + + void dump() const { print("dump output"); } +}; +} + +#endif From bob.wilson at apple.com Tue Aug 4 18:37:07 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 23:37:07 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78123 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Message-ID: <200908042337.n74Nb8VR025991@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 18:36:57 2009 New Revision: 78123 URL: http://llvm.org/viewvc/llvm-project?rev=78123&view=rev Log: Initialize to avoid gcc warning. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=78123&r1=78122&r2=78123&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Aug 4 18:36:57 2009 @@ -2045,7 +2045,7 @@ case NEON_BUILTIN_vld4_dup: { const VectorType *VTy = GetVldstType(exp, insn_data[icode].operand[0].mode); - unsigned NumVecs; + unsigned NumVecs = 0; switch (neon_code) { case NEON_BUILTIN_vld1_dup: NumVecs = 1; break; case NEON_BUILTIN_vld2_dup: NumVecs = 2; break; From bob.wilson at apple.com Tue Aug 4 18:43:04 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 04 Aug 2009 23:43:04 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r78124 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Message-ID: <200908042343.n74Nh6dD026201@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 18:42:46 2009 New Revision: 78124 URL: http://llvm.org/viewvc/llvm-project?rev=78124&view=rev Log: More initialization to avoid warnings. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=78124&r1=78123&r2=78124&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Tue Aug 4 18:42:46 2009 @@ -269,7 +269,7 @@ std::vector &Ops) { neon_datatype datatype = neon_datatype_unspecified; bool isRounded = false; - Intrinsic::ID intID; + Intrinsic::ID intID = Intrinsic::not_intrinsic; Function *intFn; const Type* intOpTypes[2]; @@ -2013,7 +2013,7 @@ case NEON_BUILTIN_vld4_lane: { const VectorType *VTy = GetVldstType(exp, insn_data[icode].operand[0].mode); - unsigned LaneVal, NumVecs; + unsigned LaneVal, NumVecs = 0; switch (neon_code) { case NEON_BUILTIN_vld1_lane: NumVecs = 1; break; case NEON_BUILTIN_vld2_lane: NumVecs = 2; break; @@ -2140,7 +2140,7 @@ case NEON_BUILTIN_vst4_lane: { const VectorType *VTy = GetVldstType(exp, insn_data[icode].operand[1].mode); - unsigned LaneVal, NumVecs; + unsigned LaneVal, NumVecs = 0; switch (neon_code) { case NEON_BUILTIN_vst1_lane: NumVecs = 1; break; case NEON_BUILTIN_vst2_lane: NumVecs = 2; break; From evan.cheng at apple.com Tue Aug 4 18:47:57 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Aug 2009 23:47:57 -0000 Subject: [llvm-commits] [llvm] r78126 - in /llvm/trunk: lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/load-global.ll test/CodeGen/Thumb2/pic-load.ll Message-ID: <200908042348.n74Nm14v026344@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 18:47:55 2009 New Revision: 78126 URL: http://llvm.org/viewvc/llvm-project?rev=78126&view=rev Log: Fix part 1 of pr4682. PICADD is a 16-bit instruction even in thumb2 mode. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/CodeGen/Thumb2/load-global.ll llvm/trunk/test/CodeGen/Thumb2/pic-load.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=78126&r1=78125&r2=78126&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Aug 4 18:47:55 2009 @@ -808,6 +808,10 @@ class TI pattern> : ThumbI; +// Two-address instructions +class TIt pattern> + : ThumbI; + // tBL, tBX instructions class TIx2 pattern> : ThumbI; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=78126&r1=78125&r2=78126&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Aug 4 18:47:55 2009 @@ -127,10 +127,11 @@ [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb1Only]>; } +// For both thumb1 and thumb2. let isNotDuplicable = 1 in -def tPICADD : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, pclabel:$cp), - "$cp:\n\tadd $dst, pc", - [(set tGPR:$dst, (ARMpic_add tGPR:$lhs, imm:$cp))]>; +def tPICADD : TIt<(outs GPR:$dst), (ins GPR:$lhs, pclabel:$cp), + "$cp:\n\tadd $dst, pc", + [(set GPR:$dst, (ARMpic_add GPR:$lhs, imm:$cp))]>; // PC relative add. def tADDrPCi : T1I<(outs tGPR:$dst), (ins i32imm:$rhs), Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=78126&r1=78125&r2=78126&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Aug 4 18:47:55 2009 @@ -422,12 +422,6 @@ // Miscellaneous Instructions. // -let isNotDuplicable = 1 in -def t2PICADD : T2XI<(outs GPR:$dst), (ins GPR:$lhs, pclabel:$cp), - "$cp:\n\tadd.w $dst, $lhs, pc", - [(set GPR:$dst, (ARMpic_add GPR:$lhs, imm:$cp))]>; - - // LEApcrel - Load a pc-relative address into a register without offending the // assembler. def t2LEApcrel : T2XI<(outs GPR:$dst), (ins i32imm:$label, pred:$p), Modified: llvm/trunk/test/CodeGen/Thumb2/load-global.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/load-global.ll?rev=78126&r1=78125&r2=78126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/load-global.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/load-global.ll Tue Aug 4 18:47:55 2009 @@ -17,7 +17,7 @@ ; DYNAMIC: .long L_G$non_lazy_ptr ; PIC: _test1 -; PIC: add.w r0, r0, pc +; PIC: add r0, pc ; PIC: .long L_G$non_lazy_ptr-(LPC0+4) ; LINUX: test1 Modified: llvm/trunk/test/CodeGen/Thumb2/pic-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/pic-load.ll?rev=78126&r1=78125&r2=78126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/pic-load.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/pic-load.ll Tue Aug 4 18:47:55 2009 @@ -8,7 +8,7 @@ define hidden arm_apcscc i32 @atexit(void ()* %func) nounwind { entry: ; CHECK: atexit: -; CHECK: add.w r0, r0, pc +; CHECK: add r0, pc %r = alloca %struct.one_atexit_routine, align 4 ; <%struct.one_atexit_routine*> [#uses=3] %0 = getelementptr %struct.one_atexit_routine* %r, i32 0, i32 0, i32 0 ; [#uses=1] store void ()* %func, void ()** %0, align 4 From resistor at mac.com Tue Aug 4 18:47:57 2009 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Aug 2009 23:47:57 -0000 Subject: [llvm-commits] [llvm] r78125 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp Message-ID: <200908042348.n74Nm1Gk026342@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 18:47:44 2009 New Revision: 78125 URL: http://llvm.org/viewvc/llvm-project?rev=78125&view=rev Log: Privatize the VectorType uniquing. Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78125&r1=78124&r2=78125&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug 4 18:47:44 2009 @@ -129,6 +129,7 @@ ConstantInt *TheFalseVal; TypeMap ArrayTypes; + TypeMap VectorTypes; LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { } }; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=78125&r1=78124&r2=78125&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Aug 4 18:47:44 2009 @@ -818,19 +818,19 @@ return true; } -static ManagedStatic > VectorTypes; - VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { assert(ElementType && "Can't get vector of types!"); VectorValType PVT(ElementType, NumElements); VectorType *PT = 0; + LLVMContextImpl *pImpl = ElementType->getContext().pImpl; + sys::SmartScopedLock L(*TypeMapLock); - PT = VectorTypes->get(PVT); + PT = pImpl->VectorTypes.get(PVT); if (!PT) { - VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements)); + pImpl->VectorTypes.add(PVT, PT = new VectorType(ElementType, NumElements)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; @@ -1130,11 +1130,13 @@ // void VectorType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - VectorTypes->RefineAbstractType(this, OldType, NewType); + LLVMContextImpl *pImpl = OldType->getContext().pImpl; + pImpl->VectorTypes.RefineAbstractType(this, OldType, NewType); } void VectorType::typeBecameConcrete(const DerivedType *AbsTy) { - VectorTypes->TypeBecameConcrete(this, AbsTy); + LLVMContextImpl *pImpl = AbsTy->getContext().pImpl; + pImpl->VectorTypes.TypeBecameConcrete(this, AbsTy); } // refineAbstractType - Called when a contained type is found to be more From jyasskin at google.com Tue Aug 4 18:53:35 2009 From: jyasskin at google.com (Jeffrey Yasskin) Date: Tue, 04 Aug 2009 23:53:35 -0000 Subject: [llvm-commits] [llvm] r78127 - in /llvm/trunk: lib/ExecutionEngine/ExecutionEngine.cpp unittests/ExecutionEngine/ExecutionEngineTest.cpp unittests/ExecutionEngine/Makefile Message-ID: <200908042353.n74NrdXX026510@zion.cs.uiuc.edu> Author: jyasskin Date: Tue Aug 4 18:53:16 2009 New Revision: 78127 URL: http://llvm.org/viewvc/llvm-project?rev=78127&view=rev Log: Make ExecutionEngine::updateGlobalMapping(GV, NULL) properly remove GV's old address from the reverse mapping, and add a test that this works now. Added: llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp llvm/trunk/unittests/ExecutionEngine/Makefile Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=78127&r1=78126&r2=78127&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Tue Aug 4 18:53:16 2009 @@ -179,7 +179,7 @@ } if (!state.getGlobalAddressReverseMap(locked).empty()) - state.getGlobalAddressReverseMap(locked).erase(Addr); + state.getGlobalAddressReverseMap(locked).erase(OldVal); return OldVal; } Added: llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp?rev=78127&view=auto ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp (added) +++ llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Tue Aug 4 18:53:16 2009 @@ -0,0 +1,92 @@ +//===- ExecutionEngineTest.cpp - Unit tests for ExecutionEngine -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DerivedTypes.h" +#include "llvm/GlobalVariable.h" +#include "llvm/LLVMContext.h" +#include "llvm/Module.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ExecutionEngine/Interpreter.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +class ExecutionEngineTest : public testing::Test { +protected: + ExecutionEngineTest() + : M(new Module("
    ", getGlobalContext())), + Engine(EngineBuilder(M).create()) { + } + + virtual void SetUp() { + ASSERT_TRUE(Engine.get() != NULL); + } + + GlobalVariable *NewExtGlobal(const Type *T, const Twine &Name) { + return new GlobalVariable(*M, T, false, // Not constant. + GlobalValue::ExternalLinkage, NULL, Name); + } + + Module *const M; + const OwningPtr Engine; +}; + +TEST_F(ExecutionEngineTest, ForwardGlobalMapping) { + GlobalVariable *G1 = NewExtGlobal(Type::Int32Ty, "Global1"); + int32_t Mem1 = 3; + Engine->addGlobalMapping(G1, &Mem1); + EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G1)); + int32_t Mem2 = 4; + Engine->updateGlobalMapping(G1, &Mem2); + EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1)); + Engine->updateGlobalMapping(G1, NULL); + EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G1)); + Engine->updateGlobalMapping(G1, &Mem2); + EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1)); + + GlobalVariable *G2 = NewExtGlobal(Type::Int32Ty, "Global1"); + EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G2)) + << "The NULL return shouldn't depend on having called" + << " updateGlobalMapping(..., NULL)"; + // Check that update...() can be called before add...(). + Engine->updateGlobalMapping(G2, &Mem1); + EXPECT_EQ(&Mem1, Engine->getPointerToGlobalIfAvailable(G2)); + EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1)) + << "A second mapping shouldn't affect the first."; +} + +TEST_F(ExecutionEngineTest, ReverseGlobalMapping) { + GlobalVariable *G1 = NewExtGlobal(Type::Int32Ty, "Global1"); + + int32_t Mem1 = 3; + Engine->addGlobalMapping(G1, &Mem1); + EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1)); + int32_t Mem2 = 4; + Engine->updateGlobalMapping(G1, &Mem2); + EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1)); + EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2)); + + GlobalVariable *G2 = NewExtGlobal(Type::Int32Ty, "Global2"); + Engine->updateGlobalMapping(G2, &Mem1); + EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1)); + EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2)); + Engine->updateGlobalMapping(G1, NULL); + EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1)) + << "Removing one mapping doesn't affect a different one."; + EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem2)); + Engine->updateGlobalMapping(G2, &Mem2); + EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1)); + EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem2)) + << "Once a mapping is removed, we can point another GV at the" + << " now-free address."; +} + +} Modified: llvm/trunk/unittests/ExecutionEngine/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/Makefile?rev=78127&r1=78126&r2=78127&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/Makefile (original) +++ llvm/trunk/unittests/ExecutionEngine/Makefile Tue Aug 4 18:53:16 2009 @@ -8,12 +8,11 @@ ##===----------------------------------------------------------------------===## LEVEL = ../.. +TESTNAME = ExecutionEngine +LINK_COMPONENTS := engine interpreter include $(LEVEL)/Makefile.config PARALLEL_DIRS = JIT -include $(LEVEL)/Makefile.common - -clean:: - $(Verb) $(RM) -f *Tests +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest From gohman at apple.com Tue Aug 4 19:09:29 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 00:09:29 -0000 Subject: [llvm-commits] [llvm] r78128 - /llvm/trunk/lib/System/Unix/Program.inc Message-ID: <200908050009.n7509Xqv026967@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 19:09:12 2009 New Revision: 78128 URL: http://llvm.org/viewvc/llvm-project?rev=78128&view=rev Log: Use _exit rather than exit in the child process after a failed exec. Add a comment explaining why. Modified: llvm/trunk/lib/System/Unix/Program.inc Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=78128&r1=78127&r2=78128&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Tue Aug 4 19:09:12 2009 @@ -200,9 +200,13 @@ execve(path.c_str(), (char**)args, (char**)envp); else execv(path.c_str(), (char**)args); - // If the execve() failed, we should exit and let the parent pick up - // our non-zero exit status. - exit(errno == ENOENT ? 127 : 126); + // If the execve() failed, we should exit. Follow Unix protocol and + // return 127 if the executable was not found, and 126 otherwise. + // Use _exit rather than exit so that atexit functions and static + // object destructors cloned from the parent process aren't + // redundantly run, and so that any data buffered in stdio buffers + // cloned from the parent aren't redundantly written out. + _exit(errno == ENOENT ? 127 : 126); } // Parent process: Break out of the switch to do our processing. From bruno.cardoso at gmail.com Tue Aug 4 19:11:22 2009 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 05 Aug 2009 00:11:22 -0000 Subject: [llvm-commits] [llvm] r78129 - in /llvm/trunk: include/llvm/CodeGen/JITCodeEmitter.h include/llvm/CodeGen/MachineCodeEmitter.h include/llvm/CodeGen/ObjectCodeEmitter.h lib/Target/X86/X86CodeEmitter.cpp lib/Target/X86/X86JITInfo.cpp lib/Target/X86/X86Relocations.h Message-ID: <200908050011.n750BMKO027050@zion.cs.uiuc.edu> Author: bruno Date: Tue Aug 4 19:11:21 2009 New Revision: 78129 URL: http://llvm.org/viewvc/llvm-project?rev=78129&view=rev Log: 1) Proper emit displacements for x86, using absolute relocations where necessary for ELF to work. 2) RIP addressing: Use SIB bytes for absolute relocations where RegBase=0, IndexReg=0. 3) The JIT can get the real address of cstpools and jmptables during code emission, fix that for object code emission Modified: llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp llvm/trunk/lib/Target/X86/X86JITInfo.cpp llvm/trunk/lib/Target/X86/X86Relocations.h Modified: llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h (original) +++ llvm/trunk/include/llvm/CodeGen/JITCodeEmitter.h Tue Aug 4 19:11:21 2009 @@ -289,6 +289,13 @@ return CurBufferPtr-BufferBegin; } + /// earlyResolveAddresses - True if the code emitter can use symbol addresses + /// during code emission time. The JIT is capable of doing this because it + /// creates jump tables or constant pools in memory on the fly while the + /// object code emitters rely on a linker to have real addresses and should + /// use relocations instead. + bool earlyResolveAddresses() const { return true; } + /// addRelocation - Whenever a relocatable address is needed, it should be /// noted with this interface. virtual void addRelocation(const MachineRelocation &MR) = 0; Modified: llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineCodeEmitter.h Tue Aug 4 19:11:21 2009 @@ -280,6 +280,13 @@ return CurBufferPtr-BufferBegin; } + /// earlyResolveAddresses - True if the code emitter can use symbol addresses + /// during code emission time. The JIT is capable of doing this because it + /// creates jump tables or constant pools in memory on the fly while the + /// object code emitters rely on a linker to have real addresses and should + /// use relocations instead. + virtual bool earlyResolveAddresses() const = 0; + /// addRelocation - Whenever a relocatable address is needed, it should be /// noted with this interface. virtual void addRelocation(const MachineRelocation &MR) = 0; Modified: llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h (original) +++ llvm/trunk/include/llvm/CodeGen/ObjectCodeEmitter.h Tue Aug 4 19:11:21 2009 @@ -109,6 +109,13 @@ /// noted with this interface. void addRelocation(const MachineRelocation& relocation); + /// earlyResolveAddresses - True if the code emitter can use symbol addresses + /// during code emission time. The JIT is capable of doing this because it + /// creates jump tables or constant pools in memory on the fly while the + /// object code emitters rely on a linker to have real addresses and should + /// use relocations instead. + bool earlyResolveAddresses() const { return false; } + /// startFunction - This callback is invoked when the specified function is /// about to be code generated. This initializes the BufferBegin/End/Ptr /// fields. Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Tue Aug 4 19:11:21 2009 @@ -87,7 +87,7 @@ intptr_t PCAdj = 0); void emitDisplacementField(const MachineOperand *RelocOp, int DispVal, - intptr_t PCAdj = 0); + intptr_t Adj = 0, bool IsPCRel = true); void emitRegModRMByte(unsigned ModRMReg, unsigned RegOpcodeField); void emitRegModRMByte(unsigned RegOpcodeField); @@ -175,7 +175,7 @@ intptr_t PCAdj /* = 0 */, bool NeedStub /* = false */, bool Indirect /* = false */) { - intptr_t RelocCST = 0; + intptr_t RelocCST = Disp; if (Reloc == X86::reloc_picrel_word) RelocCST = PICBaseOffset; else if (Reloc == X86::reloc_pcrel_word) @@ -309,34 +309,42 @@ template void Emitter::emitDisplacementField(const MachineOperand *RelocOp, - int DispVal, intptr_t PCAdj) { + int DispVal, + intptr_t Adj /* = 0 */, + bool IsPCRel /* = true */) { // If this is a simple integer displacement that doesn't require a relocation, // emit it now. if (!RelocOp) { emitConstant(DispVal, 4); return; } - + // Otherwise, this is something that requires a relocation. Emit it as such // now. if (RelocOp->isGlobal()) { // In 64-bit static small code model, we could potentially emit absolute. - // But it's probably not beneficial. + // But it's probably not beneficial. If the MCE supports using RIP directly + // do it, otherwise fallback to absolute (this is determined by IsPCRel). // 89 05 00 00 00 00 mov %eax,0(%rip) # PC-relative // 89 04 25 00 00 00 00 mov %eax,0x0 # Absolute - unsigned rt = Is64BitMode ? X86::reloc_pcrel_word + unsigned rt = Is64BitMode ? + (IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext) : (IsPIC ? X86::reloc_picrel_word : X86::reloc_absolute_word); bool NeedStub = isa(RelocOp->getGlobal()); bool Indirect = gvNeedsNonLazyPtr(*RelocOp, TM); emitGlobalAddress(RelocOp->getGlobal(), rt, RelocOp->getOffset(), - PCAdj, NeedStub, Indirect); + Adj, NeedStub, Indirect); } else if (RelocOp->isCPI()) { - unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word; + unsigned rt = Is64BitMode ? + (IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext) + : (IsPCRel ? X86::reloc_picrel_word : X86::reloc_absolute_word); emitConstPoolAddress(RelocOp->getIndex(), rt, - RelocOp->getOffset(), PCAdj); + RelocOp->getOffset(), Adj); } else if (RelocOp->isJTI()) { - unsigned rt = Is64BitMode ? X86::reloc_pcrel_word : X86::reloc_picrel_word; - emitJumpTableAddress(RelocOp->getIndex(), rt, PCAdj); + unsigned rt = Is64BitMode ? + (IsPCRel ? X86::reloc_pcrel_word : X86::reloc_absolute_word_sext) + : (IsPCRel ? X86::reloc_picrel_word : X86::reloc_absolute_word); + emitJumpTableAddress(RelocOp->getIndex(), rt, Adj); } else { llvm_unreachable("Unknown value to relocate!"); } @@ -354,14 +362,14 @@ if (Op3.isGlobal()) { DispForReloc = &Op3; } else if (Op3.isCPI()) { - if (Is64BitMode || IsPIC) { + if (!MCE.earlyResolveAddresses() || Is64BitMode || IsPIC) { DispForReloc = &Op3; } else { DispVal += MCE.getConstantPoolEntryAddress(Op3.getIndex()); DispVal += Op3.getOffset(); } } else if (Op3.isJTI()) { - if (Is64BitMode || IsPIC) { + if (!MCE.earlyResolveAddresses() || Is64BitMode || IsPIC) { DispForReloc = &Op3; } else { DispVal += MCE.getJumpTableEntryAddress(Op3.getIndex()); @@ -376,17 +384,23 @@ unsigned BaseReg = Base.getReg(); + // Indicate that the displacement will use an pcrel or absolute reference + // by default. MCEs able to resolve addresses on-the-fly use pcrel by default + // while others, unless explicit asked to use RIP, use absolute references. + bool IsPCRel = MCE.earlyResolveAddresses() ? true : false; + // Is a SIB byte needed? + // If no BaseReg, issue a RIP relative instruction only if the MCE can + // resolve addresses on-the-fly, otherwise use SIB (Intel Manual 2A, table + // 2-7) and absolute references. if ((!Is64BitMode || DispForReloc || BaseReg != 0) && - IndexReg.getReg() == 0 && - (BaseReg == 0 || BaseReg == X86::RIP || - getX86RegNum(BaseReg) != N86::ESP)) { - if (BaseReg == 0 || - BaseReg == X86::RIP) { // Just a displacement? + IndexReg.getReg() == 0 && + ((BaseReg == 0 && MCE.earlyResolveAddresses()) || BaseReg == X86::RIP || + (BaseReg != 0 && getX86RegNum(BaseReg) != N86::ESP))) { + if (BaseReg == 0 || BaseReg == X86::RIP) { // Just a displacement? // Emit special case [disp32] encoding MCE.emitByte(ModRMByte(0, RegOpcodeField, 5)); - - emitDisplacementField(DispForReloc, DispVal, PCAdj); + emitDisplacementField(DispForReloc, DispVal, PCAdj, true); } else { unsigned BaseRegNo = getX86RegNum(BaseReg); if (!DispForReloc && DispVal == 0 && BaseRegNo != N86::EBP) { @@ -399,7 +413,7 @@ } else { // Emit the most general non-SIB encoding: [REG+disp32] MCE.emitByte(ModRMByte(2, RegOpcodeField, BaseRegNo)); - emitDisplacementField(DispForReloc, DispVal, PCAdj); + emitDisplacementField(DispForReloc, DispVal, PCAdj, IsPCRel); } } @@ -435,13 +449,13 @@ unsigned SS = SSTable[Scale.getImm()]; if (BaseReg == 0) { - // Handle the SIB byte for the case where there is no base. The - // displacement has already been output. + // Handle the SIB byte for the case where there is no base, see Intel + // Manual 2A, table 2-7. The displacement has already been output. unsigned IndexRegNo; if (IndexReg.getReg()) IndexRegNo = getX86RegNum(IndexReg.getReg()); - else - IndexRegNo = 4; // For example [ESP+1*+4] + else // Examples: [ESP+1*+4] or [scaled idx]+disp32 (MOD=0,BASE=5) + IndexRegNo = 4; emitSIBByte(SS, IndexRegNo, 5); } else { unsigned BaseRegNo = getX86RegNum(BaseReg); @@ -457,7 +471,7 @@ if (ForceDisp8) { emitConstant(DispVal, 1); } else if (DispVal != 0 || ForceDisp32) { - emitDisplacementField(DispForReloc, DispVal, PCAdj); + emitDisplacementField(DispForReloc, DispVal, PCAdj, IsPCRel); } } } Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Tue Aug 4 19:11:21 2009 @@ -538,6 +538,7 @@ break; } case X86::reloc_absolute_word: + case X86::reloc_absolute_word_sext: // Absolute relocation, just add the relocated value to the value already // in memory. *((unsigned*)RelocPos) += (unsigned)ResultPtr; Modified: llvm/trunk/lib/Target/X86/X86Relocations.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Relocations.h?rev=78129&r1=78128&r2=78129&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Relocations.h (original) +++ llvm/trunk/lib/Target/X86/X86Relocations.h Tue Aug 4 19:11:21 2009 @@ -20,7 +20,9 @@ namespace X86 { /// RelocationType - An enum for the x86 relocation codes. Note that /// the terminology here doesn't follow x86 convention - word means - /// 32-bit and dword means 64-bit. + /// 32-bit and dword means 64-bit. The relocations will be treated + /// by JIT or ObjectCode emitters, this is transparent to the x86 code + /// emitter but JIT and ObjectCode will treat them differently enum RelocationType { /// reloc_pcrel_word - PC relative relocation, add the relocated value to /// the value already in memory, after we adjust it for where the PC is. @@ -30,11 +32,19 @@ /// value to the value already in memory, after we adjust it for where the /// PIC base is. reloc_picrel_word = 1, - - /// reloc_absolute_word, reloc_absolute_dword - Absolute relocation, just - /// add the relocated value to the value already in memory. + + /// reloc_absolute_word - absolute relocation, just add the relocated + /// value to the value already in memory. reloc_absolute_word = 2, - reloc_absolute_dword = 3 + + /// reloc_absolute_word_sext - absolute relocation, just add the relocated + /// value to the value already in memory. In object files, it represents a + /// value which must be sign-extended when resolving the relocation. + reloc_absolute_word_sext = 3, + + /// reloc_absolute_dword - absolute relocation, just add the relocated + /// value to the value already in memory. + reloc_absolute_dword = 4 }; } } From resistor at mac.com Tue Aug 4 19:15:12 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 05 Aug 2009 00:15:12 -0000 Subject: [llvm-commits] [llvm] r78130 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp Message-ID: <200908050015.n750FCdA027198@zion.cs.uiuc.edu> Author: resistor Date: Tue Aug 4 19:15:12 2009 New Revision: 78130 URL: http://llvm.org/viewvc/llvm-project?rev=78130&view=rev Log: Privatize the PointerType factory. Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h llvm/trunk/lib/VMCore/Type.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78130&r1=78129&r2=78130&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug 4 19:15:12 2009 @@ -130,6 +130,7 @@ TypeMap ArrayTypes; TypeMap VectorTypes; + TypeMap PointerTypes; LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { } }; Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=78130&r1=78129&r2=78130&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Tue Aug 4 19:15:12 2009 @@ -901,8 +901,6 @@ // Pointer Type Factory... // -static ManagedStatic > PointerTypes; - PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) { assert(ValueType && "Can't get a pointer to type!"); assert(ValueType != Type::VoidTy && @@ -912,12 +910,14 @@ PointerType *PT = 0; + LLVMContextImpl *pImpl = ValueType->getContext().pImpl; + sys::SmartScopedLock L(*TypeMapLock); - PT = PointerTypes->get(PVT); + PT = pImpl->PointerTypes.get(PVT); if (!PT) { // Value not found. Derive a new type! - PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); + pImpl->PointerTypes.add(PVT, PT = new PointerType(ValueType, AddressSpace)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; @@ -1158,11 +1158,13 @@ // void PointerType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - PointerTypes->RefineAbstractType(this, OldType, NewType); + LLVMContextImpl *pImpl = OldType->getContext().pImpl; + pImpl->PointerTypes.RefineAbstractType(this, OldType, NewType); } void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { - PointerTypes->TypeBecameConcrete(this, AbsTy); + LLVMContextImpl *pImpl = AbsTy->getContext().pImpl; + pImpl->PointerTypes.TypeBecameConcrete(this, AbsTy); } bool SequentialType::indexValid(const Value *V) const { From gohman at apple.com Tue Aug 4 19:17:00 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 00:17:00 -0000 Subject: [llvm-commits] [llvm] r78131 - /llvm/trunk/lib/System/Unix/Program.inc Message-ID: <200908050017.n750H0AL027272@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 19:17:00 2009 New Revision: 78131 URL: http://llvm.org/viewvc/llvm-project?rev=78131&view=rev Log: Remove needless uses of std::flush in the parent process after a fork call. This eliminates a need for . Also remove needless fsync calls. Modified: llvm/trunk/lib/System/Unix/Program.inc Modified: llvm/trunk/lib/System/Unix/Program.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Program.inc?rev=78131&r1=78130&r2=78131&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Program.inc (original) +++ llvm/trunk/lib/System/Unix/Program.inc Tue Aug 4 19:17:00 2009 @@ -18,7 +18,6 @@ #include #include "Unix.h" -#include #if HAVE_SYS_STAT_H #include #endif @@ -214,12 +213,6 @@ break; } - // Make sure stderr and stdout have been flushed - std::cerr << std::flush; - std::cout << std::flush; - fsync(1); - fsync(2); - Pid_ = child; return true; From gohman at apple.com Tue Aug 4 19:28:59 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 00:28:59 -0000 Subject: [llvm-commits] [llvm] r78133 - /llvm/trunk/tools/lli/lli.cpp Message-ID: <200908050028.n750Sxm5027649@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 19:28:59 2009 New Revision: 78133 URL: http://llvm.org/viewvc/llvm-project?rev=78133&view=rev Log: lli doesn't need anymore. Modified: llvm/trunk/tools/lli/lli.cpp Modified: llvm/trunk/tools/lli/lli.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=78133&r1=78132&r2=78133&view=diff ============================================================================== --- llvm/trunk/tools/lli/lli.cpp (original) +++ llvm/trunk/tools/lli/lli.cpp Tue Aug 4 19:28:59 2009 @@ -31,7 +31,6 @@ #include "llvm/System/Process.h" #include "llvm/System/Signals.h" #include "llvm/Target/TargetSelect.h" -#include #include using namespace llvm; From alenhar2 at cs.uiuc.edu Tue Aug 4 19:30:23 2009 From: alenhar2 at cs.uiuc.edu (Andrew Lenharth) Date: Wed, 05 Aug 2009 00:30:23 -0000 Subject: [llvm-commits] [poolalloc] r78134 - in /poolalloc/trunk: include/rdsa/ lib/rDSA/ Message-ID: <200908050030.n750UOV4027725@zion.cs.uiuc.edu> Author: alenhar2 Date: Tue Aug 4 19:30:22 2009 New Revision: 78134 URL: http://llvm.org/viewvc/llvm-project?rev=78134&view=rev Log: New branch to clean up DSA some, may focus on precision rather than speed too Added: poolalloc/trunk/include/rdsa/ - copied from r78082, poolalloc/trunk/include/dsa/ poolalloc/trunk/include/rdsa/DSNode.h - copied, changed from r78087, poolalloc/trunk/include/dsa/DSNode.h poolalloc/trunk/lib/rDSA/ - copied from r78082, poolalloc/trunk/lib/DSA/ poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/BottomUpClosure.cpp poolalloc/trunk/lib/rDSA/CallTargets.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/CallTargets.cpp poolalloc/trunk/lib/rDSA/DataStructure.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/DataStructure.cpp poolalloc/trunk/lib/rDSA/DataStructureStats.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/DataStructureStats.cpp poolalloc/trunk/lib/rDSA/Local.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/rDSA/Printer.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/Printer.cpp poolalloc/trunk/lib/rDSA/StdLibPass.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/StdLibPass.cpp poolalloc/trunk/lib/rDSA/TopDownClosure.cpp - copied, changed from r78088, poolalloc/trunk/lib/DSA/TopDownClosure.cpp Modified: poolalloc/trunk/include/rdsa/DSGraph.h poolalloc/trunk/include/rdsa/DSGraphTraits.h poolalloc/trunk/include/rdsa/DSSupport.h poolalloc/trunk/lib/rDSA/Basic.cpp poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp poolalloc/trunk/lib/rDSA/DataStructureAA.cpp poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp poolalloc/trunk/lib/rDSA/GraphChecker.cpp poolalloc/trunk/lib/rDSA/Makefile poolalloc/trunk/lib/rDSA/Steensgaard.cpp poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp Modified: poolalloc/trunk/include/rdsa/DSGraph.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSGraph.h?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/include/rdsa/DSGraph.h (original) +++ poolalloc/trunk/include/rdsa/DSGraph.h Tue Aug 4 19:30:22 2009 @@ -15,7 +15,7 @@ #ifndef LLVM_ANALYSIS_DSGRAPH_H #define LLVM_ANALYSIS_DSGRAPH_H -#include "dsa/DSNode.h" +#include "rdsa/DSNode.h" #include "llvm/ADT/EquivalenceClasses.h" #include "poolalloc/ADT/HashExtras.h" Modified: poolalloc/trunk/include/rdsa/DSGraphTraits.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSGraphTraits.h?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/include/rdsa/DSGraphTraits.h (original) +++ poolalloc/trunk/include/rdsa/DSGraphTraits.h Tue Aug 4 19:30:22 2009 @@ -16,7 +16,7 @@ #ifndef LLVM_ANALYSIS_DSGRAPHTRAITS_H #define LLVM_ANALYSIS_DSGRAPHTRAITS_H -#include "dsa/DSGraph.h" +#include "rdsa/DSGraph.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/iterator.h" #include "llvm/ADT/STLExtras.h" Copied: poolalloc/trunk/include/rdsa/DSNode.h (from r78087, poolalloc/trunk/include/dsa/DSNode.h) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSNode.h?p2=poolalloc/trunk/include/rdsa/DSNode.h&p1=poolalloc/trunk/include/dsa/DSNode.h&r1=78087&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSNode.h (original) +++ poolalloc/trunk/include/rdsa/DSNode.h Tue Aug 4 19:30:22 2009 @@ -14,7 +14,7 @@ #ifndef LLVM_ANALYSIS_DSNODE_H #define LLVM_ANALYSIS_DSNODE_H -#include "dsa/DSSupport.h" +#include "rdsa/DSSupport.h" #include "llvm/Support/Streams.h" #include "poolalloc/ADT/HashExtras.h" @@ -289,11 +289,18 @@ /// void mergeWith(const DSNodeHandle &NH, unsigned Offset); - /// addGlobal - Add an entry for a global value to the Globals list. This - /// also marks the node with the 'G' flag if it does not already have it. + /// addGlobal - Add an entry for a global value to the Globals list. + /// This also marks the node with the 'G' flag if it does not + /// already have it. /// void addGlobal(const GlobalValue *GV); + /// addFunction - Add an entry for a function value to the + /// Functionss list. This also marks the node with the 'F' flag if + /// it does not already have it. + /// + void addFunction(const Function* FV); + /// removeGlobal - Remove the specified global that is explicitly in the /// globals list. void removeGlobal(const GlobalValue *GV); @@ -483,7 +490,7 @@ return HandleForwarding(); } -inline void DSNodeHandle::setTo(DSNode *n, unsigned NewOffset) const { +inline const DSNodeHandle& DSNodeHandle::setTo(DSNode *n, unsigned NewOffset) const { assert((!n || !n->isForwarding()) && "Cannot set node to a forwarded node!"); if (N) getNode()->NumReferrers--; N = n; @@ -499,6 +506,7 @@ assert(!N || ((N->NodeType & DSNode::DeadNode) == 0)); assert((!N || Offset < N->Size || (N->Size == 0 && Offset == 0) || N->isForwarding()) && "Node handle offset out of range!"); + return *this; } inline bool DSNodeHandle::hasLink(unsigned Num) const { Modified: poolalloc/trunk/include/rdsa/DSSupport.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSSupport.h?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/include/rdsa/DSSupport.h (original) +++ poolalloc/trunk/include/rdsa/DSSupport.h Tue Aug 4 19:30:22 2009 @@ -109,7 +109,7 @@ Offset = O; } - void setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h + const DSNodeHandle& setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h void addEdgeTo(unsigned LinkNo, const DSNodeHandle &N); void addEdgeTo(const DSNodeHandle &N) { addEdgeTo(0, N); } Modified: poolalloc/trunk/lib/rDSA/Basic.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Basic.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/Basic.cpp (original) +++ poolalloc/trunk/lib/rDSA/Basic.cpp Tue Aug 4 19:30:22 2009 @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" Copied: poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp (from r78088, poolalloc/trunk/lib/DSA/BottomUpClosure.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp?p2=poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp&p1=poolalloc/trunk/lib/DSA/BottomUpClosure.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp Tue Aug 4 19:30:22 2009 @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "dsa-bu" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" @@ -54,14 +54,14 @@ calculateGraphs(MainFunc, Stack, NextID, ValMap); CloneAuxIntoGlobal(getDSGraph(*MainFunc)); } else { - DEBUG(ferrs() << debugname << ": No 'main' function found!\n"); + DEBUG(errs() << debugname << ": No 'main' function found!\n"); } // Calculate the graphs for any functions that are unreachable from main... for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration() && !hasDSGraph(*I)) { if (MainFunc) - DEBUG(ferrs() << debugname << ": Function unreachable from main: " + DEBUG(errs() << debugname << ": Function unreachable from main: " << I->getName() << "\n"); calculateGraphs(I, Stack, NextID, ValMap); // Calculate all graphs. CloneAuxIntoGlobal(getDSGraph(*I)); @@ -263,12 +263,12 @@ // If this is a new SCC, process it now. if (Stack.back() == F) { // Special case the single "SCC" case here. - DEBUG(ferrs() << "Visiting single node SCC #: " << MyID << " fn: " + DEBUG(errs() << "Visiting single node SCC #: " << MyID << " fn: " << F->getName() << "\n"); Stack.pop_back(); - DEBUG(ferrs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); + DEBUG(errs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); calculateGraph(Graph); - DEBUG(ferrs() << " [BU] Done inlining: " << F->getName() << " [" + DEBUG(errs() << " [BU] Done inlining: " << F->getName() << " [" << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size() << "]\n"); @@ -297,7 +297,7 @@ ResolvedFuncs.resize(uid - ResolvedFuncs.begin()); if (ResolvedFuncs.size() || NewCalleeFuncs.size()) { - DEBUG(ferrs() << "Recalculating " << F->getName() << " due to new knowledge\n"); + DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n"); ValMap.erase(F); return calculateGraphs(F, Stack, NextID, ValMap); } else { @@ -341,7 +341,7 @@ } Stack.pop_back(); - DEBUG(ferrs() << "Calculating graph for SCC #: " << MyID << " of size: " + DEBUG(errs() << "Calculating graph for SCC #: " << MyID << " of size: " << SCCSize << "\n"); // Compute the Max SCC Size. @@ -354,7 +354,7 @@ // Now that we have one big happy family, resolve all of the call sites in // the graph... calculateGraph(SCCGraph); - DEBUG(ferrs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() + DEBUG(errs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n" << "DONE with SCC #: " << MyID << "\n"); @@ -473,7 +473,7 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline DEBUG(GI->AssertGraphOK(); GI->getGlobalsGraph()->AssertGraphOK()); - DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + DEBUG(errs() << " Inlining graph for " << Callee->getName() << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -484,19 +484,19 @@ ++NumInlines; DEBUG(Graph->AssertGraphOK();); } else if (CalledFuncs.size() > 1) { - DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); - DEBUG(ferrs() << " calls " << CalledFuncs.size() + DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(errs() << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(ferrs() << " Fns ="); + DEBUG(errs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) if (NumPrinted++ < 8) { - DEBUG(ferrs() << " " << (*I)->getName()); + DEBUG(errs() << " " << (*I)->getName()); } - DEBUG(ferrs() << "\n"); + DEBUG(errs() << "\n"); if (!isComplete) { for (unsigned x = 0; x < CalledFuncs.size(); ) @@ -547,13 +547,13 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); + DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG(ferrs() << " Inlining multi callee graph " + DEBUG(errs() << " Inlining multi callee graph " << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -622,7 +622,7 @@ // Get the data structure graph for the called function. GI = getDSGraph(*Callee); // Graph to inline if (GI == Graph) continue; - DEBUG(ferrs() << " Inlining graph for " << Callee->getName() + DEBUG(errs() << " Inlining graph for " << Callee->getName() << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" @@ -631,19 +631,19 @@ DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes); ++NumInlines; } else { - DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n"); + DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n"); DEBUG(std::cerr << " calls " << CalledFuncs.size() << " fns from site: " << CS.getCallSite().getInstruction() << " " << *CS.getCallSite().getInstruction()); - DEBUG(ferrs() << " Fns ="); + DEBUG(errs() << " Fns ="); unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) if (NumPrinted++ < 8) { - DEBUG(ferrs() << " " << (*I)->getName()); + DEBUG(errs() << " " << (*I)->getName()); } - DEBUG(ferrs() << "\n"); + DEBUG(errs() << "\n"); for (unsigned x = 0; x < CalledFuncs.size(); ) if (!hasDSGraph(*CalledFuncs[x])) @@ -696,13 +696,13 @@ // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n"); + DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n"); } GI = IndCallGraph.first; // Merge the unified graph into this graph now. - DEBUG(ferrs() << " Inlining multi callee graph " + DEBUG(errs() << " Inlining multi callee graph " << "[" << GI->getGraphSize() << "+" << GI->getAuxFunctionCalls().size() << "] into '" << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+" Copied: poolalloc/trunk/lib/rDSA/CallTargets.cpp (from r78088, poolalloc/trunk/lib/DSA/CallTargets.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/CallTargets.cpp?p2=poolalloc/trunk/lib/rDSA/CallTargets.cpp&p1=poolalloc/trunk/lib/DSA/CallTargets.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CallTargets.cpp (original) +++ poolalloc/trunk/lib/rDSA/CallTargets.cpp Tue Aug 4 19:30:22 2009 @@ -19,9 +19,9 @@ #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" -#include "dsa/CallTargets.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" +#include "rdsa/CallTargets.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormattedStream.h" @@ -74,7 +74,7 @@ } if (N->isCompleteNode() && !IndMap[cs].size()) { ++CompleteEmpty; - DEBUG(ferrs() << "Call site empty: '" + DEBUG(errs() << "Call site empty: '" << cs.getInstruction()->getName() << "' In '" << cs.getInstruction()->getParent()->getParent()->getName() Modified: poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp (original) +++ poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp Tue Aug 4 19:30:22 2009 @@ -14,8 +14,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "dsa-cbu" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Module.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Debug.h" Copied: poolalloc/trunk/lib/rDSA/DataStructure.cpp (from r78088, poolalloc/trunk/lib/DSA/DataStructure.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructure.cpp?p2=poolalloc/trunk/lib/rDSA/DataStructure.cpp&p1=poolalloc/trunk/lib/DSA/DataStructure.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/rDSA/DataStructure.cpp Tue Aug 4 19:30:22 2009 @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DSGraphTraits.h" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" -#include "dsa/DSSupport.h" +#include "rdsa/DSGraphTraits.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" +#include "rdsa/DSSupport.h" #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" @@ -234,6 +234,14 @@ } } +/// addFunction - Add an entry for a function value to the +/// Functionss list. This also marks the node with the 'F' flag if +/// it does not already have it. +/// +void DSNode::addFunction(const Function* FV) { + addGlobal(FV); +} + // removeGlobal - Remove the specified global that is explicitly in the globals // list. void DSNode::removeGlobal(const GlobalValue *GV) { Modified: poolalloc/trunk/lib/rDSA/DataStructureAA.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureAA.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/DataStructureAA.cpp (original) +++ poolalloc/trunk/lib/rDSA/DataStructureAA.cpp Tue Aug 4 19:30:22 2009 @@ -18,8 +18,8 @@ #include "llvm/Module.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/Passes.h" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" using namespace llvm; namespace { Modified: poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp (original) +++ poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp Tue Aug 4 19:30:22 2009 @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Analysis/Passes.h" #include "llvm/Module.h" #include "llvm/Constant.h" Copied: poolalloc/trunk/lib/rDSA/DataStructureStats.cpp (from r78088, poolalloc/trunk/lib/DSA/DataStructureStats.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureStats.cpp?p2=poolalloc/trunk/lib/rDSA/DataStructureStats.cpp&p1=poolalloc/trunk/lib/DSA/DataStructureStats.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original) +++ poolalloc/trunk/lib/rDSA/DataStructureStats.cpp Tue Aug 4 19:30:22 2009 @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" @@ -97,7 +97,7 @@ totalNumCallees += Callees.size(); ++numIndirectCalls; } else { - DEBUG(ferrs() << "WARNING: No callee in Function '" + DEBUG(errs() << "WARNING: No callee in Function '" << F.getNameStr() << "' at call: \n" << *I->getCallSite().getInstruction()); } @@ -107,7 +107,7 @@ NumIndirectCalls += numIndirectCalls; if (numIndirectCalls) { - DEBUG(ferrs() << " In function " << F.getName() << ": " + DEBUG(errs() << " In function " << F.getName() << ": " << (totalNumCallees / (double) numIndirectCalls) << " average callees per indirect call\n"); } Modified: poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp (original) +++ poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp Tue Aug 4 19:30:22 2009 @@ -15,11 +15,11 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "ECGraphs" -#include "dsa/DataStructure.h" +#include "rdsa/DataStructure.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "dsa/DSGraph.h" +#include "rdsa/DSGraph.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Debug.h" #include "llvm/ADT/SCCIterator.h" Modified: poolalloc/trunk/lib/rDSA/GraphChecker.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/GraphChecker.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/GraphChecker.cpp (original) +++ poolalloc/trunk/lib/rDSA/GraphChecker.cpp Tue Aug 4 19:30:22 2009 @@ -23,8 +23,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Streams.h" #include "llvm/Value.h" Copied: poolalloc/trunk/lib/rDSA/Local.cpp (from r78088, poolalloc/trunk/lib/DSA/Local.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Local.cpp?p2=poolalloc/trunk/lib/rDSA/Local.cpp&p1=poolalloc/trunk/lib/DSA/Local.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/rDSA/Local.cpp Tue Aug 4 19:30:22 2009 @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -41,42 +41,100 @@ X("dsa-local", "Local Data Structure Analysis"); namespace { + //===--------------------------------------------------------------------===// - // GraphBuilder Class + // GraphBuilderBase Class //===--------------------------------------------------------------------===// // - /// This class is the builder class that constructs the local data structure - /// graph by performing a single pass over the function in question. + /// This class contains the common graph building coe. /// - class GraphBuilder : InstVisitor { - DSGraph &G; - Function* FB; - DataStructures* DS; - - //////////////////////////////////////////////////////////////////////////// - // Helper functions used to implement the visitation functions... - - void MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C); - + class GraphBuilderBase { + DSGraph* G; + protected: /// createNode - Create a new DSNode, ensuring that it is properly added to /// the graph. /// - DSNode *createNode(const Type *Ty = 0) - { - DSNode* ret = new DSNode(Ty, &G); - assert(ret->getParentGraph() && "No parent?"); - return ret; + DSNode* createNode(const Type *Ty = 0) { + return new DSNode(Ty, G); + } + DSNode* createNode(const Type *Ty, GlobalVariable* GV) { + DSNode* N = new DSNode(Ty, G); + N->addGlobal(GV); + return N; + } + DSNode* createNode(const Type *Ty, Function* FV) { + DSNode* N = new DSNode(Ty, G); + N->addFunction(FV); + return N; + } + + DSNodeHandle& getNodeForValue(const Value *V) { + return G->getScalarMap()[V]; + } + + bool hasNodeForValue(const Value* V) const { + return G->hasNodeForValue(V); + } + void eraseNodeForValue(const Value* V) { + G->eraseNodeForValue(V); + } + + void addDSCallSite(const DSCallSite& DSCS) { + G->getFunctionCalls().push_back(DSCS); } + /// getValueDest - Return the DSNode that the actual value points to. + /// + DSNodeHandle getValueDest(Value &V); + /// setDestTo - Set the ScalarMap entry for the specified value to point to /// the specified destination. If the Value already points to a node, make /// sure to merge the two destinations together. /// void setDestTo(Value &V, const DSNodeHandle &NH); - /// getValueDest - Return the DSNode that the actual value points to. - /// - DSNodeHandle getValueDest(Value &V); + void visitGetElementPtrInst(User &GEP); + + GraphBuilderBase(DSGraph* _G) :G(_G) {} + + }; + + //===--------------------------------------------------------------------===// + // GraphBuilderGlobal Class + //===--------------------------------------------------------------------===// + // + /// This class is the builder class that constructs the local data structure + /// graph by performing a single pass over the function in question. + /// + class GraphBuilderGlobal : GraphBuilderBase { + + void MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C); + + public: + // GraphBuilderGlobal ctor for working on the globals graph + explicit GraphBuilderGlobal(DSGraph* g) + :GraphBuilderBase(g) + {} + + void mergeInGlobalInitializer(GlobalVariable *GV); + void mergeFunction(Function& F) { getValueDest(F); } + + }; + + + //===--------------------------------------------------------------------===// + // GraphBuilderLocal Class + //===--------------------------------------------------------------------===// + // + /// This class is the builder class that constructs the local data structure + /// graph by performing a single pass over the function in question. + /// + class GraphBuilderLocal : GraphBuilderBase, InstVisitor { + DataStructures* DS; + DSNodeHandle& RetNode; + + //////////////////////////////////////////////////////////////////////////// + // Helper functions used to implement the visitation functions... /// getLink - This method is used to return the specified link in the /// specified node if one exists. If a link does not already exist (it's @@ -86,7 +144,7 @@ //////////////////////////////////////////////////////////////////////////// // Visitor functions, used to handle each instruction type we encounter... - friend class InstVisitor; + friend class InstVisitor; void visitMallocInst(MallocInst &MI) { setDestTo(MI, createNode()->setHeapMarker()); } @@ -111,18 +169,23 @@ void visitBitCastInst(BitCastInst &I); void visitCmpInst(CmpInst &I); + void visitExtractValueInst(ExtractValueInst &I); + void visitInsertValueInst(InsertValueInst &I); + //the nasty ones - void visitGetElementPtrInst(User &GEP); void visitCallInst(CallInst &CI); void visitInvokeInst(InvokeInst &II); void visitInstruction(Instruction &I); + void visitGetElementPtrInst(User &GEP) { + GraphBuilderBase::visitGetElementPtrInst(GEP); + } bool visitIntrinsic(CallSite CS, Function* F); void visitCallSite(CallSite CS); public: - GraphBuilder(Function &f, DSGraph &g, DataStructures& DSi) - : G(g), FB(&f), DS(&DSi) { + GraphBuilderLocal(Function& f, DSNodeHandle& retnode, DSGraph* g, DataStructures& DSi) + : GraphBuilderBase(g), DS(&DSi), RetNode(retnode) { // Create scalar nodes for all pointer arguments... for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end(); I != E; ++I) { @@ -135,37 +198,26 @@ } } - // Create an entry for the return, which tracks which functions are in - // the graph - g.getOrCreateReturnNodeFor(f); - visit(f); // Single pass over the function // If there are any constant globals referenced in this function, merge // their initializers into the local graph from the globals graph. - if (g.getScalarMap().global_begin() != g.getScalarMap().global_end()) { - ReachabilityCloner RC(&g, g.getGlobalsGraph(), 0); + if (g->getScalarMap().global_begin() != g->getScalarMap().global_end()) { + ReachabilityCloner RC(g, g->getGlobalsGraph(), 0); - for (DSScalarMap::global_iterator I = g.getScalarMap().global_begin(); - I != g.getScalarMap().global_end(); ++I) + for (DSScalarMap::global_iterator I = g->getScalarMap().global_begin(); + I != g->getScalarMap().global_end(); ++I) if (const GlobalVariable *GV = dyn_cast(*I)) if (!GV->isDeclaration() && GV->isConstant()) - RC.merge(g.getNodeForValue(GV), g.getGlobalsGraph()->getNodeForValue(GV)); + RC.merge(g->getNodeForValue(GV), g->getGlobalsGraph()->getNodeForValue(GV)); } - g.markIncompleteNodes(DSGraph::MarkFormalArgs); + g->markIncompleteNodes(DSGraph::MarkFormalArgs); // Remove any nodes made dead due to merging... - g.removeDeadNodes(DSGraph::KeepUnreachableGlobals); + g->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } - // GraphBuilder ctor for working on the globals graph - explicit GraphBuilder(DSGraph& g) - :G(g), FB(0) - {} - - void mergeInGlobalInitializer(GlobalVariable *GV); - void mergeFunction(Function& F) { getValueDest(F); } }; /// Traverse the whole DSGraph, and propagate the unknown flags through all @@ -198,28 +250,37 @@ /// /// getValueDest - Return the DSNode that the actual value points to. /// -DSNodeHandle GraphBuilder::getValueDest(Value &Val) { +DSNodeHandle GraphBuilderBase::getValueDest(Value &Val) { Value *V = &Val; if (isa(V) && cast(V)->isNullValue()) return 0; // Null doesn't point to anything, don't add to ScalarMap! - DSNodeHandle &NH = G.getNodeForValue(V); + DSNodeHandle &NH = getNodeForValue(V); if (!NH.isNull()) return NH; // Already have a node? Just return it... // Otherwise we need to create a new node to point to. + + if (GlobalVariable* GV = dyn_cast(V)) + // Create a new global node for this global variable. + return NH.setTo(createNode(GV->getType()->getElementType(), GV), 0); + + if (Function* FV = dyn_cast(V)) + // Create a new global node for this global variable. + return NH.setTo(createNode(0, FV), 0); + + if (GlobalAlias* GA = dyn_cast(V)) + return NH = getValueDest(*(GA->getAliasee())); + + if (isa(V)) { + eraseNodeForValue(V); + return 0; + } + // Check first for constant expressions that must be traversed to // extract the actual value. DSNode* N; - if (GlobalVariable* GV = dyn_cast(V)) { - // Create a new global node for this global variable. - N = createNode(GV->getType()->getElementType()); - N->addGlobal(GV); - } else if (Function* GV = dyn_cast(V)) { - // Create a new global node for this global variable. - N = createNode(); - N->addGlobal(GV); - } else if (Constant *C = dyn_cast(V)) { + if (Constant *C = dyn_cast(V)) { if (ConstantExpr *CE = dyn_cast(C)) { if (CE->isCast()) { if (isa(CE->getOperand(0)->getType())) @@ -228,29 +289,19 @@ NH = createNode()->setUnknownMarker(); } else if (CE->getOpcode() == Instruction::GetElementPtr) { visitGetElementPtrInst(*CE); - assert(G.hasNodeForValue(CE) && "GEP didn't get processed right?"); - NH = G.getNodeForValue(CE); + assert(hasNodeForValue(CE) && "GEP didn't get processed right?"); + NH = getNodeForValue(CE); } else { // This returns a conservative unknown node for any unhandled ConstExpr return NH = createNode()->setUnknownMarker(); } if (NH.isNull()) { // (getelementptr null, X) returns null - G.eraseNodeForValue(V); + eraseNodeForValue(V); return 0; } return NH; - } else if (isa(C)) { - G.eraseNodeForValue(V); - return 0; - } else if (isa(C)) { - // XXX: Need more investigation - // According to Andrew, DSA is broken on global aliasing, since it does - // not handle the aliases of parameters correctly. Here is only a quick - // fix for some special cases. - NH = getValueDest(*(cast(C)->getAliasee())); - return 0; } else { - DEBUG(ferrs() << "Unknown constant: " << *C << "\n"); + DEBUG(errs() << "Unknown constant: " << *C << "\n"); assert(0 && "Unknown constant type!"); } N = createNode(); // just create a shadow node @@ -259,8 +310,7 @@ N = createNode(); } - NH.setTo(N, 0); // Remember that we are pointing to it... - return NH; + return NH.setTo(N, 0); // Remember that we are pointing to it... } @@ -270,7 +320,7 @@ /// specify the type of the Node field we are accessing so that we know what /// type should be linked to if we need to create a new node. /// -DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) { +DSNodeHandle &GraphBuilderLocal::getLink(const DSNodeHandle &node, unsigned LinkNo) { DSNodeHandle &Node = const_cast(node); DSNodeHandle &Link = Node.getLink(LinkNo); if (Link.isNull()) { @@ -285,8 +335,8 @@ /// specified destination. If the Value already points to a node, make sure to /// merge the two destinations together. /// -void GraphBuilder::setDestTo(Value &V, const DSNodeHandle &NH) { - G.getNodeForValue(&V).mergeWith(NH); +void GraphBuilderBase::setDestTo(Value &V, const DSNodeHandle &NH) { + getNodeForValue(&V).mergeWith(NH); } @@ -297,26 +347,26 @@ // PHINode - Make the scalar for the PHI node point to all of the things the // incoming values point to... which effectively causes them to be merged. // -void GraphBuilder::visitPHINode(PHINode &PN) { +void GraphBuilderLocal::visitPHINode(PHINode &PN) { if (!isa(PN.getType())) return; // Only pointer PHIs - DSNodeHandle &PNDest = G.getNodeForValue(&PN); + DSNodeHandle &PNDest = getNodeForValue(&PN); for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i))); } -void GraphBuilder::visitSelectInst(SelectInst &SI) { +void GraphBuilderLocal::visitSelectInst(SelectInst &SI) { if (!isa(SI.getType())) return; // Only pointer Selects - DSNodeHandle &Dest = G.getNodeForValue(&SI); + DSNodeHandle &Dest = getNodeForValue(&SI); DSNodeHandle S1 = getValueDest(*SI.getOperand(1)); DSNodeHandle S2 = getValueDest(*SI.getOperand(2)); Dest.mergeWith(S1); Dest.mergeWith(S2); } -void GraphBuilder::visitLoadInst(LoadInst &LI) { +void GraphBuilderLocal::visitLoadInst(LoadInst &LI) { DSNodeHandle Ptr = getValueDest(*LI.getOperand(0)); if (Ptr.isNull()) return; // Load from null @@ -331,7 +381,7 @@ setDestTo(LI, getLink(Ptr)); } -void GraphBuilder::visitStoreInst(StoreInst &SI) { +void GraphBuilderLocal::visitStoreInst(StoreInst &SI) { const Type *StoredTy = SI.getOperand(0)->getType(); DSNodeHandle Dest = getValueDest(*SI.getOperand(1)); if (Dest.isNull()) return; @@ -347,12 +397,12 @@ Dest.addEdgeTo(getValueDest(*SI.getOperand(0))); } -void GraphBuilder::visitReturnInst(ReturnInst &RI) { +void GraphBuilderLocal::visitReturnInst(ReturnInst &RI) { if (RI.getNumOperands() && isa(RI.getOperand(0)->getType())) - G.getOrCreateReturnNodeFor(*FB).mergeWith(getValueDest(*RI.getOperand(0))); + RetNode.mergeWith(getValueDest(*RI.getOperand(0))); } -void GraphBuilder::visitVAArgInst(VAArgInst &I) { +void GraphBuilderLocal::visitVAArgInst(VAArgInst &I) { //FIXME: also updates the argument DSNodeHandle Ptr = getValueDest(*I.getOperand(0)); if (Ptr.isNull()) return; @@ -368,30 +418,30 @@ setDestTo(I, getLink(Ptr)); } -void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) { +void GraphBuilderLocal::visitIntToPtrInst(IntToPtrInst &I) { // std::cerr << "cast in " << I.getParent()->getParent()->getName() << "\n"; // I.dump(); setDestTo(I, createNode()->setUnknownMarker()->setIntToPtrMarker()); } -void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) { +void GraphBuilderLocal::visitPtrToIntInst(PtrToIntInst& I) { if (DSNode* N = getValueDest(*I.getOperand(0)).getNode()) N->setPtrToIntMarker(); } -void GraphBuilder::visitBitCastInst(BitCastInst &I) { +void GraphBuilderLocal::visitBitCastInst(BitCastInst &I) { if (!isa(I.getType())) return; // Only pointers DSNodeHandle Ptr = getValueDest(*I.getOperand(0)); if (Ptr.isNull()) return; setDestTo(I, Ptr); } -void GraphBuilder::visitCmpInst(CmpInst &I) { - //Should this merge or not? I don't think so. +void GraphBuilderLocal::visitCmpInst(CmpInst &I) { + // TODO: must merge pointers } -void GraphBuilder::visitGetElementPtrInst(User &GEP) { +void GraphBuilderBase::visitGetElementPtrInst(User &GEP) { DSNodeHandle Value = getValueDest(*GEP.getOperand(0)); if (Value.isNull()) Value = createNode(); @@ -488,7 +538,7 @@ // Variable index into a node. We must merge all of the elements of the // sequential type here. if (isa(STy)) { - DEBUG(ferrs() << "Pointer indexing not handled yet!\n"); + DEBUG(errs() << "Pointer indexing not handled yet!\n"); } else { const ArrayType *ATy = cast(STy); unsigned ElSize = TD.getTypeAllocSize(CurTy); @@ -537,7 +587,7 @@ { if (G.getPoolDescriptorsMap().count(N) != 0) if (G.getPoolDescriptorsMap()[N]) { - DEBUG(ferrs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"); + DEBUG(errs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n"); } } } @@ -546,16 +596,16 @@ } -void GraphBuilder::visitCallInst(CallInst &CI) { +void GraphBuilderLocal::visitCallInst(CallInst &CI) { visitCallSite(&CI); } -void GraphBuilder::visitInvokeInst(InvokeInst &II) { +void GraphBuilderLocal::visitInvokeInst(InvokeInst &II) { visitCallSite(&II); } /// returns true if the intrinsic is handled -bool GraphBuilder::visitIntrinsic(CallSite CS, Function *F) { +bool GraphBuilderLocal::visitIntrinsic(CallSite CS, Function *F) { switch (F->getIntrinsicID()) { case Intrinsic::vastart: { // Mark the memory written by the vastart intrinsic as incomplete @@ -697,14 +747,14 @@ return true; } - DEBUG(ferrs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); + DEBUG(errs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n"); assert(0 && "Unhandled intrinsic"); return false; } } } -void GraphBuilder::visitCallSite(CallSite CS) { +void GraphBuilderLocal::visitCallSite(CallSite CS) { Value *Callee = CS.getCalledValue(); // Special case handling of certain libc allocation functions here. @@ -728,7 +778,7 @@ if (!isa(Callee)) { CalleeNode = getValueDest(*Callee).getNode(); if (CalleeNode == 0) { - DEBUG(ferrs() << "WARNING: Program is calling through a null pointer?\n" << *I); + DEBUG(errs() << "WARNING: Program is calling through a null pointer?\n" << *I); return; // Calling a null pointer? } } @@ -740,20 +790,21 @@ for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I) if (isa((*I)->getType())) Args.push_back(getValueDest(**I)); + else + Args.push_back(0); // Add a new function call entry... if (CalleeNode) { - G.getFunctionCalls().push_back(DSCallSite(CS, RetVal, CalleeNode, Args)); + addDSCallSite(DSCallSite(CS, RetVal, CalleeNode, Args)); DS->callee_site(CS.getInstruction()); - }else - G.getFunctionCalls().push_back(DSCallSite(CS, RetVal, cast(Callee), - Args)); + } else + addDSCallSite(DSCallSite(CS, RetVal, cast(Callee), Args)); } // visitInstruction - For all other instruction types, if we have any arguments // that are of pointer type, make them have unknown composition bits, and merge // the nodes together. -void GraphBuilder::visitInstruction(Instruction &Inst) { +void GraphBuilderLocal::visitInstruction(Instruction &Inst) { DSNodeHandle CurNode; if (isa(Inst.getType())) CurNode = getValueDest(Inst); @@ -765,6 +816,13 @@ N->setUnknownMarker(); } +void GraphBuilderLocal::visitExtractValueInst(ExtractValueInst &I) { + assert(!isa(I.getType()) && "ExtractValue not supported"); +} + +void GraphBuilderLocal::visitInsertValueInst(InsertValueInst &I) { + assert(!isa((*(I.op_begin()))->getType()) && "InsertValue not supported"); +} //===----------------------------------------------------------------------===// @@ -773,7 +831,7 @@ // MergeConstantInitIntoNode - Merge the specified constant into the node // pointed to by NH. -void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C) { +void GraphBuilderGlobal::MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C) { // Ensure a type-record exists... DSNode *NHN = NH.getNode(); NHN->mergeTypeInfo(Ty, NH.getOffset()); @@ -814,13 +872,14 @@ } } -void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) { +void GraphBuilderGlobal::mergeInGlobalInitializer(GlobalVariable *GV) { assert(!GV->isDeclaration() && "Cannot merge in external global!"); // Get a node handle to the global node and merge the initializer into it. DSNodeHandle NH = getValueDest(*GV); MergeConstantInitIntoNode(NH, GV->getType()->getElementType(), GV->getInitializer()); } + char LocalDataStructures::ID; bool LocalDataStructures::runOnModule(Module &M) { @@ -828,7 +887,7 @@ // First step, build the globals graph. { - GraphBuilder GGB(*GlobalsGraph); + GraphBuilderGlobal GGB(GlobalsGraph); // Add initializers for all of the globals to the globals graph. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); @@ -849,7 +908,7 @@ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isDeclaration()) { DSGraph* G = new DSGraph(GlobalECs, getTargetData(), GlobalsGraph); - GraphBuilder GGB(*I, *G, *this); + GraphBuilderLocal GGB(*I, G->getOrCreateReturnNodeFor(*I), G, *this); G->getAuxFunctionCalls() = G->getFunctionCalls(); setDSGraph(*I, G); propagateUnknownFlag(G); Modified: poolalloc/trunk/lib/rDSA/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Makefile?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/Makefile (original) +++ poolalloc/trunk/lib/rDSA/Makefile Tue Aug 4 19:30:22 2009 @@ -10,7 +10,7 @@ LEVEL = ../.. BUILD_RELINKED=1 SHARED_LIBRARY=1 -LIBRARYNAME = LLVMDataStructure +LIBRARYNAME = rDSA include $(LEVEL)/Makefile.common Copied: poolalloc/trunk/lib/rDSA/Printer.cpp (from r78088, poolalloc/trunk/lib/DSA/Printer.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Printer.cpp?p2=poolalloc/trunk/lib/rDSA/Printer.cpp&p1=poolalloc/trunk/lib/DSA/Printer.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Printer.cpp (original) +++ poolalloc/trunk/lib/rDSA/Printer.cpp Tue Aug 4 19:30:22 2009 @@ -13,8 +13,8 @@ #define DEBUG_TYPE "dsgraph-printer" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "dsa/DSGraphTraits.h" #include "llvm/Module.h" #include "llvm/Constants.h" @@ -339,17 +339,16 @@ << "] nodes total" << std::endl; } - void DataStructures::dumpCallGraph() const { for( ActualCalleesTy::const_iterator ii = ActualCallees.begin(), ee = ActualCallees.end(); ii != ee; ++ii) { - if (ii->first) ferrs() << ii->first->getParent()->getParent()->getName() << " "; - ferrs() << ii->first << ": ["; + if (ii->first) errs() << ii->first->getParent()->getParent()->getName() << " "; + errs() << ii->first << ": ["; for (callee_iterator cbi = ii->second.begin(), cbe = ii->second.end(); cbi != cbe; ++cbi) { - ferrs() << (*cbi)->getName() << " "; + errs() << (*cbi)->getName() << " "; } - ferrs() << "]\n"; + errs() << "]\n"; if (ii->first) ii->first->dump(); } } Copied: poolalloc/trunk/lib/rDSA/StdLibPass.cpp (from r78088, poolalloc/trunk/lib/DSA/StdLibPass.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/StdLibPass.cpp?p2=poolalloc/trunk/lib/rDSA/StdLibPass.cpp&p1=poolalloc/trunk/lib/DSA/StdLibPass.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/rDSA/StdLibPass.cpp Tue Aug 4 19:30:22 2009 @@ -10,8 +10,8 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/Statistic.h" -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" @@ -183,7 +183,7 @@ if (CI->getOperand(0) == F) { DSGraph* Graph = getDSGraph(*CI->getParent()->getParent()); //delete the call - DEBUG(ferrs() << "Removing " << F->getNameStr() << " from " + DEBUG(errs() << "Removing " << F->getNameStr() << " from " << CI->getParent()->getParent()->getNameStr() << "\n"); Graph->removeFunctionCalls(*F); } Modified: poolalloc/trunk/lib/rDSA/Steensgaard.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Steensgaard.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/Steensgaard.cpp (original) +++ poolalloc/trunk/lib/rDSA/Steensgaard.cpp Tue Aug 4 19:30:22 2009 @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/Passes.h" #include "llvm/Module.h" Modified: poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp?rev=78134&r1=78082&r2=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp (original) +++ poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp Tue Aug 4 19:30:22 2009 @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#include "dsa/DataStructure.h" -#include "dsa/DSGraph.h" +#include "rdsa/DataStructure.h" +#include "rdsa/DSGraph.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/Passes.h" #include "llvm/Module.h" Copied: poolalloc/trunk/lib/rDSA/TopDownClosure.cpp (from r78088, poolalloc/trunk/lib/DSA/TopDownClosure.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/TopDownClosure.cpp?p2=poolalloc/trunk/lib/rDSA/TopDownClosure.cpp&p1=poolalloc/trunk/lib/DSA/TopDownClosure.cpp&r1=78088&r2=78134&rev=78134&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/trunk/lib/rDSA/TopDownClosure.cpp Tue Aug 4 19:30:22 2009 @@ -15,10 +15,10 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "td_dsa" -#include "dsa/DataStructure.h" +#include "rdsa/DataStructure.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" -#include "dsa/DSGraph.h" +#include "rdsa/DSGraph.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" @@ -198,7 +198,7 @@ RC.getClonedNH(GG->getNodeForValue(*GI)); } - DEBUG(ferrs() << "[TD] Inlining callers into '" + DEBUG(errs() << "[TD] Inlining callers into '" << DSG->getFunctionNames() << "'\n"); // Iteratively inline caller graphs into this graph. @@ -215,15 +215,15 @@ do { const DSCallSite &CS = *EdgesFromCaller.back().CS; const Function &CF = *EdgesFromCaller.back().CalledFunction; - DEBUG(ferrs() << " [TD] Inlining graph into Fn '" + DEBUG(errs() << " [TD] Inlining graph into Fn '" << CF.getNameStr() << "' from "); if (CallerGraph->getReturnNodes().empty()) { - DEBUG(ferrs() << "SYNTHESIZED INDIRECT GRAPH"); + DEBUG(errs() << "SYNTHESIZED INDIRECT GRAPH"); } else { - DEBUG(ferrs() << "Fn '" << CS.getCallSite().getInstruction()-> + DEBUG(errs() << "Fn '" << CS.getCallSite().getInstruction()-> getParent()->getParent()->getNameStr() << "'"); } - DEBUG(ferrs() << ": " << CF.getFunctionType()->getNumParams() + DEBUG(errs() << ": " << CF.getFunctionType()->getNumParams() << " args\n"); // Get the formal argument and return nodes for the called function and @@ -339,7 +339,7 @@ // If we already have this graph, recycle it. if (IndCallRecI != IndCallMap.end() && IndCallRecI->first == Callees) { - DEBUG(ferrs() << " [TD] *** Reuse of indcall graph for " << Callees.size() + DEBUG(errs() << " [TD] *** Reuse of indcall graph for " << Callees.size() << " callees!\n"); IndCallGraph = IndCallRecI->second; } else { From gohman at apple.com Tue Aug 4 19:44:03 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 00:44:03 -0000 Subject: [llvm-commits] [llvm] r78135 - /llvm/trunk/lib/Support/GraphWriter.cpp Message-ID: <200908050044.n750i3Dp028143@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 19:44:01 2009 New Revision: 78135 URL: http://llvm.org/viewvc/llvm-project?rev=78135&view=rev Log: cerr isn't buffered so it doesn't need to be flushed. Modified: llvm/trunk/lib/Support/GraphWriter.cpp Modified: llvm/trunk/lib/Support/GraphWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/GraphWriter.cpp?rev=78135&r1=78134&r2=78135&view=diff ============================================================================== --- llvm/trunk/lib/Support/GraphWriter.cpp (original) +++ llvm/trunk/lib/Support/GraphWriter.cpp Tue Aug 4 19:44:01 2009 @@ -29,7 +29,7 @@ args.push_back(Filename.c_str()); args.push_back(0); - cerr << "Running 'Graphviz' program... " << std::flush; + cerr << "Running 'Graphviz' program... "; if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,0,&ErrMsg)) { cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n"; } @@ -98,7 +98,7 @@ args.push_back(PSFilename.c_str()); args.push_back(0); - cerr << "Running '" << prog << "' program... " << std::flush; + cerr << "Running '" << prog << "' program... "; if (sys::Program::ExecuteAndWait(prog, &args[0],0,0,0,0,&ErrMsg)) { cerr << "Error viewing graph " << Filename << ": '" << ErrMsg << "\n"; @@ -133,7 +133,7 @@ args.push_back(Filename.c_str()); args.push_back(0); - cerr << "Running 'dotty' program... " << std::flush; + cerr << "Running 'dotty' program... "; if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,0,&ErrMsg)) { cerr << "Error viewing graph " << Filename << ": " << ErrMsg << "\n"; } else { From bob.wilson at apple.com Tue Aug 4 19:49:09 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 05 Aug 2009 00:49:09 -0000 Subject: [llvm-commits] [llvm] r78136 - in /llvm/trunk/lib/Target/ARM: ARMISelDAGToDAG.cpp ARMISelLowering.cpp ARMInstrNEON.td ARMTargetMachine.cpp Message-ID: <200908050049.n750n91q028324@zion.cs.uiuc.edu> Author: bwilson Date: Tue Aug 4 19:49:09 2009 New Revision: 78136 URL: http://llvm.org/viewvc/llvm-project?rev=78136&view=rev Log: Change DAG nodes for Neon VLD2/3/4 operations to return multiple results. Get rid of yesterday's code to fix the register usage during isel. Select the new DAG nodes to machine instructions. The new pre-alloc pass to choose adjacent registers for these results is not done, so the results of this will generally not assemble yet. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=78136&r1=78135&r2=78136&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Tue Aug 4 19:49:09 2009 @@ -1284,7 +1284,7 @@ MVT HalfVT; unsigned Opc = 0; switch (VT.getVectorElementType().getSimpleVT()) { - default: assert(false && "unhandled VDUP splat type"); + default: llvm_unreachable("unhandled VDUP splat type"); case MVT::i8: Opc = ARM::VDUPLN8q; HalfVT = MVT::v8i8; break; case MVT::i16: Opc = ARM::VDUPLN16q; HalfVT = MVT::v4i16; break; case MVT::i32: Opc = ARM::VDUPLN32q; HalfVT = MVT::v2i32; break; @@ -1304,6 +1304,62 @@ break; } + + case ARMISD::VLD2D: { + MVT VT = Op.getValueType(); + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc)) + return NULL; + unsigned Opc; + switch (VT.getSimpleVT()) { + default: llvm_unreachable("unhandled VLD2D type"); + case MVT::v8i8: Opc = ARM::VLD2d8; break; + case MVT::v4i16: Opc = ARM::VLD2d16; break; + case MVT::v2f32: + case MVT::v2i32: Opc = ARM::VLD2d32; break; + case MVT::v1i64: Opc = ARM::VLD2d64; break; + } + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc }; + return CurDAG->getTargetNode(Opc, dl, VT, VT, MVT::Other, Ops, 3); + } + + case ARMISD::VLD3D: { + MVT VT = Op.getValueType(); + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc)) + return NULL; + unsigned Opc; + switch (VT.getSimpleVT()) { + default: llvm_unreachable("unhandled VLD3D type"); + case MVT::v8i8: Opc = ARM::VLD3d8; break; + case MVT::v4i16: Opc = ARM::VLD3d16; break; + case MVT::v2f32: + case MVT::v2i32: Opc = ARM::VLD3d32; break; + case MVT::v1i64: Opc = ARM::VLD3d64; break; + } + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc }; + return CurDAG->getTargetNode(Opc, dl, VT, VT, VT, MVT::Other, Ops, 3); + } + + case ARMISD::VLD4D: { + MVT VT = Op.getValueType(); + SDValue MemAddr, MemUpdate, MemOpc; + if (!SelectAddrMode6(Op, N->getOperand(1), MemAddr, MemUpdate, MemOpc)) + return NULL; + unsigned Opc; + switch (VT.getSimpleVT()) { + default: llvm_unreachable("unhandled VLD4D type"); + case MVT::v8i8: Opc = ARM::VLD4d8; break; + case MVT::v4i16: Opc = ARM::VLD4d16; break; + case MVT::v2f32: + case MVT::v2i32: Opc = ARM::VLD4d32; break; + case MVT::v1i64: Opc = ARM::VLD4d64; break; + } + const SDValue Ops[] = { MemAddr, MemUpdate, MemOpc }; + std::vector ResTys(4, VT); + ResTys.push_back(MVT::Other); + return CurDAG->getTargetNode(Opc, dl, ResTys, Ops, 3); + } } return SelectCode(Op); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=78136&r1=78135&r2=78136&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Aug 4 19:49:09 2009 @@ -1323,7 +1323,7 @@ } static SDValue LowerNeonVLDIntrinsic(SDValue Op, SelectionDAG &DAG, - unsigned Opcode, unsigned NumVecs) { + unsigned Opcode) { SDNode *Node = Op.getNode(); MVT VT = Node->getValueType(0); DebugLoc dl = Op.getDebugLoc(); @@ -1332,25 +1332,8 @@ return SDValue(); // unimplemented SDValue Ops[] = { Node->getOperand(0), - Node->getOperand(1) }; - SDVTList Tys = DAG.getVTList(MVT::Other, MVT::Flag); - SDValue Result = DAG.getNode(Opcode, dl, Tys, Ops, 2); - - static const unsigned VLDRegs[] = { - ARM::D0, ARM::D1, ARM::D2, ARM::D3 - }; - - SmallVector ResultVals; - SDValue Chain = Result.getValue(0); - SDValue Flag = Result.getValue(1); - for (unsigned N = 0; N < NumVecs; ++N) { - Chain = DAG.getCopyFromReg(Chain, dl, VLDRegs[N], VT, Flag).getValue(1); - ResultVals.push_back(Chain.getValue(0)); - Flag = Chain.getValue(2); - } - ResultVals.push_back(Chain); - return DAG.getNode(ISD::MERGE_VALUES, dl, Node->getVTList(), - ResultVals.data(), NumVecs + 1); + Node->getOperand(2) }; + return DAG.getNode(Opcode, dl, Node->getVTList(), Ops, 2); } SDValue @@ -1359,13 +1342,13 @@ switch (IntNo) { case Intrinsic::arm_neon_vld2i: case Intrinsic::arm_neon_vld2f: - return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD2D, 2); + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD2D); case Intrinsic::arm_neon_vld3i: case Intrinsic::arm_neon_vld3f: - return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD3D, 3); + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD3D); case Intrinsic::arm_neon_vld4i: case Intrinsic::arm_neon_vld4f: - return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD4D, 4); + return LowerNeonVLDIntrinsic(Op, DAG, ARMISD::VLD4D); case Intrinsic::arm_neon_vst2i: case Intrinsic::arm_neon_vst2f: case Intrinsic::arm_neon_vst3i: Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=78136&r1=78135&r2=78136&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Aug 4 19:49:09 2009 @@ -68,13 +68,18 @@ def NEONvduplaneq : SDNode<"ARMISD::VDUPLANEQ", SDTypeProfile<1, 2, [SDTCisVT<2, i32>]>>; -def SDTARMVLD : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; -def NEONvld2d : SDNode<"ARMISD::VLD2D", SDTARMVLD, - [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; -def NEONvld3d : SDNode<"ARMISD::VLD3D", SDTARMVLD, - [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; -def NEONvld4d : SDNode<"ARMISD::VLD4D", SDTARMVLD, - [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>; +def SDTARMVLD2 : SDTypeProfile<2, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<2>]>; +def SDTARMVLD3 : SDTypeProfile<3, 1, [SDTCisSameAs<0, 1>, + SDTCisSameAs<0, 2>, SDTCisPtrTy<3>]>; +def SDTARMVLD4 : SDTypeProfile<4, 1, [SDTCisSameAs<0, 1>, + SDTCisSameAs<0, 2>, + SDTCisSameAs<0, 3>, SDTCisPtrTy<4>]>; +def NEONvld2d : SDNode<"ARMISD::VLD2D", SDTARMVLD2, + [SDNPHasChain, SDNPMayLoad]>; +def NEONvld3d : SDNode<"ARMISD::VLD3D", SDTARMVLD3, + [SDNPHasChain, SDNPMayLoad]>; +def NEONvld4d : SDNode<"ARMISD::VLD4D", SDTARMVLD4, + [SDNPHasChain, SDNPMayLoad]>; //===----------------------------------------------------------------------===// // NEON operand definitions @@ -183,6 +188,37 @@ def VST1qf : VST1Q<"vst1.32", v4f32, int_arm_neon_vst1f>; def VST1q64 : VST1Q<"vst1.64", v2i64, int_arm_neon_vst1i>; +// VLD2 : Vector Load (multiple 2-element structures) +class VLD2D + : NLdSt<(outs DPR:$dst1, DPR:$dst2), (ins addrmode6:$addr), + !strconcat(OpcodeStr, "\t\\{$dst1,$dst2\\}, $addr"), []>; + +def VLD2d8 : VLD2D<"vld2.8">; +def VLD2d16 : VLD2D<"vld2.16">; +def VLD2d32 : VLD2D<"vld2.32">; +def VLD2d64 : VLD2D<"vld2.64">; + +// VLD3 : Vector Load (multiple 3-element structures) +class VLD3D + : NLdSt<(outs DPR:$dst1, DPR:$dst2, DPR:$dst3), (ins addrmode6:$addr), + !strconcat(OpcodeStr, "\t\\{$dst1,$dst2,$dst3\\}, $addr"), []>; + +def VLD3d8 : VLD3D<"vld3.8">; +def VLD3d16 : VLD3D<"vld3.16">; +def VLD3d32 : VLD3D<"vld3.32">; +def VLD3d64 : VLD3D<"vld3.64">; + +// VLD4 : Vector Load (multiple 4-element structures) +class VLD4D + : NLdSt<(outs DPR:$dst1, DPR:$dst2, DPR:$dst3, DPR:$dst4), + (ins addrmode6:$addr), + !strconcat(OpcodeStr, "\t\\{$dst1,$dst2,$dst3,$dst4\\}, $addr"), []>; + +def VLD4d8 : VLD4D<"vld4.8">; +def VLD4d16 : VLD4D<"vld4.16">; +def VLD4d32 : VLD4D<"vld4.32">; +def VLD4d64 : VLD4D<"vld4.64">; + //===----------------------------------------------------------------------===// // NEON pattern fragments Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=78136&r1=78135&r2=78136&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Tue Aug 4 19:49:09 2009 @@ -93,6 +93,8 @@ bool ARMBaseTargetMachine::addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { + // Call NEON pre-alloc pass here. + // FIXME: temporarily disabling load / store optimization pass for Thumb mode. if (OptLevel != CodeGenOpt::None && !DisableLdStOpti && !Subtarget.isThumb()) PM.add(createARMLoadStoreOptimizationPass(true)); From gohman at apple.com Tue Aug 4 19:49:25 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 00:49:25 -0000 Subject: [llvm-commits] [llvm] r78137 - in /llvm/trunk/lib/Target: ARM/AsmPrinter/ARMAsmPrinter.cpp MSP430/MSP430AsmPrinter.cpp PowerPC/AsmPrinter/PPCAsmPrinter.cpp SystemZ/AsmPrinter/SystemZAsmPrinter.cpp X86/AsmPrinter/X86ATTAsmPrinter.cpp X86/AsmPrinter/X86IntelAsmPrinter.cpp Message-ID: <200908050049.n750nPTI028374@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 19:49:25 2009 New Revision: 78137 URL: http://llvm.org/viewvc/llvm-project?rev=78137&view=rev Log: Don't flush the raw_ostream between each MachineFunction. These flush calls were originally put in place because errs() at one time was not unbuffered, and these print routines are commonly used with errs() for debugging. However, errs() is now properly unbuffered, so the flush calls are no longer needed. This significantly reduces the number of write(2) calls for regular asm printing when there are many small functions. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -330,8 +330,6 @@ // Emit post-function debug information. DW->EndFunction(&MF); - O.flush(); - return false; } Modified: llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -134,8 +134,6 @@ if (TAI->hasDotTypeDotSizeDirective()) O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n'; - O.flush(); - // We didn't modify anything return false; } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -646,8 +646,6 @@ // Emit post-function debug information. DW->EndFunction(&MF); - O.flush(); - // We didn't modify anything. return false; } Modified: llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -144,8 +144,6 @@ // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); - O.flush(); - // We didn't modify anything return false; } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -284,8 +284,6 @@ // Print out jump tables referenced by the function. EmitJumpTableInfo(MF.getJumpTableInfo(), MF); - O.flush(); - // We didn't modify anything. return false; } Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=78137&r1=78136&r2=78137&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Tue Aug 4 19:49:25 2009 @@ -183,8 +183,6 @@ O << CurrentFnName << "\tendp\n"; - O.flush(); - // We didn't modify anything. return false; } From gohman at apple.com Tue Aug 4 19:52:45 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 4 Aug 2009 17:52:45 -0700 Subject: [llvm-commits] [llvm] r78097 - in /llvm/trunk: include/llvm/LLVMContext.h lib/VMCore/Constants.cpp lib/VMCore/LLVMContextImpl.cpp lib/VMCore/LLVMContextImpl.h In-Reply-To: <200908042025.n74KPVti018779@zion.cs.uiuc.edu> References: <200908042025.n74KPVti018779@zion.cs.uiuc.edu> Message-ID: <23F64AF9-FDE2-436D-8F46-D00EFE1FE871@apple.com> On Aug 4, 2009, at 1:25 PM, Owen Anderson wrote: > -class LLVMContext { > +struct LLVMContext { > LLVMContextImpl* pImpl; Hi Owen, With the pImpl member being public, would it make sense to make it const? It looks like it's never modified after its initialization in the LLVMContext constructor. Alternatively, perhaps this could be accessed with an accessor function. Dan From deeppatel1987 at gmail.com Tue Aug 4 19:54:16 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Wed, 5 Aug 2009 00:54:16 +0000 Subject: [llvm-commits] [patch] CBackend improvements In-Reply-To: <70D7905D-DDC2-400C-9C6F-992EFA75D44C@apple.com> References: <305d6f60907232339k582287b3p93baf72cfbc85041@mail.gmail.com> <70D7905D-DDC2-400C-9C6F-992EFA75D44C@apple.com> Message-ID: <305d6f60908041754j63b2663erc26b22bdfe279a3@mail.gmail.com> ping. Can somebody commit this? deep On Sun, Jul 26, 2009 at 6:47 PM, Evan Cheng wrote: > Ok. Thanks. > > Evan > > On Jul 23, 2009, at 11:39 PM, Sandeep Patel wrote: > >> The attached causes module asms to be emitted by the CBackend and >> makes #line directive filenames slightly more correct >> >> deep >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From gohman at apple.com Tue Aug 4 20:06:40 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 01:06:40 -0000 Subject: [llvm-commits] [llvm] r78138 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Message-ID: <200908050106.n7516fpV029022@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 20:06:38 2009 New Revision: 78138 URL: http://llvm.org/viewvc/llvm-project?rev=78138&view=rev Log: Remove an unnecessary flush in the CppBackend's output. Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=78138&r1=78137&r2=78138&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Tue Aug 4 20:06:38 2009 @@ -1816,7 +1816,6 @@ Out << "int main(int argc, char**argv) {\n"; Out << " Module* Mod = " << fname << "();\n"; Out << " verifyModule(*Mod, PrintMessageAction);\n"; - Out << " outs().flush();\n"; Out << " PassManager PM;\n"; Out << " PM.add(createPrintModulePass(&outs()));\n"; Out << " PM.run(*Mod);\n"; From gohman at apple.com Tue Aug 4 20:19:01 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 01:19:01 -0000 Subject: [llvm-commits] [llvm] r78139 - /llvm/trunk/lib/CodeGen/MachineSink.cpp Message-ID: <200908050119.n751J16g029458@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 20:19:01 2009 New Revision: 78139 URL: http://llvm.org/viewvc/llvm-project?rev=78139&view=rev Log: Various comment fixes. Modified: llvm/trunk/lib/CodeGen/MachineSink.cpp Modified: llvm/trunk/lib/CodeGen/MachineSink.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSink.cpp?rev=78139&r1=78138&r2=78139&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSink.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSink.cpp Tue Aug 4 20:19:01 2009 @@ -7,7 +7,12 @@ // //===----------------------------------------------------------------------===// // -// This pass +// This pass moves instructions into successor blocks, when possible, so that +// they aren't executed on paths where their results aren't needed. +// +// This pass is not intended to be a replacement or a complete alternative +// for an LLVM-IR-level sinking pass. It is only designed to sink simple +// constructs that are not exposed before lowering and instruction selection. // //===----------------------------------------------------------------------===// @@ -31,7 +36,7 @@ const TargetInstrInfo *TII; MachineFunction *CurMF; // Current MachineFunction MachineRegisterInfo *RegInfo; // Machine register information - MachineDominatorTree *DT; // Machine dominator tree for the current Loop + MachineDominatorTree *DT; // Machine dominator tree public: static char ID; // Pass identification @@ -152,7 +157,7 @@ // also sink them down before their first use in the block. This xform has to // be careful not to *increase* register pressure though, e.g. sinking // "x = y + z" down if it kills y and z would increase the live ranges of y - // and z only the shrink the live range of x. + // and z and only shrink the live range of x. // Loop over all the operands of the specified instruction. If there is // anything we can't handle, bail out. From evan.cheng at apple.com Tue Aug 4 20:29:24 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 05 Aug 2009 01:29:24 -0000 Subject: [llvm-commits] [llvm] r78141 - in /llvm/trunk: lib/CodeGen/LowerSubregs.cpp test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll Message-ID: <200908050129.n751TOKR029848@zion.cs.uiuc.edu> Author: evancheng Date: Tue Aug 4 20:29:24 2009 New Revision: 78141 URL: http://llvm.org/viewvc/llvm-project?rev=78141&view=rev Log: If the insert_subreg source is , insert an implicit_def instead of a copy. Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=78141&r1=78140&r2=78141&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original) +++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Tue Aug 4 20:29:24 2009 @@ -254,7 +254,13 @@ // Insert sub-register copy const TargetRegisterClass *TRC0= TRI.getPhysicalRegisterRegClass(DstSubReg); const TargetRegisterClass *TRC1= TRI.getPhysicalRegisterRegClass(InsReg); - TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1); + if (MI->getOperand(2).isUndef()) + // If the source register being inserted is undef, then this becomes an + // implicit_def. + BuildMI(*MBB, MI, MI->getDebugLoc(), + TII.get(TargetInstrInfo::IMPLICIT_DEF), DstSubReg); + else + TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC0, TRC1); MachineBasicBlock::iterator CopyMI = MI; --CopyMI; @@ -270,7 +276,7 @@ } // Make sure the inserted register gets killed - if (MI->getOperand(2).isKill()) + if (MI->getOperand(2).isKill() && !MI->getOperand(2).isUndef()) TransferKillFlag(MI, InsReg, TRI); } Added: llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll?rev=78141&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-08-04-SubregLoweringBug.ll Tue Aug 4 20:29:24 2009 @@ -0,0 +1,34 @@ +; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin9 -mattr=+neon,+neonfp +; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin9 -mattr=+neon,+neonfp | grep fcpys | count 1 +; rdar://7117307 + + %struct.Hosp = type { i32, i32, i32, %struct.List, %struct.List, %struct.List, %struct.List } + %struct.List = type { %struct.List*, %struct.Patient*, %struct.List* } + %struct.Patient = type { i32, i32, i32, %struct.Village* } + %struct.Results = type { float, float, float } + %struct.Village = type { [4 x %struct.Village*], %struct.Village*, %struct.List, %struct.Hosp, i32, i32 } + +define arm_apcscc void @get_results(%struct.Results* noalias nocapture sret %agg.result, %struct.Village* %village) nounwind { +entry: + br i1 undef, label %bb, label %bb6.preheader + +bb6.preheader: ; preds = %entry + call void @llvm.memcpy.i32(i8* undef, i8* undef, i32 12, i32 4) + br i1 undef, label %bb15, label %bb13 + +bb: ; preds = %entry + ret void + +bb13: ; preds = %bb13, %bb6.preheader + %0 = fadd float undef, undef ; [#uses=1] + %1 = fadd float undef, 1.000000e+00 ; [#uses=1] + br i1 undef, label %bb15, label %bb13 + +bb15: ; preds = %bb13, %bb6.preheader + %r1.0.0.lcssa = phi float [ 0.000000e+00, %bb6.preheader ], [ %1, %bb13 ] ; [#uses=1] + %r1.1.0.lcssa = phi float [ undef, %bb6.preheader ], [ %0, %bb13 ] ; [#uses=0] + store float %r1.0.0.lcssa, float* undef, align 4 + ret void +} + +declare void @llvm.memcpy.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind From gohman at apple.com Tue Aug 4 20:29:29 2009 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Aug 2009 01:29:29 -0000 Subject: [llvm-commits] [llvm] r78142 - in /llvm/trunk: include/llvm/CodeGen/ include/llvm/Target/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PIC16/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ test/CodeGen/X86/ Message-ID: <200908050129.n751TVCZ029906@zion.cs.uiuc.edu> Author: djg Date: Tue Aug 4 20:29:28 2009 New Revision: 78142 URL: http://llvm.org/viewvc/llvm-project?rev=78142&view=rev Log: Major calling convention code refactoring. Instead of awkwardly encoding calling-convention information with ISD::CALL, ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering provides three virtual functions for targets to override: LowerFormalArguments, LowerCall, and LowerRet, which replace the custom lowering done on the special nodes. They provide the same information, but in a more immediately usable format. This also reworks much of the target-independent tail call logic. The decision of whether or not to perform a tail call is now cleanly split between target-independent portions, and the target dependent portion in IsEligibleForTailCallOptimization. This also synchronizes all in-tree targets, to help enable future refactoring and feature work. Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Target/TargetSelectionDAG.td llvm/trunk/lib/CodeGen/SelectionDAG/CallingConvLower.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/Alpha/AlphaISelLowering.cpp llvm/trunk/lib/Target/Alpha/AlphaISelLowering.h llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinISelLowering.h llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsISelLowering.h llvm/trunk/lib/Target/Mips/MipsMachineFunction.h llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.cpp llvm/trunk/lib/Target/PIC16/PIC16ISelLowering.h llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.td llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp llvm/trunk/lib/Target/Sparc/SparcISelLowering.h llvm/trunk/lib/Target/Sparc/SparcInstrInfo.td llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86Instr64bit.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Target/XCore/XCoreISelLowering.h llvm/trunk/test/CodeGen/X86/tailcallstack64.ll Modified: llvm/trunk/include/llvm/CodeGen/CallingConvLower.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CallingConvLower.h?rev=78142&r1=78141&r2=78142&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CallingConvLower.h (original) +++ llvm/trunk/include/llvm/CodeGen/CallingConvLower.h Tue Aug 4 20:29:28 2009 @@ -172,17 +172,20 @@ return UsedRegs[Reg/32] & (1 << (Reg&31)); } - /// AnalyzeFormalArguments - Analyze an ISD::FORMAL_ARGUMENTS node, + /// AnalyzeFormalArguments - Analyze an array of argument values, /// incorporating info about the formals into this state. - void AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn); + void AnalyzeFormalArguments(const SmallVectorImpl &Ins, + CCAssignFn Fn); - /// AnalyzeReturn - Analyze the returned values of an ISD::RET node, + /// AnalyzeReturn - Analyze the returned values of a return, /// incorporating info about the result values into this state. - void AnalyzeReturn(SDNode *TheRet, CCAssignFn Fn); + void AnalyzeReturn(const SmallVectorImpl &Outs, + CCAssignFn Fn); - /// AnalyzeCallOperands - Analyze an ISD::CALL node, incorporating info - /// about the passed values into this state. - void AnalyzeCallOperands(CallSDNode *TheCall, CCAssignFn Fn); + /// AnalyzeCallOperands - Analyze the outgoing arguments to a call, + /// incorporating info about the passed values into this state. + void AnalyzeCallOperands(const SmallVectorImpl &Outs, + CCAssignFn Fn); /// AnalyzeCallOperands - Same as abov