1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

3096 Commits

Author SHA1 Message Date
Rafael Espindola
cb99753ea9 Pass a FD to resise_file and add a testcase.
I will add a real use in another commit.

llvm-svn: 224136
2014-12-12 17:55:12 +00:00
Rafael Espindola
56ca84422a Remove unused feature. NFC.
llvm-svn: 224135
2014-12-12 17:35:34 +00:00
Rafael Espindola
a4ea055f1a 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.

llvm-svn: 224046
2014-12-11 20:12:55 +00:00
Michael Ilseman
5ae09fdaf3 Silence static analyzer warnings in LLVMSupport.
The static analyzer catches a few potential bugs in LLVMSupport. Add
in asserts to silence the warnings.

llvm-svn: 224044
2014-12-11 19:46:38 +00:00
Rafael Espindola
22caf7934c Remove dead code. NFC.
llvm-svn: 224029
2014-12-11 17:17:26 +00:00
Yaron Keren
3a3a3de962 Silence warning: variable 'buffer' set but not used.
llvm-svn: 223389
2014-12-04 21:36:38 +00:00
Rafael Espindola
ba5f108739 Remove dead code. NFC.
This interface was added 2 years ago but users never developed.

llvm-svn: 223368
2014-12-04 16:59:36 +00:00
Tom Stellard
a73fa23ade Triple: Add AMDHSA operating system type
This operating system type represents the AMD HSA runtime,
and will be required by the R600 backend in order to generate
correct code for this runtime.

llvm-svn: 223124
2014-12-02 16:45:47 +00:00
Chandler Carruth
42b7a037b7 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.

llvm-svn: 223099
2014-12-02 00:52:01 +00:00
Evgeniy Stepanov
930e5bcfb5 [msan] Annotate zlib functions for MemorySanitizer.
Mark destination buffer in zlib::compress and zlib::decompress as fully
initialized.

When building LLVM with system zlib and MemorySanitizer instrumentation,
MSan does not observe memory writes in zlib code and erroneously considers
zlib output buffers as uninitialized, resulting in false use-of-uninitialized
memory reports. This change helps MSan understand the state of that memory
and prevents such reports.

llvm-svn: 222763
2014-11-25 15:24:07 +00:00
Paul Robinson
a98fe04f95 More long path name support on Windows, this time in program execution.
Allows long paths for the executable and redirected stdin/stdout/stderr.
Addresses PR21563.

llvm-svn: 222671
2014-11-24 18:05:29 +00:00
Matthias Braun
cfe609e473 Allow multiple -debug-only args
Debug output is shown if any of the -debug-only arguments match.

llvm-svn: 222547
2014-11-21 18:06:09 +00:00
Alexey Samsonov
b78ee81286 Remove support for undocumented SpecialCaseList entries.
"global-init", "global-init-src" and "global-init-type" were originally
used to blacklist entities in ASan init-order checker. However, they
were never documented, and later were replaced by "=init" category.

Old blacklist entries should be converted as follows:
  * global-init:foo -> global:foo=init
  * global-init-src:bar -> src:bar=init
  * global-init-type:baz -> type:baz=init

llvm-svn: 222401
2014-11-20 01:27:19 +00:00
Lang Hames
2082c9d610 [ADT] Fix PR20728 - Incorrect APFloat::fusedMultiplyAdd results for x86_fp80.
As detailed at http://llvm.org/PR20728, due to an internal overflow in
APFloat::multiplySignificand the APFloat::fusedMultiplyAdd method can return
incorrect results for x87DoubleExtended (x86_fp80) values. This commonly
manifests as incorrect constant folding of libm fmal calls on x86. E.g.

fmal(1.0L, 1.0L, 3.0L) == 0.0L      (should be 4.0L)

This patch fixes PR20728 by adding an extra bit to the significand for
intermediate results of APFloat::multiplySignificand, avoiding the overflow.

llvm-svn: 222374
2014-11-19 19:15:41 +00:00
David Blaikie
60e6c80905 Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool>
This is to be consistent with StringSet and ultimately with the standard
library's associative container insert function.

This lead to updating SmallSet::insert to return pair<iterator, bool>,
and then to update SmallPtrSet::insert to return pair<iterator, bool>,
and then to update all the existing users of those functions...

llvm-svn: 222334
2014-11-19 07:49:26 +00:00
David Blaikie
7499cbae4c Remove StringMap::GetOrCreateValue in favor of StringMap::insert
Having two ways to do this doesn't seem terribly helpful and
consistently using the insert version (which we already has) seems like
it'll make the code easier to understand to anyone working with standard
data structures. (I also updated many references to the Entry's
key and value to use first() and second instead of getKey{Data,Length,}
and get/setValue - for similar consistency)

Also removes the GetOrCreateValue functions so there's less surface area
to StringMap to fix/improve/change/accommodate move semantics, etc.

llvm-svn: 222319
2014-11-19 05:49:42 +00:00
Michael J. Spencer
312f54fa4a Support ELF files of unknown type.
llvm-svn: 222208
2014-11-18 01:14:25 +00:00
Renato Golin
b92ad16856 Fix ARM triple parsing
The triple parser should only accept existing architecture names
when the triple starts with armv, armebv, thumbv or thumbebv.

Patch by Gabor Ballabas.

llvm-svn: 222129
2014-11-17 14:08:57 +00:00
Yaron Keren
6469f7bd2d silence gcc 4.9.1 warning in /llvm/lib/Support/Windows/Path.inc:564:39:
warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   if (ec = widenPath(path, path_utf16))

llvm-svn: 222122
2014-11-17 09:29:33 +00:00
NAKAMURA Takumi
d1ba90ee16 SearchForAddressOfSymbol(): Disable 3 symbols, copysignf, fminf, and fmaxf, on msc17. *These were added in VS 2013*
llvm-svn: 221971
2014-11-14 04:53:55 +00:00
Reid Kleckner
824f28d87f Fix the VS 2012 build
VS 2012 doesn't have fminf or fmaxf.

llvm-svn: 221949
2014-11-13 23:45:50 +00:00
Reid Kleckner
b9aef21886 Fix symbol resolution of floating point libc builtins in MCJIT
Fix for LLI failure on Windows\X86: http://llvm.org/PR5053

LLI.exe crashes on Windows\X86 when single precession floating point
intrinsics like the following are used: acos, asin, atan, atan2, ceil,
copysign, cos, cosh, exp, floor, fmin, fmax, fmod, log, pow, sin, sinh,
sqrt, tan, tanh

The above intrinsics are defined as inline-expansions in math.h, and are
not exported by msvcr120.dll (Win32 API GetProcAddress returns null).

For an FREM instruction, the JIT compiler generates a call to a stub for
the fmodf() intrinsic, and adds a relocation to fixup at load time. The
loader searches the libraries for the function, but fails because the
symbol is not exported. So, the call target remains NULL and the
execution crashes.

