1092 Commits

Author SHA1 Message Date
Sam McCall
a46ae18100 [Support] Listing a directory containing dangling symlinks is not an error.
Summary:
Reporting this as an error required stat()ing every file, as well as seeming
semantically questionable.

Reviewers: vsk, bkramer

Subscribers: mgrang, kristina, llvm-commits, liaoyuke

Differential Revision: https://reviews.llvm.org/D52648

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343460 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 12:17:05 +00:00
Peter Smith
274ec57233 [ARM] Remove non-existent cpu arm1176j-s and use mpcore for v6k
The ARMTargetParser.def contains an entry for arm1176j-s which is the
default for the ArmV6K architecture. This cpu does not exist, there are
only arm1176jz-s and arm1176jzf-s and they are both architecture ArmV6KZ.
The only CPUs that are actually ArmV6K are the mpcore, mpcore_nofpu and
later revisions of the arm1136 family r1px (which we don't have a table
entry for).

This patch removes the arm1176j-s and makes mpcore the default for armv6k.

Differential Revision: https://reviews.llvm.org/D52594


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343303 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 09:04:27 +00:00
Oliver Stannard
aba0e1b1de [AArch64][v8.5A] Add Armv8.5-A random number instructions
This adds two new system registers, used to generate random numbers.

This is an optional extension to v8.5-A, and will be controlled by the
"+rng" modifier of the -march= and -mcpu= options.

Patch by Pablo Barrio!

Differential revision: https://reviews.llvm.org/D52481



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343217 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 14:01:40 +00:00
Fangrui Song
3b35e17b21 llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb

Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits

Differential Revision: https://reviews.llvm.org/D52573

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343163 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:13:45 +00:00
Oliver Stannard
1eb922bdfc [ARM/AArch64] Add target parser unit tests for Armv8.4-A
These were missed when adding Armv8.4-A support.

Patch by Pablo Barrio!

Differential revision: https://reviews.llvm.org/D52471



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343106 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 13:09:15 +00:00
Oliver Stannard
ecc449e514 [ARM/AArch64][v8.5A] Add Armv8.5-A target
This patch allows targeting Armv8.5-A, adding the architecture to
tablegen and setting the options to be identical to Armv8.4-A for the
time being. Subsequent patches will add support for the different
features included in the Armv8.5-A Reference Manual.

Patch by Pablo Barrio!

Differential revision: https://reviews.llvm.org/D52470



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343102 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 12:48:21 +00:00
Nico Weber
cb24b2be15 Remove dead function user_cache_directory()
It's been unused since it was added almost 3 years ago in
https://reviews.llvm.org/D13801

Motivated by https://reviews.llvm.org/rL342002 since it removes one of the
functions keeping a ref to SHGetKnownFolderPath.

Differential Revision: https://reviews.llvm.org/D52184


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342485 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 15:06:16 +00:00
Richard Smith
03e629a1a4 Fix a couple of mangling canonicalizer corner case bugs.
Summary:
The hash computed for an ArrayType was different when first constructed
versus when later profiled due to the constructor default argument, and
we were not tracking constructor / destructor variant as part of the
mangled name AST, leading to incorrect equivalences.

Reviewers: erik.pilkington

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D51463

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342166 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-13 20:00:21 +00:00
Richard Smith
9d93ec6c77 Common infrastructure for reading a profile remapping file and building
a mangling remapper from it.

Differential Revision: https://reviews.llvm.org/D51246

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342161 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-13 18:51:44 +00:00
Alexandre Ganea
1b609e0623 [Error] Reintroduce type validation in createFileError()
This prevents from using ErrorSuccess as an argument to createFileError().

Differential Revision: https://reviews.llvm.org/D51490


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341689 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-07 18:32:59 +00:00
Alexandre Ganea
60d68978a7 More build fix for r341064.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341070 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 14:05:49 +00:00
Alexandre Ganea
0993f24765 [Error] Add FileError helper; upgrade StringError behavior
FileError is meant to encapsulate both an Error and a file name/path. It should be used in cases where an Error occurs deep down the call chain, and we want to return it to the caller along with the file name.

