summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
Commit message (Collapse)AuthorAgeFilesLines
...
* Do not pollute the namespace in a header file.Kristof Beyls2017-03-311-7/+7
| | | | llvm-svn: 299203
* Following r297661, disable dup workaround to disable duplicate STDOUT fd ↵Yaron Keren2017-03-301-1/+8
| | | | | | | | | | | | | | | | closing and instead directly prevent closing of STD* file descriptors. We do not want to close STDOUT as there may have been several uses of it such as the case: llc %s -o=- -pass-remarks-output=- -filetype=asm which cause multiple closes of STDOUT_FILENO and/or use-after-close of it. Using dup() in getFD doesn't work as we end up with original STDOUT_FILENO open anyhow. reviewed by Rafael Espindola Differential Revision: https://reviews.llvm.org/D31505 llvm-svn: 299098
* Revert "Make naming in Host.h in line with coding standards."Kristof Beyls2017-03-302-12/+12
| | | | | | | | | | | | | | | | | | | This reverts r299062, which caused build failures on Windows. It also reverts the attempts to fix the windows builds in r299064 and r299065. The introduction of namespace llvm::sys::detail makes MSVC, and seemingly also mingw, complain about ambiguity with the existing namespace llvm::detail. E.g.: C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/MathExtras.h(184): error C2872: 'detail': ambiguous symbol C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/PointerLikeTypeTraits.h(31): note: could be 'llvm::detail' C:\b\slave\sanitizer-windows\llvm\include\llvm/Support/Host.h(80): note: or 'llvm::sys::detail' In r299064 and r299065 I tried to fix these ambiguities, based on the errors reported in the log files. It seems however that the build stops early when this kind of error is encountered, and many build-then-fix-iterations on Windows may be needed to fix this. Therefore reverting r299062 for now to get the build working again on Windows. llvm-svn: 299066
* Make naming in Host.h in line with coding standards.Kristof Beyls2017-03-302-12/+12
| | | | | | | Based on post-commit review comments by Chandler Carruth on https://reviews.llvm.org/D31236. Thanks! llvm-svn: 299062
* Refactor getHostCPUName to allow testing on non-native hardware.Kristof Beyls2017-03-301-214/+204
| | | | | | | | | | | | | | | | | | | | | | | | | This refactors getHostCPUName so that for the architectures that get the host cpu info on linux from /proc/cpuinfo, the /proc/cpuinfo parsing logic is present in the build, even if it wasn't built on a linux system for that architecture. Since the code is present in the build, we can then test that code also on other systems, i.e. we don't need to have buildbots setup for all architectures on linux to be able to test this. Instead, developers will test this as part of the regression test run. As an example, a few unit tests are added to test getHostCPUName for ARM running linux. A unit test is preferred over a lit-based test, since the expectation is that in the future, the functionality here will grow over what can be tested with "llc -mcpu=native". This is a preparation step to enable implementing the range of improvements discussed on PR30516, such as adding AArch64 support, support for big.LITTLE systems, reducing code duplication. Differential Revision: https://reviews.llvm.org/D31236 llvm-svn: 299060
* [APInt] Reformat tc functions to put opening curly braces on the end of the ↵Craig Topper2017-03-281-104/+45
| | | | | | previous line. NFC llvm-svn: 298900
* [APInt] Remove an anonymous namespace around static functions. NFCCraig Topper2017-03-281-35/+33
| | | | llvm-svn: 298899
* [APInt] Combine variable declaration and initialization where possible in ↵Craig Topper2017-03-281-76/+36
| | | | | | the tc functions. NFCI llvm-svn: 298898
* [APInt] Use 'unsigned' instead of 'unsigned int' in the interface to the ↵Craig Topper2017-03-281-36/+36
| | | | | | APInt tc functions. This is more consistent with the rest of the codebase. NFC llvm-svn: 298897
* [APInt] Move the single word cases of the bitwise operators inline.Craig Topper2017-03-281-18/+3
| | | | llvm-svn: 298894
* [APInt] Move operator=(uint64_t) inline as its pretty simple and is often ↵Craig Topper2017-03-271-10/+0
| | | | | | | | used with small constants that the compiler can optimize. While there recognize that we only need to clearUnusedBits on the single word case. llvm-svn: 298881
* [Support] Avoid concurrency hazard in signal handler registrationBruno Cardoso Lopes2017-03-271-5/+1
| | | | | | | | | | | | | | | | | | Several static functions from the signal API can be invoked simultaneously; RemoveFileOnSignal for instance can be called indirectly by multiple parallel loadModule() invocations, which might lead to the assertion: Assertion failed: (NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) && "Out of space for signal handlers!"), function RegisterHandler, file /llvm/lib/Support/Unix/Signals.inc, line 105. RemoveFileOnSignal calls RegisterHandlers(), which isn't currently mutex protected, leading to the behavior above. This potentially affect a few other users of RegisterHandlers() too. rdar://problem/30381224 llvm-svn: 298871
* [APInt] Move operator&=(uint64_t) inline and use memset to clear the upper ↵Craig Topper2017-03-271-12/+0
| | | | | | | | words. This method is pretty new and probably isn't use much in the code base so this should have a negligible size impact. The OR and XOR operators are already inline. llvm-svn: 298870
* [APInt] Move the >64 bit case for flipAllBits out of line.Craig Topper2017-03-271-0/+5
| | | | | | This is more consistent with what we do for other operations. This shrinks the opt binary on my build by ~72k. llvm-svn: 298858
* Correct OptionCategoryCompare() in the command line library.Daniel Sanders2017-03-271-2/+3
| | | | | | | | | | | | | | | | | Summary: It should return <0, 0, or >0 for less-than, equal, and greater-than like strcmp() (according to the history, it used to be implemented with strcmp()) but it actually returned 0, or 1 for not-equal and equal. Reviewers: qcolombet Reviewed By: qcolombet Subscribers: qcolombet, llvm-commits Differential Revision: https://reviews.llvm.org/D30996 llvm-svn: 298844
* Make home_directory look in the password database in addition to $HOME.Zachary Turner2017-03-221-5/+11
| | | | | | | | | | | | | This is something of an edge case, but when the $HOME environment variable is not set, we can still look in the password database to get the current user's home directory. Added a test for this by getting the value of $HOME, then unsetting it, then calling home_directory() and verifying that it succeeds and that the value is the same as what we originally read from the environment. llvm-svn: 298513
* [Support] Fill the file_status struct with link count.Zachary Turner2017-03-202-5/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D31110 llvm-svn: 298326
* Add a function to MD5 a file's contents.Zachary Turner2017-03-202-7/+42
| | | | | | | | | | | | | | | In doing so, clean up the MD5 interface a little. Most existing users only care about the lower 8 bytes of an MD5, but for some users that care about the upper and lower, there wasn't a good interface. Furthermore, consumers of the MD5 checksum were required to handle endianness details on their own, so it seems reasonable to abstract this into a nicer interface that just gives you the right value. Differential Revision: https://reviews.llvm.org/D31105 llvm-svn: 298322
* Support, LTO: When pruning a directory, ignore files matching a prefix.Peter Collingbourne2017-03-201-2/+5
| | | | | | | | | | This is a safeguard against data loss if the user specifies a directory that is not a cache directory. Teach the existing cache pruning clients to create files with appropriate names. Differential Revision: https://reviews.llvm.org/D31109 llvm-svn: 298271
* Use MutableArrayRef for APFloat::convertToIntegerSimon Pilgrim2017-03-201-29/+34
| | | | | | As discussed on D31074, use MutableArrayRef for destination integer buffers to help assert before stack overflows happen. llvm-svn: 298253
* Strip trailing whitespaceSimon Pilgrim2017-03-201-5/+5
| | | | llvm-svn: 298247
* [APInt] Don't initialize VAL to 0 in APInt constructors. Push it down to the ↵Craig Topper2017-03-201-2/+5
| | | | | | | | | | initSlowCase and other init methods. I'm not sure if zeroing VAL before writing pVal is really necessary, but at least one other place did it in code. But by taking the store out of line, this reduces the opt binary by about 20k on my local x86-64 build. llvm-svn: 298233
* [LockFileManager] Reduce lock timeoutBruno Cardoso Lopes2017-03-181-3/+3
| | | | | | | | | | Go back to behavior pre-r231309 and reduce the timeout from 8 to ~1.5 min now that we have (a) PCMCache mechanism (r298165) and (b) timeout that doesn't cause a failure, but actually build the module (r298175). rdar://problem/30297862 llvm-svn: 298176
* Fix linux build.Zachary Turner2017-03-161-1/+2
| | | | llvm-svn: 298007
* [Support] Support both Windows and Posix paths on both platforms.Zachary Turner2017-03-162-224/+203
| | | | | | | | | | | | | | | | | | Previously which path syntax we supported dependend on what platform we were compiling LLVM on. While this is normally desirable, there are situations where we need to be able to handle a path that we know was generated on a remote host. Remote debugging, for example, or parsing debug info. 99% of the code in LLVM for handling paths was platform agnostic and literally just a few branches were gated behind pre-processor checks, so this changes those sites to use runtime checks instead, and adds a flag to every path API that allows one to override the host native syntax. Differential Revision: https://reviews.llvm.org/D30858 llvm-svn: 298004
* [Support] Add support for getting file system permissions on Windows and ↵James Henderson2017-03-163-8/+58
| | | | | | | | | | | | | | | | | | implement sys::fs::set/getPermissions to work with them This change adds support for functions to set and get file permissions, in a similar manner to the C++17 permissions() function in <filesystem>. The setter uses chmod on Unix systems and SetFileAttributes on Windows, setting the permissions as passed in. The getter simply uses the existing status() function. Prior to this change, status() would always return an unknown value for the permissions on a Windows file, making it impossible to test the new function on Windows. I have therefore added support for this as well. On Linux, prior to this change, the permissions included the file type, which should actually be accessed via a different member of the file_status class. Note that on Windows, only the *_write permission bits have any affect - if any are set, the file is writable, and if not, the file is read-only. This is in common with what MSDN describes for their behaviour of std::filesystem::permissions(), and also what boost::filesystem does. The motivation behind this change is so that we can easily test behaviour on read-only files in LLVM unit tests, but I am sure that others may find it useful in some situations. Reviewers: zturner, amccarth, aaron.ballman Differential Revision: https://reviews.llvm.org/D30736 llvm-svn: 297945
* Fix pessimising moves.Peter Collingbourne2017-03-161-2/+2
| | | | llvm-svn: 297928
* Support: Add a cache pruning policy parser.Peter Collingbourne2017-03-161-0/+68
| | | | | | | | | The idea is that the policy string fully specifies the policy and is portable between clients. Differential Revision: https://reviews.llvm.org/D31020 llvm-svn: 297927
* Support: Simplify the CachePruning API. NFCI.Peter Collingbourne2017-03-151-8/+14
| | | | | | | | | Change the function that implements the pruning into a free function that takes the policy as a struct argument. Differential Revision: https://reviews.llvm.org/D31009 llvm-svn: 297907
* [pdb] Write the module info and symbol record streams.Zachary Turner2017-03-151-0/+9
| | | | | | | | | | | Previously we did not have support for writing detailed module information for each module, as well as the symbol records. This patch adds support for this, and in doing so enables the ability to construct minimal PDBs from just a few lines of YAML. A test is added to illustrate this functionality. llvm-svn: 297900
* [YAML] When outputting, provide the ability to write default values.Zachary Turner2017-03-151-12/+5
| | | | | | | | | Previously, if you attempted to write a key/value pair and the value was equal to the key's default value, we would not output the value. Sometimes it is useful to be able to see this value in the output anyway. llvm-svn: 297864
* [Support][CommandLine] Make it possible to get error messages from ↵Eric Liu2017-03-151-27/+24
| | | | | | | | | | | | | | | | | | | ParseCommandLineOptions when ignoring errors. Summary: Previously, ParseCommandLineOptions returns false and ignores error messages when IgnoreErrors. It would be useful to also return error messages if users decide to check parsing result instead of having the program exit on error. Reviewers: chandlerc, mehdi_amini, rnk Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30893 llvm-svn: 297810
* Make FileOutputBuffer fail early if you pass a directory.Rui Ueyama2017-03-131-0/+2
| | | | | | | | | | Previously, it created a temporary directory and then failed when FileOutputBuffer tried to rename that file to the destination file (which is actually a directory name). Differential Revision: https://reviews.llvm.org/D30912 llvm-svn: 297679
* Bring back r297624.Rafael Espindola2017-03-131-1/+1
| | | | | | The issues was just a missing REQUIRES in the test. llvm-svn: 297661
* Revert "Fix crash when multiple raw_fd_ostreams to stdout are created."Rafael Espindola2017-03-131-1/+1
| | | | | | | This reverts commit r297624. It was failing on the bots. llvm-svn: 297657
* Fix crash when multiple raw_fd_ostreams to stdout are created.Rafael Espindola2017-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | If raw_fd_ostream is constructed with the path of "-", it claims ownership of the stdout file descriptor. This means that it closes stdout when it is destroyed. If there are multiple users of raw_fd_ostream wrapped around stdout, then a crash can occur because of operations on a closed stream. An example of this would be running something like "clang -S -o - -MD -MF - test.cpp". Alternatively, using outs() (which creates a local version of raw_fd_stream to stdout) anywhere combined with such a stream usage would cause the crash. The fix duplicates the stdout file descriptor when used within raw_fd_ostream, so that only that particular descriptor is closed when the stream is destroyed. Patch by James Henderson! llvm-svn: 297624
* Reverting r297617 because it broke some bots:Aaron Ballman2017-03-133-81/+31
| | | | | | http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/49970 llvm-svn: 297618
* Add support for getting file system permissions and implement ↵Aaron Ballman2017-03-133-31/+81
| | | | | | | | sys::fs::permissions to set them. Patch by James Henderson. llvm-svn: 297617
* [Support] Don't return an error if realPath fails.Zachary Turner2017-03-101-3/+2
| | | | | | | | | | | In openFileForRead, we would not previously return an error if real_path resolution failed. After a recent patch, we started propagating this error up. This caused a failure in clang when trying to call openFileForRead("nul"). This patch restores the previous behavior of not propagating this error up. llvm-svn: 297488
* Add llvm::sys::fs::real_path.Zachary Turner2017-03-102-16/+161
| | | | | | | | | | | | | | | | | | | | | LLVM already has real_path like functionality, but it is cumbersome to use and involves clean up after (e.g. you have to call openFileForRead, then close the resulting FD). Furthermore, on Windows it doesn't work for directories since opening a directory and opening a file require slightly different flags. So I add a simple function `real_path` which works for all paths on all platforms and has a simple to use interface. In doing so, I add the ability to opt in to resolving tilde expressions (e.g. ~/foo), which are normally handled by the shell. Differential Revision: https://reviews.llvm.org/D30668 llvm-svn: 297483
* [APInt] Add APInt::insertBits() method to insert an APInt into a larger APIntSimon Pilgrim2017-03-101-0/+59
| | | | | | | | | | | | We currently have to insert bits via a temporary variable of the same size as the target with various shift/mask stages, resulting in further temporary variables, all of which require the allocation of memory for large APInts (MaskSizeInBits > 64). This is another of the compile time issues identified in PR32037 (see also D30265). This patch adds the APInt::insertBits() helper method which avoids the temporary memory allocation and masks/inserts the raw bits directly into the target. Differential Revision: https://reviews.llvm.org/D30780 llvm-svn: 297458
* Fixed typos in comments. NFCI.Simon Pilgrim2017-03-091-6/+6
| | | | llvm-svn: 297379
* fix build on CygwinNuno Lopes2017-03-091-0/+3
| | | | llvm-svn: 297378
* [Support] Add llvm::sys::fs::remove_directories.Zachary Turner2017-03-083-5/+75
| | | | | | | | | | | | | | | | | | | | | We already have a function create_directories() which can create an entire tree, and remove() which can remove an empty directory, but we do not have remove_directories() which can remove an entire tree. This patch adds such a function. Because removing a directory tree can have dangerous consequences when the tree contains a directory symlink, the patch here updates the existing directory_iterator construct to optionally not follow symlinks (previously it would always follow symlinks). The delete algorithm uses this flag so that for symlinks, only the links are removed, and not the targets. On Windows this is implemented with SHFileOperation, which also does not recurse into symbolic links or junctions. Differential Revision: https://reviews.llvm.org/D30676 llvm-svn: 297314
* Resubmit FileSystem changes.Zachary Turner2017-03-081-0/+12
| | | | | | | | | | This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300
* Recommit: [globalisel] Change LLT constructor string into an LLT-based ↵Daniel Sanders2017-03-072-0/+48
| | | | | | | | | | | | | | | | | | | | object that knows how to generate it. Summary: This will allow future patches to inspect the details of the LLT. The implementation is now split between the Support and CodeGen libraries to allow TableGen to use this class without introducing layering concerns. Thanks to Ahmed Bougacha for finding a reasonable way to avoid the layering issue and providing the version of this patch without that problem. The problem with the previous commit appears to have been that TableGen was including CodeGen/LowLevelType.h instead of Support/LowLevelTypeImpl.h. Reviewers: t.p.northover, qcolombet, rovka, aditya_nandakumar, ab, javed.absar Subscribers: arsenm, nhaehnle, mgorny, dberris, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D30046 llvm-svn: 297241
* Fix C2712 build error on WindowsKonstantin Zhuravlyov2017-03-071-6/+12
| | | | | | | | Move the __try/__except block outside of the set_thread_name function to avoid a conflict with object unwinding due to the use of the llvm::Storage. Differential Revision: https://reviews.llvm.org/D30707 llvm-svn: 297192
* Revert r297177: Change LLT constructor string into an LLT-based object ...Daniel Sanders2017-03-072-48/+0
| | | | | | | | | | More module problems. This time it only showed up in the stage 2 compile of clang-x86_64-linux-selfhost-modules-2 but not the stage 1 compile. Somehow, this change causes the build to need Attributes.gen before it's been generated. llvm-svn: 297188
* [globalisel] Change LLT constructor string into an LLT-based object that ↵Daniel Sanders2017-03-072-0/+48
| | | | | | | | | | | | | | | | | | knows how to generate it. Summary: This will allow future patches to inspect the details of the LLT. The implementation is now split between the Support and CodeGen libraries to allow TableGen to use this class without introducing layering concerns. Thanks to Ahmed Bougacha for finding a reasonable way to avoid the layering issue and providing the version of this patch without that problem. Reviewers: t.p.northover, qcolombet, rovka, aditya_nandakumar, ab, javed.absar Subscribers: arsenm, nhaehnle, mgorny, dberris, llvm-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D30046 llvm-svn: 297177
* [fs] Make sure to check S_ISLNK() in fillStatus.Zachary Turner2017-03-071-0/+2
| | | | llvm-svn: 297167
OpenPOWER on IntegriCloud