Since the math functions are loaded at JIT/runtime, the JIT can patch
CALL instruction directly instead of the searching the libraries'
exported symbols.  However, this fix caused build failures due to
unresolved symbols like _fmodf at link time.

Therefore, the current fix defines helper functions in the Runtime
link/load library to perform the above operations.  The address of these
helper functions are used to patch up the CALL instruction at load time.

Reviewers: lhames, rnk

Reviewed By: rnk

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

Patch by Swaroop Sridhar!

llvm-svn: 221947
2014-11-13 23:32:52 +00:00
Reid Kleckner
aa6f2355ba Avoid usage of char16_t as MSVC "14" doesn't appear to support it
Fixes the MSVC "14" build.

llvm-svn: 221932
2014-11-13 22:09:56 +00:00
Aaron Ballman
f9b64b77a6 Fixing -Wtype-limits warnings with the asserts (the expression would always evaluate to true). Also fixing a -Wcast-qual warning, where the cast expression isn't required.
llvm-svn: 221888
2014-11-13 13:55:13 +00:00
Rafael Espindola
ad6b4ce7dc Read 64 bits at a time in the bitcode reader.
The reading of 64 bit values could still be optimized, but at least this cuts
down on the number of virtual calls to fetch more data.

llvm-svn: 221865
2014-11-13 07:23:22 +00:00
Paul Robinson
2c8990690e Improve long path name support on Windows.
Windows normally limits the length of an absolute path name to 260
characters; directories can have lower limits.  These limits increase
to about 32K if you use absolute paths with the special '\\?\'
prefix. Teach Support\Windows\Path.inc to use that prefix as needed.

TODO: Other parts of Support could also learn to use this prefix.
llvm-svn: 221841
2014-11-13 00:12:14 +00:00
Rafael Espindola
290c50c9e5 Use the return of readBytes to find out if we are at the end of the stream.
This allows the removal of isObjectEnd and opens the way for reading 64 bits
at a time.

llvm-svn: 221804
2014-11-12 18:37:00 +00:00
Rafael Espindola
9b65f4ede9 Return the number of read bytes in MemoryObject::readBytes.
Returning more information will allow BitstreamReader to be simplified a bit
and changed to read 64 bits at a time.

llvm-svn: 221794
2014-11-12 17:11:16 +00:00
Rafael Espindola
ed6949a6a7 Merge StreamableMemoryObject into MemoryObject.
Every MemoryObject is a StreamableMemoryObject since the removal of
StringRefMemoryObject, so just merge the two.

I will clean up the MemoryObject interface in the upcoming commits.

llvm-svn: 221766
2014-11-12 03:55:46 +00:00
Rafael Espindola
60f320af5d Remove unused method. NFC.
llvm-svn: 221759
2014-11-12 02:35:31 +00:00
Rafael Espindola
78355a98d5 Make readBytes pure virtual. Every real implementation has it.
llvm-svn: 221758
2014-11-12 02:30:38 +00:00
Rafael Espindola
06dc952912 Remove unused method. NFC.
llvm-svn: 221757
2014-11-12 02:27:40 +00:00
Rafael Espindola
e9b4057db3 Remove the now unused StringRefMemoryObject.h.
llvm-svn: 221755
2014-11-12 02:13:27 +00:00
Michael J. Spencer
6a5243a18f Fix style.
llvm-svn: 221547
2014-11-07 21:30:36 +00:00
NAKAMURA Takumi
e4e7919bbd [CMake] LLVMSupport: Give system_libs PRIVATE scope when LLVMSupport is built as SHARED. Users of LLVMSupport won't inherit ${system_libs}.
unittests/SupporTests is another user of libpthreads. Apply LLVM_SYSTEM_LIBS for him explicitly.

llvm-svn: 221531
2014-11-07 16:08:19 +00:00
Matt Arsenault
1ef7d8d172 Remove unnecessary .c_str() when implicitly converting to Twine
llvm-svn: 221422
2014-11-06 01:13:27 +00:00
David Majnemer
2aea4add6d llvm-readobj: Add support for dumping the DOS header in PE files
llvm-svn: 221333
2014-11-05 06:24:35 +00:00
Jiangning Liu
8d0fd58599 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.

llvm-svn: 221331
2014-11-05 04:44:31 +00:00
Rafael Espindola
c270ce792c Remove FindProgramByName. NFC.
llvm-svn: 221258
2014-11-04 12:35:47 +00:00
Yaron Keren
b77437e0cb Fix Visual C++ warning, Program.inc(85): warning C4018: '<' : signed/unsigned mismatch.
llvm-svn: 221252
2014-11-04 09:22:41 +00:00
NAKAMURA Takumi
021ccf3422 sys::findProgramByName(): [Win32] Tweak to pass lowercase .exe to SearchPath() to appease clang Driver's tests.
It seems SearchPath() doesn't show actual extension on the filesystem.

FIXME: Shall we use FindFirstFile() here?
llvm-svn: 221246
2014-11-04 08:17:15 +00:00
Yaron Keren
5cf7c4e8f0 #include <winbase.h> is not enough for Visual C++ 2013, it errors:
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(46):
error C2146: syntax error : missing ';' before identifier 'nLength'
1>C:\Program Files (x86)\Windows Kits\8.1\Include\um\minwinbase.h(46):
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
...

including <windows.h> is actually required.

llvm-svn: 221244
2014-11-04 07:53:30 +00:00
Michael J. Spencer
17a3ab5413 Use findProgramByName.
llvm-svn: 221221
2014-11-04 01:29:59 +00:00
Michael J. Spencer
5dc02583f8 [Support][Program] Add findProgramByName(Name, OptionalPaths)
llvm-svn: 221220
2014-11-04 01:29:29 +00:00
Rafael Espindola
2def7a3218 Add CRLF support to LineIterator.
The MRI scripts have to work with CRLF, and in general it is probably
a good idea to support this in a core utility like LineIterator.

llvm-svn: 221153
2014-11-03 14:09:47 +00:00
Peter Collingbourne
a81f6c243f CMake: Add libm to list of system libs printed by llvm-config.
This is required by the interpreter library, and also matches the autoconf
behavior.

llvm-svn: 221147
2014-11-03 10:38:26 +00:00
David Blaikie
41026cffab 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.

llvm-svn: 220969
2014-10-31 17:02:30 +00:00
Hans Wennborg
2d821f95ed Speculative fix for Windows build after r220932
llvm-svn: 220936
2014-10-30 23:10:01 +00:00
Chris Bieneman
6184f87702 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

llvm-svn: 220932
2014-10-30 22:07:09 +00:00
Rafael Espindola
01a14a8846 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!

