Skip to content

Commit 2747193

Browse files
authored
[Flang][MLIR][OpenMP] Remove the early outlining interface (#78450)
After the removal of the OpenMP early outlining MLIR pass in #67319, the `EarlyOutliningInterface` stopped doing any useful work. It used to be necessary to tie the name of the function from which a target region was outlined to that new function, so it would be used when translating to LLVM IR in place of the outlined function's name. This is not necessary anymore, so this patch removes all references to this interface and uses of the `omp.outline_parent_name` discardable attribute in tests.
1 parent fb2c6bb commit 2747193

File tree

9 files changed

+2
-115
lines changed

9 files changed

+2
-115
lines changed

flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ mangleExternalName(const std::pair<fir::NameUniquer::NameKind,
4444
appendUnderscore);
4545
}
4646

47-
/// Update the early outlining parent name
48-
void updateEarlyOutliningParentName(mlir::func::FuncOp funcOp,
49-
bool appendUnderscore) {
50-
if (auto earlyOutlineOp = llvm::dyn_cast<mlir::omp::EarlyOutliningInterface>(
51-
funcOp.getOperation())) {
52-
auto oldName = earlyOutlineOp.getParentName();
53-
if (oldName != "") {
54-
auto dName = fir::NameUniquer::deconstruct(oldName);
55-
std::string newName = mangleExternalName(dName, appendUnderscore);
56-
earlyOutlineOp.setParentName(newName);
57-
}
58-
}
59-
}
60-
6147
//===----------------------------------------------------------------------===//
6248
// Rewrite patterns
6349
//===----------------------------------------------------------------------===//
@@ -93,8 +79,6 @@ struct MangleNameOnFuncOp : public mlir::OpRewritePattern<mlir::func::FuncOp> {
9379
op->setAttr(fir::getInternalFuncNameAttrName(),
9480
mlir::StringAttr::get(op->getContext(), oldName));
9581
}
96-
97-
updateEarlyOutliningParentName(op, appendUnderscore);
9882
rewriter.finalizeOpModification(op);
9983
return ret;
10084
}

flang/test/Fir/external-mangling.fir

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,3 @@ func.func @_QPcaller() {
8989

9090
// LLVMIR-NOUNDER: llvm.call @callee() : () -> ()
9191
// LLVMIR-NOUNDER: llvm.call @callee() : () -> ()
92-
93-
// -----
94-
95-
func.func @_QPwriteindex_omp_outline_0() attributes {omp.outline_parent_name = "_QPwriteindex"} {
96-
return
97-
}
98-
99-
// CHECK-UNDER: attributes {fir.internal_name = "_QPwriteindex_omp_outline_0", omp.outline_parent_name = "writeindex_"}
100-
// CHECK-NOUNDER: attributes {fir.internal_name = "_QPwriteindex_omp_outline_0", omp.outline_parent_name = "writeindex"}

mlir/include/mlir/Dialect/OpenMP/OpenMPInterfaces.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ struct DeclareTargetDefaultModel
3636
: public DeclareTargetInterface::ExternalModel<DeclareTargetDefaultModel<T>,
3737
T> {};
3838

39-
template <typename T>
40-
struct EarlyOutliningDefaultModel
41-
: public EarlyOutliningInterface::ExternalModel<
42-
EarlyOutliningDefaultModel<T>, T> {};
43-
4439
} // namespace mlir::omp
4540

4641
#endif // MLIR_DIALECT_OPENMP_OPENMPINTERFACES_H_

mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -288,44 +288,4 @@ def OffloadModuleInterface : OpInterface<"OffloadModuleInterface"> {
288288
];
289289
}
290290

