Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 899647f

Browse files
author
Ivan Butygin
authored
update to llvm master (#197)
1 parent c3061dc commit 899647f

9 files changed

Lines changed: 27 additions & 24 deletions

File tree

‎mlir-compiler/llvm-sha.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ba87f99168c93461b28a4aa2d05e238ff774d57a
1+
7d09e1d7cf27ce781e83f9d388a7a3e1e6487ead

‎mlir-compiler/mlir-compiler/src/lowering.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <mlir/Dialect/StandardOps/IR/Ops.h>
1414

1515
#include <mlir/Target/LLVMIR.h>
16+
#include <mlir/Target/LLVMIR/Export.h>
1617

1718
#include <llvm/Bitcode/BitcodeWriter.h>
1819

@@ -660,6 +661,7 @@ py::bytes gen_ll_module(mlir::ModuleOp mod)
660661
std::unique_ptr<llvm::Module> ll_mod;
661662
plier::scoped_diag_handler(*mod.getContext(), diag_handler, [&]()
662663
{
664+
mlir::registerLLVMDialectTranslation(*mod.getContext());
663665
ll_mod = mlir::translateModuleToLLVMIR(mod, ll_ctx);
664666
if (nullptr == ll_mod)
665667
{

‎mlir-compiler/mlir-compiler/src/pipelines/lower_to_llvm.cpp‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ mlir::FuncOp get_to_memref_conversion_func(
273273
auto func_type = mlir::FunctionType::get(builder.getContext(), src_type, dst_type);
274274
auto loc = builder.getUnknownLoc();
275275
auto new_func = plier::add_function(builder, module, func_name, func_type);
276-
auto alwaysinline = mlir::StringAttr::get("alwaysinline", builder.getContext());
277-
new_func->setAttr("passthrough", mlir::ArrayAttr::get(alwaysinline, builder.getContext()));
276+
auto alwaysinline = mlir::StringAttr::get(builder.getContext(), "alwaysinline");
277+
new_func->setAttr("passthrough", mlir::ArrayAttr::get(builder.getContext(), alwaysinline));
278278
mlir::OpBuilder::InsertionGuard guard(builder);
279279
auto block = new_func.addEntryBlock();
280280
builder.setInsertionPointToStart(block);
@@ -326,8 +326,8 @@ mlir::FuncOp get_from_memref_conversion_func(
326326
auto func_type = mlir::FunctionType::get(builder.getContext(), src_type, dst_type);
327327
auto loc = builder.getUnknownLoc();
328328
auto new_func = plier::add_function(builder, module, func_name, func_type);
329-
auto alwaysinline = mlir::StringAttr::get("alwaysinline", builder.getContext());
330-
new_func->setAttr("passthrough", mlir::ArrayAttr::get(alwaysinline, builder.getContext()));
329+
auto alwaysinline = mlir::StringAttr::get(builder.getContext(), "alwaysinline");
330+
new_func->setAttr("passthrough", mlir::ArrayAttr::get(builder.getContext(), alwaysinline));
331331
mlir::OpBuilder::InsertionGuard guard(builder);
332332
auto block = new_func.addEntryBlock();
333333
builder.setInsertionPointToStart(block);
@@ -377,10 +377,10 @@ mlir::Attribute get_fastmath_attrs(mlir::MLIRContext& ctx)
377377
auto add_pair = [&](auto name, auto val)
378378
{
379379
const mlir::Attribute attrs[] = {
380-
mlir::StringAttr::get(name, &ctx),
381-
mlir::StringAttr::get(val, &ctx)
380+
mlir::StringAttr::get(&ctx, name),
381+
mlir::StringAttr::get(&ctx, val)
382382
};
383-
return mlir::ArrayAttr::get(attrs, &ctx);
383+
return mlir::ArrayAttr::get(&ctx, attrs);
384384
};
385385
const mlir::Attribute attrs[] = {
386386
add_pair("denormal-fp-math", "preserve-sign,preserve-sign"),
@@ -391,7 +391,7 @@ mlir::Attribute get_fastmath_attrs(mlir::MLIRContext& ctx)
391391
add_pair("unsafe-fp-math", "true"),
392392
add_pair(plier::attributes::getFastmathName(), "1"),
393393
};
394-
return mlir::ArrayAttr::get(attrs, &ctx);
394+
return mlir::ArrayAttr::get(&ctx, attrs);
395395
}
396396

397397
void fix_func_sig(LLVMTypeHelper& type_helper, mlir::FuncOp func)
@@ -805,9 +805,10 @@ class CheckForPlierTypes :
805805
void runOnOperation() override
806806
{
807807
markAllAnalysesPreserved();
808+
auto plier_dialect = getContext().getOrLoadDialect<plier::PlierDialect>();
808809
getOperation()->walk([&](mlir::Operation* op)
809810
{
810-
if (op->getName().getDialect() == plier::PlierDialect::getDialectNamespace())
811+
if (op->getName().getDialect() == plier_dialect)
811812
{
812813
op->emitOpError(": not all plier ops were translated\n");
813814
signalPassFailure();
@@ -1170,7 +1171,7 @@ struct LowerParallelToCFGPass :
11701171
mlir::OwningRewritePatternList patterns;
11711172
patterns.insert<LowerParallel>(&getContext());
11721173

1173-
mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
1174+
(void)mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
11741175
}
11751176
};
11761177

@@ -1194,7 +1195,7 @@ struct PreLLVMLowering : public mlir::PassWrapper<PreLLVMLowering, mlir::Functio
11941195
patterns.insert<ReturnOpLowering>(&getContext(),
11951196
type_helper.get_type_converter());
11961197

1197-
mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
1198+
(void)mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
11981199
}
11991200
};
12001201

@@ -1283,7 +1284,7 @@ struct LLVMLoweringPass : public mlir::PassWrapper<LLVMLoweringPass, mlir::Opera
12831284
if (failed(applyPartialConversion(m, target, std::move(patterns))))
12841285
signalPassFailure();
12851286
m->setAttr(LLVM::LLVMDialect::getDataLayoutAttrName(),
1286-
StringAttr::get(options.dataLayout.getStringRepresentation(), m.getContext()));
1287+
StringAttr::get(m.getContext(), options.dataLayout.getStringRepresentation()));
12871288
}
12881289

12891290
private:

‎mlir-compiler/mlir-compiler/src/pipelines/plier_to_linalg.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ bool check_numpy_args(llvm::ArrayRef<mlir::Value> args, unsigned expected_count)
156156
void rerun_std_pipeline(mlir::Operation* op)
157157
{
158158
assert(nullptr != op);
159-
auto marker = mlir::StringAttr::get(plier_to_std_pipeline_name(), op->getContext());
159+
auto marker = mlir::StringAttr::get(op->getContext(), plier_to_std_pipeline_name());
160160
auto mod = op->getParentOfType<mlir::ModuleOp>();
161161
assert(nullptr != mod);
162162
plier::add_pipeline_jump_marker(mod, marker);
@@ -834,7 +834,7 @@ void PostFusionOptPass::runOnOperation()
834834

835835
plier::populate_index_propagate_patterns(context, patterns);
836836

837-
mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
837+
(void)mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
838838
}
839839

840840
struct LoopInvariantCodeMotion : public mlir::OpRewritePattern<mlir::scf::ForOp>
@@ -894,7 +894,7 @@ void PostLinalgOptPass::runOnOperation()
894894

895895
plier::populate_index_propagate_patterns(context, patterns);
896896

897-
mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
897+
(void)mlir::applyPatternsAndFoldGreedily(getOperation(), std::move(patterns));
898898
}
899899

900900
void populate_plier_to_linalg_gen_pipeline(mlir::OpPassManager& pm)

‎mlir-compiler/mlir-compiler/src/py_linalg_resolver.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ auto get_iterators(py::list iterators, mlir::MLIRContext& ctx)
304304
llvm::SmallVector<llvm::StringRef> ret(iterators.size());
305305
for (auto it : llvm::enumerate(iterators))
306306
{
307-
ret[it.index()] = mlir::StringAttr::get(it.value().cast<std::string>(), &ctx).getValue();
307+
ret[it.index()] = mlir::StringAttr::get(&ctx, it.value().cast<std::string>()).getValue();
308308
}
309309
return ret;
310310
}
@@ -896,7 +896,7 @@ py::object reshape_impl(py::capsule context, py::handle tensor, py::int_ out_dim
896896
{
897897
affine_maps[index] = get_affine_map_attr(obj, *builder.getContext());
898898
});
899-
auto affine_maps_attr = mlir::ArrayAttr::get(affine_maps, builder.getContext());
899+
auto affine_maps_attr = mlir::ArrayAttr::get(builder.getContext(), affine_maps);
900900
auto reshape = builder.create<mlir::linalg::TensorReshapeOp>(loc, new_type, tensor_val, affine_maps_attr);
901901
return ctx.context.create_var(context, reshape);
902902
}