StringError was updated to display the error messages in different ways. These can be:

1. display the error_code message, and convert to the same error_code (ECError behavior)
2. display an arbitrary string, and convert to a provided error_code (current StringError behavior)
3. display both an error_code message and a string, in this order; and convert to the same error_code

These behaviors can be triggered depending on the constructor. The goal is to use StringError as a base class, when a library needs to provide a explicit Error type.

Differential Revision: https://reviews.llvm.org/D50807

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341064 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 13:10:42 +00:00
Alexandre Ganea
ed91909be8 [DebugCounters] Fix DebugCounterTest when running all SupportTests
Previously, the DebugCounterTest was failing because CommandLineTest.GetCommandLineArguments was clearing all the global singletons.

Differential Revision: https://reviews.llvm.org/D51423


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340935 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 16:11:48 +00:00
Chandler Carruth
9842cc486c Replace fancy use of initializer lists with simple functions that return
vectors, and move this test code into an anonymous namespace.

Hoping that this will avoid hitting an MSVC bug that causes it to crash
and burn pretty spectacularly. Also, this degree of clever use of
initializer lists seems somewhat questionable in general. ;]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340702 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 10:03:08 +00:00
Richard Smith
fc721a89bb Allow demangler's node allocator to fail, and bail out of the entire
demangling process when it does.

Use this to support a "lookup" query for the mangling canonicalizer that
does not create new nodes. This could also be used to implement
demangling with a fixed-size temporary storage buffer.

Reviewers: erik.pilkington

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D51003

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340670 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 23:26:05 +00:00
Richard Smith
a5beadf824 Add data structure to form equivalence classes of mangled names.
Summary:
Given a set of equivalent name fragments, this mechanism determines whether two
mangled names are equivalent. The intent is to use this for fuzzy matching of
profile data against the program after certain refactorings are performed.

Reviewers: erik.pilkington, dlj

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D50935

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340663 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 22:31:51 +00:00
Kirill Bobyrev
ade2e57434 [llvm] Make YAML serialization up to 2.5 times faster
This patch significantly improves performance of the YAML serializer by
optimizing `YAML::isNumeric` function. This function is called on the
most strings and is highly inefficient for two reasons:

* It uses `Regex`, which is parsed and compiled each time this
  function is called
* It uses multiple passes which are not necessary

