-
Notifications
You must be signed in to change notification settings - Fork 15k
[clang] Load -fembed-offload-object= through the VFS
#160906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Jan Svoboda (jansvoboda11) ChangesThis PR loads the path from Full diff: https://github.com/llvm/llvm-project/pull/160906.diff 4 Files Affected:
diff --git a/clang/include/clang/CodeGen/BackendUtil.h b/clang/include/clang/CodeGen/BackendUtil.h
index 92e0d13bf25b6..8b0d975a876e6 100644
--- a/clang/include/clang/CodeGen/BackendUtil.h
+++ b/clang/include/clang/CodeGen/BackendUtil.h
@@ -49,7 +49,7 @@ void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
llvm::MemoryBufferRef Buf);
void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
- DiagnosticsEngine &Diags);
+ llvm::vfs::FileSystem &VFS, DiagnosticsEngine &Diags);
} // namespace clang
#endif
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index d2ab7aa0b0369..e7de251086869 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1475,13 +1475,13 @@ void clang::EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
}
void clang::EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
- DiagnosticsEngine &Diags) {
+ llvm::vfs::FileSystem &VFS, DiagnosticsEngine &Diags) {
if (CGOpts.OffloadObjects.empty())
return;
for (StringRef OffloadObject : CGOpts.OffloadObjects) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ObjectOrErr =
- llvm::MemoryBuffer::getFileOrSTDIN(OffloadObject);
+ VFS.getBufferForFile(OffloadObject);
if (ObjectOrErr.getError()) {
auto DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
"could not open '%0' for embedding");
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index 8e3234998df2a..9286f1f25c6cc 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1141,7 +1141,8 @@ void CodeGenAction::ExecuteAction() {
TheModule->setTargetTriple(Triple(TargetOpts.Triple));
}
- EmbedObject(TheModule.get(), CodeGenOpts, Diagnostics);
+ EmbedObject(TheModule.get(), CodeGenOpts, CI.getVirtualFileSystem(),
+ Diagnostics);
EmbedBitcode(TheModule.get(), CodeGenOpts, *MainFile);
LLVMContext &Ctx = TheModule->getContext();
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 0eac7c351b164..875f06b53f53d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1556,7 +1556,7 @@ void CodeGenModule::Release() {
EmitBackendOptionsMetadata(getCodeGenOpts());
// If there is device offloading code embed it in the host now.
- EmbedObject(&getModule(), CodeGenOpts, getDiags());
+ EmbedObject(&getModule(), CodeGenOpts, *getFileSystem(), getDiags());
// Set visibility from DLL storage class
// We do this at the end of LLVM IR generation; after any operation
|
|
LGTM. |
This PR loads the path from `-fembed-offload-object=<path>` through the VFS rather than going straight to the real file system. This matches the behavior of other input files of the compiler. This technically changes behavior in that `-fembed-offload-object=-` no longer loads the file from stdin, but I don't think that was the intention of the original code anyways.
This PR loads the path from `-fembed-offload-object=<path>` through the VFS rather than going straight to the real file system. This matches the behavior of other input files of the compiler. This technically changes behavior in that `-fembed-offload-object=-` no longer loads the file from stdin, but I don't think that was the intention of the original code anyways.
This PR loads the path from `-fembed-offload-object=<path>` through the VFS rather than going straight to the real file system. This matches the behavior of other input files of the compiler. This technically changes behavior in that `-fembed-offload-object=-` no longer loads the file from stdin, but I don't think that was the intention of the original code anyways.
This PR loads the path from
-fembed-offload-object=<path>through the VFS rather than going straight to the real file system. This matches the behavior of other input files of the compiler. This technically changes behavior in that-fembed-offload-object=-no longer loads the file from stdin, but I don't think that was the intention of the original code anyways.