[Mlir-commits] [mlir] fdaf2f9 - [mlir][LLVM] Fix export call mapping for calls with a result
Christian Ulmann
llvmlistbot at llvm.org
Mon Aug 21 22:32:39 PDT 2023
Author: Christian Ulmann
Date: 2023-08-22T05:25:10Z
New Revision: fdaf2f9c96fa1d1ea46cdf09ec372056b32cf2e0
URL: https://github.com/llvm/llvm-project/commit/fdaf2f9c96fa1d1ea46cdf09ec372056b32cf2e0
DIFF: https://github.com/llvm/llvm-project/commit/fdaf2f9c96fa1d1ea46cdf09ec372056b32cf2e0.diff
LOG: [mlir][LLVM] Fix export call mapping for calls with a result
This commit adds a missed update of the call mapping in the LLVM export
for calls with no result. Before, these calls were not inserted and
thus, the export dropped branch weights on them.
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D158453
Added:
Modified:
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/llvmir.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
index b9e1c358eccfec..9b438090c84cac 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -220,12 +220,10 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
moduleTranslation.setTBAAMetadata(callOp, call);
// If the called function has a result, remap the corresponding value. Note
// that LLVM IR dialect CallOp has either 0 or 1 result.
- if (opInst.getNumResults() != 0) {
+ if (opInst.getNumResults() != 0)
moduleTranslation.mapValue(opInst.getResult(0), call);
- return success();
- }
// Check that LLVM call returns void for 0-result functions.
- if (!call->getType()->isVoidTy())
+ else if (!call->getType()->isVoidTy())
return failure();
moduleTranslation.mapCall(callOp, call);
return success();
diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index 90991e79e23dc2..308bf41c290a58 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1838,6 +1838,19 @@ llvm.func @call_branch_weights() {
// -----
+llvm.func @fn() -> i32
+
+// CHECK-LABEL: @call_branch_weights
+llvm.func @call_branch_weights() {
+ // CHECK: !prof ![[NODE:[0-9]+]]
+ %res = llvm.call @fn() {branch_weights = array<i32 : 42>} : () -> i32
+ llvm.return
+}
+
+// CHECK: ![[NODE]] = !{!"branch_weights", i32 42}
+
+// -----
+
llvm.func @foo()
llvm.func @__gxx_personality_v0(...) -> i32
More information about the Mlir-commits
mailing list