[Mlir-commits] [mlir] 8cf6bcf - [mlir][llvm] Add assert in CallOp builder (#76240)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Dec 27 08:08:39 PST 2023


Author: gitoleg
Date: 2023-12-27T17:08:35+01:00
New Revision: 8cf6bcf5a30673dd8a234ae3ef4ab4c1e63786b1

URL: https://github.com/llvm/llvm-project/commit/8cf6bcf5a30673dd8a234ae3ef4ab4c1e63786b1
DIFF: https://github.com/llvm/llvm-project/commit/8cf6bcf5a30673dd8a234ae3ef4ab4c1e63786b1.diff

LOG: [mlir][llvm] Add assert in CallOp builder (#76240)

This commit adds an assert in one of the CallOp builders to ensure it is not use to create an indirect call. Otherwise, the callee type would include the callee pointer type which is handed in as first argument.

Added: 
    

Modified: 
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 458bf83eac17f8..64388a9a01812a 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -908,6 +908,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
 
 void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
                    FlatSymbolRefAttr callee, ValueRange args) {
+  assert(callee && "expected non-null callee in direct call builder");
   build(builder, state, results,
         TypeAttr::get(getLLVMFuncType(builder.getContext(), results, args)),
         callee, args, /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,


        


More information about the Mlir-commits mailing list