From 0184a841d3914bb78c7c6fa87ce9da86a2d5992a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 11:17:50 +0000 Subject: Begin sketching out the process interface. The coding style used here is not LLVM's style because this is modeled after a Boost interface and thus done in the style of a candidate C++ standard library interface. I'll probably end up proposing it as a standard C++ library if it proves to be reasonably portable and useful. This is just the most basic parts of the interface -- getting the process ID out of it. However, it helps sketch out some of the boiler plate such as the base class, derived class, shared code, and static factory function. It also introduces a unittest so that I can incrementally ensure this stuff works. However, I've not even compiled this code for Windows yet. I'll try to fix any Windows fallout from the bots, and if I can't fix it I'll revert and get someone on Windows to help out. There isn't a lot more that is mandatory, so soon I'll switch to just stubbing out the Windows side and get Michael Spencer to help with implementation as he can test it directly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171289 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Process.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/Support/Process.cpp') diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 88ca7c3f22..8d1b64897c 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -11,8 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Process.h" #include "llvm/Config/config.h" +#include "llvm/Support/Process.h" +#include "llvm/Support/ErrorHandling.h" namespace llvm { using namespace sys; @@ -22,6 +23,25 @@ using namespace sys; //=== independent code. //===----------------------------------------------------------------------===// +// Empty virtual destructor to anchor the vtable for the process class. +process::~process() {} + +self_process *process::get_self() { + // Use a function local static for thread safe initialization and allocate it + // as a raw pointer to ensure it is never destroyed. + static self_process *SP = new self_process(); + + return SP; +} + +// The destructor for the self_process subclass must never actually be +// executed. There should be at most one instance of this class, and that +// instance should live until the process terminates to avoid the potential for +// racy accesses during shutdown. +self_process::~self_process() { + llvm_unreachable("This destructor must never be executed!"); +} + } // Include the platform-specific parts of this class. -- cgit v1.2.3-70-g09d2 From c9bdcac41213f3994709fd06de8d85dbc1b2daa1 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 11:39:02 +0000 Subject: Suppress a MSVC warning complaining about the code working as intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171290 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Process.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/Support/Process.cpp') diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 8d1b64897c..5f8655efc6 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -34,14 +34,27 @@ self_process *process::get_self() { return SP; } +#if defined(_MSC_VER) +// Visual Studio complains that the self_process destructor never exits. This +// doesn't make much sense, as that's the whole point of calling abort... Just +// silence this warning. +#pragma warning(push) +#pragma warning(disable:4722) +#endif + // The destructor for the self_process subclass must never actually be // executed. There should be at most one instance of this class, and that // instance should live until the process terminates to avoid the potential for // racy accesses during shutdown. self_process::~self_process() { + assert(TempDirectory->exists() && "Who has removed TempDirectory?"); llvm_unreachable("This destructor must never be executed!"); } +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + } // Include the platform-specific parts of this class. -- cgit v1.2.3-70-g09d2 From 8e98c1f2540be6e5adfcae15064a831fa0b3a8c9 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 11:40:04 +0000 Subject: Delete a cut/paste-o from r171290. Very sorry about the noise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171291 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Process.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/Support/Process.cpp') diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 5f8655efc6..6e24c45fa0 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -47,7 +47,6 @@ self_process *process::get_self() { // instance should live until the process terminates to avoid the potential for // racy accesses during shutdown. self_process::~self_process() { - assert(TempDirectory->exists() && "Who has removed TempDirectory?"); llvm_unreachable("This destructor must never be executed!"); } -- cgit v1.2.3-70-g09d2 From 9b4aba85a89f9347212e00f80953f2a685ffeb36 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 11:45:20 +0000 Subject: Switch this code to a more idiomatic double using namespace directive. Fix a truly odd namespace qualifier that was flat out wrong in the process. The fully qualified namespace would have been llvm::sys::TimeValue, llvm::TimeValue makes no sense. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171292 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Process.cpp | 3 +-- lib/Support/Unix/Process.inc | 2 +- lib/Support/Windows/Process.inc | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/Support/Process.cpp') diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 6e24c45fa0..1e21d64e60 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -15,7 +15,7 @@ #include "llvm/Support/Process.h" #include "llvm/Support/ErrorHandling.h" -namespace llvm { +using namespace llvm; using namespace sys; //===----------------------------------------------------------------------===// @@ -54,7 +54,6 @@ self_process::~self_process() { #pragma warning(pop) #endif -} // Include the platform-specific parts of this class. #ifdef LLVM_ON_UNIX diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index dedc4430d6..b83f5079ce 100644 --- a/lib/Support/Unix/Process.inc +++ b/lib/Support/Unix/Process.inc @@ -324,7 +324,7 @@ static unsigned GetRandomNumberSeed() { // Otherwise, swizzle the current time and the process ID to form a reasonable // seed. - TimeValue Now = llvm::TimeValue::now(); + TimeValue Now = TimeValue::now(); return hash_combine(Now.seconds(), Now.nanoseconds(), ::getpid()); } #endif diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index fc24ceaf07..9ad7917714 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -35,7 +35,7 @@ # define _HEAPOK (-2) #endif -namespace llvm { +using namespace llvm; using namespace sys; @@ -261,5 +261,3 @@ const char *Process::ResetColor() { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors()); return 0; } - -} -- cgit v1.2.3-70-g09d2 From 814afe91ccad0e5e1f767303d780fa0318fa5212 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 23:23:35 +0000 Subject: Flesh out a page size accessor in the new API. Implement the old API in terms of the new one. This simplifies the implementation on Windows which can now re-use the self_process's once initialization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171330 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Process.h | 20 ++++++++++++++++++++ lib/Support/Process.cpp | 8 ++++++++ lib/Support/Unix/Process.inc | 11 +++++++---- lib/Support/Windows/Process.inc | 14 ++++++-------- unittests/Support/ProcessTest.cpp | 2 ++ 5 files changed, 43 insertions(+), 12 deletions(-) (limited to 'lib/Support/Process.cpp') diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 6b29f57fc1..15fa3763c9 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -89,7 +89,27 @@ class self_process : public process { public: virtual id_type get_id(); + /// \name Process configuration (sysconf on POSIX) + /// @{ + + /// \brief Get the virtual memory page size. + /// + /// Query the operating system for this process's page size. + size_t page_size() const { return PageSize; }; + + /// @} + private: + /// \name Cached process state. + /// @{ + + /// \brief Cached page size, this cannot vary during the life of the process. + size_t PageSize; + + /// @} + + /// \brief Constructor, used by \c process::get_self() only. + self_process(); }; diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 1e21d64e60..9d87b7744b 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -55,6 +55,14 @@ self_process::~self_process() { #endif +//===----------------------------------------------------------------------===// +// Implementations of legacy functions in terms of the new self_process object. + +unsigned Process::GetPageSize() { + return process::get_self()->page_size(); +} + + // Include the platform-specific parts of this class. #ifdef LLVM_ON_UNIX #include "Unix/Process.inc" diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index e96d37ce56..9ad6272bab 100644 --- a/lib/Support/Unix/Process.inc +++ b/lib/Support/Unix/Process.inc @@ -49,10 +49,7 @@ process::id_type self_process::get_id() { return getpid(); } - -unsigned -Process::GetPageSize() -{ +static unsigned getPageSize() { #if defined(__CYGWIN__) // On Cygwin, getpagesize() returns 64k but the page size for the purposes of // memory protection and mmap() is 4k. @@ -68,6 +65,12 @@ Process::GetPageSize() return static_cast(page_size); } +// This constructor guaranteed to be run exactly once on a single thread, and +// sets up various process invariants that can be queried cheaply from then on. +self_process::self_process() : PageSize(getPageSize()) { +} + + size_t Process::GetMallocUsage() { #if defined(HAVE_MALLINFO) struct mallinfo mi; diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index d3a0c94e1c..9eb611be87 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -43,11 +43,9 @@ process::id_type self_process::get_id() { return GetCurrentProcess(); } - // This function retrieves the page size using GetSystemInfo and is present -// solely so it can be called once in Process::GetPageSize to initialize the -// static variable PageSize. -inline unsigned GetPageSizeOnce() { +// solely so it can be called once to initialize the self_process member below. +static unsigned getPageSize() { // NOTE: A 32-bit application running under WOW64 is supposed to use // GetNativeSystemInfo. However, this interface is not present prior // to Windows XP so to use it requires dynamic linking. It is not clear @@ -58,12 +56,12 @@ inline unsigned GetPageSizeOnce() { return static_cast(info.dwPageSize); } -unsigned -Process::GetPageSize() { - static const unsigned PageSize = GetPageSizeOnce(); - return PageSize; +// This constructor guaranteed to be run exactly once on a single thread, and +// sets up various process invariants that can be queried cheaply from then on. +self_process::self_process() : PageSize(getPageSize()) { } + size_t Process::GetMallocUsage() { diff --git a/unittests/Support/ProcessTest.cpp b/unittests/Support/ProcessTest.cpp index d4c4b54ccc..58a7c4acaa 100644 --- a/unittests/Support/ProcessTest.cpp +++ b/unittests/Support/ProcessTest.cpp @@ -28,6 +28,8 @@ TEST(ProcessTest, SelfProcess) { #elif defined(LLVM_ON_WIN32) EXPECT_EQ(GetCurrentProcess(), process::get_self()->get_id()); #endif + + EXPECT_LT(1u, process::get_self()->page_size()); } } // end anonymous namespace -- cgit v1.2.3-70-g09d2 From f5867ab7178784bc63a3deafcf4fb09260e4d19a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 31 Dec 2012 23:31:56 +0000 Subject: Go ahead and get rid of the old page size interface and convert all the users over to the new one. No sense maintaining this "compatibility" layer it seems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171331 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Process.h | 6 ------ lib/Support/MemoryBuffer.cpp | 4 ++-- lib/Support/Process.cpp | 8 -------- lib/Support/Unix/Memory.inc | 16 ++++++++-------- lib/Support/Unix/PathV2.inc | 2 +- unittests/Support/MemoryTest.cpp | 2 +- 6 files changed, 12 insertions(+), 26 deletions(-) (limited to 'lib/Support/Process.cpp') diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 15fa3763c9..f149a4e058 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -117,12 +117,6 @@ private: /// current executing process. class Process { public: - /// \brief Get the virtual memory page size - /// This static function will return the operating system's virtual memory - /// page size. - /// \returns The number of bytes in a virtual memory page. - static unsigned GetPageSize(); - /// \brief Return process memory usage. /// This static function will return the total amount of memory allocated /// by the process. This only counts the memory allocated via the malloc, diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index cb587d59c9..65b43322e6 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -187,7 +187,7 @@ public: : MemoryBufferMem(Buffer, RequiresNullTerminator) { } ~MemoryBufferMMapFile() { - static int PageSize = sys::Process::GetPageSize(); + static int PageSize = sys::process::get_self()->page_size(); uintptr_t Start = reinterpret_cast(getBufferStart()); size_t Size = getBufferSize(); @@ -309,7 +309,7 @@ error_code MemoryBuffer::getOpenFile(int FD, const char *Filename, uint64_t FileSize, uint64_t MapSize, int64_t Offset, bool RequiresNullTerminator) { - static int PageSize = sys::Process::GetPageSize(); + static int PageSize = sys::process::get_self()->page_size(); // Default is to map the full file. if (MapSize == uint64_t(-1)) { diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 9d87b7744b..1e21d64e60 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -55,14 +55,6 @@ self_process::~self_process() { #endif -//===----------------------------------------------------------------------===// -// Implementations of legacy functions in terms of the new self_process object. - -unsigned Process::GetPageSize() { - return process::get_self()->page_size(); -} - - // Include the platform-specific parts of this class. #ifdef LLVM_ON_UNIX #include "Unix/Process.inc" diff --git a/lib/Support/Unix/Memory.inc b/lib/Support/Unix/Memory.inc index 9a8abd27f1..40d6b3fefd 100644 --- a/lib/Support/Unix/Memory.inc +++ b/lib/Support/Unix/Memory.inc @@ -73,7 +73,7 @@ Memory::allocateMappedMemory(size_t NumBytes, if (NumBytes == 0) return MemoryBlock(); - static const size_t PageSize = Process::GetPageSize(); + static const size_t PageSize = process::get_self()->page_size(); const size_t NumPages = (NumBytes+PageSize-1)/PageSize; int fd = -1; @@ -166,8 +166,8 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock, std::string *ErrMsg) { if (NumBytes == 0) return MemoryBlock(); - size_t pageSize = Process::GetPageSize(); - size_t NumPages = (NumBytes+pageSize-1)/pageSize; + size_t PageSize = process::get_self()->page_size(); + size_t NumPages = (NumBytes+PageSize-1)/PageSize; int fd = -1; #ifdef NEED_DEV_ZERO_FOR_MMAP @@ -191,10 +191,10 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock, NearBlock->size() : 0; #if defined(__APPLE__) && defined(__arm__) - void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_EXEC, + void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_EXEC, flags, fd, 0); #else - void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC, + void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC, flags, fd, 0); #endif if (pa == MAP_FAILED) { @@ -207,7 +207,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock, #if defined(__APPLE__) && defined(__arm__) kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)pa, - (vm_size_t)(pageSize*NumPages), 0, + (vm_size_t)(PageSize*NumPages), 0, VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY); if (KERN_SUCCESS != kr) { MakeErrMsg(ErrMsg, "vm_protect max RX failed"); @@ -215,7 +215,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock, } kr = vm_protect(mach_task_self(), (vm_address_t)pa, - (vm_size_t)(pageSize*NumPages), 0, + (vm_size_t)(PageSize*NumPages), 0, VM_PROT_READ | VM_PROT_WRITE); if (KERN_SUCCESS != kr) { MakeErrMsg(ErrMsg, "vm_protect RW failed"); @@ -225,7 +225,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock, MemoryBlock result; result.Address = pa; - result.Size = NumPages*pageSize; + result.Size = NumPages*PageSize; return result; } diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 453267046a..25712a8a9f 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -575,7 +575,7 @@ const char *mapped_file_region::const_data() const { } int mapped_file_region::alignment() { - return Process::GetPageSize(); + return process::get_self()->page_size(); } error_code detail::directory_iterator_construct(detail::DirIterState &it, diff --git a/unittests/Support/MemoryTest.cpp b/unittests/Support/MemoryTest.cpp index 4164713fcb..fae67a8dd2 100644 --- a/unittests/Support/MemoryTest.cpp +++ b/unittests/Support/MemoryTest.cpp @@ -21,7 +21,7 @@ class MappedMemoryTest : public ::testing::TestWithParam { public: MappedMemoryTest() { Flags = GetParam(); - PageSize = sys::Process::GetPageSize(); + PageSize = sys::process::get_self()->page_size(); } protected: -- cgit v1.2.3-70-g09d2 From 58a2cbef4aac9ee7d530dfb690c78d6fc11a2371 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 2 Jan 2013 10:22:59 +0000 Subject: Resort the #include lines in include/... and lib/... with the utils/sort_includes.py script. Most of these are updating the new R600 target and fixing up a few regressions that have creeped in since the last time I sorted the includes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171362 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 1 - include/llvm/MC/MCInstrDesc.h | 4 ++-- include/llvm/MC/MCSectionELF.h | 2 +- include/llvm/Operator.h | 2 +- include/llvm/Option/ArgList.h | 3 +-- include/llvm/Option/Option.h | 2 +- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 +- lib/Option/Arg.cpp | 1 - lib/Option/ArgList.cpp | 1 - lib/Option/OptTable.cpp | 3 +-- lib/Option/Option.cpp | 4 +--- lib/Support/Process.cpp | 2 +- lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- lib/Target/ARM/Thumb2SizeReduction.cpp | 2 +- lib/Target/Mips/Mips16FrameLowering.cpp | 2 +- lib/Target/R600/AMDGPUAsmPrinter.cpp | 2 +- lib/Target/R600/AMDGPUInstrInfo.h | 3 +-- lib/Target/R600/AMDGPUMCInstLower.cpp | 2 +- lib/Target/R600/AMDGPUStructurizeCFG.cpp | 4 ++-- lib/Target/R600/AMDILCFGStructurizer.cpp | 2 +- lib/Target/R600/AMDILEvergreenDevice.h | 2 +- lib/Target/R600/AMDILISelLowering.cpp | 2 +- lib/Target/R600/AMDILIntrinsicInfo.cpp | 2 +- lib/Target/R600/AMDILNIDevice.cpp | 2 +- lib/Target/R600/AMDILNIDevice.h | 2 +- lib/Target/R600/AMDILSIDevice.cpp | 2 +- lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp | 2 +- lib/Target/R600/MCTargetDesc/R600MCCodeEmitter.cpp | 3 +-- lib/Target/R600/MCTargetDesc/SIMCCodeEmitter.cpp | 2 +- lib/Target/R600/R600ExpandSpecialInstrs.cpp | 2 +- lib/Target/R600/R600ISelLowering.cpp | 2 +- lib/Target/R600/R600InstrInfo.cpp | 2 +- lib/Target/R600/R600InstrInfo.h | 3 +-- lib/Target/R600/R600RegisterInfo.h | 2 +- lib/Target/R600/SIAnnotateControlFlow.cpp | 7 +++---- lib/Target/R600/SIInstrInfo.cpp | 1 - lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp | 2 +- lib/Target/XCore/XCoreAsmPrinter.cpp | 2 +- lib/Transforms/Instrumentation/AddressSanitizer.cpp | 2 +- lib/Transforms/Scalar/ObjCARC.cpp | 2 +- lib/Transforms/Utils/Local.cpp | 2 +- 41 files changed, 41 insertions(+), 53 deletions(-) (limited to 'lib/Support/Process.cpp') diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 6608d96e4b..5e148c3b09 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -15,7 +15,6 @@ #include "llvm/MC/MCObjectStreamer.h" #include "llvm/MC/SectionKind.h" #include "llvm/Support/DataTypes.h" - #include namespace llvm { diff --git a/include/llvm/MC/MCInstrDesc.h b/include/llvm/MC/MCInstrDesc.h index cb87641daa..9b5415add2 100644 --- a/include/llvm/MC/MCInstrDesc.h +++ b/include/llvm/MC/MCInstrDesc.h @@ -15,9 +15,9 @@ #ifndef LLVM_MC_MCINSTRDESC_H #define LLVM_MC_MCINSTRDESC_H -#include "llvm/Support/DataTypes.h" -#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCInst.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index 451a1623c1..4b8b849c79 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -16,9 +16,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCSection.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Debug.h" namespace llvm { diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h index b2bb2e6b31..6fadc6fa7b 100644 --- a/include/llvm/Operator.h +++ b/include/llvm/Operator.h @@ -19,8 +19,8 @@ #include "llvm/DataLayout.h" #include "llvm/DerivedTypes.h" #include "llvm/Instruction.h" -#include "llvm/Type.h" #include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Type.h" namespace llvm { diff --git a/include/llvm/Option/ArgList.h b/include/llvm/Option/ArgList.h index 7d09f8e6cc..378b58a87d 100644 --- a/include/llvm/Option/ArgList.h +++ b/include/llvm/Option/ArgList.h @@ -12,9 +12,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Option/Option.h" #include "llvm/Option/OptSpecifier.h" - +#include "llvm/Option/Option.h" #include #include #include diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h index d0e46112a3..ee5eec417d 100644 --- a/include/llvm/Option/Option.h +++ b/include/llvm/Option/Option.h @@ -10,8 +10,8 @@ #ifndef LLVM_SUPPORT_OPTION_H_ #define LLVM_SUPPORT_OPTION_H_ -#include "llvm/ADT/StringRef.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Option/OptTable.h" #include "llvm/Support/ErrorHandling.h" diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index ea80acdd59..e9b3706612 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -41,7 +41,6 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Support/Mutex.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/TargetTransformInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetLowering.h" @@ -49,6 +48,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetSelectionDAGInfo.h" +#include "llvm/TargetTransformInfo.h" #include #include using namespace llvm; diff --git a/lib/Option/Arg.cpp b/lib/Option/Arg.cpp index 9f547bd825..4c8da58f53 100644 --- a/lib/Option/Arg.cpp +++ b/lib/Option/Arg.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Option/Arg.h" - #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Option/ArgList.h" diff --git a/lib/Option/ArgList.cpp b/lib/Option/ArgList.cpp index 65cb51959e..39b22d776e 100644 --- a/lib/Option/ArgList.cpp +++ b/lib/Option/ArgList.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Option/ArgList.h" - #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Option/Arg.h" diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp index 3b34bf3b3a..5c8a0eacd1 100644 --- a/lib/Option/OptTable.cpp +++ b/lib/Option/OptTable.cpp @@ -8,12 +8,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Option/OptTable.h" - #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" #include #include diff --git a/lib/Option/Option.cpp b/lib/Option/Option.cpp index 003f07f037..0e2263475e 100644 --- a/lib/Option/Option.cpp +++ b/lib/Option/Option.cpp @@ -8,13 +8,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Option/Option.h" - #include "llvm/ADT/Twine.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/ErrorHandling.h" - +#include "llvm/Support/raw_ostream.h" #include #include diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 1e21d64e60..64a1fa237e 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Config/config.h" -#include "llvm/Support/Process.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Process.h" using namespace llvm; using namespace sys; diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index c781967692..f4958f3a38 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -12,9 +12,9 @@ //===----------------------------------------------------------------------===// #include "ARMMCTargetDesc.h" +#include "ARMBaseInfo.h" #include "ARMELFStreamer.h" #include "ARMMCAsmInfo.h" -#include "ARMBaseInfo.h" #include "InstPrinter/ARMInstPrinter.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/MC/MCInstrAnalysis.h" diff --git a/lib/Target/ARM/Thumb2SizeReduction.cpp b/lib/Target/ARM/Thumb2SizeReduction.cpp index 4a7eb4010b..e1490ba209 100644 --- a/lib/Target/ARM/Thumb2SizeReduction.cpp +++ b/lib/Target/ARM/Thumb2SizeReduction.cpp @@ -19,10 +19,10 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/Function.h" // To access Function attributes #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Function.h" // To access Function attributes using namespace llvm; STATISTIC(NumNarrows, "Number of 32-bit instrs reduced to 16-bit ones"); diff --git a/lib/Target/Mips/Mips16FrameLowering.cpp b/lib/Target/Mips/Mips16FrameLowering.cpp index 5c80a6c609..c2153676e5 100644 --- a/lib/Target/Mips/Mips16FrameLowering.cpp +++ b/lib/Target/Mips/Mips16FrameLowering.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "Mips16FrameLowering.h" -#include "Mips16InstrInfo.h" #include "MCTargetDesc/MipsBaseInfo.h" +#include "Mips16InstrInfo.h" #include "MipsInstrInfo.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" diff --git a/lib/Target/R600/AMDGPUAsmPrinter.cpp b/lib/Target/R600/AMDGPUAsmPrinter.cpp index 4553c4556c..754506c837 100644 --- a/lib/Target/R600/AMDGPUAsmPrinter.cpp +++ b/lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -22,8 +22,8 @@ #include "SIMachineFunctionInfo.h" #include "SIRegisterInfo.h" #include "llvm/MC/MCStreamer.h" -#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Support/TargetRegistry.h" +#include "llvm/Target/TargetLoweringObjectFile.h" using namespace llvm; diff --git a/lib/Target/R600/AMDGPUInstrInfo.h b/lib/Target/R600/AMDGPUInstrInfo.h index 32ac691fe0..cb97af9831 100644 --- a/lib/Target/R600/AMDGPUInstrInfo.h +++ b/lib/Target/R600/AMDGPUInstrInfo.h @@ -16,10 +16,9 @@ #ifndef AMDGPUINSTRUCTIONINFO_H #define AMDGPUINSTRUCTIONINFO_H -#include "AMDGPURegisterInfo.h" #include "AMDGPUInstrInfo.h" +#include "AMDGPURegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" - #include #define GET_INSTRINFO_HEADER diff --git a/lib/Target/R600/AMDGPUMCInstLower.cpp b/lib/Target/R600/AMDGPUMCInstLower.cpp index 32275a2b04..46a569f079 100644 --- a/lib/Target/R600/AMDGPUMCInstLower.cpp +++ b/lib/Target/R600/AMDGPUMCInstLower.cpp @@ -19,9 +19,9 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Constants.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCExpr.h" #include "llvm/Support/ErrorHandling.h" using namespace llvm; diff --git a/lib/Target/R600/AMDGPUStructurizeCFG.cpp b/lib/Target/R600/AMDGPUStructurizeCFG.cpp index 22338b5bf7..d14428fd2d 100644 --- a/lib/Target/R600/AMDGPUStructurizeCFG.cpp +++ b/lib/Target/R600/AMDGPUStructurizeCFG.cpp @@ -16,11 +16,11 @@ //===----------------------------------------------------------------------===// #include "AMDGPU.h" -#include "llvm/Module.h" #include "llvm/ADT/SCCIterator.h" -#include "llvm/Analysis/RegionIterator.h" #include "llvm/Analysis/RegionInfo.h" +#include "llvm/Analysis/RegionIterator.h" #include "llvm/Analysis/RegionPass.h" +#include "llvm/Module.h" #include "llvm/Transforms/Utils/SSAUpdater.h" using namespace llvm; diff --git a/lib/Target/R600/AMDILCFGStructurizer.cpp b/lib/Target/R600/AMDILCFGStructurizer.cpp index 9de97b6269..aa8ab6bd93 100644 --- a/lib/Target/R600/AMDILCFGStructurizer.cpp +++ b/lib/Target/R600/AMDILCFGStructurizer.cpp @@ -18,7 +18,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/DominatorInternals.h" #include "llvm/Analysis/Dominators.h" -#include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" @@ -26,6 +25,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineLoopInfo.h" +#include "llvm/CodeGen/MachinePostDominators.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" diff --git a/lib/Target/R600/AMDILEvergreenDevice.h b/lib/Target/R600/AMDILEvergreenDevice.h index 6dc2deb9ed..ea90f774a8 100644 --- a/lib/Target/R600/AMDILEvergreenDevice.h +++ b/lib/Target/R600/AMDILEvergreenDevice.h @@ -16,8 +16,8 @@ //===----------------------------------------------------------------------===// #ifndef AMDILEVERGREENDEVICE_H #define AMDILEVERGREENDEVICE_H -#include "AMDILDevice.h" #include "AMDGPUSubtarget.h" +#include "AMDILDevice.h" namespace llvm { class AMDGPUSubtarget; diff --git a/lib/Target/R600/AMDILISelLowering.cpp b/lib/Target/R600/AMDILISelLowering.cpp index 8bfd30c6e3..9dda186872 100644 --- a/lib/Target/R600/AMDILISelLowering.cpp +++ b/lib/Target/R600/AMDILISelLowering.cpp @@ -14,9 +14,9 @@ #include "AMDGPUISelLowering.h" #include "AMDGPURegisterInfo.h" +#include "AMDGPUSubtarget.h" #include "AMDILDevices.h" #include "AMDILIntrinsicInfo.h" -#include "AMDGPUSubtarget.h" #include "llvm/CallingConv.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" diff --git a/lib/Target/R600/AMDILIntrinsicInfo.cpp b/lib/Target/R600/AMDILIntrinsicInfo.cpp index 70db4e6da2..d3125ab410 100644 --- a/lib/Target/R600/AMDILIntrinsicInfo.cpp +++ b/lib/Target/R600/AMDILIntrinsicInfo.cpp @@ -13,8 +13,8 @@ //===-----------------------------------------------------------------------===// #include "AMDILIntrinsicInfo.h" -#include "AMDIL.h" #include "AMDGPUSubtarget.h" +#include "AMDIL.h" #include "llvm/DerivedTypes.h" #include "llvm/Intrinsics.h" #include "llvm/Module.h" diff --git a/lib/Target/R600/AMDILNIDevice.cpp b/lib/Target/R600/AMDILNIDevice.cpp index b82da5908a..47c3f7f209 100644 --- a/lib/Target/R600/AMDILNIDevice.cpp +++ b/lib/Target/R600/AMDILNIDevice.cpp @@ -8,8 +8,8 @@ /// \file //==-----------------------------------------------------------------------===// #include "AMDILNIDevice.h" -#include "AMDILEvergreenDevice.h" #include "AMDGPUSubtarget.h" +#include "AMDILEvergreenDevice.h" using namespace llvm; diff --git a/lib/Target/R600/AMDILNIDevice.h b/lib/Target/R600/AMDILNIDevice.h index bc7df37b26..24a640845e 100644 --- a/lib/Target/R600/AMDILNIDevice.h +++ b/lib/Target/R600/AMDILNIDevice.h @@ -15,8 +15,8 @@ //===---------------------------------------------------------------------===// #ifndef AMDILNIDEVICE_H #define AMDILNIDEVICE_H -#include "AMDILEvergreenDevice.h" #include "AMDGPUSubtarget.h" +#include "AMDILEvergreenDevice.h" namespace llvm { diff --git a/lib/Target/R600/AMDILSIDevice.cpp b/lib/Target/R600/AMDILSIDevice.cpp index 7c2710f1b2..3096c22067 100644 --- a/lib/Target/R600/AMDILSIDevice.cpp +++ b/lib/Target/R600/AMDILSIDevice.cpp @@ -8,9 +8,9 @@ /// \file //==-----------------------------------------------------------------------===// #include "AMDILSIDevice.h" +#include "AMDGPUSubtarget.h" #include "AMDILEvergreenDevice.h" #include "AMDILNIDevice.h" -#include "AMDGPUSubtarget.h" using namespace llvm; diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp index 6a62856e10..072ee49b63 100644 --- a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp +++ b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp @@ -15,12 +15,12 @@ #include "AMDGPUMCTargetDesc.h" #include "AMDGPUMCAsmInfo.h" #include "InstPrinter/AMDGPUInstPrinter.h" -#include "llvm/MC/MachineLocation.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MachineLocation.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/TargetRegistry.h" diff --git a/lib/Target/R600/MCTargetDesc/R600MCCodeEmitter.cpp b/lib/Target/R600/MCTargetDesc/R600MCCodeEmitter.cpp index dc91924c73..36deae9c0a 100644 --- a/lib/Target/R600/MCTargetDesc/R600MCCodeEmitter.cpp +++ b/lib/Target/R600/MCTargetDesc/R600MCCodeEmitter.cpp @@ -19,8 +19,8 @@ //===----------------------------------------------------------------------===// #include "R600Defines.h" -#include "MCTargetDesc/AMDGPUMCTargetDesc.h" #include "MCTargetDesc/AMDGPUMCCodeEmitter.h" +#include "MCTargetDesc/AMDGPUMCTargetDesc.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCInst.h" @@ -28,7 +28,6 @@ #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/raw_ostream.h" - #include #define SRC_BYTE_COUNT 11 diff --git a/lib/Target/R600/MCTargetDesc/SIMCCodeEmitter.cpp b/lib/Target/R600/MCTargetDesc/SIMCCodeEmitter.cpp index c47dc995c7..b4bdb25289 100644 --- a/lib/Target/R600/MCTargetDesc/SIMCCodeEmitter.cpp +++ b/lib/Target/R600/MCTargetDesc/SIMCCodeEmitter.cpp @@ -17,11 +17,11 @@ #include "MCTargetDesc/AMDGPUMCCodeEmitter.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCFixup.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" -#include "llvm/MC/MCFixup.h" #include "llvm/Support/raw_ostream.h" #define VGPR_BIT(src_idx) (1ULL << (9 * src_idx - 1)) diff --git a/lib/Target/R600/R600ExpandSpecialInstrs.cpp b/lib/Target/R600/R600ExpandSpecialInstrs.cpp index b6e62b7cef..b903d4aedd 100644 --- a/lib/Target/R600/R600ExpandSpecialInstrs.cpp +++ b/lib/Target/R600/R600ExpandSpecialInstrs.cpp @@ -17,8 +17,8 @@ #include "AMDGPU.h" #include "R600Defines.h" #include "R600InstrInfo.h" -#include "R600RegisterInfo.h" #include "R600MachineFunctionInfo.h" +#include "R600RegisterInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" diff --git a/lib/Target/R600/R600ISelLowering.cpp b/lib/Target/R600/R600ISelLowering.cpp index 19e6f9c057..da72c6d93e 100644 --- a/lib/Target/R600/R600ISelLowering.cpp +++ b/lib/Target/R600/R600ISelLowering.cpp @@ -17,10 +17,10 @@ #include "R600InstrInfo.h" #include "R600MachineFunctionInfo.h" #include "llvm/Argument.h" -#include "llvm/Function.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/SelectionDAG.h" +#include "llvm/Function.h" using namespace llvm; diff --git a/lib/Target/R600/R600InstrInfo.cpp b/lib/Target/R600/R600InstrInfo.cpp index 28637b890b..06b78d09cc 100644 --- a/lib/Target/R600/R600InstrInfo.cpp +++ b/lib/Target/R600/R600InstrInfo.cpp @@ -13,8 +13,8 @@ //===----------------------------------------------------------------------===// #include "R600InstrInfo.h" -#include "AMDGPUTargetMachine.h" #include "AMDGPUSubtarget.h" +#include "AMDGPUTargetMachine.h" #include "R600Defines.h" #include "R600RegisterInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" diff --git a/lib/Target/R600/R600InstrInfo.h b/lib/Target/R600/R600InstrInfo.h index 6bb0ca92e4..11685af5b0 100644 --- a/lib/Target/R600/R600InstrInfo.h +++ b/lib/Target/R600/R600InstrInfo.h @@ -15,11 +15,10 @@ #ifndef R600INSTRUCTIONINFO_H_ #define R600INSTRUCTIONINFO_H_ -#include "AMDIL.h" #include "AMDGPUInstrInfo.h" +#include "AMDIL.h" #include "R600Defines.h" #include "R600RegisterInfo.h" - #include namespace llvm { diff --git a/lib/Target/R600/R600RegisterInfo.h b/lib/Target/R600/R600RegisterInfo.h index c170ccb378..f9ca918f24 100644 --- a/lib/Target/R600/R600RegisterInfo.h +++ b/lib/Target/R600/R600RegisterInfo.h @@ -15,8 +15,8 @@ #ifndef R600REGISTERINFO_H_ #define R600REGISTERINFO_H_ -#include "AMDGPUTargetMachine.h" #include "AMDGPURegisterInfo.h" +#include "AMDGPUTargetMachine.h" namespace llvm { diff --git a/lib/Target/R600/SIAnnotateControlFlow.cpp b/lib/Target/R600/SIAnnotateControlFlow.cpp index 92385b6878..1c1e0a613e 100644 --- a/lib/Target/R600/SIAnnotateControlFlow.cpp +++ b/lib/Target/R600/SIAnnotateControlFlow.cpp @@ -13,12 +13,11 @@ //===----------------------------------------------------------------------===// #include "AMDGPU.h" - -#include "llvm/Pass.h" -#include "llvm/Module.h" +#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/Analysis/Dominators.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/Transforms/Utils/SSAUpdater.h" using namespace llvm; diff --git a/lib/Target/R600/SIInstrInfo.cpp b/lib/Target/R600/SIInstrInfo.cpp index adcffa8bbd..c6ad4d531d 100644 --- a/lib/Target/R600/SIInstrInfo.cpp +++ b/lib/Target/R600/SIInstrInfo.cpp @@ -18,7 +18,6 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/MC/MCInstrDesc.h" - #include using namespace llvm; diff --git a/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp b/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp index 048f9ebe05..b5b072dcbd 100644 --- a/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ b/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "XCoreMCTargetDesc.h" -#include "XCoreMCAsmInfo.h" #include "InstPrinter/XCoreInstPrinter.h" +#include "XCoreMCAsmInfo.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp index 474d3aa215..14ffbe51a9 100644 --- a/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -14,9 +14,9 @@ #define DEBUG_TYPE "asm-printer" #include "XCore.h" +#include "InstPrinter/XCoreInstPrinter.h" #include "XCoreInstrInfo.h" #include "XCoreMCInstLower.h" -#include "InstPrinter/XCoreInstPrinter.h" #include "XCoreSubtarget.h" #include "XCoreTargetMachine.h" #include "llvm/ADT/SmallString.h" diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 1c12391948..ab03bb58f1 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -26,8 +26,8 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Triple.h" -#include "llvm/DataLayout.h" #include "llvm/DIBuilder.h" +#include "llvm/DataLayout.h" #include "llvm/Function.h" #include "llvm/IRBuilder.h" #include "llvm/InlineAsm.h" diff --git a/lib/Transforms/Scalar/ObjCARC.cpp b/lib/Transforms/Scalar/ObjCARC.cpp index 3c4aea1330..8fa703893a 100644 --- a/lib/Transforms/Scalar/ObjCARC.cpp +++ b/lib/Transforms/Scalar/ObjCARC.cpp @@ -30,8 +30,8 @@ #define DEBUG_TYPE "objc-arc" #include "llvm/ADT/DenseMap.h" -#include "llvm/Support/Debug.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 7c18a38829..f2783c304c 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -14,8 +14,8 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/MemoryBuiltins.h" -- cgit v1.2.3-70-g09d2 From 73c35d86b9d5236be5b3f49bc8df11008b96636e Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 4 Jan 2013 23:19:55 +0000 Subject: Add time getters to the process interface for requesting the elapsed wall time, user time, and system time since a process started. For walltime, we currently use TimeValue's interface and a global initializer to compute a close approximation of total process runtime. For user time, this adds support for an somewhat more precise timing mechanism -- clock_gettime with the CLOCK_PROCESS_CPUTIME_ID clock selected. For system time, we have to do a full getrusage call to extract the system time from the OS. This is expensive but unavoidable. In passing, clean up the implementation of the old APIs and fix some latent bugs in the Windows code. This might have manifested on Windows ARM systems or other systems with strange 64-bit integer behavior. The old API for this both user time and system time simultaneously from a single getrusage call. While this results in fewer system calls, it also results in a lower precision user time and if only user time is desired, it introduces a higher overhead. It may be worthwhile to switch some of the pass timers to not track system time and directly track user and wall time. The old API also tracked walltime in a confusing way -- it just set it to the current walltime rather than providing any measure of wall time since the process started the way buth user and system time are tracked. The new API is more consistent here. The plan is to eventually implement these methods for a *child* process by using the wait3(2) system call to populate an rusage struct representing the whole subprocess execution. That way, after waiting on a child process its stats will become accurate and cheap to query. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171551 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/configure.ac | 4 ++ cmake/config-ix.cmake | 1 + cmake/modules/LLVM-Config.cmake | 7 ++- configure | 104 ++++++++++++++++++++++++++++++++++++++ include/llvm/Support/Process.h | 20 ++++++++ lib/Support/Process.cpp | 25 +++++++++ lib/Support/Unix/Process.inc | 62 +++++++++++++++-------- lib/Support/Windows/Process.inc | 51 ++++++++++++++----- unittests/Support/ProcessTest.cpp | 7 +++ 9 files changed, 244 insertions(+), 37 deletions(-) (limited to 'lib/Support/Process.cpp') diff --git a/autoconf/configure.ac b/autoconf/configure.ac index c5ac14999f..fdda3f9567 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1250,6 +1250,10 @@ AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1], [Define if dlopen() is available on this platform.]), AC_MSG_WARN([dlopen() not found - disabling plugin support])) +dnl clock_gettime() is required for modern timing support. +AC_SEARCH_LIBS(clock_gettime,rt,[], + AC_MSG_ERROR([clock_gettime not found and is required for modern POSIX timing uspport])) + dnl libffi is optional; used to call external functions from the interpreter if test "$llvm_cv_enable_libffi" = "yes" ; then AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1], diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 274de31c9e..c625b871e4 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -99,6 +99,7 @@ if( NOT PURE_WINDOWS ) endif() endif() check_library_exists(dl dlopen "" HAVE_LIBDL) + check_library_exists(rt clock_gettime "" HAVE_LIBRT) endif() # function checks diff --git a/cmake/modules/LLVM-Config.cmake b/cmake/modules/LLVM-Config.cmake index 574335c49d..163401c857 100755 --- a/cmake/modules/LLVM-Config.cmake +++ b/cmake/modules/LLVM-Config.cmake @@ -4,11 +4,14 @@ function(get_system_libs return_var) if( MINGW ) set(system_libs ${system_libs} imagehlp psapi) elseif( CMAKE_HOST_UNIX ) + if( HAVE_LIBRT ) + set(system_libs ${system_libs} rt) + endif() if( HAVE_LIBDL ) - set(system_libs ${system_libs} ${CMAKE_DL_LIBS}) + set(system_libs ${system_libs} ${CMAKE_DL_LIBS}) endif() if( LLVM_ENABLE_THREADS AND HAVE_LIBPTHREAD ) - set(system_libs ${system_libs} pthread) + set(system_libs ${system_libs} pthread) endif() endif( MINGW ) endif( NOT MSVC ) diff --git a/configure b/configure index e466dd67ca..8e06154b98 100755 --- a/configure +++ b/configure @@ -12517,6 +12517,110 @@ echo "$as_me: WARNING: dlopen() not found - disabling plugin support" >&2;} fi +{ echo "$as_me:$LINENO: checking for library containing clock_gettime" >&5 +echo $ECHO_N "checking for library containing clock_gettime... $ECHO_C" >&6; } +if test "${ac_cv_search_clock_gettime+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char clock_gettime (); +int +main () +{ +return clock_gettime (); + ; + return 0; +} +_ACEOF +for ac_lib in '' rt; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_clock_gettime=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_clock_gettime+set}" = set; then + break +fi +done +if test "${ac_cv_search_clock_gettime+set}" = set; then + : +else + ac_cv_search_clock_gettime=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_clock_gettime" >&5 +echo "${ECHO_T}$ac_cv_search_clock_gettime" >&6; } +ac_res=$ac_cv_search_clock_gettime +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + { { echo "$as_me:$LINENO: error: clock_gettime not found and is required for modern POSIX timing uspport" >&5 +echo "$as_me: error: clock_gettime not found and is required for modern POSIX timing uspport" >&2;} + { (exit 1); exit 1; }; } +fi + + if test "$llvm_cv_enable_libffi" = "yes" ; then { echo "$as_me:$LINENO: checking for library containing ffi_call" >&5 echo $ECHO_N "checking for library containing ffi_call... $ECHO_C" >&6; } diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index f149a4e058..ea8da6d4c5 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -64,6 +64,23 @@ public: /// \brief Get the operating system specific identifier for this process. virtual id_type get_id() = 0; + /// \brief Get the user time consumed by this process. + /// + /// Note that this is often an approximation and may be zero on platforms + /// where we don't have good support for the functionality. + virtual TimeValue get_user_time() const = 0; + + /// \brief Get the system time consumed by this process. + /// + /// Note that this is often an approximation and may be zero on platforms + /// where we don't have good support for the functionality. + virtual TimeValue get_system_time() const = 0; + + /// \brief Get the wall time consumed by this process. + /// + /// Note that this is often an approximation and may be zero on platforms + /// where we don't have good support for the functionality. + virtual TimeValue get_wall_time() const = 0; /// \name Static factory routines for processes. /// @{ @@ -88,6 +105,9 @@ class self_process : public process { public: virtual id_type get_id(); + virtual TimeValue get_user_time() const; + virtual TimeValue get_system_time() const; + virtual TimeValue get_wall_time() const; /// \name Process configuration (sysconf on POSIX) /// @{ diff --git a/lib/Support/Process.cpp b/lib/Support/Process.cpp index 64a1fa237e..2c0d37bb32 100644 --- a/lib/Support/Process.cpp +++ b/lib/Support/Process.cpp @@ -50,6 +50,31 @@ self_process::~self_process() { llvm_unreachable("This destructor must never be executed!"); } +/// \brief A helper function to compute the elapsed wall-time since the program +/// started. +/// +/// Note that this routine actually computes the elapsed wall time since the +/// first time it was called. However, we arrange to have it called during the +/// startup of the process to get approximately correct results. +static TimeValue getElapsedWallTime() { + static TimeValue &StartTime = *new TimeValue(TimeValue::now()); + return TimeValue::now() - StartTime; +} + +/// \brief A special global variable to ensure we call \c getElapsedWallTime +/// during global initialization of the program. +/// +/// Note that this variable is never referenced elsewhere. Doing so could +/// create race conditions during program startup or shutdown. +static volatile TimeValue DummyTimeValue = getElapsedWallTime(); + +// Implement this routine by using the static helpers above. They're already +// portable. +TimeValue self_process::get_wall_time() const { + return getElapsedWallTime(); +} + + #if defined(_MSC_VER) #pragma warning(pop) #endif diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index 9ad6272bab..a525538f78 100644 --- a/lib/Support/Unix/Process.inc +++ b/lib/Support/Unix/Process.inc @@ -49,6 +49,43 @@ process::id_type self_process::get_id() { return getpid(); } +static std::pair getRUsageTimes() { +#if defined(HAVE_GETRUSAGE) + struct rusage RU; + ::getrusage(RUSAGE_SELF, &RU); + return std::make_pair( + TimeValue( + static_cast(RU.ru_utime.tv_sec), + static_cast( + RU.ru_utime.tv_usec * TimeValue::NANOSECONDS_PER_MICROSECOND)), + TimeValue( + static_cast(RU.ru_stime.tv_sec), + static_cast( + RU.ru_stime.tv_usec * TimeValue::NANOSECONDS_PER_MICROSECOND))); +#else +#warning Cannot get usage times on this platform + return std::make_pair(TimeValue(), TimeValue()); +#endif +} + +TimeValue self_process::get_user_time() const { +#ifdef _POSIX_CPUTIME + // Try to get a high resolution CPU timer. + struct timespec TS; + if (::clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &TS) == 0) + return TimeValue(static_cast(TS.tv_sec), + static_cast(TS.tv_nsec)); +#endif + + // Otherwise fall back to rusage based timing. + return getRUsageTimes().first; +} + +TimeValue self_process::get_system_time() const { + // We can only collect system time by inspecting the results of getrusage. + return getRUsageTimes().second; +} + static unsigned getPageSize() { #if defined(__CYGWIN__) // On Cygwin, getpagesize() returns 64k but the page size for the purposes of @@ -95,29 +132,10 @@ size_t Process::GetMallocUsage() { #endif } -void -Process::GetTimeUsage(TimeValue& elapsed, TimeValue& user_time, - TimeValue& sys_time) -{ +void Process::GetTimeUsage(TimeValue &elapsed, TimeValue &user_time, + TimeValue &sys_time) { elapsed = TimeValue::now(); -#if defined(HAVE_GETRUSAGE) - struct rusage usage; - ::getrusage(RUSAGE_SELF, &usage); - user_time = TimeValue( - static_cast( usage.ru_utime.tv_sec ), - static_cast( usage.ru_utime.tv_usec * - TimeValue::NANOSECONDS_PER_MICROSECOND ) ); - sys_time = TimeValue( - static_cast( usage.ru_stime.tv_sec ), - static_cast( usage.ru_stime.tv_usec * - TimeValue::NANOSECONDS_PER_MICROSECOND ) ); -#else -#warning Cannot get usage times on this platform - user_time.seconds(0); - user_time.microseconds(0); - sys_time.seconds(0); - sys_time.microseconds(0); -#endif + llvm::tie(user_time, sys_time) = getRUsageTimes(); } int Process::GetCurrentUserId() { diff --git a/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index 9eb611be87..789ae7ddce 100644 --- a/lib/Support/Windows/Process.inc +++ b/lib/Support/Windows/Process.inc @@ -43,6 +43,36 @@ process::id_type self_process::get_id() { return GetCurrentProcess(); } +static TimeValue getTimeValueFromFILETIME(FILETIME Time) { + ULARGE_INTEGER TimeInteger; + TimeInteger.LowPart = Time.dwLowDateTime; + TimeInteger.HighPart = Time.dwHighDateTime; + + // FILETIME's are # of 100 nanosecond ticks (1/10th of a microsecond) + return TimeValue( + static_cast(TimeInteger.QuadPart / 10000000), + static_cast( + (TimeInteger.QuadPart % 10000000) * 100)); +} + +TimeValue self_process::get_user_time() const { + FILETIME ProcCreate, ProcExit, KernelTime, UserTime; + if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, + &UserTime) == 0) + return TimeValue(); + + return getTimeValueFromFILETIME(UserTime); +} + +TimeValue self_process::get_system_time() const { + FILETIME ProcCreate, ProcExit, KernelTime, UserTime; + if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, + &UserTime) == 0) + return TimeValue(); + + return getTimeValueFromFILETIME(KernelTime); +} + // This function retrieves the page size using GetSystemInfo and is present // solely so it can be called once to initialize the self_process member below. static unsigned getPageSize() { @@ -76,22 +106,17 @@ Process::GetMallocUsage() return size; } -void -Process::GetTimeUsage( - TimeValue& elapsed, TimeValue& user_time, TimeValue& sys_time) -{ +void Process::GetTimeUsage(TimeValue &elapsed, TimeValue &user_time, + TimeValue &sys_time) { elapsed = TimeValue::now(); - uint64_t ProcCreate, ProcExit, KernelTime, UserTime; - GetProcessTimes(GetCurrentProcess(), (FILETIME*)&ProcCreate, - (FILETIME*)&ProcExit, (FILETIME*)&KernelTime, - (FILETIME*)&UserTime); + FILETIME ProcCreate, ProcExit, KernelTime, UserTime; + if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, + &UserTime) == 0) + return; - // FILETIME's are # of 100 nanosecond ticks (1/10th of a microsecond) - user_time.seconds( UserTime / 10000000 ); - user_time.nanoseconds( unsigned(UserTime % 10000000) * 100 ); - sys_time.seconds( KernelTime / 10000000 ); - sys_time.nanoseconds( unsigned(KernelTime % 10000000) * 100 ); + user_time = getTimeValueFromFILETIME(UserTime); + sys_time = getTimeValueFromFILETIME(SystemTime); } int Process::GetCurrentUserId() diff --git a/unittests/Support/ProcessTest.cpp b/unittests/Support/ProcessTest.cpp index 58a7c4acaa..e57c0e6eaf 100644 --- a/unittests/Support/ProcessTest.cpp +++ b/unittests/Support/ProcessTest.cpp @@ -30,6 +30,13 @@ TEST(ProcessTest, SelfProcess) { #endif EXPECT_LT(1u, process::get_self()->page_size()); + + EXPECT_LT(TimeValue::MinTime, process::get_self()->get_user_time()); + EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_user_time()); + EXPECT_LT(TimeValue::MinTime, process::get_self()->get_system_time()); + EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_system_time()); + EXPECT_LT(TimeValue::MinTime, process::get_self()->get_wall_time()); + EXPECT_GT(TimeValue::MaxTime, process::get_self()->get_wall_time()); } } // end anonymous namespace -- cgit v1.2.3-70-g09d2