This patch introduces stateful ad hoc YAML number parser which does not
rely on `Regex`. It also fixes YAML number format inconsistency: current
implementation supports C-stile octal number format (`01234567`) which
was present in YAML 1.0 specialization (http://yaml.org/spec/1.0/),
[Section 2.4. Tags, Example 2.19] but was deprecated and is no longer
present in latest YAML 1.2 specification
(http://yaml.org/spec/1.2/spec.html), see [Section 10.3.2. Tag
Resolution]. Since the rest of the rest of the implementation does not
support other deprecated YAML 1.0 numeric features such as sexagecimal
numbers, commas as delimiters it is treated as inconsistency and not
longer supported. This patch also adds unit tests to ensure the validity
of proposed implementation.

This performance bottleneck was identified while profiling Clangd's
global-symbol-builder tool with my colleague @ilya-biryukov. The
substantial part of the runtime was spent during a single-thread Reduce
phase, which concludes with YAML serialization of collected symbol
collection. Regex matching was accountable for approximately 45% of the
whole runtime (which involves sharded Map phase), now it is reduced to
18% (which is spent in `clang::clangd::CanonicalIncludes` and can be
also optimized because all used regexes are in fact either suffix
matches or exact matches).

`llvm-yaml-numeric-parser-fuzzer` was used to ensure the validity of the
proposed regex replacement. Fuzzing for ~60 hours using 10 threads did
not expose any bugs.

Benchmarking `global-symbol-builder` (using `hyperfine --warmup 2
--min-runs 5 'command 1' 'command 2'`) tool by processing a reasonable
amount of code (26 source files matched by
`clang-tools-extra/clangd/*.cpp` with all transitive includes) confirmed
our understanding of the performance bottleneck nature as it speeds up
the command by the factor of 1.6x:

| Command | Mean [s] | Min…Max [s] |
| this patch (D50839) | 84.7 ± 0.6 | 83.3…84.7 |
| master (rL339849) | 133.1 ± 0.8 | 132.4…134.6 |

Using smaller samples (e.g. by collecting symbols from
`clang-tools-extra/clangd/AST.cpp` only) yields even better performance
improvement, which is expected because Map phase takes less time
compared to Reduce and is 2.05x faster and therefore would significantly
improve the performance of standalone YAML serializations.

| Command | Mean [ms] | Min…Max [ms] |
| this patch (D50839) | 3702.2 ± 48.7 | 3635.1…3752.3 |
| master (rL339849) | 7607.6 ± 109.5 | 7533.3…7796.4 |

Reviewed by: zturner, ilya-biryukov

Differential revision: https://reviews.llvm.org/D50839

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340154 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-20 07:00:36 +00:00
Bernard Ogden
c30814805c [ARM/AArch64] Support FP16 +fp16fml instructions
Add +fp16fml feature for new FP16 instructions, which are a
mandatory part of FP16 from v8.4-A and an optional part of FP16
from v8.2-A. It doesn't seem to be possible to model this in
LLVM, but the relationship between the options is handled by
the related clang patch.

In keeping with what I think is the usual practice, the fp16fml
extension is accepted regardless of base architecture version.

Builds on/replaces Sjoerd Meijer's patch to add these instructions at
https://reviews.llvm.org/D49839.

Differential Revision: https://reviews.llvm.org/D50228



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340013 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 11:29:49 +00:00
Bernard Ogden
3a4d2d38bf [ARM/AArch64] TargetParserTest fixes
Adds some missing tests for the FP16 extension,
fixes an existing test that misnames it.

Differential Revision: https://reviews.llvm.org/D50227


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340012 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 11:26:57 +00:00
Lang Hames
e0dc5c1ea2 [Support] Add a basic C API for llvm::Error.
Summary:
The C-API supports consuming errors, converting an error to a string error
message, and querying an error's type. Other LLVM C APIs that wish to use
llvm::Error can supply error-type-id checkers and custom
error-to-structured-type converters for any custom errors they provide.

Reviewers: bogner, zturner, labath, dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D50716

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339802 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 18:42:11 +00:00
Jordan Rupprecht
f0b29b88a4 [Support] NFC: Allow modifying access/modification times independently in sys::fs::setLastModificationAndAccessTime.
Summary:
Add an overload to sys::fs::setLastModificationAndAccessTime that allows setting last access and modification times separately. This will allow tools to use this API when they want to preserve both the access and modification times from an input file, which may be different.

Also note that both the POSIX (futimens/futimes) and Windows (SetFileTime) APIs take the two timestamps in the order of (1) access (2) modification time, so this renames the method to "setLastAccessAndModificationTime" to make it clear which timestamp is which.

For existing callers, the 1-arg overload just sets both timestamps to the same thing.

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D50521

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339628 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 23:03:45 +00:00
Simon Pilgrim
5da7a1c1e5 Remove extra semicolon (fixes -Wpedantic warning). NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339549 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 10:05:34 +00:00
Rui Ueyama
1090c4ba25 Use the same constants as zlib to represent compression level.
This change allows users pass compression level that was not listed
in the enum. Also, I think using different values than zlib's
compression levels was just confusing.

Differential Revision: https://reviews.llvm.org/D50196

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338939 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-04 00:13:13 +00:00
Bob Haarman
15bc9858ad [Support] fix TempFile infinite loop and permission denied errors
Summary:
On Windows, TempFile::create() was prone to failing with permission
denied errors when a process created many tempfiles without providing
a model large enough to accommodate them. There was also a problem
with createUniqueEntity getting into an infinite loop when all names
permitted by the model are in use. This change fixes both of these
problems and adds a unit test for them.

Reviewers: pcc, rnk, zturner

Reviewed By: zturner

Subscribers: inglorion, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D50126

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338745 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-02 17:41:38 +00:00
Victor Leschuk
f4c9d7c0dc [Support] Introduce createStringError helper function
The function in question is copy-pasted lots of times in DWARF-related classes.
Thus it will make sense to place its implementation into the Support library.

Reviewed by: lhames

Differential Revision: https://reviews.llvm.org/D49824



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337995 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-26 02:21:40 +00:00
George Burgess IV
4f40986a05 [DebugCounters] Keep track of total counts
This patch makes debug counters keep track of the total number of times
we've called `shouldExecute` for each counter, so it's easier to build
automated tooling on top of these.

A patch to print these counts is coming soon.

Patch by Zhizhou Yang!

Differential Revision: https://reviews.llvm.org/D49560


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337748 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-23 21:49:36 +00:00
Sam McCall
ee39f0be06 [Support] Require llvm::Error passed to formatv() to be wrapped in fmt_consume()
Summary:
Someone must be responsible for handling an Error. When formatv takes
ownership of an Error, the formatv_object destructor must take care of this.

Passing an error by value to formatv() is not considered explicit enough to mark
the error as handled (see D49013), so we require callers to use a format adapter
to confirm this intent.

Reviewers: zturner

Subscribers: llvm-commits, lhames

Differential Revision: https://reviews.llvm.org/D49170

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336888 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-12 07:11:28 +00:00
Sam McCall
18ff70955f [Support] Harded JSON against invalid UTF-8.
Parsing invalid UTF-8 input is now a parse error.
Creating JSON values from invalid UTF-8 now triggers an assertion, and
(in no-assert builds) substitutes the unicode replacement character.
Strings retrieved from json::Value are always valid UTF-8.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336657 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-10 11:51:26 +00:00
Sam McCall
ceb3c09eb4 [Support] Allow JSON serialization of Optional<T> for supported T.
This is ported from r333881 to JSON's new home.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336542 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 12:26:09 +00:00
Sam McCall
8d164e7fb3 [Support] Make JSON handle doubles and int64s losslessly
Summary:
This patch adds a new "integer" ValueType, and renames Number -> Double.
This allows us to preserve the full precision of int64_t when parsing integers
from the wire, or constructing from an integer.
The API is unchanged, other than giving asInteger() a clearer contract.

In addition, always output doubles with enough precision that parsing will
reconstruct the same double.

Reviewers: simon_tatham

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D46209

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336541 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 12:16:40 +00:00
Sam McCall
5070d36f88 Lift JSON library from clang-tools-extra/clangd to llvm/Support.
Summary:
This consists of four main parts:
 - an type json::Expr representing JSON values of dynamic kind, which can be
   composed, inspected, and modified
 - a JSON parser from string -> json::Expr
 - a JSON printer from json::Expr -> string, with optional pretty-printing
 - a convention for mapping json::Expr <=> native types (fromJSON/toJSON)
   Mapping functions are provided for primitives (e.g. int, vector) and the
   ObjectMapper helper helps implement fromJSON for struct/object types.

Based on clangd's usage, a couple of places I'd appreciate review attention:
 - fromJSON returns only bool. A richer error-signaling mechanism may be useful
   to provide useful messages, or let recursive fromJSONs (containers/structs)
   do careful error recovery.
 - should json::obj be always explicitly written (like json::ary)
 - there's no streaming parse API. I suspect there are some simple wins like
   a callback API where the document is a long array, and each element is small.
   But this can probably be bolted on easily when we see the need.

Reviewers: bkramer, labath

Subscribers: mgorny, ilya-biryukov, ioeric, MaskRay, llvm-commits

Differential Revision: https://reviews.llvm.org/D45753

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336534 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-09 10:05:41 +00:00
Chandler Carruth
5fd5dc8e41 [Support] Clear errno before calling the function in RetryAfterSignal.
For certain APIs, the return value of the function does not distinguish
between failure (which populates errno) and other non-error conditions
(which do not set errno).

For example, `fgets` returns `NULL` both when an error has occurred, or
upon EOF. If `errno` is already `EINTR` for whatever reason, then
```
RetryAfterSignal(nullptr, fgets, ...);
```
on a stream that has reached EOF would infinite loop.

Fix this by setting `errno` to `0` before each attempt in
`RetryAfterSignal`.

Patch by Ricky Zhou!

Differential Revision: https://reviews.llvm.org/D48755

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336479 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-07 02:46:12 +00:00
Sam McCall
a2b35082b0 [Support] Make support types more easily printable.
Summary:
Error's new operator<< is the first way to print an error without consuming it.

formatv() can now print objects with an operator<< that works with raw_ostream.

Reviewers: bkramer

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D48966

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336412 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-06 05:45:45 +00:00
Aaron Ballman
2dc5cd2beb Silence an MSVC C4189 warning about a local variable being initialized but not used; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336298 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-04 21:22:28 +00:00
Andrew Ng
645f3d0f00 [ThinLTO] Update ThinLTO cache file atimes when on Windows
ThinLTO cache file access times are used for expiration based pruning
and since Vista, file access times are not updated by Windows by
default:

https://blogs.technet.microsoft.com/filecab/2006/11/07/disabling-last-access-time-in-windows-vista-to-improve-ntfs-performance

This means on Windows, cache files are currently being pruned from
creation time. This change manually updates cache files that are
accessed by ThinLTO, when on Windows.

Patch by Owen Reynolds.

Differential Revision: https://reviews.llvm.org/D47266

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336276 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-04 14:17:10 +00:00
Chandler Carruth
344a827483 [Support] This sanity check in the test only works with certain versions
of libstdc++, not just certain versions of GCC. The original macros
broke when using Clang + libstdc++4.9 sadly.

Sadly, testing for versions of libstdc++ has been extremely problematic
in the past, so I'm just narrowing this down to Windows and when using
libc++ as that seems at least very unlikely to keep build bots broken.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336174 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 07:51:01 +00:00
Chandler Carruth
52b38c4e9f [Support] Fix llvm::unique_function when building with GCC 4.9 by
introducing llvm::trivially_{copy,move}_constructible type traits.

This uses a completely portable implementation of these traits provided
by Richard Smith. You can see it on compiler explorer in all its glory:

  https://godbolt.org/g/QEDZjW

I have transcribed it, clang-formatted it, added some comments, and made
the tests fit into a unittest file.

I have also switched llvm::unique_function over to use these new, much
more portable traits. =D

Hopefully this will fix the build bot breakage from my prior commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336161 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 01:18:21 +00:00
Benjamin Kramer
540a311718 [SupportTests] Silence -Wsign-compare warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335921 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 21:03:24 +00:00
Zachary Turner
c8bdc2e033 Fix padding with custom character in formatv.
The format string for formatv allows to specify a custom padding
character instead of the default space.  This custom character was
parsed correctly, but not passed on to the formatter.

Patch by Marcel Köppe
Differential Revision: https://reviews.llvm.org/D48140

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335915 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 20:09:37 +00:00
Zachary Turner
822461008d Add a flag to FileOutputBuffer that allows modification.
FileOutputBuffer creates a temp file and on commit atomically
renames the temp file to the destination file.  Sometimes we
want to modify an existing file in place, but still have the
atomicity guarantee.  To do this we can initialize the contents
of the temp file from the destination file (if it exists), that
way the resulting FileOutputBuffer can have only selective
bytes modified.  Committing will then atomically replace the
destination file as desired.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335902 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 18:49:09 +00:00
Nico Weber
823c169bec Build TaskQueueTest in threads=on builds, fixes regression from r335608.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335724 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 11:52:30 +00:00
Nico Weber
7b36ec6b5e Fix LLVM_ENABLE_THREADS=0 builds after r335440.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335608 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 14:42:48 +00:00
Zachary Turner
761de65715 One more build fix for non MSVC compilers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335443 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 04:38:03 +00:00
Zachary Turner
19eaf65da0 Add a TaskQueue that can serialize work on a ThreadPool.
We have ThreadPool, which can execute work asynchronously on N
background threads, but sometimes you need to make sure the work
is executed asynchronously but also serially.  That is, if task
B is enqueued after task A, then task B should not begin until
task A has completed.  This patch adds such a class.

Differential Revision: https://reviews.llvm.org/D48240

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335440 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-25 03:13:09 +00:00
Zachary Turner
7c17201f14 Revert "Enable ThreadPool to queue tasks that return values."
This is failing to compile when LLVM_ENABLE_THREADS is false,
and the fix is not immediately obvious, so reverting while I look
into it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334658 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 21:24:19 +00:00
Zachary Turner
4090b47b77 Enable ThreadPool to support tasks that return values.
Previously ThreadPool could only queue async "jobs", i.e. work
that was done for its side effects and not for its result.  It's
useful occasionally to queue async work that returns a value.
From an API perspective, this is very intuitive.  The previous
API just returned a shared_future<void>, so all we need to do is
make it return a shared_future<T>, where T is the type of value
that the operation returns.

Making this work required a little magic, but ultimately it's not
too bad.  Instead of keeping a shared queue<packaged_task<void()>>
we just keep a shared queue<unique_ptr<TaskBase>>, where TaskBase
is a class with a pure virtual execute() method, then have a
templated derived class that stores a packaged_task<T()>.  Everything
else works out pretty cleanly.

Differential Revision: https://reviews.llvm.org/D48115

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334643 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 19:29:16 +00:00
George Karpenkov
b97b3021fc Add checkMulAdd helper function to CheckedArithmetic
Multiplication followed by addition
(https://en.wikipedia.org/wiki/Multiply–accumulate_operation) is a
sufficiently common use-case to warrant a separate helper.

Differential Revision: https://reviews.llvm.org/D48138

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334635 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 18:32:02 +00:00
George Karpenkov
ba86f98ba7 Change checked arithmetic functions API to return Optional
Returning optional is much safer.
The previous API had potential to cause use of undefined variables, if
the value passed by pointer was accidentally read afterwards.

Differential Revision: https://reviews.llvm.org/D48137

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334634 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 18:31:43 +00:00
Hans Wennborg
7c4ee81607 Do not enforce absolute path argv0 in windows
Even if we support no-canonical-prefix on
clang-cl(https://reviews.llvm.org/D47480), argv0 becomes absolute path
in clang-cl and that embeds absolute path in /showIncludes.

This patch removes such full path normalization from InitLLVM on
windows, and that removes absolute path from clang-cl output
(obj/stdout/stderr) when debug flag is disabled.

Patch by Takuto Ikuta!

Differential Revision https://reviews.llvm.org/D47578

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334602 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 14:29:26 +00:00
Zachary Turner
0dcc1159b4 Refactor ExecuteAndWait to take StringRefs.
This simplifies some code which had StringRefs to begin with, and
makes other code more complicated which had const char* to begin
with.

In the end, I think this makes for a more idiomatic and platform
agnostic API.  Not all platforms launch process with null terminated
c-string arrays for the environment pointer and argv, but the api
was designed that way because it allowed easy pass-through for
posix-based platforms.  There's a little additional overhead now
since on posix based platforms we'll be takign StringRefs which
were constructed from null terminated strings and then copying
them to null terminate them again, but from a readability and
usability standpoint of the API user, I think this API signature
is strictly better.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334518 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 17:43:52 +00:00