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)
1038
1038
/*HasRequiresReverseOffload*/ false, /*HasRequiresUnifiedAddress*/ false,
1039
1039
hasRequiresUnifiedSharedMemory(), /*HasRequiresDynamicAllocators*/ false);
1040
1040
OMPBuilder.initialize();
1041
- OMPBuilder.loadOffloadInfoMetadata(CGM.getLangOpts().OpenMPIsTargetDevice
1041
+ OMPBuilder.loadOffloadInfoMetadata(*CGM.getFileSystem(),
1042
+ CGM.getLangOpts().OpenMPIsTargetDevice
1042
1043
? CGM.getLangOpts().OMPHostIRFile
1043
1044
: StringRef{});
1044
1045
OMPBuilder.setConfig(Config);
Original file line number Diff line number Diff line change @@ -582,8 +582,7 @@ void CodeGenModule::createOpenCLRuntime() {
582
582
}
583
583
584
584
void CodeGenModule::createOpenMPRuntime () {
585
- if (!LangOpts.OMPHostIRFile .empty () &&
586
- !llvm::sys::fs::exists (LangOpts.OMPHostIRFile ))
585
+ if (!LangOpts.OMPHostIRFile .empty () && !FS->exists (LangOpts.OMPHostIRFile ))
587
586
Diags.Report (diag::err_omp_host_ir_file_not_found)
588
587
<< LangOpts.OMPHostIRFile ;
589
588
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;
39
39
class LoopAnalysis ;
40
40
class LoopInfo ;
41
41
42
+ namespace vfs {
43
+ class FileSystem ;
44
+ } // namespace vfs
45
+
42
46
// / Move the instruction after an InsertPoint to the beginning of another
43
47
// / BasicBlock.
44
48
// /
@@ -3629,7 +3633,8 @@ class OpenMPIRBuilder {
3629
3633
// / \param HostFilePath The path to the host IR file,
3630
3634
// / used to load in offload metadata for the device, allowing host and device
3631
3635
// / to maintain the same metadata mapping.
3632
- LLVM_ABI void loadOffloadInfoMetadata (StringRef HostFilePath);
3636
+ LLVM_ABI void loadOffloadInfoMetadata (vfs::FileSystem &VFS,
3637
+ StringRef HostFilePath);
3633
3638
3634
3639
// / Gets (if variable with the given name already exist) or creates
3635
3640
// / internal global variable with the specified Name. The created variable has
Original file line number Diff line number Diff line change 50
50
#include " llvm/Support/CommandLine.h"
51
51
#include " llvm/Support/ErrorHandling.h"
52
52
#include " llvm/Support/FileSystem.h"
53
+ #include " llvm/Support/VirtualFileSystem.h"
53
54
#include " llvm/Target/TargetMachine.h"
54
55
#include " llvm/Target/TargetOptions.h"
55
56
#include " llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -10531,11 +10532,12 @@ void OpenMPIRBuilder::loadOffloadInfoMetadata(Module &M) {
10531
10532
}
10532
10533
}
10533
10534
10534
- void OpenMPIRBuilder::loadOffloadInfoMetadata (StringRef HostFilePath) {
10535
+ void OpenMPIRBuilder::loadOffloadInfoMetadata (vfs::FileSystem &VFS,
10536
+ StringRef HostFilePath) {
10535
10537
if (HostFilePath.empty ())
10536
10538
return ;
10537
10539
10538
- auto Buf = MemoryBuffer::getFile (HostFilePath);
10540
+ auto Buf = VFS. getBufferForFile (HostFilePath);
10539
10541
if (std::error_code Err = Buf.getError ()) {
10540
10542
report_fatal_error ((" error opening host file from host file path inside of "
10541
10543
" OpenMPIRBuilder: " +
Original file line number Diff line number Diff line change 33
33
#include " llvm/IR/MDBuilder.h"
34
34
#include " llvm/IR/ReplaceConstant.h"
35
35
#include " llvm/Support/FileSystem.h"
36
+ #include " llvm/Support/VirtualFileSystem.h"
36
37
#include " llvm/TargetParser/Triple.h"
37
38
#include " llvm/Transforms/Utils/ModuleUtils.h"
38
39
@@ -6334,7 +6335,9 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
6334
6335
if (auto filepathAttr = dyn_cast<StringAttr>(attr)) {
6335
6336
llvm::OpenMPIRBuilder *ompBuilder =
6336
6337
moduleTranslation.getOpenMPBuilder ();
6337
- ompBuilder->loadOffloadInfoMetadata (filepathAttr.getValue ());
6338
+ auto VFS = llvm::vfs::getRealFileSystem ();
6339
+ ompBuilder->loadOffloadInfoMetadata (*VFS,
6340
+ filepathAttr.getValue ());
6338
6341
return success ();
6339
6342
}
6340
6343
return failure ();
You can’t perform that action at this time.
0 commit comments