Commit Graph

323 Commits

Author SHA1 Message Date
Chandler Carruth
1b279144ec [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 11:23:27 +00:00
Alexey Samsonov
af94b8a441 Remove unnecessary StringRef->std::string conversion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224953 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-29 20:59:02 +00:00
David Majnemer
1691fa27d7 ThreadLocal: Move Unix-specific code out of Support/ThreadLocal.cpp
Just a cleanup, no functionality change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224227 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:19:53 +00:00
David Majnemer
1f59bf4441 ThreadLocal: Return a mutable pointer if templated with a non-const type
It makes more sense for ThreadLocal<const T>::get to return a const T*
and ThreadLocal<T>::get to return a T*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224225 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:04:45 +00:00
Rafael Espindola
8ef835e3dc MAP_FILE is the default. We don't need to add it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224144 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 19:12:42 +00:00
Rafael Espindola
7f4b22e7de Move the resize file feature from mapped_file_region to the only user.
This removes a duplicated stat on every file that llvm-ar looks at.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224138 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 18:13:23 +00:00
Rafael Espindola
e1136e38a7 Pass a FD to resise_file and add a testcase.
I will add a real use in another commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224136 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 17:55:12 +00:00
Rafael Espindola
0be06cf360 Remove a convoluted way of calling close by moving the call to the only caller.
As a bonus we can actually check the return value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 20:12:55 +00:00
Rafael Espindola
de15d01f9d Remove dead code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224029 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 17:17:26 +00:00
Rafael Espindola
3f598f77bd Remove dead code. NFC.
This interface was added 2 years ago but users never developed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223368 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 16:59:36 +00:00
Chandler Carruth
84c0f65446 Fix several bugs in r221220's new program finding code.
In both the Unix and Windows variants, std::getenv was called and the
result passed directly to a function accepting a StringRef. This isn't
OK because it might return a null pointer and that causes the StringRef
constructor to assert (and generally produces crash-prone code if
asserts are disabled). Fix this by independently testing the result as
non-null prior to splitting things.

This in turn uncovered another bug in the Unix variant where it would
infinitely recurse if PATH="", or after this fix if PATH isn't set.
There is no need to recurse at all. Slightly re-arrange the code to make
it clear that we can just fixup the Paths argument based on the
environment if we find anything.

I don't know of a particularly useful way to test these routines in
LLVM. I'll commit a test to Clang that ensures that its driver correctly
handles various settings of PATH. However, I have no idea how to
correctly write a Windows test for the PATHEXT change. Any Windows
developers who could provide such a test, please have at. =D

Many thanks to Nick Lewycky and others for helping debug this. =/ It was
quite nasty for us to track down.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223099 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-02 00:52:01 +00:00
Jiangning Liu
07e1080b89 Revert 220932.
Commit 220932 caused crash when building clang-tblgen on aarch64 debian target,
so it's blocking all daily tests.

The std::call_once implementation in pthread has bug for aarch64 debian.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221331 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-05 04:44:31 +00:00
Rafael Espindola
5dac5bd225 Remove FindProgramByName. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221258 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04 12:35:47 +00:00
Michael J. Spencer
376a2e104f [Support][Program] Add findProgramByName(Name, OptionalPaths)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221220 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04 01:29:29 +00:00
David Blaikie
c700c4d161 Update the non-pthreads fallback for RWMutex on Unix
Tested this by #if 0'ing out the pthreads implementation, which
indicated that this fallback was not currently compiling successfully
and applying this patch resolves that.

Patch by Andy Chien.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220969 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-31 17:02:30 +00:00
Chris Bieneman
8744520b53 Removing the static initializer in ManagedStatic.cpp by using llvm_call_once to initialize the ManagedStatic mutex.
Summary:
This patch adds an llvm_call_once which is a wrapper around std::call_once on platforms where it is available and devoid of bugs. The patch also migrates the ManagedStatic mutex to be allocated using llvm_call_once.

These changes are philosophically equivalent to the changes added in r219638, which were reverted due to a hang on Win32 which was the result of a bug in the Windows implementation of std::call_once.

Reviewers: aaron.ballman, chapuni, chandlerc, rnk

Reviewed By: rnk

Subscribers: majnemer, llvm-commits

Differential Revision: http://reviews.llvm.org/D5922

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220932 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-30 22:07:09 +00:00
Rafael Espindola
f6066a7fd3 Fix bug where sys::Wait could wait on wrong pid.
Setting ChildPid to -1 would cause waitpid to wait for any child process.

Patch by Daniel Reynaud!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220717 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-27 20:30:04 +00:00
Benjamin Kramer
9552fcab70 Strength reduce constant-sized vectors into arrays. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220412 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 19:55:26 +00:00
NAKAMURA Takumi
5adece02b6 Unix/Signals.inc: Let findModulesAndOffsets() built conditionally regarding to (defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)). [-Wunused-function]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219596 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-13 04:32:43 +00:00
Benjamin Kramer
b85e7ae9ab [Modules] Add some missing includes to make files compile stand-alone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219592 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-12 22:49:26 +00:00
Chandler Carruth
fade9f1d17 Guard the definition of the stack tracing function with the same macros
that guard its usage. Without this, we can get unused function warnings
when backtraces are disabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-11 01:04:40 +00:00
Alexey Samsonov
fab0a999d7 Follow-up to r219534 to make symbolization more robust.
1) Explicitly provide important arguments to llvm-symbolizer,
not relying on defaults.
2) Be more defensive about symbolizer output.

