Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
938091d
[Flang][mlir] - Translation of delayed privatization for deferred tar…
bhandarkar-pranav Jun 17, 2025
f72152a
Add some comments and clean up some codoe
bhandarkar-pranav Aug 26, 2025
c859bbc
Fix CHECK stmts in test to account for constant folding done by the g…
bhandarkar-pranav Aug 26, 2025
697cc4f
Fix clang-format issues
bhandarkar-pranav Aug 27, 2025
bc107cd
Checkpoint commit, working with operaiton->walk
bhandarkar-pranav Sep 5, 2025
f7dacb3
Address more comments from tblah and meinersbur
bhandarkar-pranav Sep 8, 2025
f4a13ea
Handle boxchars
bhandarkar-pranav Sep 10, 2025
c8fad74
fix testcases
bhandarkar-pranav Sep 11, 2025
e74fa7d
Revert "Fix CHECK stmts in test to account for constant folding done …
bhandarkar-pranav Sep 11, 2025
343f7ec
Fix more testcases
bhandarkar-pranav Sep 11, 2025
41bb5b2
Reset some tests back to their old states
bhandarkar-pranav Sep 11, 2025
3264bfe
Undo empty line removal
bhandarkar-pranav Sep 11, 2025
b9fb8ce
Add back some CHECK statements in flang/test/Fir/target.fir and flang…
bhandarkar-pranav Sep 11, 2025
7032cae
use the init region to initialize the heap allocated private variable
bhandarkar-pranav Sep 17, 2025
269c575
use the copy region to copy the private variable into its heap alloca…
bhandarkar-pranav Sep 17, 2025
3109e4f
Fix for boxchars is working
bhandarkar-pranav Sep 18, 2025
d5b9c27
Adjust mlir/test/Dialect/LLVMIR/omp-offload-privatization-prepare.mli…
bhandarkar-pranav Sep 18, 2025
8bd4359
Address minor review comments
bhandarkar-pranav Sep 18, 2025
a393ff1
Handle the case where varPtr is a blockargument. - Take the varType f…
bhandarkar-pranav Sep 24, 2025
28ec66a
clean up the pass a little bit
bhandarkar-pranav Sep 24, 2025
d95799d
Do not include OpenMPOffloadPrivatizationPrepare.h in Pipelines.h. In…
bhandarkar-pranav Sep 24, 2025
0829719
Move PrepareForOMPOffloadPrivatizationPass from Transforms in LLVMIR …
bhandarkar-pranav Sep 25, 2025
01d1f69
Add a lit test for boxchars
bhandarkar-pranav Sep 25, 2025
d595572
Make createFuncForRegionAndCallIt take an arrayref as argumen
bhandarkar-pranav Sep 26, 2025
bf949fa
clean up
bhandarkar-pranav Sep 26, 2025
72a769f
make clang-format happy
bhandarkar-pranav Sep 26, 2025
061669f
Add some more comments and fix a typo
bhandarkar-pranav Sep 29, 2025
e036923
Checkpoint commit - dealloc working - need to fix lit testcase to tes…
bhandarkar-pranav Oct 4, 2025
5b78bab
fix lit testcase for dealloc region generation
bhandarkar-pranav Oct 5, 2025
b34b0e0
fix clang-format problems
bhandarkar-pranav Oct 6, 2025
4c5d8d8
Update test for differences between downstream and upstream
bhandarkar-pranav Oct 6, 2025
6288da9
Make changes requested by reviewers - Formatting changes requested by…
bhandarkar-pranav Oct 15, 2025
0a4ef58
Update test (again) for differences between downstream and upstream
bhandarkar-pranav Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/include/flang/Optimizer/Passes/Pipelines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "mlir/Conversion/SCFToControlFlow/SCFToControlFlow.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
#include "mlir/Dialect/LLVMIR/Transforms/OpenMPOffloadPrivatizationPrepare.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/Passes.h"
Expand Down
7 changes: 7 additions & 0 deletions flang/lib/Optimizer/Passes/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ void createMLIRToLLVMPassPipeline(mlir::PassManager &pm,

// Add codegen pass pipeline.
fir::createDefaultFIRCodeGenPassPipeline(pm, config, inputFilename);

// Run a pass to prepare for translation of delayed privatization in the
// context of deferred target tasks.
addNestedPassConditionally<mlir::LLVM::LLVMFuncOp>(
pm, disableFirToLlvmIr, [&]() {
return mlir::LLVM::createPrepareForOMPOffloadPrivatizationPass();
});
}

} // namespace fir
2 changes: 2 additions & 0 deletions flang/test/Fir/basic-program.fir
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,6 @@ func.func @_QQmain() {
// PASSES-NEXT: LowerNontemporalPass
// PASSES-NEXT: FIRToLLVMLowering
// PASSES-NEXT: ReconcileUnrealizedCasts
// PASSES-NEXT: 'llvm.func' Pipeline
// PASSES-NEXT: PrepareForOMPOffloadPrivatizationPass
// PASSES-NEXT: LLVMIRLoweringPass
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===- OpenMPOffloadPrivatizationPrepare.h -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_LLVMIR_TRANSFORMS_PREPAREFOROMPOFFLOADPRIVATIZATIONPASS_H
#define MLIR_DIALECT_LLVMIR_TRANSFORMS_PREPAREFOROMPOFFLOADPRIVATIZATIONPASS_H

#include <memory>

namespace mlir {
class Pass;
namespace LLVM {
#define GEN_PASS_DECL_PREPAREFOROMPOFFLOADPRIVATIZATIONPASS
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
} // namespace LLVM
} // namespace mlir

#endif // MLIR_DIALECT_LLVMIR_TRANSFORMS_PREPAREFOROMPOFFLOADPRIVATIZATIONPASS_H
12 changes: 12 additions & 0 deletions mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@ def DIScopeForLLVMFuncOpPass : Pass<"ensure-debug-info-scope-on-llvm-func", "::m
];
}

def PrepareForOMPOffloadPrivatizationPass : Pass<"omp-offload-privatization-prepare", "::mlir::LLVM::LLVMFuncOp"> {
let summary = "Prepare OpenMP maps for privatization for deferred target tasks";
let description = [{
When generating LLVMIR for privatized variables in an OpenMP offloading directive (eg. omp::TargetOp)
that creates a deferred target task (when the nowait clause is used), we need to copy the privatized
variable out of the stack of the generating task and into the heap so that the deferred target task
can still access it. However, if such a privatized variable is also mapped, typically the case for
allocatables, then the corresponding `omp::MapInfoOp` needs to be fixed up to map the new heap-allocated
variable and not the original variable.
}];
let dependentDialects = ["LLVM::LLVMDialect", "mlir::omp::OpenMPDialect"];
}
#endif // MLIR_DIALECT_LLVMIR_TRANSFORMS_PASSES
2 changes: 2 additions & 0 deletions mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ add_mlir_dialect_library(MLIRLLVMIRTransforms
LegalizeForExport.cpp
OptimizeForNVVM.cpp
RequestCWrappers.cpp
OpenMPOffloadPrivatizationPrepare.cpp

DEPENDS
MLIRLLVMPassIncGen
Expand All @@ -18,4 +19,5 @@ add_mlir_dialect_library(MLIRLLVMIRTransforms
MLIRPass
MLIRTransforms
MLIRNVVMDialect
MLIROpenMPDialect
)
Loading
Loading