Changeset View
Changeset View
Standalone View
Standalone View
clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | Target("target", cl::Required, | ||||
cl::value_desc("triple"), cl::cat(ClangOffloadWrapperCategory)); | cl::value_desc("triple"), cl::cat(ClangOffloadWrapperCategory)); | ||||
static cl::opt<bool> SaveTemps( | static cl::opt<bool> SaveTemps( | ||||
"save-temps", | "save-temps", | ||||
cl::desc("Save temporary files that may be produced by the tool. " | cl::desc("Save temporary files that may be produced by the tool. " | ||||
"This option forces print-out of the temporary files' names."), | "This option forces print-out of the temporary files' names."), | ||||
cl::Hidden); | cl::Hidden); | ||||
static cl::opt<bool> AddOpenMPOffloadNotes( | |||||
JonChesterfield: I'd have probably gone with an explicit false here but it doesn't make much difference. | |||||
"add-omp-offload-notes", | |||||
cl::desc("Add LLVMOMPOFFLOAD ELF notes to ELF device images."), cl::Hidden); | |||||
namespace { | namespace { | ||||
class BinaryWrapper { | class BinaryWrapper { | ||||
LLVMContext C; | LLVMContext C; | ||||
Module M; | Module M; | ||||
StructType *EntryTy = nullptr; | StructType *EntryTy = nullptr; | ||||
StructType *ImageTy = nullptr; | StructType *ImageTy = nullptr; | ||||
▲ Show 20 Lines • Show All 538 Lines • ▼ Show 20 Lines | int main(int argc, const char **argv) { | ||||
for (const std::string &File : Inputs) { | for (const std::string &File : Inputs) { | ||||
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr = | ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr = | ||||
MemoryBuffer::getFileOrSTDIN(File); | MemoryBuffer::getFileOrSTDIN(File); | ||||
if (!BufOrErr) { | if (!BufOrErr) { | ||||
reportError(createFileError(File, BufOrErr.getError())); | reportError(createFileError(File, BufOrErr.getError())); | ||||
return 1; | return 1; | ||||
} | } | ||||
std::unique_ptr<MemoryBuffer> Buffer(std::move(*BufOrErr)); | std::unique_ptr<MemoryBuffer> Buffer(std::move(*BufOrErr)); | ||||
if (File != "-") { | if (File != "-" && AddOpenMPOffloadNotes) { | ||||
// Adding ELF notes for STDIN is not supported yet. | // Adding ELF notes for STDIN is not supported yet. | ||||
Buffer = Wrapper.addELFNotes(std::move(Buffer), File); | Buffer = Wrapper.addELFNotes(std::move(Buffer), File); | ||||
} | } | ||||
const std::unique_ptr<MemoryBuffer> &Buf = | const std::unique_ptr<MemoryBuffer> &Buf = | ||||
Buffers.emplace_back(std::move(Buffer)); | Buffers.emplace_back(std::move(Buffer)); | ||||
Images.emplace_back(Buf->getBufferStart(), Buf->getBufferSize()); | Images.emplace_back(Buf->getBufferStart(), Buf->getBufferSize()); | ||||
} | } | ||||
Show All 21 Lines |
I'd have probably gone with an explicit false here but it doesn't make much difference.