Commit Graph

2467 Commits

Author SHA1 Message Date
Rafael Espindola db7c03f05e Remove sys::PathSeparator.
llvm-svn: 184852
2013-06-25 14:32:45 +00:00
Rafael Espindola 8c8117240c keep only the StringRef version of getFileOrSTDIN.
llvm-svn: 184826
2013-06-25 05:28:34 +00:00
Rafael Espindola 138e55aa5a Don't assume ResultPath is null terminated.
llvm-svn: 184824
2013-06-25 04:23:46 +00:00
Rafael Espindola 7c4d2da8e8 Cleanup in unique_file when we only want the name.
This is really ugly, but it is no worse than what we have in clang right now and
it is better to get it working first and clean/optimize it afterwards.

Will be tested from clang in the next patch.

llvm-svn: 184802
2013-06-25 00:49:40 +00:00
Michael Gottesman 40e8a187f6 [APFloat] Added support for parsing float strings which contain {inf,-inf,NaN,-NaN}.
llvm-svn: 184713
2013-06-24 09:58:05 +00:00
Michael Gottesman c4facdf390 [APFloat] Added make{Zero,Inf} methods and implemented get{Zero,Inf} on top of them.
llvm-svn: 184712
2013-06-24 09:58:02 +00:00
Michael Gottesman f0e8cd1a7f [APFloat] Removed a assert from significandParts() which says that one can only access the significand of FiniteNonZero/NaN floats.
The method significandParts() is a helper method meant to ease access to
APFloat's significand by allowing the user to not need to be aware of whether or
not the APFloat is using memory allocated in the instance itself or in an
external array.

This assert says that one can only access the significand of FiniteNonZero/NaN
floats. This makes it cumbersome and more importantly dangerous when one wishes
to zero out the significand of a zero/infinity value since one will have to deal
with the aforementioned quandary related to how the memory in APFloat is
allocated.

llvm-svn: 184711
2013-06-24 09:57:59 +00:00
Michael Gottesman 9b877e18a3 [APFloat] Rename macro convolve => PackCategoriesIntoKey so that it is clear what APFloat is actually using said macro for.
In the context of APFloat, seeing a macro called convolve suggests that APFloat
is using said value in some sort of convolution somewhere in the source code.
This is misleading.

I also added a documentation comment to the macro.

llvm-svn: 184710
2013-06-24 09:57:57 +00:00
Michael Gottesman 9dc98338b8 [APFloat] Rename llvm::exponent_t => llvm::APFloat::ExponentType.
exponent_t is only used internally in APFloat and no exponent_t values are
exposed via the APFloat API. In light of such conditions it does not make any
sense to gum up the llvm namespace with said type. Plus it makes it clearer that
exponent_t is associated with APFloat.

llvm-svn: 184686
2013-06-24 04:06:23 +00:00
Benjamin Kramer bfb84d0bd6 Revert "BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability."
This reverts commit r184584. Breaks PPC selfhost.

llvm-svn: 184590
2013-06-21 20:20:27 +00:00
Benjamin Kramer bd0f107929 BlockFrequency: Saturate at 1 instead of 0 when multiplying a frequency with a branch probability.
Zero is used by BlockFrequencyInfo as a special "don't know" value. It also
causes a sink for frequencies as you can't ever get off a zero frequency with
more multiplies.

This recovers a 10% regression on MultiSource/Benchmarks/7zip. A zero frequency
was propagated into an inner loop causing excessive spilling.

PR16402.

llvm-svn: 184584
2013-06-21 19:30:05 +00:00
Justin Holewinski b6e6cd356e [NVPTX] Add support for selecting CUDA vs OCL mode based on triple
IR for CUDA should use "nvptx[64]-nvidia-cuda", and IR for NV OpenCL should use "nvptx[64]-nvidia-nvcl"

llvm-svn: 184579
2013-06-21 18:51:49 +00:00
Rafael Espindola 1efb69cdca Add another fixme.
llvm-svn: 184488
2013-06-20 22:07:53 +00:00
Rafael Espindola e34d6a5fac Remove last use of PathV1.h from Archive.cpp.
llvm-svn: 184484
2013-06-20 22:02:10 +00:00
Rafael Espindola be3ede7958 make getLastModificationTime const. Move it with the other getters.
llvm-svn: 184478
2013-06-20 21:51:49 +00:00
Rafael Espindola 4a3365c869 Add a setLastModificationAndAccessTime to PathV2.
With this we can remove the last use of PathV1 from llvm-ar.cpp.

llvm-svn: 184464
2013-06-20 20:56:14 +00:00
Rafael Espindola db5d8feeea Add support for getting the last modification time from a file_status.
Use that in llvm-ar.cpp to replace a use of sys::PathWithStatus.

llvm-svn: 184450
2013-06-20 18:42:04 +00:00
Evgeniy Stepanov 6eb4484319 Fix get_magic() handling of short reads.
PR16389

llvm-svn: 184434
2013-06-20 15:56:05 +00:00
Rafael Espindola 7cf7c51cc4 Rename fs::GetUniqueID to fs::getUniqueID to match the style guide.
llvm-svn: 184431
2013-06-20 15:06:35 +00:00
Evgeniy Stepanov ca692609d0 Remove MSan hack that is no longer needed.
llvm-svn: 184428
2013-06-20 14:19:10 +00:00
Argyrios Kyrtzidis f1d8f52a36 [Support/CrashRecoveryContext] Make sure CrashRecoveryContext does not clear the thread-local "CurrentContext"
in the "parent" thread, when we are using CrashRecoveryContext::RunSafelyOnThread.

When using CrashRecoveryContext::RunSafelyOnThread, we would set a CrashRecoveryContextImpl* to a thread-local variable
for the "child" thread, but CrashRecoveryContext would erroneously clear it in the "parent" thread.

The result was that if CrashRecoveryContext::RunSafelyOnThread was called again in the "child" thread it would mess up
crash-recovery for its parent.

A test for this will be added in the clang repository.
rdar://14204560

llvm-svn: 184380
2013-06-19 22:53:45 +00:00
Michael Gottesman 3cb77ab98a [APFloat] Converted all references to APFloat::isNormal => APFloat::isFiniteNonZero.
Turns out all the references were in llvm and not in clang.

llvm-svn: 184356
2013-06-19 21:23:18 +00:00
Aaron Ballman 9fbe530d74 Modified the implementation of fs::GetUniqueID on Windows such that it actually finds a unique identifier for a file. Also adds unit tests for GetUniqueID.
llvm-svn: 184351
2013-06-19 21:03:50 +00:00
Rafael Espindola 02d0ec8e70 Remove Path::getDirectoryContents.
llvm-svn: 184311
2013-06-19 15:32:37 +00:00
Rafael Espindola 6d1e379158 Remove Path::isObjectFile.
llvm-svn: 184305
2013-06-19 14:25:38 +00:00
Rafael Espindola 988252dcd2 Remove Path::canExecute.
llvm-svn: 184298
2013-06-19 13:25:31 +00:00
Michael Gottesman a7cc1243cc Fixed comment typo that causes the given comment to actually make sense.
llvm-svn: 184286
2013-06-19 07:34:21 +00:00
Rafael Espindola 2bf893664b Remove Path::canWrite.
llvm-svn: 184235
2013-06-18 21:10:03 +00:00
Rafael Espindola a1280c16fb Add a can_write function to PathV2.
llvm-svn: 184233
2013-06-18 20:56:38 +00:00
Rafael Espindola 3025f2366f Remove unused Path::canRead.
llvm-svn: 184229
2013-06-18 20:42:25 +00:00
Rafael Espindola 8f181a5406 Remove uniqueID from PathV1.h.
llvm-svn: 184219
2013-06-18 19:46:19 +00:00
Rafael Espindola 45e6c2406d Add a GetUniqueID that will replace the uniqueID of PathV1.h.
llvm-svn: 184217
2013-06-18 19:34:49 +00:00
Rafael Espindola 4526b1d410 Add a version of unique_file that return just the file name.
llvm-svn: 184206
2013-06-18 17:01:00 +00:00
Alexey Samsonov e6388e622e Basic support for parsing Mach-O universal binaries in LLVMObject library
llvm-svn: 184191
2013-06-18 15:03:28 +00:00
Rafael Espindola 702a80c72f Reapply r183985 now that the missing check was added to PathV2.
llvm-svn: 184120
2013-06-17 20:37:56 +00:00
Rafael Espindola 8cd62b01ef Only delete regular files and directories.
This ports a missing feature from PathV1.h. I am not sure how to test this
with the regular infrastructure, but an Apple bot should check this when
r183985 is reapplied.