This might fix weird failures on ninja-x64-msvc-RA-centos6 buildbot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219541 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 22:58:26 +00:00
Alexey Samsonov
fcc00a10e3 Re-land r219354: Use llvm-symbolizer to symbolize LLVM/Clang crash dumps.
In fact, symbolization is now expected to work only on Linux and
FreeBSD/NetBSD, where we have dl_iterate_phdr and can learn the
main executable name without argv0 (it will be possible on BSD systems
after http://reviews.llvm.org/D5693 lands). #ifdef-out the code for
all the rest Unix systems.

Reviewed in http://reviews.llvm.org/D5610


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219534 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 22:06:59 +00:00
Alexey Samsonov
aa486d0764 Revert r219354. It seems to break some buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 23:07:59 +00:00
Alexey Samsonov
ee3948fdbe Use llvm-symbolizer to symbolize LLVM/Clang crash dumps.
This change modifies fatal signal handler used in LLVM tools.
Now it attempts to find llvm-symbolizer binary and communicates
with it in order to turn instruction addresses into
function/file/line info entries. This should significantly improve
stack traces readability in Debug builds.

This feature only works on selected platforms (including Darwin
and Linux). If the symbolization fails for some reason, signal
handler will fallback to the original behavior.

Reviewed in http://reviews.llvm.org/D5610


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219354 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 22:57:47 +00:00
David Majnemer
8e0fd8cd7c Unix/Process: Don't use pthread_sigmask if we aren't built with threads
We won't link in pthreads if we weren't built with LLVM_ENABLE_THREADS
which means we won't get access to pthread_sigmask.  Use sigprocmask
instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219288 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 08:48:43 +00:00
David Majnemer
ba2113f934 Attempt to calm down buildbots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219190 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-07 05:56:45 +00:00
David Majnemer
220c5ca8f4 Support: Don't call close again if we get EINTR
Most Unix-like operating systems guarantee that the file descriptor is
closed after a call to close(2), even if close comes back with EINTR.
For these systems, calling close _again_ will either do nothing or close
some other file descriptor open(2)'d by another thread. (Linux)

However, some operating systems do not have this behavior.  They require
at least another call to close(2) before guaranteeing that the
descriptor is closed. (HP-UX)

And some operating systems have an unpredictable blend of the two
behaviors! (xnu)

Avoid this disaster by blocking all signals before we call close(2).
This ensures that a signal will not be delivered to the thread and
close(2) will not give us back EINTR.  We restore the signal mask once
the operation is done.

N.B. This isn't a problem on Windows, it doesn't have a notion of EINTR
because signals always get delivered to dedicated signal handling
threads.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219189 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-07 05:48:40 +00:00
David Majnemer
3ba3a4ccfd Support: Add a utility to remap std{in,out,err} to /dev/null if closed
It's possible to start a program with one (or all) of the standard file
descriptors closed.  Subsequent open system calls will give the program
a low-numbered file descriptor.

This is problematic because we may believe we are writing to standard
out instead of a file.

Introduce Process::FixupStandardFileDescriptors, a helper function to
remap standard file descriptors to /dev/null if they were closed before
the program started.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219170 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-06 23:16:18 +00:00
Chris Bieneman
4bb780af42 Adding #ifdef around TermColorMutex based on feedback from Craig Topper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 18:35:58 +00:00
NAKAMURA Takumi
d968b05f4d Unix/Host.inc: Remove <cstdlib>. It has been unused for a long time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218373 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 04:45:02 +00:00
NAKAMURA Takumi
4921f68311 Unix/Host.inc: Wrap a comment line in 80-col.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218371 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 04:44:50 +00:00
NAKAMURA Takumi
c44f94d681 Unix/Host.inc: Remove leading whitespace. It had been here since r56942!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218370 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-24 04:44:37 +00:00
Chris Bieneman
f1a19cd9fc Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218283 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-22 22:39:20 +00:00
Rafael Espindola
8d230cd536 Misc cleanups to the FileSytem api.
The main difference is the removal of

std::error_code exists(const Twine &path, bool &result);

It was an horribly redundant interface since a file not existing is also a valid
error_code. Now we have an access function that returns just an error_code. This
is the only function that has to be implemented for Unix and Windows. The
functions can_write, exists and can_execute an now just wrappers.

One still has to be very careful using these function to avoid introducing
race conditions (Time of check to time of use).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 20:30:02 +00:00
Rafael Espindola
52fa0d066a Add writeFileWithSystemEncoding to LibLLVMSuppor.
This patch adds to LLVMSupport the capability of writing files with
international characters encoded in the current system encoding. This
is relevant for Windows, where we can either use UTF16 or the current
code page (the legacy Windows international characters). On UNIX, the
file is always saved in UTF8.

This will be used in a patch for clang to thoroughly support response
files creation when calling other tools, addressing PR15171. On
Windows, to correctly support internationalization, we need the
ability to write response files both in UTF16 or the current code
page, depending on the tool we will call. GCC for mingw, for instance,
requires files to be encoded in the current code page. MSVC tools
requires files to be encoded in UTF16.

Patch by Rafael Auler!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217068 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 20:02:00 +00:00
Chris Bieneman
16632ce4c7 Cleaning up remaining static initializers in Signals.inc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216996 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 23:48:13 +00:00
Chris Bieneman
d814e38de8 Cleaning up static initializers in Signals.inc
Reviewed by: Chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216704 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 01:05:16 +00:00
Chris Bieneman
77bf4f97bf Cleaning up static initializers in TimeValue.
Code reviewed by Chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216703 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 01:05:12 +00:00
Benjamin Kramer
ccce7032ae Add an explicit cast to pacify implicit boolean conversion warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216539 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 11:47:52 +00:00
Rafael Espindola
9be4884731 Merge TempDir and system_temp_directory.
We had two functions for finding the temp or cache directory. Each had a
different set of smarts about OS specific APIs.

With this patch system_temp_directory becomes the only way to do it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216460 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 14:47:52 +00:00
Rafael Espindola
c33fe1b296 Fix bug in llvm::sys::argumentsFitWithinSystemLimits().
This patch fixes a subtle bug in the UNIX implementation of
llvm::sys::argumentsFitWithinSystemLimits() regarding the misuse of a static
variable. This bug causes our cached number that stores the system command line
maximum length to be halved after each call to the function. With a sufficient
number of calls to this function, it will eventually report any given command
line string to be over system limits.

Patch by Rafael Auler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216415 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 22:53:21 +00:00
Dylan Noblesmith
389f13012f Support: add llvm::unique_lock
Based on the STL class of the same name, it guards a mutex
while also allowing it to be unlocked conditionally before
destruction.

This eliminates the last naked usages of mutexes in LLVM and
clang.

It also uncovered and fixed a bug in callExternalFunction()
when compiled without USE_LIBFFI, where the mutex would never
be unlocked if the end of the function was reached.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216338 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 23:07:14 +00:00
Dylan Noblesmith
d930a30833 Support: make LLVM Mutexes STL-compatible
Use lock/unlock() convention instead of acquire/release().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216336 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 22:49:22 +00:00
Dylan Noblesmith
7e3e4311c5 Support/Unix: use ScopedLock wherever possible
Only one function remains a bit too complicated
for a simple mutex guard. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 22:49:17 +00:00
Benjamin Kramer
00e08fcaa0 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Rafael Espindola
d6039e045f Remove dead code. Fixes pr20544.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215243 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 21:35:52 +00:00
Alp Toker
46e17cae55 Build fix for systems without futimes/futimens
Some versions of Android don't have futimes/futimens and this code wasn't
updated during the recent errc refactoring.

Patch by Luqman Aden!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212055 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 18:57:04 +00:00
Julien Lerouge
86ebb340ef lldb can interrupt waitpid, so EINTR shouldn't be an error. This fixes the case
where there is no timeout. In the case where there is a timeout though, the
code is still wrong since it doesn't check that the alarm really went off.

Without this patch, I cannot debug a program that forks itself using
sys::ExecuteAndWait with lldb.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211918 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 18:02:54 +00:00
Daniel Sanders
d3aaad2d26 Revert: r211588 - [mips] Use __clear_cache builtin instead of cacheflush() in Unix Memory::InvalidateInstructionCache()
Buildbot reports a test failure on the llvm-mips-linux builder and blames r211588.
Although it doesn't appear in the blamelist, it seems it could also be r211587
(because it's committed to compiler-rt?) since they were tested together.

Reverting the most likely suspect (r211588) to confirm one way or the other.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211594 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 13:53:56 +00:00