llvm-svn: 220717
2014-10-27 20:30:04 +00:00
Frederic Riss
bd8529ec43 Modernize doxygen comments in Support/Dwarf.h
In post-commit review of r219442, Rafael pointed out that the comment style
of the newly introduced helper didn't follow LLVM's coding standard.
Modernize the whole file to the new standards.

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

llvm-svn: 220467
2014-10-23 04:08:38 +00:00
Benjamin Kramer
a6c059251d Strength reduce constant-sized vectors into arrays. No functionality change.
llvm-svn: 220412
2014-10-22 19:55:26 +00:00
David Blaikie
de3ceaae80 PR21202: Memory leak in Windows RWMutexImpl when using SRWLOCK
llvm-svn: 220251
2014-10-21 00:34:39 +00:00
Peter Collingbourne
133a76a302 Introduce LLVMParseCommandLineOptions C API function.
llvm-svn: 219975
2014-10-16 22:47:52 +00:00
Chris Bieneman
937b40b209 Defining a new API for debug options that doesn't rely on static global cl::opts.
Summary:
This is based on the discussions from the LLVMDev thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-August/075886.html

Reviewers: chandlerc

Reviewed By: chandlerc

Subscribers: llvm-commits

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

llvm-svn: 219854
2014-10-15 21:54:35 +00:00
Hal Finkel
717a51f66b Revert "r216914 - Revert: [APFloat] Fixed a bug in method 'fusedMultiplyAdd'"
Reapply r216913, a fix for PR20832 by Andrea Di Biagio. The commit was reverted
because of buildbot failures, and credit goes to Ulrich Weigand for isolating
the underlying issue (which can be confirmed by Valgrind, which does helpfully
light up like the fourth of July). Uli explained the problem with the original
patch as:

  It seems the problem is calling multiplySignificand with an addend of category
  fcZero; that is not expected by this routine.  Note that for fcZero, the
  significand parts are simply uninitialized, but the code in (or rather, called
  from) multiplySignificand will unconditionally access them -- in effect using
  uninitialized contents.

This version avoids using a category == fcZero addend within
multiplySignificand, which avoids this problem (the Valgrind output is also now
clean).

Original commit message:

[APFloat] Fixed a bug in method 'fusedMultiplyAdd'.

When folding a fused multiply-add builtin call, make sure that we propagate the
correct result in the case where the addend is zero, and the two other operands
are finite non-zero.

Example:
  define double @test() {
    %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
    ret double %1
  }

Before this patch, the instruction simplifier wrongly folded the builtin call
in function @test to constant 'double 7.0'.
With this patch, method 'fusedMultiplyAdd' correctly evaluates the multiply and
propagates the expected result (i.e. 56.0).

Added test fold-builtin-fma.ll with the reproducible from PR20832 plus extra
test cases to verify the behavior of method 'fusedMultiplyAdd' in the presence
of NaN/Inf operands.

This fixes PR20832.

llvm-svn: 219708
2014-10-14 19:23:07 +00:00
NAKAMURA Takumi
6727c3f0f4 Revert r219638, (r219640 and r219676), "Removing the static destructor from ManagedStatic.cpp by controlling the allocation and de-allocation of the mutex."
It caused hang-up on msc17 builder, probably deadlock.

llvm-svn: 219687
2014-10-14 15:58:16 +00:00
Chris Bieneman
2f2f9c1cde Removing the static destructor from ManagedStatic.cpp by controlling the allocation and de-allocation of the mutex.
This patch adds a new llvm_call_once function which is used by the ManagedStatic implementation to safely initialize a global to avoid static construction and destruction.

llvm-svn: 219638
2014-10-13 22:37:25 +00:00
David Majnemer
0e491f60c5 InstCombine: Don't miscompile (x lshr C1) udiv C2
We have a transform that changes:
  (x lshr C1) udiv C2
into:
  x udiv (C2 << C1)

However, it is unsafe to do so if C2 << C1 discards any of C2's bits.

This fixes PR21255.

llvm-svn: 219634
2014-10-13 21:48:30 +00:00
NAKAMURA Takumi
bdabb1a1e6 Unix/Signals.inc: Let findModulesAndOffsets() built conditionally regarding to (defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)). [-Wunused-function]
llvm-svn: 219596
2014-10-13 04:32:43 +00:00
Benjamin Kramer
bb84b2ad29 [Modules] Add some missing includes to make files compile stand-alone.
llvm-svn: 219592
2014-10-12 22:49:26 +00:00
Benjamin Kramer
6b288538ef Modernize old-style static asserts. NFC.
llvm-svn: 219588
2014-10-12 17:56:40 +00:00
Chandler Carruth
c9cd836263 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.

llvm-svn: 219558
2014-10-11 01:04:40 +00:00
Alexey Samsonov
8bdcdd9e37 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.

llvm-svn: 219541
2014-10-10 22:58:26 +00:00
Alexey Samsonov
6c7aeddca0 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

llvm-svn: 219534
2014-10-10 22:06:59 +00:00
Benjamin Kramer
5b356ef312 APInt: Unfold return expressions so RVO can work.
Saves a couple of expensive deep copies. NFC.

llvm-svn: 219487
2014-10-10 10:18:12 +00:00
Chandler Carruth
e6b432108a [ADT] Add the scalbn function for APFloat.
llvm-svn: 219473
2014-10-10 04:54:30 +00:00
Frederic Riss
d7a0c1935d Add ApplePropertyString dump helper to Dwarf.{h|cpp}.
Reviewers: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 219442
2014-10-09 20:43:04 +00:00
Alexey Samsonov
88789ae22c Revert r219354. It seems to break some buildbots.
llvm-svn: 219355
2014-10-08 23:07:59 +00:00
Alexey Samsonov
6a2cac3b87 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

llvm-svn: 219354
2014-10-08 22:57:47 +00:00
David Majnemer
e12e7ef0c8 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.

llvm-svn: 219288
2014-10-08 08:48:43 +00:00
Nick Kledzik
8ae11e4491 [Support] Add MemoryBuffer::getFileSlice()
mach-o supports "fat" files which are a header/table-of-contents followed by a
concatenation of mach-o files built for different architectures. Currently, 
MemoryBuffer has no easy way to map a subrange (slice) of a file which lld
will need to select a mach-o slice of a fat file. The new function provides 
an easy way to map a slice of a file into a MemoryBuffer. Test case included.

llvm-svn: 219260
2014-10-08 00:22:18 +00:00
Rafael Espindola
0ca90603b7 Remove the IsVolatileSize parameter of getOpenFileSlice.
getOpenFileSlice gets passed the map size, so it makes no sense to say that
the size is volatile. The code will not even compute the size.

llvm-svn: 219226
2014-10-07 19:09:05 +00:00
Rafael Espindola
9b4288f80d Be consistent about using "const Twine &" for filenames.
On this file we had a mix of
* Twine
* const char *
* StringRef

