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 @@ -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" 
@@ -10531,11 +10532,12 @@ void OpenMPIRBuilder::loadOffloadInfoMetadata(Module &M) {
1053110532  }
1053210533}
1053310534
10534- void  OpenMPIRBuilder::loadOffloadInfoMetadata (StringRef HostFilePath) {
10535+ void  OpenMPIRBuilder::loadOffloadInfoMetadata (vfs::FileSystem &VFS,
10536+                                               StringRef HostFilePath) {
1053510537  if  (HostFilePath.empty ())
1053610538    return ;
1053710539
10538-   auto  Buf = MemoryBuffer::getFile (HostFilePath);
10540+   auto  Buf = VFS. getBufferForFile (HostFilePath);
1053910541  if  (std::error_code Err = Buf.getError ()) {
1054010542    report_fatal_error ((" error opening host file from host file path inside of " 
1054110543                        " OpenMPIRBuilder: " 
Original file line number Diff line number Diff line change 3333#include  " llvm/IR/MDBuilder.h" 
3434#include  " llvm/IR/ReplaceConstant.h" 
3535#include  " llvm/Support/FileSystem.h" 
36+ #include  " llvm/Support/VirtualFileSystem.h" 
3637#include  " llvm/TargetParser/Triple.h" 
3738#include  " llvm/Transforms/Utils/ModuleUtils.h" 
3839
@@ -6334,7 +6335,9 @@ LogicalResult OpenMPDialectLLVMIRTranslationInterface::amendOperation(
63346335              if  (auto  filepathAttr = dyn_cast<StringAttr>(attr)) {
63356336                llvm::OpenMPIRBuilder *ompBuilder =
63366337                    moduleTranslation.getOpenMPBuilder ();
6337-                 ompBuilder->loadOffloadInfoMetadata (filepathAttr.getValue ());
6338+                 auto  VFS = llvm::vfs::getRealFileSystem ();
6339+                 ompBuilder->loadOffloadInfoMetadata (*VFS,
6340+                                                     filepathAttr.getValue ());
63386341                return  success ();
63396342              }
63406343              return  failure ();
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments