Skip to content

Commit d6b89f0

Browse files
wsmosesftynse
andauthored
Apply suggestions from code review
Co-authored-by: Oleksandr "Alex" Zinenko <[email protected]>
1 parent 7c849d7 commit d6b89f0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ struct OpToFuncCallLoweringBase : public ConvertOpToLLVMPattern<SourceOp> {
4747
SmallVector<Value, 1> castedOperands;
4848
for (Value operand : adaptor.getOperands())
4949
castedOperands.push_back(
50-
((const DerivedTy *)this)->maybeCast(operand, rewriter));
50+
static_cast<const DerivedTy *>(this)->maybeCast(operand, rewriter));
5151

5252
Type resultType = castedOperands.front().getType();
5353
Type funcType = getFunctionType(resultType, castedOperands);
5454
StringRef funcName =
55-
((const DerivedTy *)this)
55+
static_cast<const DerivedTy *>(this)
5656
->getFunctionName(
5757
cast<LLVM::LLVMFunctionType>(funcType).getReturnType(), op);
5858
if (funcName.empty())
@@ -85,11 +85,13 @@ struct OpToFuncCallLoweringBase : public ConvertOpToLLVMPattern<SourceOp> {
8585
using LLVM::LLVMFuncOp;
8686

8787
auto funcAttr = StringAttr::get(op->getContext(), funcName);
88-
Operation *funcOp = SymbolTable::lookupNearestSymbolFrom(op, funcAttr);
88+
auto funcOp = SymbolTable::lookupNearestSymbolFrom<LLVMFuncOp>(op, funcAttr);
8989
if (funcOp)
90-
return cast<LLVMFuncOp>(*funcOp);
90+
return funcOp;
9191

92-
mlir::OpBuilder b(op->getParentOfType<FunctionOpInterface>());
92+
auto parentFunc = op->getParentOfType<FunctionOpInterface>();
93+
assert(parentFunc && "expected there to be a parent function");
94+
OpBuilder b(parentFunc);
9395
return b.create<LLVMFuncOp>(op->getLoc(), funcName, funcType);
9496
}
9597
};

0 commit comments

Comments
 (0)