File tree Expand file tree Collapse file tree 6 files changed +50
-7
lines changed
include/llvm/Frontend/OpenMP
mlir/lib/Target/LLVMIR/Dialect/OpenMP Expand file tree Collapse file tree 6 files changed +50
-7
lines changed Original file line number Diff line number Diff line change @@ -1038,7 +1038,8 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
10381038 /*HasRequiresReverseOffload*/ false, /*HasRequiresUnifiedAddress*/ false,
10391039 hasRequiresUnifiedSharedMemory(), /*HasRequiresDynamicAllocators*/ false);
10401040 OMPBuilder.initialize();
1041- OMPBuilder.loadOffloadInfoMetadata(CGM.getLangOpts().OpenMPIsTargetDevice
1041+ OMPBuilder.loadOffloadInfoMetadata(*CGM.getFileSystem(),
1042+ CGM.getLangOpts().OpenMPIsTargetDevice
10421043 ? CGM.getLangOpts().OMPHostIRFile
10431044 : StringRef{});
10441045 OMPBuilder.setConfig(Config);
Original file line number Diff line number Diff line change @@ -588,8 +588,7 @@ void CodeGenModule::createOpenCLRuntime() {
588588}
589589
590590void CodeGenModule::createOpenMPRuntime () {
591- if (!LangOpts.OMPHostIRFile .empty () &&
592- !llvm::sys::fs::exists (LangOpts.OMPHostIRFile ))
591+ if (!LangOpts.OMPHostIRFile .empty () && !FS->exists (LangOpts.OMPHostIRFile ))
593592 Diags.Report (diag::err_omp_host_ir_file_not_found)
594593 << LangOpts.OMPHostIRFile ;
595594
Original file line number Diff line number Diff line change 1+ // This test checks that the OpenMP host IR file goes through VFS overlays.
2+
3+ // RUN: rm -rf %t
4+ // RUN: split-file %s %t
5+
6+ // RUN: sed -e "s|DIR|%/t|g" %t/vfs.json.in > %t/vfs.json
7+ // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %t/host.c -o %t/host.bc
8+
9+ // RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %t/device.c -o - \
10+ // RUN: -fopenmp-is-target-device -fopenmp-host-ir-file-path %t/virtual/host.bc -ivfsoverlay %t/vfs.json -verify
11+
12+ //--- vfs.json.in
13+ {
14+ 'version' : 0 ,
15+ 'use-external-names' : true,
16+ 'roots' : [
17+ {
18+ 'name' : 'DIR/virtual' ,
19+ 'type' : 'directory' ,
20+ 'contents' : [
21+ {
22+ 'name' : 'host.bc' ,
23+ 'type' : 'file' ,
24+ 'external-contents' : 'DIR/host.bc'
25+ }
26+ ]
27+ }
28+ ]
29+ }
30+
31+ //--- host.c
32+ //--- device.c
33+ // expected-no-diagnostics
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class Loop;
3838class LoopAnalysis ;
3939class LoopInfo ;
4040
41+ namespace vfs {
42+ class FileSystem ;
43+ } // namespace vfs
44+
4145// / Move the instruction after an InsertPoint to the beginning of another
4246// / BasicBlock.
4347// /
@@ -3491,7 +3495,8 @@ class OpenMPIRBuilder {
34913495 // / \param HostFilePath The path to the host IR file,
34923496 // / used to load in offload metadata for the device, allowing host and device
34933497 // / to maintain the same metadata mapping.
3494- LLVM_ABI void loadOffloadInfoMetadata (StringRef HostFilePath);
3498+ LLVM_ABI void loadOffloadInfoMetadata (vfs::FileSystem &VFS,
3499+ StringRef HostFilePath);
34953500
34963501 // / Gets (if variable with the given name already exist) or creates
34973502 // / internal global variable with the specified Name. The created variable has
Original file line number Diff line number Diff line change 5151#include " llvm/Support/CommandLine.h"
5252#include " llvm/Support/ErrorHandling.h"
5353#include " llvm/Support/FileSystem.h"
54+ #include " llvm/Support/VirtualFileSystem.h"
5455#include " llvm/Target/TargetMachine.h"
5556#include " llvm/Target/TargetOptions.h"
5657#include " llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -10083,11 +10084,12 @@ void OpenMPIRBuilder::loadOffloadInfoMetadata(Module &M) {
1008310084 }
1008410085}
1008510086
10086- void OpenMPIRBuilder::loadOffloadInfoMetadata (StringRef HostFilePath) {
10087+ void OpenMPIRBuilder::loadOffloadInfoMetadata (vfs::FileSystem &VFS,
10088+ StringRef HostFilePath) {
1008710089 if (HostFilePath.empty ())
1008810090 return ;
1008910091
10090- auto Buf = MemoryBuffer::getFile (HostFilePath);
10092+ auto Buf = VFS. getBufferForFile (HostFilePath);
1009110093 if (std::error_code Err = Buf.getError ()) {
1009210094 report_fatal_error ((" error opening host file from host file path inside of "
1009310095 " OpenMPIRBuilder: " +
Original file line number Diff line number Diff line change 3636#include " llvm/IR/MDBuilder.h"
3737#include " llvm/IR/ReplaceConstant.h"
3838#include " llvm/Support/FileSystem.h"
39+ #include " llvm/Support/VirtualFileSystem.h"
3940#include " llvm/TargetParser/Triple.h"
4041#include " llvm/Transforms/Utils/ModuleUtils.h"
4142
@@ -6185,7 +6186,9 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
61856186 if (auto filepathAttr = dyn_cast<StringAttr>(attr)) {
61866187 llvm::OpenMPIRBuilder *ompBuilder =
61876188 moduleTranslation.getOpenMPBuilder ();
6188- ompBuilder->loadOffloadInfoMetadata (filepathAttr.getValue ());
6189+ auto VFS = llvm::vfs::getRealFileSystem ();
6190+ ompBuilder->loadOffloadInfoMetadata (*VFS,
6191+ filepathAttr.getValue ());
61896192 return success ();
61906193 }
61916194 return failure ();
You can’t perform that action at this time.
0 commit comments