Skip to content
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
5 changes: 5 additions & 0 deletions mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ struct OpToFuncCallLowering : public ConvertOpToLLVMPattern<SourceOp> {
SourceOp>::value,
"expected op with same operand and result types");

if (!op->template getParentOfType<FunctionOpInterface>()) {
return rewriter.notifyMatchFailure(
op, "expected op to be within a function region");
}

SmallVector<Value, 1> castedOperands;
for (Value operand : adaptor.getOperands())
castedOperands.push_back(maybeCast(operand, rewriter));
Expand Down
16 changes: 15 additions & 1 deletion mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: mlir-opt %s -convert-math-to-rocdl -split-input-file | FileCheck %s
// RUN: mlir-opt %s -convert-math-to-rocdl -allow-unregistered-dialect -split-input-file | FileCheck %s

module @test_module {
// CHECK: llvm.func @__ocml_fmod_f16(f16, f16) -> f16
Expand Down Expand Up @@ -481,3 +481,17 @@ module @test_module {
func.return %resultf16, %resultf32, %resultf64, %resultbf16 : f16, f32, f64, bf16
}
}

// -----

// Math operation not inside function
// Ensure it not crash

module {
"test.some_op_with_region"() ({
^bb0(%arg0: f64):
// CHECK: math.atan
%0 = math.atan %arg0 : f64
"test.possible_terminator"() : () -> ()
}) : () -> ()
}
Loading