summaryrefslogtreecommitdiffstats
path: root/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Use InitLLVM to setup a pretty stack printer"Nico Weber2019-11-251-2/+1
| | | | | | | This reverts commit 3f76260dc0674cc0acb25f550a0f0c594cf537ea. Breaks at least these tests on Windows: Clang :: Driver/clang-offload-bundler.c Clang :: Driver/clang-offload-wrapper.c
* Use InitLLVM to setup a pretty stack printerRui Ueyama2019-11-261-1/+2
| | | | | | | | | | | | | | InitLLVM does not only save a few lines from main() but also makes the commands do the right thing for multibyte character pathnames on Windows (i.e. canonicalize argv's to UTF-8) because of the code we have in this file: https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/InitLLVM.cpp#L32 For many LLVM commands, we already have calls of InitLLVM, but there are still remainings. Differential Revision: https://reviews.llvm.org/D70702
* Reland "[Clang][Bundler] Error reporting improvements"Sergey Dmitriev2019-10-251-196/+213
| | | | | | | | - Changed FileHandler read/write methods to return llvm::Error - Using unified way of reporting errors - Removed trailing '.' from the error messages Differential Revision: https://reviews.llvm.org/D67031
* Revert "[Clang][Bundler] Error reporting improvements"Sergey Dmitriev2019-10-251-213/+196
| | | | This reverts commit dd501045cdea1c80b6788f0266d2a79f8b412eea.
* [Clang][Bundler] Error reporting improvementsSergey Dmitriev2019-10-251-196/+213
| | | | | | | | - Changed FileHandler read/write methods to return llvm::Error - Using unified way of reporting errors - Removed trailing '.' from the error messages Differential Revision: https://reviews.llvm.org/D67031
* [clang] [clang-offload-bundler] Fix finding installed llvm-objcopyMichal Gorny2019-10-141-0/+2
| | | | | | | | | | | | | | | | | Allow finding installed llvm-objcopy in PATH if it's not present in the directory containing clang-offload-bundler. This is the case if clang is being built stand-alone, and llvm-objcopy is already installed while the c-o-b tool is still present in build directory. This is consistent with how e.g. llvm-symbolizer is found in LLVM. However, most of similar searches in LLVM and Clang are performed without special-casing the program directory. Fixes r369955. Differential Revision: https://reviews.llvm.org/D68931 llvm-svn: 374754
* [clang-offload-bundler] Support `.cui` and `.d`.Michael Liao2019-10-091-0/+8
| | | | | | | | | | | | Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68663 llvm-svn: 374167
* [Clang][Bundler] Replace std::vector by SmallVector [NFC]Sergey Dmitriev2019-09-111-6/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D67413 llvm-svn: 371637
* [Clang][Bundler] Fix for a potential memory leak [NFC]Sergey Dmitriev2019-09-111-16/+7
| | | | | | | | Bundler leaks memory if it is called with -type=o but given input isn't an object file (though it has to have a known binary type like IR, archive, etc...). Memory leak is happening when binary object returned by the createBinary(...) call cannot be casted to an ObjectFile type. In this case returned BinaryOrErr object releases ownership of the binary, but no one is taking it (see line 626). Differential Revision: https://reviews.llvm.org/D67416 llvm-svn: 371633
* [Clang][Bundler] Do not require host triple for extracting device bundlesSergey Dmitriev2019-08-281-3/+6
| | | | | | | | Bundler currently requires host triple to be provided no matter if you are performing bundling or unbundling, but for unbundling operation such requirement is too restrictive. You may for example want to examine device part of the object for a particular offload target, but you have to extract host part as well even though you do not need it. Host triple isn't really needed for unbundling, so this patch removes that requirement. Differential Revision: https://reviews.llvm.org/D66601 llvm-svn: 370143
* [Clang][Bundler] Fix for a hang when unbundling fat binarySergey Dmitriev2019-08-271-4/+5
| | | | | | | | clang-offload-bundler tool may hang under certain conditions when it extracts a subset of all available device bundles from the fat binary that is handled by the BinaryFileHandler. This patch fixes this problem. Differential Revision: https://reviews.llvm.org/D66598 llvm-svn: 370115
* [Clang][Bundler] Use llvm-objcopy for creating fat object filesSergey Dmitriev2019-08-261-118/+24
| | | | | | | | clang-offload-bundler currently uses partial linking for creating fat object files, but such technique cannot be used on Windows due to the absence of partial linking support in the linker. This patch changes implementation to use llvm-objcopy for merging device and host objects instead of doing partial linking. This is one step forward towards enabling OpenMP offload on Windows. Differential Revision: https://reviews.llvm.org/D66485 llvm-svn: 369955
* [Driver][Bundler] Improve bundling of object files.Alexey Bataev2019-08-151-26/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, object files were bundled using partial linking. It resulted in the following structure of the bundled objects: ``` <host_code> clang-offload-bundle __CLANG_OFFLOAD_BUNDLE__<target> <target_code> ``` But when we tried to unbundle object files, it worked correctly only for the target objects. The host object remains bundled. It produced a lot of junk sections in the host object files and in some cases may caused incorrect linking. Patch improves bundling of the object files. After this patch the bundled object looks like this: ``` <host_code> clang-offload-bundle __CLANG_OFFLOAD_BUNDLE__<target> <target_code> __CLANG_OFFLOAD_BUNDLE__<host> <host_code> ``` With this structure we are able to unbundle the host object files too so that after unbundling they are the same as were before. The host section is bundled twice. The bundled section is used to unbundle the original host section. Reviewers: yaxunl, tra, jlebar, hfinkel, jdoerfert Subscribers: caomhin, kkwli0, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65819 llvm-svn: 369019
* [clang] - An update after LLVM change.George Rimar2019-08-141-1/+4
| | | | | | SectionRef::getName() was changed to return Expected<> (D66089) llvm-svn: 368825
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-5/+5
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Recommit [Object] Change object::SectionRef::getContents() to return ↵Fangrui Song2019-05-161-4/+7
| | | | | | | | | | | | Expected<StringRef> r360876 didn't fix 2 call sites in clang. Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now. Follow-up of D61781. llvm-svn: 360892
* Allow bundle size to be 0 in clang-offload-bundlerYaxun Liu2019-03-051-1/+1
| | | | | | | | | | | | | | HIP uses clang-offload-bundler to create fat binary. The bundle for host is empty. Currently clang-offload-bundler checks if the bundle size is 0 when unbundling. If so it will exit without unbundling the remaining bundles. This causes clang-offload-bundler not being able to unbundle fat binaries generated for HIP. This patch allows bundles size to be 0 when clang-offload-bundler unbundles input files. Differential Revision: https://reviews.llvm.org/D58057 llvm-svn: 355419
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-121-12/+11
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 334518
* [HIP] Let clang-offload-bundler support HIPYaxun Liu2018-05-111-5/+5
| | | | | | | | | | When bundle/unbundle intermediate files for HIP, there may be multiple sub archs, therefore BoundArch needs to be included in the target and output file names for clang-offload-bundler. Differential Revision: https://reviews.llvm.org/D46473 llvm-svn: 332121
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Update for llvm change. NFC.Rafael Espindola2018-02-141-1/+1
| | | | llvm-svn: 325156
* [NFC] fix trivial typos in commentsHiroshi Inoue2018-01-291-1/+1
| | | | | | "to to" -> "to" llvm-svn: 323627
* Update for llvm change.Rafael Espindola2017-09-081-1/+3
| | | | llvm-svn: 312766
* Print registered targets in clang's version informationDimitry Andric2017-06-061-2/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Other llvm tools display their registered targets when showing version information, but for some reason clang has never done this. To support this, D33899 adds the llvm parts, which make it possible to print version information to arbitrary raw_ostreams. This change adds a call to printRegisteredTargetsForVersion in clang's PrintVersion, and adds a raw_ostream parameter to two other PrintVersion functions. Reviewers: beanz, chandlerc, dberris, mehdi_amini, zturner Reviewed By: mehdi_amini Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33900 llvm-svn: 304836
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-1/+1
| | | | llvm-svn: 299083
* Avoid calling dump() in normal codeMatthias Braun2017-01-281-1/+4
| | | | | | | dump() is only available in debug builds and meant for debugger usage, normal code should use something like print(errs()); llvm-svn: 293364
* Mirror the llvm changes that split Bitcode/ReaderWriter.hTeresa Johnson2016-11-111-1/+1
| | | | | | | | | | The change in D26502 splits ReaderWriter.h, which contains the APIs into both the BitReader and BitWriter libraries, into BitcodeReader.h and BitcodeWriter.h. Change clang uses to the appropriate split header(s). llvm-svn: 286567
* [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and ↵Eugene Zelenko2016-09-071-80/+120
| | | | | | | | Include What You Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D24165 llvm-svn: 280828
* Fix memory leaks in clang-offload-bundlerVitaly Buka2016-08-251-9/+11
| | | | | | | | | | | | | | Summary: 1. Pair removed from StringMap was not destroyed 2. ObjectFile had no owner Reviewers: sfantao Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23865 llvm-svn: 279722
* [Driver][OpenMP][CUDA] Add capability to bundle object files in sections of ↵Samuel Antao2016-08-241-7/+296
| | | | | | | | | | | | | | | | | | | the host binary format. Summary: This patch adds the capability to bundle object files in sections of the host binary using a designated naming convention for these sections. This patch uses the functionality of the object reader already in the LLVM library to read bundled files, and invokes clang with the incremental linking options to create bundle files. Bundling files involves creating an IR file with the contents of the bundle assigned as initializers of globals binded to the designated sections. This way the bundling implementation is agnostic of the host object format. The features added by this patch were requested in the RFC discussion in http://lists.llvm.org/pipermail/cfe-dev/2016-February/047547.html. Reviewers: echristo, tra, jlebar, hfinkel, ABataev, Hahnfeld Subscribers: mkuron, whchung, cfe-commits, andreybokhanko, Hahnfeld, arpith-jacob, carlo.bertolli, mehdi_amini, caomhin Differential Revision: https://reviews.llvm.org/D21851 llvm-svn: 279634
* clang-offload-bundler - offload files bundling/unbundling toolSamuel Antao2016-08-241-0/+681
Summary: One of the goals of programming models that support offloading (e.g. OpenMP) is to enable users to offload with little effort, by annotating the code with a few pragmas. I'd also like to save users the trouble of changing their existent applications' build system. So having the compiler always return a single file instead of one for the host and each target even if the user is doing separate compilation is desirable. This diff proposes a tool named clang-offload-bundler (happy to change the name if required) that is used to bundle files associated with the same user source file but different targets, or to unbundle a file into separate files associated with different targets. This tool supports the driver support for OpenMP under review in http://reviews.llvm.org/D9888. The tool is used there to enable separate compilation, so that the very first action on input files that are not source files is a "unbundling action" and the very last non-linking action is a "bundling action". The format of the bundled files is currently very simple: text formats are concatenated with comments that have a magic string and target identifying triple in between, and binary formats have a header that contains the triple and the offset and size of the code for host and each target. The goal is to improve this tool in the future to deal with archive files so that each individual file in the archive is properly dealt with. We see that archives are very commonly used in current applications to combine separate compilation results. So I'm convinced users would enjoy this feature. This tool can be used like this: `clang-offload-bundler -targets=triple1,triple2 -type=ii -inputs=a.triple1.ii,a.triple2.ii -outputs=a.ii` or `clang-offload-bundler -targets=triple1,triple2 -type=ii -outputs=a.triple1.ii,a.triple2.ii -inputs=a.ii -unbundle` I implemented the tool under clang/tools. Please let me know if something like this should live somewhere else. This patch is prerequisite for http://reviews.llvm.org/D9888. Reviewers: hfinkel, rsmith, echristo, chandlerc, tra, jlebar, ABataev, Hahnfeld Subscribers: whchung, caomhin, andreybokhanko, arpith-jacob, carlo.bertolli, mehdi_amini, guansong, Hahnfeld, cfe-commits Differential Revision: https://reviews.llvm.org/D13909 llvm-svn: 279632
OpenPOWER on IntegriCloud