Skip to content

Commit 3640d63

Browse files
committed
[SYCL-MLIR][cgeist] Do not use SingleBlock::push_back on gpu.module
This leads to pushing operations after the terminator. Signed-off-by: Victor Perez <[email protected]>
1 parent 625575d commit 3640d63

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

polygeist/tools/cgeist/Lib/clang-mlir.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,11 +2148,13 @@ MLIRASTConsumer::createMLIRFunction(const FunctionToEmit &FTE,
21482148
Module->push_back(Function);
21492149
Functions[MangledName] = cast<func::FuncOp>(Function);
21502150
break;
2151-
case InsertionContext::SYCLDevice:
2152-
mlirclang::getDeviceModule(*Module).push_back(Function);
2151+
case InsertionContext::SYCLDevice: {
2152+
gpu::GPUModuleOp deviceModule = mlirclang::getDeviceModule(*Module);
2153+
deviceModule.insert(deviceModule.getBody()->getTerminator(), Function);
21532154
DeviceFunctions[MangledName] = Function;
21542155
break;
21552156
}
2157+
}
21562158

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

0 commit comments

Comments
 (0)