The two that make sense are
* const Twine & (caller convenience)
* consc char * (that is what will eventually be passed to open.

Given that sys::fs::openFileForRead takes a "const Twine &", I picked that.

llvm-svn: 219224
2014-10-07 18:58:55 +00:00
David Majnemer
0e26790bfa Attempt to calm down buildbots
llvm-svn: 219190
2014-10-07 05:56:45 +00:00
David Majnemer
a2fe666876 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.

llvm-svn: 219189
2014-10-07 05:48:40 +00:00
David Majnemer
8d5e532a3b 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.

llvm-svn: 219170
2014-10-06 23:16:18 +00:00
Yaron Keren
ac3c8eb1e5 Make the MD5 result name consistent between functions, header and source.
llvm-svn: 219121
2014-10-06 13:48:07 +00:00
Chris Bieneman
7798d68464 Converting the ErrorHandlerMutex to a ManagedStatic to avoid the static constructor and destructor.
llvm-svn: 219028
2014-10-03 22:03:12 +00:00
Adrian Prantl
2b1df58ebe Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.

Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.

By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.

The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)

This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.

What this patch doesn't do:

This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.

http://reviews.llvm.org/D4919
rdar://problem/17994491

Thanks to dblaikie and dexonsmith for reviewing this patch!

Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-01 18:55:02 +00:00
Adrian Prantl
0959156fa3 Revert r218778 while investigating buldbot breakage.
"Move the complex address expression out of DIVariable and into an extra"

llvm-svn: 218782
2014-10-01 18:10:54 +00:00
Adrian Prantl
229943585f Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.

Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.

By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.

The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)

This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.

What this patch doesn't do:

This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.

http://reviews.llvm.org/D4919
rdar://problem/17994491

Thanks to dblaikie and dexonsmith for reviewing this patch!

llvm-svn: 218778
2014-10-01 17:55:39 +00:00
Yaron Keren
e5099179f6 Fix llvm::huge_valf multiple initializations with Visual C++.
llvm::huge_valf is defined in a header file, so it is initialized
multiple times in every compiled unit upon program startup.

With non-VC compilers huge_valf is set to a HUGE_VALF which the
compiler can probably optimize out.

With VC numeric_limits<float>::infinity() does not return a number
but a runtime structure member which therotically may change 
between calls so the compiler does not optimize out the 
initialization and it happens many times. It can be easily seen by 
placing a breakpoint on the initialization line.

This patch moves llvm::huge_valf initialization to a source file
instead of the header.

llvm-svn: 218567
2014-09-27 14:41:29 +00:00
Yaron Keren
5cce235492 clang-format of ChangeStdinToBinary & ChangeStdoutToBinary.
llvm-svn: 218547
2014-09-26 22:27:11 +00:00
David Majnemer
b3c0e72987 Support: Remove undefined behavior from &raw_ostream::operator<<
Don't negate signed integer types in &raw_ostream::operator<<(const
FormattedNumber &FN).

llvm-svn: 218496
2014-09-26 02:48:14 +00:00
Nick Kledzik
2ac9102fff [Support] Add type-safe alternative to llvm::format()
llvm::format() is somewhat unsafe. The compiler does not check that integer
parameter size matches the %x or %d size and it does not complain when a 
StringRef is passed for a %s.  And correctly using a StringRef with format() is  
ugly because you have to convert it to a std::string then call c_str().
 
The cases where llvm::format() is useful is controlling how numbers and
strings are printed, especially when you want fixed width output.  This
patch adds some new formatting functions to raw_streams to format numbers
and StringRefs in a type safe manner. Some examples:

   OS << format_hex(255, 6)        => "0x00ff"
   OS << format_hex(255, 4)        => "0xff"
   OS << format_decimal(0, 5)      => "    0"
   OS << format_decimal(255, 5)    => "  255"
   OS << right_justify(Str, 5)     => "  foo"
   OS << left_justify(Str, 5)      => "foo  "

llvm-svn: 218463
2014-09-25 20:30:58 +00:00
Chris Bieneman
133e827a6b Adding #ifdef around TermColorMutex based on feedback from Craig Topper.
llvm-svn: 218401
2014-09-24 18:35:58 +00:00
NAKAMURA Takumi
9ca3b8d23c Windows/Host.inc: Reformat the header to fit 80-col.
llvm-svn: 218374
2014-09-24 04:45:14 +00:00
NAKAMURA Takumi
2c3275b193 Unix/Host.inc: Remove <cstdlib>. It has been unused for a long time.
llvm-svn: 218373
2014-09-24 04:45:02 +00:00
NAKAMURA Takumi
6ac62754ba Unix/Host.inc: Wrap a comment line in 80-col.
llvm-svn: 218371
2014-09-24 04:44:50 +00:00
NAKAMURA Takumi
d06d10a6aa Unix/Host.inc: Remove leading whitespace. It had been here since r56942!
llvm-svn: 218370
2014-09-24 04:44:37 +00:00
NAKAMURA Takumi
051cbc2437 Windows/DynamicLibrary.inc: Remove 'extern "C"' in ELM_Callback.
'extern "C" static' is not accepted by g++-4.7. Rather to tweak, I just removed 'extern "C"', since it doesn't affect the ABI.

llvm-svn: 218290
2014-09-23 01:09:46 +00:00
Chris Bieneman
081b3330f6 Converting terminalHasColors mutex to a global ManagedStatic to avoid the static destructor.
llvm-svn: 218283
2014-09-22 22:39:20 +00:00
Yaron Keren
f506c49c3f In this callback ModuleName includes the file path.
Comparing ModuleName to the file names listed will 
always fail. 

I wonder how this code ever worked and what its 
purpose was. Why exclude the msvc runtime DLLs
but not exclude all Windows system DLLs?

Anyhow, it does not function as intended.

clang-formatted as well.

llvm-svn: 218276
2014-09-22 21:40:15 +00:00
Matt Arsenault
62b3e7bfd0 Add hsail and amdil64 to Triple
llvm-svn: 218142
2014-09-19 19:52:11 +00:00
Justin Bogner
46a2bb923b LineIterator: Provide a variant that keeps blank lines
It isn't always useful to skip blank lines, as evidenced by the
somewhat awkward use of line_iterator in llvm-cov. This adds a knob to
control whether or not to skip blanks.

llvm-svn: 217960
2014-09-17 15:43:01 +00:00
Nick Kledzik
286efdaf32 Fix identify_magic() with mach-o stub dylibs.
The wrong value was returned and the unittest did not cover the stub dylib case.

llvm-svn: 217933
2014-09-17 00:53:44 +00:00
David Blaikie
115a9902e1 Fix memory leak in error paths in YAMLTraits by using unique_ptr
There's some other cleanup that could happen here, but this is at least
the mechanical transformation to unique_ptr.

Derived from a patch by Anton Yartsev.

llvm-svn: 217803
2014-09-15 18:39:24 +00:00
JF Bastien
a3e7a9b6a7 Add support for le64.
Summary:
le64 is a generic little-endian 64-bit processor, mimicking le32.

Depends on D5318.

Test Plan: make check-all

Reviewers: dschuff

Subscribers: llvm-commits

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

llvm-svn: 217697
2014-09-12 17:54:17 +00:00
Evgeniy Stepanov
6602036ef9 Add CMake check for libatomic.
llvm-svn: 217666
2014-09-12 11:08:59 +00:00
Rui Ueyama
3a28731f9f Support: Use llvm::COFF::BigObjMagic
Use llvm::COFF::BigObjMagic insetad of the string literal.
Also checks the version number.

llvm-svn: 217633
2014-09-11 22:34:32 +00:00
Rui Ueyama
b2048c498d Support: improve identify_magic to recognize COFF bigobj
identify_magic recognized a COFF bigobj as an import library file.
This patch fixes that.

llvm-svn: 217627
2014-09-11 21:09:57 +00:00
Rafael Espindola
832c8a58f2 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).

llvm-svn: 217625
2014-09-11 20:30:02 +00:00
Sanjay Patel
a0d0d4091d typo
llvm-svn: 217597
2014-09-11 15:41:01 +00:00
Ed Maste
97aff9f17f Use armv6k default for FreeBSD/ARM
Patch by Andrew Turner.

llvm-svn: 217454
2014-09-09 17:47:24 +00:00
Nick Lewycky
820d92269f Check whether the iterator p == the end iterator before trying to dereference it. This is a speculative fix for a failure found on the valgrind buildbot triggered by a clang test.
llvm-svn: 217295
2014-09-06 01:16:42 +00:00
Alexey Samsonov
9d03489b53 Fix right shift by 64 bits detected on CXX/lex/lex.literal/lex.ext/p4.cpp
test case on UBSan bootstrap bot.

This fixes the last failure of "check-clang" in UBSan bootstrap bot.

llvm-svn: 217294
2014-09-06 00:41:19 +00:00
Frederic Riss
7f2a6aeb9c Reapply "[dwarfdump] Add missing DW_LANG_Mips_Assembler case to LanguageString()"
This commit was reverted in r217183, but is OK to go in again now that its dependency is commited (as of r217186).

llvm-svn: 217231
2014-09-05 07:21:40 +00:00
Matthew Gardiner
4d01158d7c Removed white-space
llvm-svn: 217230
2014-09-05 07:17:15 +00:00
Matthew Gardiner
84251a24a7 Adding kalimba variants as Triple sub-architectures.
Reviewed in:

http://reviews.llvm.org/D5115

llvm-svn: 217229
2014-09-05 06:46:43 +00:00
Frederic Riss
f08f2cafec [ dwarfdump ] Add symbolic dump of known DWARF attribute values.
Reviewed By: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 217186
2014-09-04 19:39:20 +00:00
Frederic Riss
951e5b654a Revert "[dwarfdump] Add missing DW_LANG_Mips_Assembler case to LanguageString()"
This reverts commit 93c7e6161e1adbd2c7ac81fa081823183035cb64.

This commit got approved first, but was dependant on another one going in (The one pretty printing attribute values). I'll reapply when the other one is in.

llvm-svn: 217183
2014-09-04 18:55:46 +00:00
Frederic Riss
29626708ae [dwarfdump] Add missing DW_LANG_Mips_Assembler case to LanguageString()
Reviewed By: dblaikie

Subscribers: llvm-commits

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

llvm-svn: 217182
2014-09-04 18:40:23 +00:00
Rafael Espindola
cb6d6ffe1e 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!

llvm-svn: 217068
2014-09-03 20:02:00 +00:00
Chris Bieneman
cc1b741a66 Removing static initializer from Debug.cpp by converting to a ManagedStatic.
This is part of our larger effort to remove static initializers from LLVM libraries.

Reviewed by: chandlerc

llvm-svn: 217053
2014-09-03 17:50:14 +00:00
Chris Bieneman
8e3b8a2da4 Cleaning up remaining static initializers in Signals.inc
llvm-svn: 216996
2014-09-02 23:48:13 +00:00
David Blaikie
697c9919bc unique_ptrify the result of SpecialCaseList::create
llvm-svn: 216925
2014-09-02 18:13:54 +00:00
David Blaikie
07f73331e4 unique_ptrify FileOutputBuffer::FileOutputBuffer
llvm-svn: 216921
2014-09-02 17:49:23 +00:00
Andrea Di Biagio
ef361be676 Revert: [APFloat] Fixed a bug in method 'fusedMultiplyAdd'.
This reverts revision 216913; the new test added at revision 216913
caused regression failures on a couple of buildbots.

llvm-svn: 216914
2014-09-02 17:22:49 +00:00
Andrea Di Biagio
2b24c712b1 [APFloat] Fixed a bug in method 'fusedMultiplyAdd'.
When folding a fused multiply-add builtin call, make sure that we propagate the
correct result in the case where the addend is zero, and the two other operands
are finite non-zero.

Example:
  define double @test() {
    %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
    ret double %1
  }

Before this patch, the instruction simplifier wrongly folded the builtin call
in function @test to constant 'double 7.0'.
With this patch, method 'fusedMultiplyAdd' correctly evaluates the multiply and
propagates the expected result (i.e. 56.0).

Added test fold-builtin-fma.ll with the reproducible from PR20832 plus extra
test cases to verify the behavior of method 'fusedMultiplyAdd' in the presence
of NaN/Inf operands.

This fixes PR20832.

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

llvm-svn: 216913
2014-09-02 16:44:56 +00:00
Craig Topper
7332ae0502 Fix some cases where StringRef was being passed by const reference. Remove const from some other StringRefs since its implicitly const already.
llvm-svn: 216820
2014-08-30 16:48:02 +00:00
Chris Bieneman
a4f3f61361 Cleaning up static initializers in Signals.inc
Reviewed by: Chandlerc

llvm-svn: 216704
2014-08-29 01:05:16 +00:00
Chris Bieneman
0f6163d2ae Cleaning up static initializers in TimeValue.
Code reviewed by Chandlerc

llvm-svn: 216703
2014-08-29 01:05:12 +00:00
Rafael Espindola
edb6051959 Return a std::unique_ptr when creating a new MemoryBuffer.
llvm-svn: 216583
2014-08-27 20:03:13 +00:00
Rafael Espindola
01d03dcba4 yaml::Stream doesn't need to take ownership of the buffer.
In fact, most users were already using the StringRef version.