‎mlir-compiler/plier/src/compiler/compiler.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct PassManagerSchedule
136136
auto it = stages_map.find(jump.data());
137137
assert(it != stages_map.end());
138138
assert(nullptr != it->second);
139-
auto name = mlir::StringAttr::get(jump, &ctx);
139+
auto name = mlir::StringAttr::get(&ctx, jump);
140140
stage.stage->add_jump(name, it->second);
141141
}
142142
}

‎mlir-compiler/plier/src/dialect.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ void PyCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir
173173
kw_names.reserve(kwargs.size());
174174
for (auto& a : kwargs)
175175
{
176-
kw_names.push_back(mlir::StringAttr::get(a.first, ctx));
176+
kw_names.push_back(mlir::StringAttr::get(ctx, a.first));
177177
all_args.push_back(a.second);
178178
}
179179
PyCallOp::build(builder, state, PyType::getUndefined(state.getContext()),
180-
func, all_args, func_name, kw_start, mlir::ArrayAttr::get(kw_names, ctx));
180+
func, all_args, func_name, kw_start, mlir::ArrayAttr::get(ctx, kw_names));
181181
}
182182

183183
void BuildTupleOp::build(mlir::OpBuilder &builder, mlir::OperationState &state,

‎mlir-compiler/plier/src/rewrites/cse.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mlir::LogicalResult simplifyRegion(ScopedMapTy& map, mlir::Region& region, mlir:
4242
bool success = false;
4343
for (auto &inst : llvm::make_early_inc_range(region.front()))
4444
{
45-
if (inst.isKnownTerminator())
45+
if (inst.hasTrait<mlir::OpTrait::IsTerminator>())
4646
{
4747
break;
4848
}

‎mlir-compiler/plier/src/transforms/pipeline_utils.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void plier::add_pipeline_jump_marker(mlir::ModuleOp module, mlir::StringAttr nam
3434
{
3535
name_list.insert(it, name);
3636
}
37-
module->setAttr(jump_markers, mlir::ArrayAttr::get(name_list, module.getContext()));
37+
module->setAttr(jump_markers, mlir::ArrayAttr::get(module.getContext(), name_list));
3838
}
3939

4040

@@ -56,5 +56,5 @@ void plier::remove_pipeline_jump_marker(mlir::ModuleOp module, mlir::StringAttr
5656
});
5757
assert(it != name_list.end());
5858
name_list.erase(it);
59-
module->setAttr(jump_markers, mlir::ArrayAttr::get(name_list, module.getContext()));
59+
module->setAttr(jump_markers, mlir::ArrayAttr::get(module.getContext(), name_list));
6060
}

0 commit comments

Comments
 (0)