llvm-svn: 184119
2013-06-17 20:35:51 +00:00
Rafael Espindola 7648aa3558 Revert "Remove a use of PathV1.h."
This reverts commit r183985.

We were missing the checks for not deleting things like /dev/null.

llvm-svn: 184111
2013-06-17 19:54:17 +00:00
Rafael Espindola 40c908bfad Don't use PathV1.h in LTOCodeGenerator.cpp
This patch also adds a simpler version of sys::fs::remove and a tool_output_file
constructor for when we already have an open file.

llvm-svn: 184095
2013-06-17 18:05:35 +00:00
Manuel Klimek 52772bf356 Fix incorrectly finding 'executable' directories instead of files.
This broke for example the 'not' utility, if a directory called
'FileCheck' is executable and in the path before the actual 'FileCheck'.

This patch steals the implementation of the "old" PathV1 canExecute
implementation:
- checks for R_OK (file readable): this is necessary for executing
  scripts; we should not regress here unless we have good reasons
- checks for S_ISREG; if we want to get rid of this, we'd need to
  change all callers who already made the assumption when depending
  on Path V1.

llvm-svn: 184074
2013-06-17 10:48:34 +00:00
Rafael Espindola 158d537c5a Add GetCurrentDirectory back.
It looks like clang-tools-extra/unittests/cpp11-migrate/TransformTest.cpp
depends on the behaviour of the old one on Windows. Maybe a difference
between GetCurrentDirectoryA and GetCurrentDirectoryW?

llvm-svn: 184009
2013-06-14 21:41:33 +00:00
Rafael Espindola ef03b9fc52 Replace use of PathV1.h in MCContext.cpp.
GetCurrentDirectory is now unused. Remove it.

llvm-svn: 184003
2013-06-14 20:26:58 +00:00
Rafael Espindola b0a5c96379 Replace use of PathV1.h in Program.cpp.
llvm-svn: 183996
2013-06-14 19:38:45 +00:00
Rafael Espindola f7c67014f3 Remove unused argument.
llvm-svn: 183992
2013-06-14 18:12:13 +00:00
Rafael Espindola 3e3e040574 Don't use PathV1.h in GraphWriter.cpp.
llvm-svn: 183988
2013-06-14 17:11:14 +00:00
Rafael Espindola 6a6f04a3b6 Convert a use of sys::Path::GetTemporaryDirectory.
llvm-svn: 183987
2013-06-14 16:43:15 +00:00
Rafael Espindola ca635dc92c Remove a use of PathV1.h.
llvm-svn: 183985
2013-06-14 16:20:18 +00:00
Rafael Espindola 5023632c9a Remove a use of PathV1.h.
llvm-svn: 183982
2013-06-14 15:24:56 +00:00
Rafael Espindola b786304fea Move PrependMainExecutablePath next to its only user.
llvm-svn: 183980
2013-06-14 15:12:13 +00:00
Rafael Espindola 9aa3d5d7b2 Remove a use of sys::Path.
llvm-svn: 183979
2013-06-14 13:59:21 +00:00
Rafael Espindola 5f81f48bd4 Try to fix the windows build.
llvm-svn: 183950
2013-06-13 21:38:21 +00:00
Rafael Espindola 4f35da77a6 Don't use PathV1.h in Signals.h.
llvm-svn: 183947
2013-06-13 21:16:58 +00:00
Rafael Espindola 280e5cb653 Don't use PathV1.h in FileUtilities.h.
llvm-svn: 183941
2013-06-13 20:41:00 +00:00
Rafael Espindola 7c1023ad27 Avoid using PathV1.h in Program.h.
llvm-svn: 183940
2013-06-13 20:25:38 +00:00
Rafael Espindola 6828fe475a Add a version of sys::ExecuteAndWait that takes StringRefs.
llvm-svn: 183934
2013-06-13 20:06:28 +00:00
Rafael Espindola 4c7ad8fc27 Have sys::FindProgramByName return a std::string.
llvm-svn: 183928
2013-06-13 19:25:37 +00:00
Rafael Espindola 04fa5c17d8 Covert remaining graph viewers from sys::Path to std::string.
llvm-svn: 183921
2013-06-13 17:32:16 +00:00
Rafael Espindola 48944e7a9a Update code for other graph viewing programs too.
llvm-svn: 183920
2013-06-13 17:27:45 +00:00
Rafael Espindola ce61b1e5b1 Reduce usage of sys::Path in the graph writer.
Now PathV1.h is not needed in GraphWriter.h.

llvm-svn: 183919
2013-06-13 17:20:48 +00:00
Reid Kleckner 6e6a0f50b3 [Support] Fix handle and memory leak for processes that are not waited for
Execute's Data parameter is now optional, so we won't allocate memory
for it on Windows and we'll close the process handle.

The Unix code should probably do something similar to avoid accumulation
of zombie children that haven't been waited on.

Tested on Linux and Windows.

llvm-svn: 183906
2013-06-13 15:27:17 +00:00
Aaron Ballman 54e9bd2239 Zero-initializing variables; fixes a build breakage introduced in r183864.
llvm-svn: 183904
2013-06-13 14:39:07 +00:00
Rafael Espindola 0c24b20d33 [Win] Put ChangeStdinToBinary ChangeStdoutToBinary ChangeStderrToBinary in sys.
llvm-svn: 183868
2013-06-12 21:25:04 +00:00
Rafael Espindola 2bb2aa27bf s/Void/void.
llvm-svn: 183866
2013-06-12 21:16:07 +00:00
Rafael Espindola 404ae77e38 Attempt at fixing the windows build.
llvm-svn: 183865
2013-06-12 21:11:50 +00:00
Rafael Espindola cb2eca0f91 Remove the program class.
It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just
those two functions and make Execute and Wait implementations details.

llvm-svn: 183864
2013-06-12 20:58:35 +00:00
Rafael Espindola 385c06ffc9 Don't use PathV1 in CommandLine.cpp.
No functionality change.