llvm-svn: 216575
2014-08-27 19:03:22 +00:00
Zachary Turner
a302d24004 Revert "Limit the symbol search in DynamicLibrary to the module that was opened."
This reverts commit r216563, which breaks lli's dynamic symbol resolution.

llvm-svn: 216569
2014-08-27 17:51:43 +00:00
Zachary Turner
aefdb6a076 Limit the symbol search in DynamicLibrary to the module that was opened.
Differential Revision: http://reviews.llvm.org/D5030

Reviewed By: Reid Kleckner, Rafael Espindola

llvm-svn: 216563
2014-08-27 17:06:22 +00:00
Benjamin Kramer
7c4796a444 Add an explicit cast to pacify implicit boolean conversion warnings.
llvm-svn: 216539
2014-08-27 11:47:52 +00:00
Craig Topper
43cee2f5fc Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
llvm-svn: 216525
2014-08-27 05:25:25 +00:00
Rafael Espindola
225cf75bef Pass a MemoryBufferRef when we can avoid taking ownership.
The attached patch simplifies a few interfaces that don't need to take
ownership of a buffer.

For example, both parseAssembly and parseBitcodeFile will parse the
entire buffer before returning. There is no need to take ownership.

Using a MemoryBufferRef makes it obvious in the type signature that
there is no ownership transfer.

llvm-svn: 216488
2014-08-26 21:49:01 +00:00
Rafael Espindola
8cbf70d62d 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.

llvm-svn: 216460
2014-08-26 14:47:52 +00:00
Dylan Noblesmith
1af83d4c81 Revert "Support/APFloat: unique_ptr-ify temp arrays"
This reverts commit rr216359.

llvm-svn: 216429
2014-08-26 02:03:33 +00:00
Dylan Noblesmith
36c670b2b8 Revert "Support/Path: remove raw delete"
This reverts commit r216360.

llvm-svn: 216428
2014-08-26 02:03:30 +00:00
Rafael Espindola
557df13e6d 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.

llvm-svn: 216415
2014-08-25 22:53:21 +00:00
Rafael Espindola
edb75ea26d Refactor argument serialization logic when executing process. NFC.
This patch refactors the argument serialization logic used in the Execute
function, used to launch new Windows processes. There is a critical step that
joins char** arguments into a single string, building the command line used to
launch the new process, and the readability of this code is improved if this
part is refactored in its own helper function.

Patch by Rafael Auler!

llvm-svn: 216411
2014-08-25 22:15:06 +00:00
Rafael Espindola
1d5713d9bf Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

llvm-svn: 216393
2014-08-25 18:16:47 +00:00
Dylan Noblesmith
9fd2309049 Support/Path: remove raw delete
llvm-svn: 216360
2014-08-25 00:58:13 +00:00
Dylan Noblesmith
f82bc070e5 Support/APFloat: unique_ptr-ify temp arrays
llvm-svn: 216359
2014-08-25 00:58:10 +00:00
Dylan Noblesmith
b48c4cfa2d 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.

llvm-svn: 216338
2014-08-23 23:07:14 +00:00
Dylan Noblesmith
2c2c44a12f Support: make LLVM Mutexes STL-compatible
Use lock/unlock() convention instead of acquire/release().

llvm-svn: 216336
2014-08-23 22:49:22 +00:00
Dylan Noblesmith
1ec1360c75 Support/Unix: use ScopedLock wherever possible
Only one function remains a bit too complicated
for a simple mutex guard. No functionality change.

llvm-svn: 216335
2014-08-23 22:49:17 +00:00
Reid Kleckner
6ab28bce46 Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind
This patch contains the LLVM side of the fix of PR17239.

This bug that happens because the /link (clang-cl.exe argument) is
marked as "consume all remaining arguments". However, when inside a
response file, /link should only consume all remaining arguments inside
the response file where it is located, not the entire command line after
expansion.

My patch will change the semantics of the RemainingArgsClass kind to
always consume only until the end of the response file when the option
originally came from a response file. There are only two options in this
class: dash dash (--) and /link.

Reviewed By: rnk

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

Patch by Rafael Auler!

llvm-svn: 216280
2014-08-22 19:29:17 +00:00
David Blaikie
7a58463dea Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr
llvm-svn: 216223
2014-08-21 20:44:56 +00:00
Craig Topper
c80a14ad2f Remove custom implementations of max/min in StringRef that was originally added to work an old gcc bug. I believe its been fixed by now.
llvm-svn: 216156
2014-08-21 04:31:10 +00:00
Alexey Samsonov
73266a6708 Fix undefined behavior (left shift by 64 bits) in ScaledNumber::toString().
This bug is reported by UBSan.

llvm-svn: 216116
2014-08-20 18:30:07 +00:00
Craig Topper
baef4556f6 Fix an off by 1 bug that prevented SmallPtrSet from using all of its 'small' capacity. Then fix the early return in the move constructor that prevented 'small' moves from clearing the NumElements in the moved from object. The directed test missed this because it was always testing large moves due to the off by 1 bug.
llvm-svn: 216044
2014-08-20 04:41:36 +00:00
Rafael Espindola
08aa78de63 Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

llvm-svn: 216002
2014-08-19 18:44:46 +00:00
Rafael Espindola
0f0b067a94 Convert an ownership comment with std::uinque_ptr.
llvm-svn: 215855
2014-08-17 22:20:33 +00:00
Sean Silva
3e323f9026 Revert "[Support] Promote cl::StringSaver to a separate utility"
This reverts commit r215784 / 3f8a26f6fe16cc76c98ab21db2c600bd7defbbaa.

LLD has 3 StringSaver's, one of which takes a lock when saving the
string... Need to investigate more closely.

llvm-svn: 215790
2014-08-15 23:39:01 +00:00
Sean Silva
4650d2b2ad [Support] Promote cl::StringSaver to a separate utility
This class is generally useful.

In breaking it out, the primary change is that it has been made
non-virtual. It seems like being abstract led to there being 3 different
(2 in llvm + 1 in clang) concrete implementations which disagreed about
the ownership of the saved strings (see the manual call to free() in the
unittest StrDupSaver; yes this is different from the CommandLine.cpp
StrDupSaver which owns the stored strings; which is different from
Clang's StringSetSaver which just holds a reference to a
std::set<std::string> which owns the strings).

I've identified 2 other places in the
codebase that are open-coding this pattern:

  memcpy(Alloc.Allocate<char>(strlen(S)+1), S, strlen(S)+1)

I'll be switching them over. They are
* llvm::sys::Process::GetArgumentVector
* The StringAllocator member of YAMLIO's Input class
This also will allow simplifying Clang's driver.cpp quite a bit.

Let me know if there are any other places that could benefit from
StringSaver. I'm also thinking of adding a saveStringRef member for
getting a stable StringRef.

llvm-svn: 215784
2014-08-15 23:18:33 +00:00
Rafael Espindola
1b2eb4e486 Delete support for AuroraUX.
auroraux.org is not resolving.

