File tree Expand file tree Collapse file tree 5 files changed +46
-6
lines changed
include/llvm/Frontend/OpenMP Expand file tree Collapse file tree 5 files changed +46
-6
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 @@ -582,8 +582,7 @@ void CodeGenModule::createOpenCLRuntime() {
582582}
583583
584584void CodeGenModule::createOpenMPRuntime () {
585- if (!LangOpts.OMPHostIRFile .empty () &&
586- !llvm::sys::fs::exists (LangOpts.OMPHostIRFile ))
585+ if (!LangOpts.OMPHostIRFile .empty () && !FS->exists (LangOpts.OMPHostIRFile ))
587586 Diags.Report (diag::err_omp_host_ir_file_not_found)
588587 << LangOpts.OMPHostIRFile ;
589588
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 @@ -39,6 +39,10 @@ class Loop;
3939class LoopAnalysis ;
4040class LoopInfo ;
4141
42+ namespace vfs {
43+ class FileSystem ;
44+ } // namespace vfs
45+
4246// / Move the instruction after an InsertPoint to the beginning of another
4347// / BasicBlock.
4448// /
@@ -3629,7 +3633,8 @@ class OpenMPIRBuilder {
36293633 // / \param HostFilePath The path to the host IR file,
36303634 // / used to load in offload metadata for the device, allowing host and device
36313635 // / to maintain the same metadata mapping.
3632- LLVM_ABI void loadOffloadInfoMetadata (StringRef HostFilePath);
3636+ LLVM_ABI void loadOffloadInfoMetadata (vfs::FileSystem &VFS,
3637+ StringRef HostFilePath);
36333638
36343639 // / Gets (if variable with the given name already exist) or creates
36353640 // / internal global variable with the specified Name. The created variable has
Original file line number Diff line number Diff line change 5050#include " llvm/Support/CommandLine.h"
5151#include " llvm/Support/ErrorHandling.h"
5252#include " llvm/Support/FileSystem.h"
53+ #include " llvm/Support/VirtualFileSystem.h"
5354#include " llvm/Target/TargetMachine.h"
5455#include " llvm/Target/TargetOptions.h"
5556#include " llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -10523,11 +10524,12 @@ void OpenMPIRBuilder::loadOffloadInfoMetadata(Module &M) {
1052310524 }
1052410525}
1052510526
10526- void OpenMPIRBuilder::loadOffloadInfoMetadata (StringRef HostFilePath) {
10527+ void OpenMPIRBuilder::loadOffloadInfoMetadata (vfs::FileSystem &VFS,
10528+ StringRef HostFilePath) {
1052710529 if (HostFilePath.empty ())
1052810530 return ;
1052910531
10530- auto Buf = MemoryBuffer::getFile (HostFilePath);
10532+ auto Buf = VFS. getBufferForFile (HostFilePath);
1053110533 if (std::error_code Err = Buf.getError ()) {
1053210534 report_fatal_error ((" error opening host file from host file path inside of "
1053310535 " OpenMPIRBuilder: " +
You can’t perform that action at this time.
0 commit comments