291-
def EarlyOutliningInterface : OpInterface<"EarlyOutliningInterface"> {
292-
let description = [{
293-
FuncOps that are a result of early outlining should have this interface.
294-
}];
295-
296-
let cppNamespace = "::mlir::omp";
297-
298-
let methods = [
299-
InterfaceMethod<
300-
/*description=*/[{
301-
Set a StringAttr on an outlined target region function containing the
302-
name of the parent function where the target region was outlined
303-
from. The parent name is used to construct the kernel names for target
304-
regions.
305-
}],
306-
/*retTy=*/"void",
307-
/*methodName=*/"setParentName",
308-
(ins "std::string":$parentName), [{}], [{
309-
$_op->setAttr(
310-
mlir::StringAttr::get($_op->getContext(),
311-
llvm::Twine{"omp.outline_parent_name"}),
312-
mlir::StringAttr::get($_op->getContext(), parentName));
313-
}]>,
314-
315-
InterfaceMethod<
316-
/*description=*/[{
317-
Returns the parent function name from where the target op was outlined
318-
from. If it doesn't exist it returns an empty string.
319-
}],
320-
/*retTy=*/"llvm::StringRef",
321-
/*methodName=*/"getParentName",
322-
(ins), [{}], [{
323-
if (Attribute parentName = $_op->getAttr("omp.outline_parent_name"))
324-
if (::llvm::isa<mlir::StringAttr>(parentName))
325-
return ::llvm::dyn_cast<mlir::StringAttr>(parentName).getValue();
326-
return {};
327-
}]>
328-
];
329-
}
330-
331291
#endif // OpenMP_OPS_INTERFACES

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ void OpenMPDialect::initialize() {
9898
*getContext());
9999
mlir::func::FuncOp::attachInterface<
100100
mlir::omp::DeclareTargetDefaultModel<mlir::func::FuncOp>>(*getContext());
101-
102-
// Attach default early outlining interface to func ops.
103-
mlir::func::FuncOp::attachInterface<
104-
mlir::omp::EarlyOutliningDefaultModel<mlir::func::FuncOp>>(*getContext());
105-
mlir::LLVM::LLVMFuncOp::attachInterface<
106-
mlir::omp::EarlyOutliningDefaultModel<mlir::LLVM::LLVMFuncOp>>(
107-
*getContext());
108101
}
109102

110103
//===----------------------------------------------------------------------===//

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,13 +2362,6 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,
23622362
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
23632363
StringRef parentName = opInst.getParentOfType<LLVM::LLVMFuncOp>().getName();
23642364

2365-
// Override parent name if early outlining function
2366-
if (auto earlyOutlineOp = llvm::dyn_cast<mlir::omp::EarlyOutliningInterface>(
2367-
opInst.getParentOfType<LLVM::LLVMFuncOp>().getOperation())) {
2368-
llvm::StringRef outlineParentName = earlyOutlineOp.getParentName();
2369-
parentName = outlineParentName.empty() ? parentName : outlineParentName;
2370-
}
2371-
23722365
llvm::TargetRegionEntryInfo entryInfo;
23732366

23742367
if (!getTargetEntryUniqueInfo(entryInfo, targetOp, parentName))

mlir/test/Dialect/OpenMP/attr.mlir

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,3 @@ llvm.mlir.global external @omp_decl_tar_data_any_enter() {omp.declare_target = #
181181
%0 = llvm.mlir.constant(1 : i32) : i32
182182
llvm.return %0 : i32
183183
}
184-
185-
// ----
186-
187-
// CHECK-LABEL: func @_QPwriteindex_omp_outline_0
188-
// CHECK-SAME: {{.*}} attributes {omp.outline_parent_name = "QPwriteindex"} {
189-
func.func @_QPwriteindex_omp_outline_0() attributes {omp.outline_parent_name = "QPwriteindex"} {
190-
return
191-
}

mlir/test/Target/LLVMIR/omptarget-parallel-llvm.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// for omp target parallel construct
55

66
module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memory_space", 5 : ui32>>, llvm.data_layout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9", llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true, omp.target = #omp.target<target_cpu = "gfx90a", target_features = "">} {
7-
llvm.func @_QQmain_omp_outline_1(%arg0: !llvm.ptr) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QQmain"} {
7+
llvm.func @_QQmain_omp_outline_1(%arg0: !llvm.ptr) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>} {
88
%0 = omp.map_info var_ptr(%arg0 : !llvm.ptr, i32) map_clauses(from) capture(ByRef) -> !llvm.ptr {name = "d"}
99
omp.target map_entries(%0 -> %arg2 : !llvm.ptr) {
1010
^bb0(%arg2: !llvm.ptr):
@@ -18,7 +18,7 @@ module attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.alloca_memo
1818
llvm.return
1919
}
2020

21-
llvm.func @_test_num_threads(%arg0: !llvm.ptr) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>, omp.outline_parent_name = "_QQmain"} {
21+
llvm.func @_test_num_threads(%arg0: !llvm.ptr) attributes {omp.declare_target = #omp.declaretarget<device_type = (host), capture_clause = (to)>} {
2222
%0 = omp.map_info var_ptr(%arg0 : !llvm.ptr, i32) map_clauses(from) capture(ByRef) -> !llvm.ptr {name = "d"}
2323
omp.target map_entries(%0 -> %arg2 : !llvm.ptr) {
2424
^bb0(%arg2: !llvm.ptr):

mlir/test/Target/LLVMIR/omptarget-region-llvm-target-device.mlir

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)