summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* Update the branch weight metadata in JumpThreading pass.Cong Hou2015-10-141-0/+41
| | | | | | | | | | Currently in JumpThreading pass, the branch weight metadata is not updated after CFG modification. Consider the jump threading on PredBB, BB, and SuccBB. After jump threading, the weight on BB->SuccBB should be adjusted as some of it is contributed by the edge PredBB->BB, which doesn't exist anymore. This patch tries to update the edge weight in metadata on BB->SuccBB by scaling it by 1 - Freq(PredBB->BB) / Freq(BB->SuccBB). This is the third attempt to submit this patch, while the first two led to failures in some FDO tests. After investigation, it is the edge weight normalization that caused those failures. In this patch the edge weight normalization is fixed so that there is no zero weight in the output and the sum of all weights can fit in 32-bit integer. Several unit tests are added. Differential revision: http://reviews.llvm.org/D10979 llvm-svn: 250345
* Add - and -= operators to BlockFrequency using saturating arithmetic.Cong Hou2015-10-121-0/+6
| | | | llvm-svn: 250077
* Fix rename() sometimes failing if another process uses openFileForRead()Greg Bedwell2015-10-122-0/+114
| | | | | | | | | | | | | | | | | | | On Windows, fs::rename() could fail is another process was reading the file at the same time using fs::openFileForRead(). In most cases the user wouldn't notice as fs::rename() will continue to retry for 2000ms. Typically this is enough for the read to complete and a retry to succeed, but if the disk is being it too hard then the response time might be longer than the retry time and the rename would fail with a permission error. Add FILE_SHARE_DELETE to the sharing flags for CreateFileW() in fs::openFileForRead() and try ReplaceFileW() prior to MoveFileExW() in fs::rename(). Based on an initial patch by Edd Dawson! Differential Revision: http://reviews.llvm.org/D13647 llvm-svn: 250046
* Fix another UBSan test error from r248897 and follow on fix r249689Teresa Johnson2015-10-081-0/+84
| | | | | | | While here fix a few more issues with potential overflow and add new tests for these cases. Ensured that test now passes with UBSan. llvm-svn: 249745
* Make test resilient against windows path separators.Benjamin Kramer2015-10-051-0/+1
| | | | llvm-svn: 249320
* [Support] Add a version of fs::make_absolute with a custom CWD.Benjamin Kramer2015-10-051-0/+4
| | | | | | This will be used soon from clang. llvm-svn: 249309
* Add support for sub-byte aligned writes to lib/Support/Endian.hTeresa Johnson2015-09-301-0/+48
| | | | | | | | | | | | | | | Summary: As per Duncan's review for D12536, I extracted the sub-byte bit aligned reading and writing code into lib/Support, and generalized it. Added calls from BackpatchWord. Also added unittests. Reviewers: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13189 llvm-svn: 248897
* HHVM calling conventions.Maksim Panchenko2015-09-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | HHVM calling convention, hhvmcc, is used by HHVM JIT for functions in translated cache. We currently support LLVM back end to generate code for X86-64 and may support other architectures in the future. In HHVM calling convention any GP register could be used to pass and return values, with the exception of R12 which is reserved for thread-local area and is callee-saved. Other than R12, we always pass RBX and RBP as args, which are our virtual machine's stack pointer and frame pointer respectively. When we enter translation cache via hhvmcc function, we expect the stack to be aligned at 16 bytes, i.e. skewed by 8 bytes as opposed to standard ABI alignment. This affects stack object alignment and stack adjustments for function calls. One extra calling convention, hhvm_ccc, is used to call C++ helpers from HHVM's translation cache. It is almost identical to standard C calling convention with an exception of first argument which is passed in RBP (before we use RDI, RSI, etc.) Differential Revision: http://reviews.llvm.org/D12681 llvm-svn: 248832
* Use fixed-point representation for BranchProbability.Cong Hou2015-09-252-85/+93
| | | | | | | | | | | | | | | | | | | | BranchProbability now is represented by its numerator and denominator in uint32_t type. This patch changes this representation into a fixed point that is represented by the numerator in uint32_t type and a constant denominator 1<<31. This is quite similar to the representation of BlockMass in BlockFrequencyInfoImpl.h. There are several pros and cons of this change: Pros: 1. It uses only a half space of the current one. 2. Some operations are much faster like plus, subtraction, comparison, and scaling by an integer. Cons: 1. Constructing a probability using arbitrary numerator and denominator needs additional calculations. 2. It is a little less precise than before as we use a fixed denominator. For example, 1 - 1/3 may not be exactly identical to 1 / 3 (this will lead to many BranchProbability unit test failures). This should not matter when we only use it for branch probability. If we use it like a rational value for some precise calculations we may need another construct like ValueRatio. One important reason for this change is that we propose to store branch probabilities instead of edge weights in MachineBasicBlock. We also want clients to use probability instead of weight when adding successors to a MBB. The current BranchProbability has more space which may be a concern. Differential revision: http://reviews.llvm.org/D12603 llvm-svn: 248633
* Pass BranchProbability/BlockMass by value instead of const& as they are ↵Cong Hou2015-09-101-1/+1
| | | | | | small. NFC. llvm-svn: 247357
* [ADT] Switch a bunch of places in LLVM that were doing single-characterChandler Carruth2015-09-101-4/+4
| | | | | | | splits to actually use the single character split routine which does less work, and in a debug build is *substantially* faster. llvm-svn: 247245
* Move twice-repeated clang path operation into a new function.Douglas Katzman2015-09-021-0/+10
| | | | | | And make it more robust in the edge case of exactly "./" as input. llvm-svn: 246711
* There is only one saver of strings.Rafael Espindola2015-08-131-1/+1
| | | | llvm-svn: 244854
* Return ErrorOr from FileOutputBuffer::create. NFC.Rafael Espindola2015-08-131-9/+16
| | | | llvm-svn: 244848
* Thread premissions through sys::fs::create_director{y|ies}Frederic Riss2015-08-061-0/+24
| | | | llvm-svn: 244268
* Fix Visual C++ error C2248: Yaron Keren2015-08-061-2/+2
| | | | | | | | | | | | 'llvm::TrailingObjects<`anonymous-namespace'::Class1,short,llvm::NoTrailingTypeArg>::additionalSizeToAlloc' : cannot access protected member declared in class 'llvm::TrailingObjects<`anonymous-namespace'::Class1,short,llvm::NoTrailingTypeArg>' I'm not sure how this compiles with gcc. Aren't protecteded members accessible only with protected or public inheritance? llvm-svn: 244199
* Add a TrailingObjects template class.James Y Knight2015-08-052-0/+148
| | | | | | | | | | This is intended to help support the idiom of a class that has some other objects (or multiple arrays of different types of objects) appended on the end, which is used quite heavily in clang. Differential Revision: http://reviews.llvm.org/D11272 llvm-svn: 244164
* Fix "the the" in comments.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240112
* Revert r239972 (YAML: Assign a value returned by the default constructor to ↵Alex Lorenz2015-06-171-28/+0
| | | | | | | | the value in an optional mapping). This change breaks clang-format tests. llvm-svn: 239976
* YAML: Assign a value returned by the default constructor to the value in an ↵Alex Lorenz2015-06-171-0/+28
| | | | | | | | | | | | | | optional mapping. This commit ensures that a value that's passed into YAML's IO mapOptional method is going to be assigned a value returned by the default constructor for that value's type when the appropriate key is not present in the YAML mapping. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D10492 llvm-svn: 239972
* Use std::unique_ptr to manage the DataStreamer in bitcode parsing.Rafael Espindola2015-06-161-4/+5
| | | | | | We were already deleting it, this just makes it explicit. llvm-svn: 239867
* llvm/unittests/Support/Path.cpp: Use <windows.h> instead of <Windows.h>.NAKAMURA Takumi2015-06-161-1/+1
| | | | llvm-svn: 239804
* Don't use std::errc.Rafael Espindola2015-06-131-2/+2
| | | | | | | | | | | | | | | | | | | | | As noted on Errc.h: // * std::errc is just marked with is_error_condition_enum. This means that // common patters like AnErrorCode == errc::no_such_file_or_directory take // 4 virtual calls instead of two comparisons. And on some libstdc++ those virtual functions conclude that ------------------------ int main() { std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory); return foo == std::errc::no_such_file_or_directory; } ------------------------- should exit with 0. llvm-svn: 239683
* Bring in a BumpPtrStringSaver from lld and simplify the interface.Rafael Espindola2015-06-131-9/+4
| | | | | | | | | | | | StringSaver now always saves to a BumpPtrAllocator. The only reason for having the virtual saveImpl is so lld can have a thread safe version. The reason for the distinct BumpPtrStringSaver class is to avoid the virtual destructor. llvm-svn: 239669
* YAML traits need to be in the llvm::yaml namespace.Frederic Riss2015-05-291-8/+8
| | | | | | | Hope this fixes the bits, eg: http://lab.llvm.org:8011/builders/clang-hexagon-elf/builds/27147 llvm-svn: 238586
* [YAMLIO] Make line-wrapping configurable and test it.Frederic Riss2015-05-291-0/+120
| | | | | | | | | | | | | | | | Summary: We would wrap flow mappings and sequences when they go over a hardcoded 70 characters limit. Make the wrapping column configurable (and default to 70 co the change should be NFC for current users). Passing 0 allows to completely suppress the wrapping which makes it easier to handle in tools like FileCheck. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10109 llvm-svn: 238584
* [Support] Fix ErrorOr equality operator.Michael J. Spencer2015-05-211-0/+5
| | | | llvm-svn: 237970
* YAML: Null terminate block scalar's value.Alex Lorenz2015-05-211-0/+12
| | | | | | | | | | | | | The commit null terminates the string value in the `yaml::BlockScalarNode` class. This change is motivated by the initial MIR serialization commit (r237708) that I reverted in r237730 because the LLVM IR source from the block scalar node wasn't terminated by a null character and thus the buildbots failed on one testcase sometimes. This change enables me to recommit the reverted commit. llvm-svn: 237942
* Fix StreamingMemoryObject to respect known object size.Derek Schuff2015-05-211-0/+9
| | | | | | | | | | | | | The existing code for method StreamingMemoryObject.fetchToPos does not respect the corresonding call to setKnownObjectSize(). As a result, it allows the StreamingMemoryObject to read bytes past the object size. This patch provides a test case, and code to fix the problem. Patch by Karl Schimpf Differential Revision: http://reviews.llvm.org/D8931 llvm-svn: 237939
* Unit tests for the getSwappedBytes(double) fix from r237673.Pawel Bylica2015-05-201-0/+25
| | | | llvm-svn: 237795
* Fix llvm::BumpPtrAllocatorImpl::Reset()Hans Wennborg2015-05-181-0/+7
| | | | | | | | BumpPtrAllocator's Reset wouldn't clear CustomSizedSlabs if Slabs.size() == 0. Patch by Kal <b17c0de@gmail.com>! llvm-svn: 237588
* YAML: Add support for literal block scalar I/O.Alex Lorenz2015-05-141-0/+140
| | | | | | | | | | | | | This commit gives the users of the YAML Traits I/O library the ability to serialize scalars using the YAML literal block scalar notation by allowing them to implement a specialization of the `BlockScalarTraits` struct for their custom types. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D9613 llvm-svn: 237404
* YAML: Implement block scalar parsing.Alex Lorenz2015-05-131-0/+27
| | | | | | | | | | | | | | | | | | | | | This commit implements the parsing of YAML block scalars. Some code existed for it before, but it couldn't parse block scalars. This commit adds a new yaml node type to represent the block scalar values. This commit also deletes the 'spec-09-27' and 'spec-09-28' tests as they are identical to the test file 'spec-09-26'. This commit introduces 3 new utility functions to the YAML scanner class: `skip_s_space`, `advanceWhile` and `consumeLineBreakIfPresent`. Reviewers: Duncan P. N. Exon Smith Differential Revision: http://reviews.llvm.org/D9503 llvm-svn: 237314
* Readdress r236990, use of static members on a non-static variable.David Blaikie2015-05-111-3/+2
| | | | | | | | | | | | The TargetRegistry is just a namespace-like class, instantiated in one place to use a range-based for loop. Instead, expose access to the registry via a range-based 'targets()' function instead. This makes most uses a bit awkward/more verbose - but eventually we should just add a range-based find_if function which will streamline these functions. I'm happy to mkae them a bit awkward in the interim as encouragement to improve the algorithms in time. llvm-svn: 237059
* Amends r236990, because I failed at hitting "save" before commit.Aaron Ballman2015-05-111-2/+1
| | | | llvm-svn: 236991
* Replacing a range-based for loop with an old-style for loop. This code was ↵Aaron Ballman2015-05-111-2/+3
| | | | | | previously causing a warning with MSVC about a compiler-generated local variable because TargetRegistry::begin() and end() are static member functions. NFC. llvm-svn: 236990
* Unbreak build: Makefile must have the same change as CMakeLists.txtDouglas Katzman2015-05-081-1/+1
| | | | | | | This was omitted from http://reviews.llvm.org/D9441 (the irony is that that was to detect omissions in something else) llvm-svn: 236878
* Prevent further errors of omission when adding backend names.Douglas Katzman2015-05-082-0/+45
| | | | | | Differential Revision: http://reviews.llvm.org/D9441 llvm-svn: 236865
* YAML: Fix crash in the skip method of KeyValueNode class. Alex Lorenz2015-05-061-0/+4
| | | | | | | | | | | | | This commit changes the 'skip' method in the 'KeyValueNode' class to ensure that it doesn't dereference a null pointer when calling the 'skip' method of its value child node. It also adds a unittest that ensures that the crash doesn't occur. This change is motivated by a patch that implements parsing of YAML block scalars (http://reviews.llvm.org/D9503), as one of the unittests in that patch triggered this problem. llvm-svn: 236669
* YAML: Add an optional 'flow' field to the mapping trait to allow flow ↵Alex Lorenz2015-05-041-0/+85
| | | | | | | | | | | | | mapping output. This patch adds an optional 'flow' field to the MappingTrait class so that yaml IO will be able to output flow mappings. Reviewers: Justin Bogner Differential Revision: http://reviews.llvm.org/D9450 llvm-svn: 236456
* YAML: Fix the output of sequences that contain flow sequences. Alex Lorenz2015-05-011-0/+65
| | | | | | | | | | | | | | | | | | | | | | | This patch fixes a bug where the YAML Output class emitted a sequence of flow sequences without the '-' characters. Before: seq: [ a, b ] [ c, d ] After: seq: - [ a, b ] - [ c, d ] Reviewers: Justin Bogner Differential Revision: http://reviews.llvm.org/D9206 llvm-svn: 236329
* Fix infinite recursion in ScaledNumber::toInt.Diego Novillo2015-05-011-0/+5
| | | | | | | | | Patch from dexonsmith. The call to toInt() was calling compareTo() which in some cases would call back to toInt(), creating an infinite loop. Fixed by simplifying the logic in compareTo() to avoid the co-recursion. llvm-svn: 236326
* Fix private constructor for ScaledNumber.Diego Novillo2015-04-301-0/+24
| | | | | | | | | | | | | | | | | | | | | | | Summary: The private constructor for ScaledNumber was using uint64_t instead of DigitsT. This was preventing instantiations of ScaledNumber with anything other than uint64_t types. In implementing the tests, I ran into another issue. Operators >>= and <<= did not have variants for accepting other ScaledNumber as the shift argument. This is expected by the SCALED_NUMBER_BOP. It makes no sense to allow shifting a ScaledNumber by another ScaledNumber, so the patch includes two new templates for shifting ScaledNumbers. Reviewers: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9350 llvm-svn: 236232
* Fix typo in comment. NFC.Diego Novillo2015-04-301-1/+1
| | | | llvm-svn: 236227
* Disable failing TestDevNull test on WindowsReid Kleckner2015-04-291-0/+2
| | | | llvm-svn: 236126
* Relax assert to avoid spurious failures with /dev/null.Rafael Espindola2015-04-291-0/+29
| | | | llvm-svn: 236106
* Don't allow pwrite to resize a stream.Rafael Espindola2015-04-201-1/+9
| | | | | | | | | | | | | | | | | | | | | The current implementations could exhibit some behavior differences: raw_fd_ostream: Whatever the underlying fd does with seek+write. In a normal file, the write position would be back to the old offset. raw_svector_ostream: The write position is always the end of the stream, so after pwrite the write position would be the new end. This matches what OS_X (all BSD?) do with a pwrite in a O_APPEND fd. Given that we don't need that feature and don't use O_APPEND a lot in LLVM, just disallow it. I am open to suggestions on renaming pwrite to something else, but this fixes the issue for now. Thanks to Yaron Keren for reporting it. llvm-svn: 235303
* Add raw_pwrite_stream type.Rafael Espindola2015-04-142-0/+26
| | | | | | | This is a raw_ostream that also supports pwrite. I will be used in a sec. llvm-svn: 234895
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-114-13/+19
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* [support] Add a macro wrapper for alignas and simplify some code.Benjamin Kramer2015-04-021-18/+4
| | | | | | | | We wrap __attribute((aligned)) for GCC 4.7 and __declspec(align) for MSVC. The latter behaves weird in some contexts so this should be used carefully. llvm-svn: 233910
OpenPOWER on IntegriCloud