llvm-svn: 183842
2013-06-12 15:37:27 +00:00
Rafael Espindola 71affba988 Inline Path::isBitcodeFile into only use and remove it.
llvm-svn: 183840
2013-06-12 15:13:57 +00:00
Rafael Espindola b703be2544 Remove Path::getMagicNumber.
llvm-svn: 183839
2013-06-12 15:07:11 +00:00
Rafael Espindola e3e790a46e Remove Path::hasMagicNumber.
llvm-svn: 183838
2013-06-12 15:04:59 +00:00
Rafael Espindola af93517dde Remove Path::isAbsolute.
llvm-svn: 183836
2013-06-12 15:02:39 +00:00
Rafael Espindola 87b03450ee Remove Path::isAbsolute().
llvm-svn: 183835
2013-06-12 14:47:33 +00:00
Rafael Espindola 46e2ea64cc Remove Path::getSuffix.
llvm-svn: 183833
2013-06-12 14:32:51 +00:00
Rafael Espindola ec4f0fc7c1 Remove sys::CopyFile.
llvm-svn: 183831
2013-06-12 14:16:52 +00:00
Patrik Hagglund 7e79636e19 Fix 'gcc -flto' builds for unittest binaries (undefined reference to
`typeinfo for llvm:🆑:GenericOptionValue').

Remove an "anchor" method for an abstract class. (This does not
increase the number of vtables.)

llvm-svn: 183830
2013-06-12 14:15:21 +00:00
Rafael Espindola d88308767b Remove the old file memory mapping functions.
llvm-svn: 183828
2013-06-12 14:11:15 +00:00
Rafael Espindola 1d08f5ae7c Remove Path::createFileOnDisk.
llvm-svn: 183827
2013-06-12 13:59:17 +00:00
Rafael Espindola d5fd942ec3 Remove Path::makeExecutableOnDisk.
llvm-svn: 183826
2013-06-12 13:55:07 +00:00
Rafael Espindola 3bc8e71909 Move PathV2.h to Path.h
Most clients have already been moved from Path V1 to V2. The ones using V1
now include PathV1.h explicitly.

llvm-svn: 183801
2013-06-11 22:21:28 +00:00
Tobias Grosser bd9e549e21 Make host ARM CPU feature detection independent of the vendor
For ARM on linux we use /proc/cpuinfo to detect the host CPU's features.
Linux derives these values without ever looking at the vendor of the
specific CPU implementation. Hence, it adds little value, if we parse
the output of /proc/cpuinfo only for certain vendors.

This patch enables us to derive the correct feature flags e.g. for Qualcomm
CPUs.

llvm-svn: 183790
2013-06-11 21:45:01 +00:00
Rafael Espindola d1fcac9126 Include PathV1.h in files that use it.
This is preparation for replacing Path.h with PathV2.h.

llvm-svn: 183782
2013-06-11 20:00:56 +00:00
Rafael Espindola c656225b9d Remove Path::getDirname.
llvm-svn: 183780
2013-06-11 19:32:57 +00:00
Rafael Espindola 4d725f66bd Remove Path::getBasename.
llvm-svn: 183779
2013-06-11 19:29:48 +00:00
Rafael Espindola 7fc279aecb Remove Path::getLast.
llvm-svn: 183778
2013-06-11 19:25:17 +00:00
Rafael Espindola 0126549185 Remove GetDLLSuffix.
llvm-svn: 183777
2013-06-11 19:18:05 +00:00
Rafael Espindola 75f89f5225 Remove GetRootDirectory.
llvm-svn: 183775
2013-06-11 19:13:52 +00:00
Rafael Espindola 8b86c6c509 Remove GetUserHomeDirectory.
llvm-svn: 183773
2013-06-11 19:08:15 +00:00
Rafael Espindola 8cc6dc26bb Remove GetSystemLibraryPaths.
llvm-svn: 183770
2013-06-11 18:58:47 +00:00
Rafael Espindola b5f4a1b0ba Remove Path::GetBitcodeLibraryPaths.
llvm-svn: 183765
2013-06-11 18:45:35 +00:00
Rafael Espindola 0487a3210f Remove unused FindLibrary function.
llvm-svn: 183764
2013-06-11 18:41:07 +00:00
Rafael Espindola 3add14d77e Remove sys::identifyFileType.
llvm-svn: 183763
2013-06-11 18:18:02 +00:00
Rafael Espindola 823de7cd4c Port r183666 to identify_magic.
It will be tested in the next commit which moves another user to identify_magic.

Original message:

Fix an out of bounds array access.

We were looking at Magic[5] without checking Length. Since this path would not
return unless Length >= 18 anyway, just move the >= 18 check up.

llvm-svn: 183753
2013-06-11 17:25:45 +00:00
Rafael Espindola 9b404295a9 Fix variable name.
llvm-svn: 183752
2013-06-11 17:22:12 +00:00
Rafael Espindola 134cc996ae Add a missing 'e'.
llvm-svn: 183692
2013-06-10 20:32:27 +00:00
Rafael Espindola 1dc43065a7 Pass a StringRef to sys::identifyFileType.
llvm-svn: 183669
2013-06-10 15:27:39 +00:00
Rafael Espindola 548e9d4834 Fix an out of bounds array access.
We were looking at Magic[5] without checking Length. Since this path would not
return unless Length >= 18 anyway, just move the >= 18 check up.

llvm-svn: 183666
2013-06-10 15:22:18 +00:00
Rafael Espindola 693b4750d1 Update for current naming conventions.
I will change identifyFileType to use a StringRef in the next patch.

llvm-svn: 183664
2013-06-10 14:56:16 +00:00
Aaron Ballman f0b5384ef9 sys::process::get_id() now returns the process ID instead of a process handle on Windows. Patch thanks to Kim Gräsman!
llvm-svn: 183621
2013-06-08 20:29:03 +00:00
Manuel Klimek d0cf5b2de3 Introduce needsCleanup() for APFloat and APInt.
This is needed in clang so one can check if the object needs the
destructor called after its memory was freed. This is useful when
creating many APInt/APFloat objects with placement new, where the
overhead of tracking the pointers for cleanup is significant.

llvm-svn: 183100
2013-06-03 13:03:05 +00:00
Benjamin Kramer b565f89929 APInt: Simplify code. No functionality change.
llvm-svn: 183073
2013-06-01 11:26:39 +00:00
Benjamin Kramer 6bef24f3d7 APFloat: Use isDenormal instead of hand-rolled code to check for denormals.
llvm-svn: 183072
2013-06-01 11:26:33 +00:00
Eric Christopher 1ec87e8bb0 Add support for adding the contents of a StringRef to the MD5 hash.
llvm-svn: 183054
2013-05-31 22:34:56 +00:00
Eric Christopher 85bd745e77 Convert more unsigned char -> uint8_t.
llvm-svn: 183053
2013-05-31 22:34:52 +00:00
Eric Christopher d0910436e7 Fix comment.
llvm-svn: 183052
2013-05-31 22:34:48 +00:00
Eric Christopher 606ecda4a1 Move "unsigned char" -> "uint8_t".
llvm-svn: 183051
2013-05-31 22:34:34 +00:00
Michael Gottesman 0c622ea8d3 Implement IEEE-754R 2008 nextUp/nextDown functions in the guise of the function APFloat::next(bool nextDown).
rdar://13852078

llvm-svn: 182945
2013-05-30 18:07:13 +00:00
Michael Gottesman 9d406f4ec7 [APInt] Implement tcDecrement as a counterpart to tcIncrement. This is for use in APFloat IEEE-754R 2008 nextUp/nextDown function.
rdar://13852078

llvm-svn: 182801
2013-05-28 19:50:20 +00:00
Eric Christopher fcee6f0abc ArrayRef-ize MD5 and clean up a few variable names.
Add a stringize method to make dumping a bit easier, and add a testcase
exercising a few different paths.

llvm-svn: 182692
2013-05-24 23:08:17 +00:00
Michael J. Spencer df1ecbd734 Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.
llvm-svn: 182680
2013-05-24 22:23:49 +00:00
Benjamin Kramer 534d3a4670 Remove the Copied parameter from MemoryObject::readBytes.
There was exactly one caller using this API right, the others were relying on
specific behavior of the default implementation. Since it's too hard to use it
right just remove it and standardize on the default behavior.

Defines away PR16132.

llvm-svn: 182636
2013-05-24 10:54:58 +00:00
Ahmed Bougacha aa79068157 MC: Disassembled CFG reconstruction.
This patch builds on some existing code to do CFG reconstruction from
a disassembled binary:
- MCModule represents the binary, and has a list of MCAtoms.
- MCAtom represents either disassembled instructions (MCTextAtom), or
  contiguous data (MCDataAtom), and covers a specific range of addresses.
- MCBasicBlock and MCFunction form the reconstructed CFG. An MCBB is
  backed by an MCTextAtom, and has the usual successors/predecessors.
- MCObjectDisassembler creates a module from an ObjectFile using a
  disassembler. It first builds an atom for each section. It can also
  construct the CFG, and this splits the text atoms into basic blocks.

MCModule and MCAtom were only sketched out; MCFunction and MCBB were
implemented under the experimental "-cfg" llvm-objdump -macho option.
This cleans them up for further use; llvm-objdump -d -cfg now generates
graphviz files for each function found in the binary.

In the future, MCObjectDisassembler may be the right place to do
"intelligent" disassembly: for example, handling constant islands is just
a matter of splitting the atom, using information that may be available
in the ObjectFile. Also, better initial atom formation than just using
sections is possible using symbols (and things like Mach-O's
function_starts load command).

This brings two minor regressions in llvm-objdump -macho -cfg:
- The printing of a relocation's referenced symbol.
- An annotation on loop BBs, i.e., which are their own successor.

Relocation printing is replaced by the MCSymbolizer; the basic CFG
annotation will be superseded by more related functionality.

llvm-svn: 182628
2013-05-24 01:07:04 +00:00
Eric Christopher db142d4e1e Add cmake bits for md5.
llvm-svn: 182349
2013-05-21 01:30:38 +00:00
Eric Christopher e1dc3c45e6 Add an md5 library derived from a public domain implementation for dwarf4
type signature computation.

llvm-svn: 182348
2013-05-21 01:28:35 +00:00
Bob Wilson 111b0b6da4 Remove declaration of __clear_cache for __APPLE__. <rdar://problem/13924072>
This fixes a bootstrapping problem with builds for Apple ARM targets.
Clang had the wrong prototype for __clear_cache with ARM targets.  Rafael
fixed that in clang svn r181784 and r181810, but without those changes,
we can't build this code for ARM because clang reports an error about the
declaration in Memory.inc not matching the builtin declaration. Some of our
buildbots need to use an older compiler that doesn't have the clang fix.
Since __clear_cache is never used here when __APPLE__ is defined, I'm just
conditionalizing the declaration to match that. I also moved the declaration
of sys_icache_invalidate inside the conditional for __APPLE__ while I was at
it.

llvm-svn: 182223
2013-05-19 20:33:51 +00:00
Tim Northover 77d0a4ac62 Invalidate instruction cache when setting memory to be executable.
lli's remote MCJIT code calls setExecutable just prior to running
code. In line with Darwin behaviour this seems to be the place to
invalidate any caches needed so that relocations can take effect
properly.

llvm-svn: 182213
2013-05-19 15:28:16 +00:00
Timur Iskhodzhanov 0588513e79 Fix build on Windows
llvm-svn: 181873
2013-05-15 09:00:30 +00:00
David Blaikie 041f1aa3e2 Use only explicit bool conversion operators
BitVector/SmallBitVector::reference::operator bool remain implicit since
they model more exactly a bool, rather than something else that can be
boolean tested.

The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

One behavior change (YAMLParser) was made, though no test case is
included as I'm not sure how to reach that code path. Essentially any
comparison of llvm::yaml::document_iterators would be invalid if neither
iterator was at the end.

This helped uncover a couple of bugs in Clang - test cases provided for
those in a separate commit along with similar changes to `operator bool`
instances in Clang.

llvm-svn: 181868
2013-05-15 07:36:59 +00:00
Rafael Espindola e16befb5f6 Fix __clear_cache declaration.
This fixes the build with gcc in gnu++98 and gnu++11 mode.

llvm-svn: 181811
2013-05-14 18:06:14 +00:00
Jakob Stoklund Olesen abc3d23ccb Recognize sparc64 as an alias for sparcv9 triples.
Patch by Brad Smith!

llvm-svn: 181808
2013-05-14 17:47:27 +00:00
Rafael Espindola 17268dc192 Declare __clear_cache.
GCC declares __clear_cache in the gnu modes (-std=gnu++98,
-std=gnu++11), but not in the strict modes (-std=c++98, -std=c++11). This patch
declares it and therefore fixes the build when using one of the strict modes.

llvm-svn: 181785
2013-05-14 13:02:37 +00:00
Shuxin Yang bbddbacd2e Fix a bug that APFloat::fusedMultiplyAdd() mistakenly evaluate "14.5f * -14.5f + 225.0f" to 225.0f.
llvm-svn: 181715
2013-05-13 18:03:12 +00:00
Alexander Kornienko 72a196a159 Better output for long help strings for command-line options.
Summary:
This patch allows using \n inside long help strings for command-line
options, so that all lines are equally indented. This is not a perfect solution,
as we don't (and probably don't want to) know about terminal width, but it
allows to format long help strings somehow readable without manually padding
them with spaces. A motivating example is -help output from clang-format (source
code in tools/clang-format/ClangFormat.cpp, see cl options offset, length,
style, and dump-config).

Reviewers: atrick, alexfh

Reviewed By: alexfh

CC: llvm-commits, rafael

Differential Revision: http://llvm-reviews.chandlerc.com/D779

llvm-svn: 181608
2013-05-10 17:15:51 +00:00
Daniel Malea f83beab4bd Add line tracking support to FormattedStream
- previously formatted_raw_ostream tracked columns, now it tracks lines too
- used by (upcoming) DebugIR pass to know the line number to connect to each IR
  instruction

llvm-svn: 181463
2013-05-08 20:29:10 +00:00
Andrew Trick 7cb710d58c Implemented public interface for modifying registered (not positional or sink options) command line options at runtime.
Patch by Dan Liew!

llvm-svn: 181254
2013-05-06 21:56:35 +00:00
Andrew Trick 0537a98878 Support command line option categories.
Patch by Dan Liew!

llvm-svn: 181253
2013-05-06 21:56:23 +00:00
Dmitri Gribenko 3238fb7595 Add ArrayRef constructor from None, and do the cleanups that this constructor enables
Patch by Robert Wilhelm.

llvm-svn: 181138
2013-05-05 00:40:33 +00:00
Tim Northover 6c26b327ef AArch64: use __clear_cache under GCCish environments
AArch64 is going to need some kind of cache-invalidation in order to
successfully JIT since it has a weak memory-model. This is provided by
a __clear_cache builtin in libgcc, which acts very much like the
32-bit ARM equivalent (on platforms where it exists).

llvm-svn: 181129
2013-05-04 18:52:44 +00:00
Tim Northover fee13d1e11 Allow host triple to be correctly overridden in CMake builds
The intended semantics mirror autoconf, where the user is able to
specify a host triple, but if it's left to the build system then
"config.guess" is invoked for the default.

This also renames the LLVM_HOSTTRIPLE define to LLVM_HOST_TRIPLE to
fit in with the style of the surrounding defines.

llvm-svn: 181112
2013-05-04 07:36:23 +00:00
Ulrich Weigand 90c9abdd27 [SystemZ] Support System Z as host architecture
The llvm::sys::AddSignalHandler function (as well as related routines) in
lib/Support/Unix/Signals.inc currently registers a signal handler routine
via "sigaction".  When this handler is called due to a SIGSEGV, SIGILL or
similar signal, it will show a stack backtrace, deactivate the handler,
and then simply return to the operating system.  The intent is that the
OS will now retry execution at the same location as before, which ought
to again trigger the same error condition and cause the same signal to be
delivered again.  Since the hander is now deactivated, the OS will take
its default action (usually, terminate the program and possibly create
a core dump).

However, this method doesn't work reliably on System Z:  With certain
signals (namely SIGILL, SIGFPE, and SIGTRAP), the program counter stored
by the kernel on the signal stack frame (which is the location where
execution will resume) is not the instruction that triggered the fault,
but then instruction *after it*.  When the LLVM signal handler simply
returns to the kernel, execution will then resume at *that* address,
which will not trigger the problem again, but simply go on and execute
potentially unrelated code leading to random errors afterwards.

To fix this, the patch simply goes and re-raises the signal in question
directly from the handler instead of returning from it.  This is done
only on System Z and only for those signals that have this particular
problem.

llvm-svn: 181010
2013-05-03 12:22:11 +00:00
Richard Sandiford a238c5e08f [SystemZ] Add llvm::Triple::systemz
First step towards reinstating the SystemZ backend.  Tests will be
included in the main backend patch.

llvm-svn: 181007
2013-05-03 11:05:17 +00:00
Benjamin Kramer b44c4275d5 X86: Add target description for btver2; make autodetection logic aware of AVX.
llvm-svn: 181005
2013-05-03 10:20:08 +00:00
Aaron Ballman fd86e16dbd Fixes a buffer overrun where the allocated buffer wasn't large enough to accommodate the closing quote escape rules in some instances.
llvm-svn: 180836
2013-05-01 02:53:14 +00:00
Benjamin Kramer 83e2a44a13 Inline variable into the #ifdef block where it's used.
llvm-svn: 180688
2013-04-28 07:47:04 +00:00
Joerg Sonnenberger 447440907e Fix typo. Stupid me.
llvm-svn: 180686
2013-04-27 22:32:54 +00:00
Joerg Sonnenberger 66241831dc Only use cxxabi.h's demangler, if it is actually available.
llvm-svn: 180684
2013-04-27 22:12:32 +00:00
Aaron Ballman 31c0adc68c Testing for _XCR_XFEATURE_ENABLED_MASK instead of a specific MSVC version because some MSVC 2010 SP1 installations do not have the _xgetbv intrinsic. Patch thanks to Serge Pavlov!
llvm-svn: 180125
2013-04-23 17:38:44 +00:00
Alexey Samsonov fdcff04ad5 Fixup for r180094: properly use MSan interface functions
llvm-svn: 180103
2013-04-23 13:35:32 +00:00
Alexey Samsonov 0c9f1bfae5 Tell MSan that memory initialized by libz is valid
llvm-svn: 180094
2013-04-23 12:17:46 +00:00
Hans Wennborg 63761d4bc4 Add llvm_unreachable after fully covered switch to pacify GCC
llvm-svn: 180087
2013-04-23 10:12:16 +00:00
Alexey Samsonov 28acf056e1 Add more guards around zlib-dependent code
llvm-svn: 180084
2013-04-23 08:57:30 +00:00
Alexey Samsonov 2fb337e77a Add basic zlib support to LLVM. This would allow to use compression/uncompression in selected LLVM tools.
llvm-svn: 180083
2013-04-23 08:28:39 +00:00
Reid Kleckner 74679a93b2 [Support] Fix argv string escape bug on Windows
Summary:
This is http://llvm.org/PR15802.  Backslashes preceding double quotes in
arguments must be escaped.  The interesting bit is that all other
backslashes should *not* be escaped, because the un-escaping logic is
only triggered by the presence of a double quote character.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D705

llvm-svn: 180035
2013-04-22 19:03:55 +00:00
Craig Topper 7af39d7de0 Convert windows line endings to linux/unix line endings.
llvm-svn: 179995
2013-04-22 05:38:01 +00:00
Rafael Espindola 41cb64f4fa Make the host endianness check an integer constant expression.
I will remove the isBigEndianHost function once I update clang.

The ifdef logic is designed to
* not use configure/cmake to avoid breaking -arch i686 -arch ppc.
* default to little endian
* be as small as possible

It looks like sys/endian.h is the preferred header on most modern BSD systems,
but it is better to change this in a followup patch as machine/endian.h is
available on FreeBSD, OpenBSD, NetBSD and OS X.

llvm-svn: 179527
2013-04-15 14:44:24 +00:00
Rafael Espindola cd848c0866 Add a function to check if an argument list is too long.
This will be used in clang to decide if it should create an @file or not. It
will be tested on the clang side.

Patch by Nathan Froyd.

llvm-svn: 179285
2013-04-11 14:06:34 +00:00
Douglas Gregor 0cb6846090 <rdar://problem/13551789> Fix a race in the LockFileManager.
It's possible for the lock file to disappear and the owning process to
return before we're able to see the generated file. Spin for a little
while to see if it shows up before failing. 

llvm-svn: 178909
2013-04-05 20:53:57 +00:00
Douglas Gregor 6bd4d8cf72 <rdar://problem/13551789> Fix yet another race in unique_file.
If the directory that will contain the unique file doesn't exist when
we tried to create the file, but another process creates it before we
get a chance to try creating it, we would bail out rather than try to
create the unique file.

llvm-svn: 178908
2013-04-05 20:48:36 +00:00
Michael J. Spencer b8055cbc9d [Support][FileSystem] Fix identify_magic for big endian ELF.
llvm-svn: 178905
2013-04-05 20:10:04 +00:00
Reid Kleckner bd39f21336 [Support] Disable assertion dialogs from the MSVC debug CRT
Summary:
Sets a report hook that emulates pressing "retry" in the "abort, retry,
ignore" dialog box that _CrtDbgReport normally raises.  There are many
other ways to disable assertion reports, but this was the only way I
could find that still calls our exception handler.

Reviewers: Bigcheese

CC: llvm-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D625

llvm-svn: 178880
2013-04-05 16:18:03 +00:00
Aaron Ballman 5e6d20524a Ensuring that both bits are set, and not just a combination of one or the other.
llvm-svn: 178674
2013-04-03 18:00:22 +00:00
Aaron Ballman edc03c660c Testing for Visual Studio 2010 SP1 or greater before calling the _xgetbv intrinsic. This also fixes a minor code formatting issue.
llvm-svn: 178666
2013-04-03 16:28:24 +00:00
Aaron Ballman 5f7c680fdc Second pass at addressing PR15351 by explicitly checking for AVX support
when getting the host processor information.  It emits a .byte sequence on GNUC compilers to work around lack of xgetbv support with older assemblers, and resolves a comment typo found in the previous patch.

llvm-svn: 178636
2013-04-03 12:25:06 +00:00
Aaron Ballman 9c0f0af54f Rolling back the AVX support patch due to breaking a gcc 4.6 build bot that doesn't understand the xgetbv instruction for some reason. Will revisit when time permits.
llvm-svn: 178614
2013-04-03 03:11:39 +00:00
Aaron Ballman 56be6ba5e4 Attempting to fix the build on older GCC versions.
llvm-svn: 178604
2013-04-03 01:39:37 +00:00
Aaron Ballman 6bc0dfc7bd This patch addresses PR15351 by explicitly checking for AVX support
when getting the host processor information.

llvm-svn: 178598
2013-04-03 00:33:32 +00:00
Benjamin Kramer a73cc5eead Put private class into an anonmyous namespace.
llvm-svn: 178420
2013-03-30 15:23:08 +00:00
Jean-Luc Duprat 89fe247094 SmallVector and SmallPtrSet allocations now power-of-two aligned.
This time tested on both OSX and Linux.

llvm-svn: 178377
2013-03-29 22:07:12 +00:00
Rafael Espindola de65751493 Revert "Fix allocations of SmallVector and SmallPtrSet so they are more prone to"
This reverts commit 617330909f0c26a3f2ab8601a029b9bdca48aa61.

It broke the bots:

/home/clangbuild2/clang-ppc64-2/llvm.src/unittests/ADT/SmallVectorTest.cpp:150: PushPopTest
/home/clangbuild2/clang-ppc64-2/llvm.src/unittests/ADT/SmallVectorTest.cpp:118: Failure
Value of: v[i].getValue()
  Actual: 0
Expected: value
Which is: 2

llvm-svn: 178334
2013-03-29 07:11:21 +00:00
Jean-Luc Duprat 67ce1472b4 Fix allocations of SmallVector and SmallPtrSet so they are more prone to
being power-of-two sized.

llvm-svn: 178332
2013-03-29 05:45:22 +00:00
Chad Rosier 7ce810cb84 Don't try to generate crash diagnostics if we had an I/O failure. It's very
likely the crash diagnostics generation will fail as well.
Part of rdar://13296693

llvm-svn: 178163
2013-03-27 18:30:00 +00:00
Chad Rosier 583b4d3961 Add a boolean parameter to the llvm::report_fatal_error() function to indicated
if crash diagnostics should be generated.  By default this is enabled.
Part of rdar://13296693

llvm-svn: 178161
2013-03-27 18:27:54 +00:00
Chad Rosier 654190a12d Add a boolean parameter to the ExecuteAndWait static function to indicated
if execution failed.  ExecuteAndWait returns -1 upon an execution failure, but
checking the return value isn't sufficient because the wait command may
return -1 as well.  This new parameter is to be used by the clang driver in a
subsequent commit.
Part of rdar://13362359

llvm-svn: 178087
2013-03-26 23:35:00 +00:00
Nick Lewycky 8d9716265e Add missing file to cmake build.
llvm-svn: 177963
2013-03-26 01:29:15 +00:00
Nick Lewycky 4e06def851 Add a new watchdog timer interface. The interface does not permit handling timeouts, so
it's only really useful if you're going to crash anyways. Use it in the pretty stack trace
printer to kill the compiler if we hang while printing the stack trace.

llvm-svn: 177962
2013-03-26 01:27:52 +00:00
Chandler Carruth 0a9875abfe Revert r177543: Add timing of the IR parsing code with a new
-time-ir-parsing flag

This breaks the layering of the Support library. We can't add an
implementation side to IRReader because it refers directly to entities
only accessible as part of the IR, AsmParser, and BitcodeReader
libraries. It can only be used in a context where all of those libraries
will be available.

We'll need to find some other way to get this functionality, and
hopefully solve the long-standing layering problem of IRReader.h...

llvm-svn: 177695
2013-03-22 02:20:34 +00:00
Douglas Gregor a86ddf0411 <rdar://problem/13477190> On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR for the system temporary directory.
The DARWIN_USER_TEMP_DIR and DARWIN_USER_CACHE_DIR configuration
settings are more idiomatic for Darwin than the TMPDIR environment
variable.

llvm-svn: 177669
2013-03-21 21:46:10 +00:00
Jakub Staszak 773be0ce1f Use pre-inc, pre-dec when possible.
They are generally faster (at least not slower) than post-inc, post-dec.

llvm-svn: 177608
2013-03-20 23:56:19 +00:00
Eli Bendersky 83b359d4c8 Add timing of the IR parsing code with a new -time-ir-parsing flag
llvm-svn: 177543
2013-03-20 17:00:25 +00:00
Hao Liu be99cc3a3e Fix AsmPrinter crashes with assertion. Bug 15318 in Bugzilla
llvm-svn: 177472
2013-03-20 01:46:36 +00:00
Michael J. Spencer d932d41190 [Support][Path][Windows] Fix dangling else. Don't call CloseHandle when CloseFD is false.
llvm-svn: 177175
2013-03-15 19:25:47 +00:00
Akira Hatanaka 7239a6003f Android uses cacheflush(long start, long end, long flags) for MIPS.
Patch by Stephen Hines.

llvm-svn: 177101
2013-03-14 19:01:00 +00:00
Michael J. Spencer 42ad29fa05 [Support] Fix lifetime of file descriptors when using MemoryBuffer.
Clients of MemoryBuffer::getOpenFile expect it not to take ownership of the file
descriptor passed in. So don't.

llvm-svn: 176995
2013-03-14 00:20:10 +00:00
Matt Beaumont-Gay a182be8a91 Don't crash if write_impl() leaves less buffer space available than expected.
This was tickled by a Clang diagnostic; Clang test case to follow.

llvm-svn: 176911
2013-03-12 23:55:24 +00:00
Michael J. Spencer 20a11b2534 [Support][Path] Don't inf loop if creating the parent directory fails.
Patch by Paul Robinson.

llvm-svn: 176908
2013-03-12 22:32:39 +00:00
Michael J. Spencer 2343a74aeb [Support][MemoryBuffer] Use sys::fs::mapped_file_region instead of sys::Path::MapInFilePages.
This gives us memory mapped file I/O on Windows.

llvm-svn: 176886
2013-03-12 19:28:19 +00:00
Craig Topper fa9888fce7 Remove an unused member variable from HelpPrinter. Move another member variable to be a local variable in the only method that uses it.
llvm-svn: 176778
2013-03-09 23:29:37 +00:00
Jan Wen Voung 7857a64909 Disable statistics on Release builds and move tests that depend on -stats.
Summary:
Statistics are still available in Release+Asserts (any +Asserts builds),
and stats can also be turned on with LLVM_ENABLE_STATS.

Move some of the FastISel stats that were moved under DEBUG()
back out of DEBUG(), since stats are disabled across the board now.

Many tests depend on grepping "-stats" output.  Move those into
a orig_dir/Stats/. so that they can be marked as unsupported
when building without statistics.

Differential Revision: http://llvm-reviews.chandlerc.com/D486

llvm-svn: 176733
2013-03-08 22:56:31 +00:00
Argyrios Kyrtzidis db4443f7af In llvm::MemoryBuffer::getFile() remove an unnecessary stat call check.
The sys::fs::is_directory() check is unnecessary because, if the filename is
a directory, the function will fail anyway with the same error code returned.
Remove the check to avoid an unnecessary stat call.

Someone needs to review on windows and see if the check is necessary there or not.

llvm-svn: 176386
2013-03-01 22:48:51 +00:00
Argyrios Kyrtzidis eed2dc5769 [PathV2] In llvm::sys::fs::unique_file, make sure it doesn't fall into an infinite loop by constantly trying
to create the parent path.

This can happen if the path is a relative filename and the current directory was removed.
Thanks to Daniel D. for the hint in fixing it.

llvm-svn: 176226
2013-02-28 00:38:19 +00:00
Roman Divacky fd666e9e3c Add support for autodetection of ADM bdver2.
llvm-svn: 176130
2013-02-26 22:41:01 +00:00
Eli Bendersky 705085da37 Previously, parsing capability of the .debug_frame section was added
to lib/DebugInfo, with dumping in llvm-dwarfdump. This patch adds
initial ability to parse and dump CFA instructions contained in
entries.

To keep it manageable, the patch omits some more advanced capabilities
(accounted in TODOs):

* Parsing of instructions with BLOCK arguments (expression lists)
* Dumping of actual instruction arguments (currently only names are
dumped). This is quite tricky since the dumper has to effectively
"interpret" the instructions.

llvm-svn: 175820
2013-02-21 22:53:19 +00:00
David Blaikie ef04593de1 Provide a "None" value for convenience when using Optional<T>()
This implementation of NoneType/None does have some holes but I haven't
found one that doesn't - open to improvement.

llvm-svn: 175696
2013-02-21 00:27:28 +00:00
Pedro Artigas 0c09481d6b as the allocator is reset zero out the number of bytes allocated, this was just
missed before but probably what was intended.

llvm-svn: 175687
2013-02-20 23:30:56 +00:00
Erik Verbruggen ef40cdd95b Fix accidental concatenation for "outputuntil" in the -debug-buffer-size option description.
llvm-svn: 175682
2013-02-20 22:33:46 +00:00
Dan Gohman f857cd7518 Rewrite comments.
llvm-svn: 175651
2013-02-20 19:28:46 +00:00
Krzysztof Parzyszek 12ba711f35 Add comment in Memory.inc explaining r175646.
llvm-svn: 175650
2013-02-20 19:25:09 +00:00
Dan Gohman 5cdb345883 SIGQUIT is a "kill" signal, rather than an "int" signal, in this context.
llvm-svn: 175648
2013-02-20 19:15:01 +00:00
Krzysztof Parzyszek 798679e140 On PowerPC, the cache-flush instructions dcbf and icbi are treated as
loads. On FreeBSD, add PROT_READ page protection flag before flushing
cache.

llvm-svn: 175646
2013-02-20 18:24:30 +00:00
Jakub Staszak 6605c604b9 Move part of APInt implementation from header to cpp file. These methods
require call cpp file anyway, so we wouldn't gain anything by keeping them
inline.

llvm-svn: 175579
2013-02-20 00:17:42 +00:00
Dan Gohman 3e1729484f Update a portability kludge to keep it in sync with changes in the code
which uses it. This is not ideal, but it ought to at least restore the
behavior to what it was before.

llvm-svn: 175571
2013-02-19 22:38:58 +00:00
Dan Gohman 782609e146 Whitelist files and block devices instead of blacklisting fifos and
character devices.

llvm-svn: 175549
2013-02-19 19:36:55 +00:00
Dan Gohman 22954dbb7e Don't trust st_size of a character device. This fixes using
/dev/stdin as an input when stdin is connected to a tty, for example.

No test, because it's difficult to write a reasonably portable test
for this. /dev/stdin isn't a character device when stdin is redirected
from a file or connected to a pipe.

llvm-svn: 175542
2013-02-19 18:57:53 +00:00
Alexey Samsonov f940f0c417 Fix initialization-order bug in llvm::Support::TimeValue. TimeValue::now() is explicitly called during module initialization of lib/Support/Process.cpp. It reads the field of global object PosixZeroTime, which is not guaranteed to be initialized at this point. Found by AddressSanitizer with -fsanitize=init-order option.
llvm-svn: 175509
2013-02-19 11:35:39 +00:00
Benjamin Kramer 6ecb1e78a9 Make helpers static. Add missing include so LLVMInitializeObjCARCOpts gets C linkage.
llvm-svn: 175264
2013-02-15 12:30:38 +00:00
Evgeniy Stepanov a5b58f9b3b Workaround an MSan false positive.
llvm-svn: 175156
2013-02-14 12:18:32 +00:00
Guy Benyei 83c74e9fad Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration.
llvm-svn: 175006
2013-02-12 21:21:59 +00:00
Evgeniy Stepanov 1f5a71492d More MSan/ASan annotations.
This change lets us bootstrap LLVM/Clang under ASan and MSan. It contains
fixes for 2 issues:

- X86JIT reads return address from stack, which MSan does not know is
  initialized.
- bugpoint tests run binaries with RLIMIT_AS. This does not work with certain
  Sanitizers.

We are no longer including config.h in Compiler.h with this change.

llvm-svn: 174306
2013-02-04 07:03:24 +00:00
Tim Northover e0e3aefdd3 Add AArch64 as an experimental target.
This patch adds support for AArch64 (ARM's 64-bit architecture) to
LLVM in the "experimental" category. Currently, it won't be built
unless requested explicitly.

This initial commit should have support for:
    + Assembly of all scalar (i.e. non-NEON, non-Crypto) instructions
      (except the late addition CRC instructions).
    + CodeGen features required for C++03 and C99.
    + Compilation for the "small" memory model: code+static data <
      4GB.
    + Absolute and position-independent code.
    + GNU-style (i.e. "__thread") TLS.
    + Debugging information.

The principal omission, currently, is performance tuning.

This patch excludes the NEON support also reviewed due to an outbreak of
batshit insanity in our legal department. That will be committed soon bringing
the changes to precisely what has been approved.

Further reviews would be gratefully received.

llvm-svn: 174054
2013-01-31 12:12:40 +00:00
Evgeniy Stepanov 130fdcd225 Annotate BumpPtrAllocator for MemorySanitizer.
This change adds MemorySanitizer annotations to BumpPtrAllocator to
improve report quality.

llvm-svn: 174051
2013-01-31 09:58:59 +00:00
Dmitri Gribenko b311f4e84a Move UTF conversion routines from clang/lib/Basic to llvm/lib/Support
This is required to use them in TableGen.

llvm-svn: 173923
2013-01-30 12:05:05 +00:00
Edwin Vane 44338e00f8 Fix gcc/printf/ISO C++ warning
Remove the use of the 't' length modifier to avoid a gcc warning. Based
on usage, 32 bits of precision is good enough for printing a stack
offset for a stack trace.

't' length modifier isn't in C++03 but it *is* in C++11. Added a FIXME
to reintroduce once LLVM makes the switch to C++11.

Reviewer: gribozavr
llvm-svn: 173711
2013-01-28 19:34:42 +00:00
Benjamin Kramer b361adbb64 APFloat: Make sure that we get a well-formed x87 NaN when converting from a smaller type.
Fixes PR15054.

llvm-svn: 173459
2013-01-25 17:01:00 +00:00
Andrew Trick b36388a1cb ScheduleDAG: colorize the DOT graph and improve formatting.
llvm-svn: 173431
2013-01-25 07:45:25 +00:00
Eli Bendersky 0893e1079d Initial patch for x32 ABI support.
Add the x32 environment kind to the triple, and separate the concept of
pointer size and callee save stack slot size, since they're not equal
on x32.

llvm-svn: 173175
2013-01-22 18:02:49 +00:00
Tim Northover 29178a348a Make APFloat constructor require explicit semantics.
Previously we tried to infer it from the bit width size, with an added
IsIEEE argument for the PPC/IEEE 128-bit case, which had a default
value. This default value allowed bugs to creep in, where it was
inappropriate.

llvm-svn: 173138
2013-01-22 09:46:31 +00:00
Jordan Rose e1f76583dd Add llvm::hexDigitValue to convert single characters to hex.
This is duplicated in a couple places in the codebase. Adopt this in APFloat.

llvm-svn: 172851
2013-01-18 21:45:30 +00:00
Peter Collingbourne a51c6ed608 Introduce llvm::sys::getProcessTriple() function.
In r143502, we renamed getHostTriple() to getDefaultTargetTriple()
as part of work to allow the user to supply a different default
target triple at configure time.  This change also affected the JIT.
However, it is inappropriate to use the default target triple in the
JIT in most circumstances because this will not necessarily match
the current architecture used by the process, leading to illegal
instruction and other such errors at run time.

Introduce the getProcessTriple() function for use in the JIT and
its clients, and cause the JIT to use it.  On architectures with a
single bitness, the host and process triples are identical.  On other
architectures, the host triple represents the architecture of the
host CPU, while the process triple represents the architecture used
by the host CPU to interpret machine code within the current process.
For example, when executing 32-bit code on a 64-bit Linux machine,
the host triple may be 'x86_64-unknown-linux-gnu', while the process
triple may be 'i386-unknown-linux-gnu'.

This fixes JIT for the 32-on-64-bit (and vice versa) build on non-Apple
platforms.

Differential Revision: http://llvm-reviews.chandlerc.com/D254

llvm-svn: 172627
2013-01-16 17:27:22 +00:00
Timur Iskhodzhanov 6c704ebbf1 Revert r171829 "Split changeset_ty using iterators instead of loops" as it breaks the VS2008 build
llvm-svn: 172411
2013-01-14 14:13:06 +00:00
Dmitri Gribenko 226fea5bd6 Remove redundant 'llvm::' qualifications
llvm-svn: 172358
2013-01-13 16:01:15 +00:00
Jordan Rose ceb1dbb41f SMDiagnostic: don't emit ranges if there are /any/ multibyte characters.
Right now, only OS X has a way to determine the column width of a string
(PR14910). Until we have a good way to deal with this, we just won't
print carets, source ranges, or fixits for SMDiagnostic if the source line
has multibyte characters in it.

llvm-svn: 172164
2013-01-11 02:37:55 +00:00
Jordan Rose efd8f80ed5 Add basic fix-its to SMDiagnostic.
Like Clang's FixItHint, SMFixIt represents an insertion, replacement, or
removal of source text. One or more fix-its can be emitted as part of
a diagnostic, and will be printed below the source range line to show the
user how they can fix their code.

Currently, the only client of SMFixIt is clang-tblgen; thus, the tests for
this behavior live in clang/test/TableGen/tg-fixits.td. If/when SMFixIt is
adopted within LLVM itself, those tests should be moved to the LLVM suite.

llvm-svn: 172086
2013-01-10 18:50:15 +00:00
Douglas Gregor 056eafd420 Fix a race condition in the lock-file manager: once the lock file is
gone, check for the actual file we care about.

llvm-svn: 172033
2013-01-10 02:01:35 +00:00
Douglas Gregor 95585ab6a4 Fix a race condition in llvm::sys::path::unique_file: when we end up
failing to create the unique file because the path doesn't exist,
don't fail if someone else manages to create the path before we do.

llvm-svn: 172032
2013-01-10 01:58:46 +00:00
Argyrios Kyrtzidis eb9ae76864 Move the internal PrintStackTrace function that is used for llvm::sys::PrintStackTraceOnErrorSignal(),
into a new function llvm::sys::PrintStackTrace, so that it's available to clients for logging purposes.

llvm-svn: 171989
2013-01-09 19:42:40 +00:00
Nick Kledzik 0dcef84b13 Fix memory leak in YAML I/O.
Stop using BumpPtrAllocator for HNodes because
they have fields (vector, map) which require HNode 
destructors to be run.

llvm-svn: 171896
2013-01-08 21:04:44 +00:00
Eric Christopher 72a529566c Remove the llvm-local DW_TAG_vector_type tag and add a test to
make sure that vector types do work.

llvm-svn: 171833
2013-01-08 01:53:52 +00:00
Lenny Maiorani fc5496823c Split changeset_ty using iterators instead of loops.
llvm-svn: 171829
2013-01-08 01:08:52 +00:00
Eric Christopher 9948d5eb6f Remove what appears to be a dead llvm-specific debug tag.
llvm-svn: 171821
2013-01-08 00:16:33 +00:00
Jordan Rose e8f1eaea8a Change SMRange to be half-open (exclusive end) instead of closed (inclusive)
This is necessary not only for representing empty ranges, but for handling
multibyte characters in the input. (If the end pointer in a range refers to
a multibyte character, should it point to the beginning or the end of the
character in a char array?) Some of the code in the asm parsers was already
assuming this anyway.

llvm-svn: 171765
2013-01-07 19:00:49 +00:00
Shuxin Yang 4fb504fec1 Implement APFloat::isDenormal()
llvm-svn: 171764
2013-01-07 18:59:35 +00:00
Chandler Carruth b5429f43b8 Eric thought that Darwin was right to use -1 consistently rather than
leaving this undefined, and despite the sentence in the standard that
seems to require it, I'll cede the point and assume its a bug in the
wording. Other parts of POSIX regularly allow for things to be -1
instead of undefined, this should too. Makes things more consistent too.

This should have to real impact for folks though.

llvm-svn: 171574
2013-01-05 00:42:50 +00:00
Chandler Carruth 2aaec89fd0 Try to suppress the use of clock_gettime on Darwin which apparantly
defines _POSIX_CPUTIME but doesn't support the clock_* functions.

I don't test the value of _POSIX_CPUTIME because the spec merely says
that if it is defined, the CPU-specific timers are available, whereas it
says that _POSIX_TIMERS must be defined and defined to a value greater
than zero. However, this may not work, as the POSIX spec clearly states:

  "If the symbolic constant _POSIX_CPUTIME is defined, then the symbolic
  constant _POSIX_TIMERS shall also be defined by the implementation to
  have the value 200112L."

If this doesn't work, I'll add more hacks for Darwin.

llvm-svn: 171565
2013-01-05 00:11:21 +00:00
Chandler Carruth b79a7aa541 Fix an obvious typo spotted by Reid Kleckner, and breaking windows builds.
llvm-svn: 171559
2013-01-04 23:46:04 +00:00
Chandler Carruth ef7f968e09 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.

llvm-svn: 171551
2013-01-04 23:19:55 +00:00
Nick Kledzik 11964f2a8f Fix how YAML I/O detects flow sequences.
Update test case to verify flow sequence is
written as a flow sequence.

llvm-svn: 171514
2013-01-04 19:32:00 +00:00
Chandler Carruth 9fb823bbd4 Move all of the header files which are involved in modelling the LLVM IR
into their new header subdirectory: include/llvm/IR. This matches the
directory structure of lib, and begins to correct a long standing point
of file layout clutter in LLVM.

There are still more header files to move here, but I wanted to handle
them in separate commits to make tracking what files make sense at each
layer easier.

The only really questionable files here are the target intrinsic
tablegen files. But that's a battle I'd rather not fight today.

I've updated both CMake and Makefile build systems (I think, and my
tests think, but I may have missed something).

I've also re-sorted the includes throughout the project. I'll be
committing updates to Clang, DragonEgg, and Polly momentarily.

llvm-svn: 171366
2013-01-02 11:36:10 +00:00
Chandler Carruth be81023d74 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.

llvm-svn: 171362
2013-01-02 10:22:59 +00:00
Chandler Carruth 76fbeef95a Remove an unused method on Program.
I'm simplifying this interface as much as I can before merging it with
the new process interface.

llvm-svn: 171334
2012-12-31 23:44:47 +00:00
Chandler Carruth db8842f9f3 Remove an unused method on the Program class.
llvm-svn: 171332
2012-12-31 23:38:28 +00:00
Chandler Carruth acd64becb1 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.

llvm-svn: 171331
2012-12-31 23:31:56 +00:00
Chandler Carruth 15dcad9e36 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.

llvm-svn: 171330
2012-12-31 23:23:35 +00:00
Chandler Carruth b12634bf80 Remove an unused function in the old Process interface.
llvm-svn: 171327
2012-12-31 22:17:59 +00:00
Chandler Carruth 5473dfb099 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.

llvm-svn: 171292
2012-12-31 11:45:20 +00:00
Chandler Carruth 304de3c424 Delete a cut/paste-o from r171290. Very sorry about the noise.
llvm-svn: 171291
2012-12-31 11:40:04 +00:00
Chandler Carruth 5412246d8b Suppress a MSVC warning complaining about the code working as intended.
llvm-svn: 171290
2012-12-31 11:39:02 +00:00
Chandler Carruth 97683aa2fa 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.

llvm-svn: 171289
2012-12-31 11:17:50 +00:00
Nick Lewycky d192517cf3 Fix whitespace. No functionality change.
llvm-svn: 171051
2012-12-25 06:13:25 +00:00
Richard Smith 045e4f1365 Don't call back() on an empty SmallVector. Found by -fsanitize=enum!
llvm-svn: 170968
2012-12-22 00:15:13 +00:00
Roman Divacky a229186a82 Remove duplicate includes.
llvm-svn: 170902
2012-12-21 17:06:44 +00:00
Bill Wendling 3d7b0b8ac7 Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future.
llvm-svn: 170502
2012-12-19 07:18:57 +00:00
Hao Liu 10be3b20f1 Define getHostCPUFeatures for ARM Linux platform
llvm-svn: 170085
2012-12-13 02:40:20 +00:00
Benjamin Kramer 36b0f12474 YAMLIO: Remove all of the template instantiation hacks, I don't see why they're necessary and it breaks linking of the unit tests.
Also comes with a clang-format run on the cpp file, it had major style violations.

llvm-svn: 170036
2012-12-12 22:40:02 +00:00
Nick Kledzik f54b15a86d Fix calls to getAsSignedInteger() to use long long - not int64_t
llvm-svn: 170030
2012-12-12 21:42:49 +00:00
Benjamin Kramer cbe058412a Fix the build on case sensitive file systems.
llvm-svn: 170021
2012-12-12 20:55:44 +00:00
Nick Kledzik f60a9279ea Initial implementation of a utility for converting native data
structures to and from YAML using traits.  The first client will
be the test suite of lld.  The documentation will show up at:

   http://llvm.org/docs/YamlIO.html

llvm-svn: 170019
2012-12-12 20:46:15 +00:00
Eli Bendersky abe546368b Make NaCl naming consistent. The triple OSType is called NaCl and is represented
textually as NativeClient. Also added a link to the native client project for
readers unfamiliar with it.

A Clang patch will follow shortly.

llvm-svn: 169291
2012-12-04 18:37:26 +00:00
Chandler Carruth 802d755533 Sort includes for all of the .h files under the 'lib' tree. These were
missed in the first pass because the script didn't yet handle include
guards.

Note that the script is now able to handle all of these headers without
manual edits. =]

llvm-svn: 169224
2012-12-04 07:12:27 +00:00
Chandler Carruth dd7ca93abc Add a comment about the requirement that the Windows.h header be last.
This comment has the dual effect of blocking reorderings with the
sort_include script.

llvm-svn: 169221
2012-12-04 07:04:57 +00:00
Michael J. Spencer 7fe24f5744 [Support] Make FileOutputBuffer work on Windows.
llvm-svn: 169167
2012-12-03 22:09:52 +00:00
Michael J. Spencer 20abb2027f [Support][FileSystem] Fix open mode in resize_file on Windows.
llvm-svn: 169166
2012-12-03 22:09:31 +00:00
Michael J. Spencer 1ad8dff4bf Revert the header sort on this file.
"Windows.h" includes <Windows.h> which defines a bunch of stuff it shouldn't
(even with all the restriction macros). We have no control over this file, so
make it's scope as small as possible.

llvm-svn: 169165
2012-12-03 22:07:00 +00:00
Chandler Carruth ed0881b2a6 Use the new script to sort the includes of every file under lib.
Sooooo many of these had incorrect or strange main module includes.
I have manually inspected all of these, and fixed the main module
include to be the nearest plausible thing I could find. If you own or
care about any of these source files, I encourage you to take some time
and check that these edits were sensible. I can't have broken anything
(I strictly added headers, and reordered them, never removed), but they
may not be the headers you'd really like to identify as containing the
API being implemented.

Many forward declarations and missing includes were added to a header
files to allow them to parse cleanly when included first. The main
module rule does in fact have its merits. =]

llvm-svn: 169131
2012-12-03 16:50:05 +00:00