Commit Graph

354 Commits

Author SHA1 Message Date
Chandler Carruth f8c5281c87 Introduce a simple line-by-line iterator type into the Support library.
This is an iterator which you can build around a MemoryBuffer. It will
iterate through the non-empty, non-comment lines of the buffer as
a forward iterator. It should be small and reasonably fast (although it
could be made much faster if anyone cares, I don't really...).

This will be used to more simply support the text-based sample
profile file format, and is largely based on the original patch by
Diego. I've re-worked the style of it and separated it from the work of
producing a MemoryBuffer from a file which both simplifies the interface
and makes it easier to test.

The style of the API follows the C++ standard naming conventions to fit
in better with iterators in general, much like the Path and FileSystem
interfaces follow standard-based naming conventions.

llvm-svn: 198068
2013-12-27 04:28:57 +00:00
NAKAMURA Takumi 1b3437c69a unittests/Support/ProcessTest.cpp: Don't use "windows.h". Use <windows.h> instead.
llvm-svn: 198011
2013-12-25 10:50:11 +00:00
Hans Wennborg fabf8bfdea Make sys::ThreadLocal<> zero-initialized on non-thread builds (PR18205)
According to the docs, ThreadLocal<>::get() should return NULL
if no object has been set. This patch makes that the case also for non-thread
builds and adds a very basic unit test to check it.

(This was causing PR18205 because PrettyStackTraceHead didn't get zero-
initialized and we'd crash trying to read past the end of that list. We didn't
notice this so much on Linux since we'd crash after printing all the entries,
but on Mac we print into a SmallString, and would crash before printing that.)

llvm-svn: 197718
2013-12-19 20:32:44 +00:00
Michael Gottesman 8f17dccdcb [block-freq] Add a right shift to BlockFrequency that saturates at 1.
llvm-svn: 197302
2013-12-14 02:24:22 +00:00
Alp Toker 4b739894f0 Swap around EXPECT_EQ() arguments orders for more natural gtest Failure messages
Somewhat counterintuitively the first arg in gtest is treated as the
expectation.

No change to the tests themselves.

llvm-svn: 197124
2013-12-12 03:31:20 +00:00
Alp Toker d0d1a74ac9 Add missing escape characters to the new Regex::escape() function
The old AddFixedStringToRegEx() it was based on got away with this for the
longest time, but the problem became easy to spot after the cleanup in r197096.

Also add a quick unit test to cover regex escaping.

llvm-svn: 197121
2013-12-12 02:51:58 +00:00
Michael Gottesman 983f94a2b6 [block-freq] Update data in test case to be unsigned long long to fix mingw build.
llvm-svn: 195411
2013-11-22 05:00:51 +00:00
Nick Kledzik 7cd45f29b2 YAML I/O add support for validate()
MappingTrait template specializations can now have a validate() method which 
performs semantic checking. For details, see <http://llvm.org/docs/YamlIO.html>.

llvm-svn: 195286
2013-11-21 00:28:07 +00:00
Nick Kledzik 4761c60eef revert r194655
llvm-svn: 195285
2013-11-21 00:20:10 +00:00
John Thompson 48e018a314 YAML I/O - Added default trait support for std:string. Making another attempt at this, this time doing a clean build on Linux, and running the LLVM, clang, and extra tests, to try to make sure there's no problems.
llvm-svn: 195134
2013-11-19 17:28:21 +00:00
Alexander Kornienko 681e37cbf6 Recover gracefully when deserializing invalid YAML input.
Fixes http://llvm.org/PR16221, http://llvm.org/PR15927
Phabricator: http://llvm-reviews.chandlerc.com/D1236

Patch by Andrew Tulloch!

llvm-svn: 195016
2013-11-18 15:50:04 +00:00
Michael Gottesman 4d078a3d6f [block-freq] Add BlockFrequency::scale that returns a remainder from the division and make the private scale in BlockFrequency more performant.
This change is the first in a series of changes improving LLVM's Block
Frequency propogation implementation to not lose probability mass in
branchy code when propogating block frequency information from a basic
block to its successors. This patch is a simple infrastructure
improvement that does not actually modify the block frequency
algorithm. The specific changes are:

1. Changes the division algorithm used when scaling block frequencies by
branch probabilities to a short division algorithm. This gives us the
remainder for free as well as provides a nice speed boost. When I
benched the old routine and the new routine on a Sandy Bridge iMac with
disabled turbo mode performing 8192 iterations on an array of length
32768, I saw ~600% increase in speed in mean/median performance.

2. Exposes a scale method that returns a remainder. This is important so
we can ensure that when we scale a block frequency by some branch
probability BP = N/D, the remainder from the division by D can be
retrieved and propagated to other children to ensure no probability mass
is lost (more to come on this).

llvm-svn: 194950
2013-11-17 03:25:24 +00:00
Rui Ueyama e448f9e418 Path: Recognize COFF import library file magic.
Summary: Make identify_magic to recognize COFF import file.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 194852
2013-11-15 21:22:02 +00:00
Rui Ueyama 829c4392e1 Recognize 0x0000 as a COFF file magic.
Summary:
Some machine-type-neutral object files containing only undefined symbols
actually do exist in the Windows standard library. Need to recognize them
as COFF files.

Reviewers: Bigcheese

CC: llvm-commits

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

llvm-svn: 194734
2013-11-14 22:09:08 +00:00
Nick Kledzik 4a9f00d8cb remove extra semicolon
llvm-svn: 194658
2013-11-14 03:03:05 +00:00
Nick Kledzik dd34f77cbd Add dyn_cast<> support to YAML I/O's IO class
llvm-svn: 194655
2013-11-14 02:38:07 +00:00
Nick Kledzik 1e6033ca33 Add simple support for tags in YAML I/O
llvm-svn: 194644
2013-11-14 00:59:59 +00:00
Rui Ueyama 5e3de7a7eb Path: Add tests for existing file magics.
llvm-svn: 194607
2013-11-13 21:55:41 +00:00
Rui Ueyama 89d1bdb687 Whitespace.
llvm-svn: 194605
2013-11-13 20:31:21 +00:00
Rafael Espindola ca35ffe6a2 Simplify ErrorOr.
ErrorOr had quiet a bit of complexity and indirection to be able to hold a user
type with the error.

That feature is not used anymore. This patch removes it, it will live in svn
history if we ever need it again.

If we do need it again, IMHO there is one thing that should be done
differently: Holding extra info in the error is not a property a function also
returning a value or not. The ability to hold extra info should be in the error
type and ErrorOr templated over it so that we don't need the funny looking
ErrorOr<void>.

llvm-svn: 194030
2013-11-05 00:28:01 +00:00
Nuno Lopes 1112eca0af make ConstantRange::signExtend() optimal
the case [x, INT_MIN) was not handled optimally

llvm-svn: 193694
2013-10-30 15:36:50 +00:00
Rafael Espindola e5bf24684f Try to fix the build on windows.
llvm-svn: 193431
2013-10-25 19:47:55 +00:00
Rafael Espindola 1d19c8f03a Change MemoryBuffer::getFile to take a Twine.
llvm-svn: 193429
2013-10-25 19:06:52 +00:00
John Thompson 6cd5bd4a3d Reverting my r193344 checkin due to build breakage.
llvm-svn: 193350
2013-10-24 14:52:56 +00:00
John Thompson e38e57206f Added std::string as a built-in type for mapping.
llvm-svn: 193344
2013-10-24 13:36:58 +00:00
Tareq A. Siraj d88b9832c8 Add non-blocking Wait() for launched processes
- New ProcessInfo class to encapsulate information about child processes.
- Generalized the Wait() to support non-blocking wait on child processes.
- ExecuteNoWait() now returns a ProcessInfo object with information about
  the launched child. Users will be able to use this object to
  perform non-blocking wait.
- ExecuteNoWait() now accepts an ExecutionFailed param that tells if execution
  failed or not.

These changes will allow users to implement basic process parallel
tools.

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

llvm-svn: 191763
2013-10-01 14:28:18 +00:00
Dmitri Gribenko 78fe2ba3ba SourceMgr diagnotics printing: fix a bug where printing a fixit for a source
range that includes a tab character will cause out-of-bounds access to the
fixit string.

llvm-svn: 191563
2013-09-27 21:24:36 +00:00
Dmitri Gribenko 8f944628ac Make SourceMgr::PrintMessage() testable and add unit tests
llvm-svn: 191558
2013-09-27 21:09:25 +00:00
Tareq A. Siraj bf40e95959 Fixed typo in CreateProcessTrailingSlash test
--gtest_filter was filtering an invalid name for the test.

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

llvm-svn: 191100
2013-09-20 18:21:59 +00:00
Rui Ueyama 106ededc4e Re-submit r190469: YAMLIO: Fix string quoting logic.
llvm-svn: 190485
2013-09-11 04:00:08 +00:00
Hans Wennborg 33ae7cea9f Revert "YAMLIO: Fix string quoting logic." (r190469)
It was turning the buildbots red.

llvm-svn: 190480
2013-09-11 01:59:32 +00:00
Rui Ueyama 38dfffa891 Remove trailing whitespace
llvm-svn: 190472
2013-09-11 00:53:07 +00:00
Rui Ueyama 9a40ae8935 YAMLIO: Fix string quoting logic.
YAMLIO printed a string as is without quotes unless it contains a newline
character. That did not suffice. We also need to quote a string if it starts
with a backquote, quote, double quote or atsign, or it's the empty string.

llvm-svn: 190469
2013-09-11 00:45:48 +00:00
Rui Ueyama 754a3ead62 Try to unbreak mingw32 buildbot.
llvm-svn: 190438
2013-09-10 21:32:42 +00:00
Rui Ueyama 471d0c57e7 Add getenv() wrapper that works on multibyte environment variable.
On Windows, character encoding of multibyte environment variable varies
depending on settings. The only reliable way to handle it I think is to use
GetEnvironmentVariableW().

GetEnvironmentVariableW() works on wchar_t string, which is on Windows UTF16
string. That's not ideal because we use UTF-8 as the internal encoding in LLVM.
This patch defines a wrapper function which takes and returns UTF-8 string for
GetEnvironmentVariableW().

The wrapper function does not do any conversion and just forwards the argument
to getenv() on Unix.

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

llvm-svn: 190423
2013-09-10 19:45:51 +00:00
Bob Wilson 6b28b3183e Update CMake file to fix buildbots.
llvm-svn: 190331
2013-09-09 19:25:11 +00:00
Bob Wilson e407736a06 Revert patches to add case-range support for PR1255.
The work on this project was left in an unfinished and inconsistent state.
Hopefully someone will eventually get a chance to implement this feature, but
in the meantime, it is better to put things back the way the were.  I have
left support in the bitcode reader to handle the case-range bitcode format,
so that we do not lose bitcode compatibility with the llvm 3.3 release.

This reverts the following commits: 155464, 156374, 156377, 156613, 156704,
156757, 156804 156808, 156985, 157046, 157112, 157183, 157315, 157384, 157575,
157576, 157586, 157612, 157810, 157814, 157815, 157880, 157881, 157882, 157884,
157887, 157901, 158979, 157987, 157989, 158986, 158997, 159076, 159101, 159100,
159200, 159201, 159207, 159527, 159532, 159540, 159583, 159618, 159658, 159659,
159660, 159661, 159703, 159704, 160076, 167356, 172025, 186736

llvm-svn: 190328
2013-09-09 19:14:35 +00:00
Dmitri Gribenko 415fb584e4 MemoryBufer: add a test: check that a file with size that is a multiple of the
page size can be null terminated correctly by MemoryBuffer.

llvm-svn: 189965
2013-09-04 18:02:13 +00:00
Alexander Kornienko 9aa60fd6f8 Move generic isPrint and columnWidth implementations to a separate header/source to allow using both generic and system-dependent versions on win32.
Summary:
This is needed so we can use generic columnWidthUTF8 in clang-format on
win32 simultaneously with a separate system-dependent implementations of
isPrint/columnWidth in TextDiagnostic.cpp to avoid attempts to print Unicode
characters using narrow-character interfaces (which is not supported on Windows,
and we'll have to figure out how to handle this).

Reviewers: jordan_rose

Reviewed By: jordan_rose

CC: llvm-commits, klimek

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

llvm-svn: 189952
2013-09-04 16:00:12 +00:00
NAKAMURA Takumi 7b5d4f97a0 [Win32] mapped_file_region: Fix a bug in CreateFileMapping() that Size must contain Offset when Offset >= 65536.
llvm-svn: 189021
2013-08-22 15:14:53 +00:00
NAKAMURA Takumi edf7615332 Whitespace.
llvm-svn: 189020
2013-08-22 15:14:45 +00:00
NAKAMURA Takumi 2f493c7777 Suppress MemoryBufferTest.cpp on win32 for now. Investigating.
llvm-svn: 189001
2013-08-22 12:00:44 +00:00
NAKAMURA Takumi 774cf3190c MemoryBufferTest.cpp: Tweak offset corresponding to the case that PageSize is greater than 8000.
PageSize, aka AllocationGranularity, is 65536 on Win32 (and Cygwin).

llvm-svn: 188999
2013-08-22 10:23:58 +00:00
Aaron Ballman 381f59f06f Removing a spurious semi-colon; this macro expands into a namespace.
llvm-svn: 188525
2013-08-16 01:53:58 +00:00
Aaron Ballman 0e63e53da1 Tighten up the yamilizer so it stops eliding empty sequences if the embedded empty sequence is the first key/value in a map which is itself in a sequence.
Patch with help from Nick Kledzik.

llvm-svn: 188508
2013-08-15 23:17:53 +00:00
Alexey Samsonov 6ede706d46 Expose CRC-32 implementation from zlib
llvm-svn: 188380
2013-08-14 16:03:29 +00:00
Tareq A. Siraj 73537eac3d Fixes a bug when iterating on paths
This fixes the incorrect implementation of iterating on file/directory
paths.

Differential Review: http://llvm-reviews.chandlerc.com/D1277

llvm-svn: 188183
2013-08-12 17:10:49 +00:00
Alexey Samsonov 96dd18c4ee Fix off-by-one error in Regex::isValid
llvm-svn: 187992
2013-08-08 17:32:45 +00:00
Benjamin Kramer 9f74a381a0 Use EXPECT_TRUE/EXPECT_FALSE to avoid bogus warnings from the guts of gtest.
llvm-svn: 187976
2013-08-08 11:17:39 +00:00
Alexander Kornienko 05e1786db6 Changed isPrint for U+00AD SOFT HYPHEN to return true.
Summary:
This is consistent with MacOSX implementation, and most terminals
actually display this character (checked on gnome-terminal, lxterminal, lxterm,
Terminal.app, iterm2). Actually, this is in line with the ISO Latin 1 standard
(ISO 8859-1), which defines it differently from the Unicode Standard. More
information here: http://www.cs.tut.fi/~jkorpela/shy.html

Reviewers: gribozavr, jordan_rose

CC: llvm-commits

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

llvm-svn: 187949
2013-08-08 01:10:50 +00:00