I will add this to the release notes as soon as I figure out where to put the
3.6 release notes :-)

llvm-svn: 215645
2014-08-14 15:15:09 +00:00
Benjamin Kramer
da144ed5a2 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.

llvm-svn: 215558
2014-08-13 16:26:38 +00:00
Saleem Abdulrasool
92b98299b9 ADT: remove MinGW32 and Cygwin OSType enum
Remove the MinGW32 and Cygwin types from the OSType enumeration.  These values
are represented via environments of Windows.  It is a source of confusion and
needlessly clutters the code.  The cost of doing this is that we must sink the
check for them into the normalization code path along with the spelling.

Addresses PR20592.

llvm-svn: 215303
2014-08-09 23:12:20 +00:00
Eric Christopher
638a0643ee Fix typo.
llvm-svn: 215266
2014-08-09 00:26:27 +00:00
Rafael Espindola
1c0c1cec43 Fix the windows build.
Sorry for the noise.

llvm-svn: 215249
2014-08-08 22:09:31 +00:00
Eric Christopher
ca5efa5bef Reword comment slightly.
llvm-svn: 215248
2014-08-08 22:09:00 +00:00
Rafael Espindola
d326af1d4b Remove dead code. Fixes pr20544.
llvm-svn: 215243
2014-08-08 21:35:52 +00:00
Rafael Espindola
d5eb943fe5 Convert from Windows to Unix paths in sys::path::native.
Part of pr20544. Test to follow in a second.

llvm-svn: 215241
2014-08-08 21:29:34 +00:00
Rafael Espindola
0c2eeeddf1 Fix bug 20125 - clang-format segfaults on bad config.
The problem was in unchecked dyn_cast inside of Input::createHNodes.
Patch by Roman Kashitsyn!

llvm-svn: 215205
2014-08-08 13:58:00 +00:00
Richard Smith
930ab2538a Remove Support/IncludeFile.h and its only user. This is actively harmful, since
it breaks the modules builds (where CallGraph.h can be quite reasonably
transitively included by an unimported portion of a module, and CallGraph.cpp
not linked in), and appears to have been entirely redundant since PR780 was
fixed back in 2008.

If this breaks anything, please revert; I have only tested this with a single
configuration, and it's possible that this is still somehow fixing something
(though I doubt it, since no other similar file uses this mechanism any more).

llvm-svn: 215142
2014-08-07 20:41:17 +00:00
Yaron Keren
baaa4b7845 getNewMemBuffer memsets the buffer to zeros,
the caller don't have to initialize it.

llvm-svn: 214994
2014-08-06 20:59:09 +00:00
Justin Bogner
cb125e9a3e Path: Stop claiming path::const_iterator is bidirectional
path::const_iterator claims that it's a bidirectional iterator, but it
doesn't satisfy all of the contracts for a bidirectional iterator.
For example, n3376 24.2.5 p6 says "If a and b are both dereferenceable,
then a == b if and only if *a and *b are bound to the same object",
but this doesn't work with how we stash and recreate Components.

This means that our use of reverse_iterator on this type is invalid
and leads to many of the valgrind errors we're hitting, as explained
by Tilmann Scheller here:

    http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140728/228654.html

Instead, we admit that path::const_iterator is only an input_iterator,
and implement a second input_iterator for path::reverse_iterator (by
changing const_iterator::operator-- to reverse_iterator::operator++).
All of the uses of this just traverse once over the path in one
direction or the other anyway.

llvm-svn: 214737
2014-08-04 17:36:41 +00:00
NAKAMURA Takumi
9474954f12 MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.
On Cygwin, getpagesize() returns 64k(AllocationGranularity).

In r214580, the size of X86GenInstrInfo.inc became 1499136.

FIXME: We should reorganize again getPageSize() on Win32.
MapFile allocates address along AllocationGranularity but view is mapped by physical page.

llvm-svn: 214681
2014-08-04 01:43:37 +00:00
Rafael Espindola
19e7ab14ac Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.

Thanks to David Blaikie for the suggestion.

llvm-svn: 214516
2014-08-01 14:31:55 +00:00
Rafael Espindola
227e62db29 Remove dead code.
llvm-svn: 213963
2014-07-25 19:06:39 +00:00
Hans Wennborg
70dd8bb7a1 Windows: Don't wildcard expand /? or -?
Even if there's a file called c:\a, we want /? to be preserved as
an option, not expanded to a filename.

llvm-svn: 213894
2014-07-24 21:09:45 +00:00
Tim Northover
c357579164 AArch64: remove "arm64_be" support in favour of "aarch64_be".
There really is no arm64_be: it was a useful fiction to test big-endian support
while both backends existed in parallel, but now the only platform that uses
the name (iOS) doesn't have a big-endian variant, let alone one called
"arm64_be".

llvm-svn: 213748
2014-07-23 12:58:11 +00:00
Tim Northover
3e8fd62854 AArch64: remove arm64 triple enumerator.
Having both Triple::arm64 and Triple::aarch64 is extremely confusing, and
invites bugs where only one is checked. In reality, the only legitimate
difference between the two (arm64 usually means iOS) is also present in the OS
part of the triple and that's what should be checked.

We still parse the "arm64" triple, just canonicalise it to Triple::aarch64, so
there aren't any LLVM-side test changes.

llvm-svn: 213743
2014-07-23 12:32:47 +00:00
David Blaikie
939901ec68 Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ".reset()"
It's also possible to just write "= nullptr", but there's some question
of whether that's as readable, so I leave it up to authors to pick which
they prefer for now. If we want to discuss standardizing on one or the
other, we can do that at some point in the future.

llvm-svn: 213438
2014-07-19 01:05:11 +00:00
Daniel Sanders
b7f4e6b616 Add MIPS Technologies to the vendors in llvm::Triple.
This is a prerequisite for checking for 'mti' and 'img' in a consistent way in
clang. Previously 'img' could use Triple::getVendor() but 'mti' could only use
Triple::getVendorName().

llvm-svn: 213381
2014-07-18 14:28:19 +00:00
Renato Golin
05cd608eea Refactor ARM subarchitecture parsing
Re-commit of a patch to rework the triple parsing on ARM to a more sane
model.

Patch by Gabor Ballabas.

llvm-svn: 213367
2014-07-18 12:00:48 +00:00
Alp Toker
1bfa029bc4 Drop the udis86 wrapper from llvm::sys
This optional dependency on the udis86 library was added some time back to aid
JIT development, but doesn't make much sense to link into LLVM binaries these
days.

llvm-svn: 213300
2014-07-17 20:05:29 +00:00
Hans Wennborg
ebf51704c5 Typo: exists -> exits
llvm-svn: 213290
2014-07-17 18:33:44 +00:00
Yi Kong
d5d6470070 Fix the prefix for arm64 triple
Triple.cpp still returns "arm64" as prefix for arm64 triple, causing Clang not
being able to select the correct GCCBuiltin IR.

