Skip to content

[SYCL-MLIR][cgeist] Do not use SingleBlock::push_back on gpu.module #11270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions mlir/include/mlir/IR/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ class Block : public IRObjectWithUseList<BlockOperand>,
//===--------------------------------------------------------------------===//

/// Get the terminator operation of this block. This function asserts that
/// the block has a valid terminator operation.
/// the block might have a valid terminator operation.
Operation *getTerminator();

/// Check whether this block has a terminator.
bool hasTerminator();
/// Check whether this block might have a terminator.
bool mightHaveTerminator();

//===--------------------------------------------------------------------===//
// Predecessors and successors.
Expand Down
4 changes: 0 additions & 4 deletions mlir/include/mlir/IR/OpDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,10 +932,6 @@ struct SingleBlock : public TraitBase<ConcreteType, SingleBlock> {
}
template <typename OpT = ConcreteType>
enable_if_single_region<OpT> insert(Block::iterator insertPt, Operation *op) {
Block *body = getBody();
// Insert op before the block's terminator if it has one
if (insertPt == body->end() && body->hasTerminator())
insertPt = Block::iterator(body->getTerminator());
getBody()->getOperations().insert(insertPt, op);
}
};
Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/IR/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ void Block::eraseArguments(function_ref<bool(BlockArgument)> shouldEraseFn) {
//===----------------------------------------------------------------------===//

/// Get the terminator operation of this block. This function asserts that
/// the block has a valid terminator operation.
/// the block might have a valid terminator operation.
Operation *Block::getTerminator() {
assert(hasTerminator());
assert(mightHaveTerminator());
return &back();
}

/// Check whether this block has a terminator.
bool Block::hasTerminator() {
/// Check whether this block might have a terminator.
bool Block::mightHaveTerminator() {
return !empty() && back().mightHaveTrait<OpTrait::IsTerminator>();
}

Expand Down
6 changes: 4 additions & 2 deletions polygeist/tools/cgeist/Lib/clang-mlir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2148,11 +2148,13 @@ MLIRASTConsumer::createMLIRFunction(const FunctionToEmit &FTE,
Module->push_back(Function);
Functions[MangledName] = cast<func::FuncOp>(Function);
break;
case InsertionContext::SYCLDevice:
mlirclang::getDeviceModule(*Module).push_back(Function);
case InsertionContext::SYCLDevice: {
gpu::GPUModuleOp deviceModule = mlirclang::getDeviceModule(*Module);
deviceModule.insert(deviceModule.getBody()->getTerminator(), Function);
DeviceFunctions[MangledName] = Function;
break;
}
}

LLVM_DEBUG(llvm::dbgs() << "Created MLIR function: " << Function << "\n");

Expand Down