This patch changes the value to correct prefix "aarch64". Regression test will
be added in the coming patch.

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

llvm-svn: 213240
2014-07-17 09:43:27 +00:00
Hans Wennborg
46aad38a9b Perform wildcard expansion in Process::GetArgumentVector on Windows (PR17098)
On Windows, wildcard expansion isn't performed by the shell, but left to the
program itself. The common way to do this is to link with setargv.obj, which
performs the expansion on argc/argv before main is entered. However, we don't
use argv in Clang on Windows, but instead call GetCommandLineW so we can handle
unicode arguments. This means we have to do wildcard expansion ourselves.

A test case will be added on the Clang side.

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

llvm-svn: 213114
2014-07-16 00:52:11 +00:00
Alp Toker
f8f97e88e9 Fix a -Wunused-local-typedefs warning
llvm-svn: 213002
2014-07-14 22:46:45 +00:00
Justin Bogner
b01116e438 Support: Use a range-based for
llvm-svn: 212973
2014-07-14 19:24:13 +00:00
Argyrios Kyrtzidis
5daccdf69f Move the API and implementation of clang::driver::getARMCPUForMArch() to llvm::Triple::getARMCPUForArch().
Suggested by Eric Christopher.

llvm-svn: 212846
2014-07-11 21:44:54 +00:00
Alp Toker
043f69cb8d Simplify the raw_svector_ostream tweak from r212816
The memcpy() and overlap helps didn't help much with timings, so clean up the change.

The difference at this point is that we now leave growth of the storage buffer
up to SmallVector's implementation:

 -   OS.reserve(OS.capacity() * 2);
 +   OS.reserve(OS.size() + 64);

llvm-svn: 212837
2014-07-11 18:23:08 +00:00
Alp Toker
0d0baf0938 raw_svector_ostream: grow and reserve atomically
Including the scratch buffer size in the initial reservation eliminates the
subsequent malloc+move operation and offers a healthier constant growth with
less memory wastage.

When doing this, take care to avoid invalidating the source buffer.

llvm-svn: 212816
2014-07-11 14:02:04 +00:00
Eric Christopher
a7f273741e Add the CSR company and the Kalimba DSP processor to Triple.
Patch by Matthew Gardiner with fixes by me.

llvm-svn: 212745
2014-07-10 17:26:54 +00:00
Peter Collingbourne
2bc51dcbef Remove move assignment operator to appease older GCCs.
llvm-svn: 212682
2014-07-10 04:39:40 +00:00
Peter Collingbourne
0ccbe0740d Explicitly define move constructor and move assignment operator to appease MSVC.
llvm-svn: 212679
2014-07-10 04:29:06 +00:00
Peter Collingbourne
e5f0c51843 SpecialCaseList: use std::unique_ptr.
llvm-svn: 212678
2014-07-10 03:55:02 +00:00
Alexey Samsonov
bea2f2e5d8 Decouple llvm::SpecialCaseList text representation and its LLVM IR semantics.
Turn llvm::SpecialCaseList into a simple class that parses text files in
a specified format and knows nothing about LLVM IR. Move this class into
LLVMSupport library. Implement two users of this class:
  * DFSanABIList in DFSan instrumentation pass.
  * SanitizerBlacklist in Clang CodeGen library.
The latter will be modified to use actual source-level information from frontend
(source file names) instead of unstable LLVM IR things (LLVM Module identifier).

Remove dependency edge from ClangCodeGen/ClangDriver to LLVMTransformUtils.

No functionality change.

llvm-svn: 212643
2014-07-09 19:40:08 +00:00
Daniel Sanders
37f35e2a7f Add Imagination Technologies to the vendors in llvm::Triple
Summary: This is a pre-requisite for supporting the mips-img-linux-gnu triple in clang.

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

llvm-svn: 212626
2014-07-09 16:03:10 +00:00
Dmitri Gribenko
42b37ff173 SourceMgr: consistently use 'unsigned' for the memory buffer ID type
llvm-svn: 212595
2014-07-09 08:30:15 +00:00
Benjamin Kramer
0ad234df3b Fix some Twine locals.
Two of those are use after frees. Found by clang-tidy, fixed by me.

llvm-svn: 212537
2014-07-08 14:55:06 +00:00
Renato Golin
74bbc07d65 Revert "Refactor ARM subarchitecture parsing"
This reverts commit 7b4a6882467e7fef4516a0cbc418cbfce0fc6f6d.

llvm-svn: 212521
2014-07-08 10:06:16 +00:00
Renato Golin
659d34425a Refactor ARM subarchitecture parsing
According to a FIXME in ARMMCTargetDesc.cpp the ARM version parsing should be
in the Triple helper class.

Patch by: Gabor Ballabas

llvm-svn: 212479
2014-07-07 20:01:11 +00:00
Rafael Espindola
858b9e1423 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Alp Toker
0ca11b2493 SourceMgr: make valid buffer IDs start from one
Use 0 for the invalid buffer instead of -1/~0 and switch to unsigned
representation to enable more idiomatic usage.

Also introduce a trivial SourceMgr::getMainFileID() instead of hard-coding 0/1
to identify the main file.

llvm-svn: 212398
2014-07-06 10:33:31 +00:00
Alp Toker
a199bb8891 Remove obsolete function TargetRegistry::getClosestTargetForJIT()
This was kept around "for compatibility through 2.6" in 2009 and is not used or
tested.

llvm-svn: 212095
2014-07-01 10:47:13 +00:00
Ehsan Akhgari
1f75365ec9 Refactor the code in clang to find a file in a PATH like environment variable into a helper function
llvm-svn: 212057
2014-06-30 19:54:20 +00:00
Alp Toker
000fb20af5 Fix 'platform-specific' hyphenations
llvm-svn: 212056
2014-06-30 18:57:16 +00:00
Alp Toker
b76b963413 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!

llvm-svn: 212055
2014-06-30 18:57:04 +00:00
Julien Lerouge
5dbf44035a 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.

llvm-svn: 211918
2014-06-27 18:02:54 +00:00
Chandler Carruth
35b7259047 Re-apply r211287: Remove support for LLVM runtime multi-threading.
I'll fix the problems in libclang and other projects in ways that don't
require <mutex> until we sort out the cygwin situation.

llvm-svn: 211900
2014-06-27 15:13:01 +00:00
Alp Toker
97022b0c1f Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

llvm-svn: 211814
2014-06-26 22:52:05 +00:00
Will Schmidt
f6e2b6e4f5 Add support for ppc64/power8 as a host
llvm-svn: 211781
2014-06-26 13:37:03 +00:00