Skip to content

Commit 59ead70

Browse files
committed
Removed WeightedBranchOpInterface from llvm.call.
1 parent c8b6770 commit 59ead70

File tree

3 files changed

+19
-30
lines changed

3 files changed

+19
-30
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -739,8 +739,7 @@ def LLVM_CallOp
739739
"call", [AttrSizedOperandSegments,
740740
DeclareOpInterfaceMethods<FastmathFlagsInterface>,
741741
DeclareOpInterfaceMethods<CallOpInterface>,
742-
DeclareOpInterfaceMethods<SymbolUserOpInterface>,
743-
DeclareOpInterfaceMethods<WeightedBranchOpInterface>]> {
742+
DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
744743
let summary = "Call to an LLVM function.";
745744
let description = [{
746745
In LLVM IR, functions may return either 0 or 1 value. LLVM IR dialect
@@ -789,21 +788,16 @@ def LLVM_CallOp
789788
OptionalAttr<FlatSymbolRefAttr>:$callee,
790789
Variadic<LLVM_Type>:$callee_operands,
791790
DefaultValuedAttr<LLVM_FastmathFlagsAttr, "{}">:$fastmathFlags,
792-
OptionalAttr<DenseI32ArrayAttr>:$branch_weights,
793791
DefaultValuedAttr<CConv, "CConv::C">:$CConv,
794792
DefaultValuedAttr<TailCallKind, "TailCallKind::None">:$TailCallKind,
795793
OptionalAttr<LLVM_MemoryEffectsAttr>:$memory_effects,
796-
UnitAttr:$convergent,
797-
UnitAttr:$no_unwind,
798-
UnitAttr:$will_return,
794+
UnitAttr:$convergent, UnitAttr:$no_unwind, UnitAttr:$will_return,
799795
VariadicOfVariadic<LLVM_Type, "op_bundle_sizes">:$op_bundle_operands,
800796
DenseI32ArrayAttr:$op_bundle_sizes,
801797
OptionalAttr<ArrayAttr>:$op_bundle_tags,
802798
OptionalAttr<DictArrayAttr>:$arg_attrs,
803-
OptionalAttr<DictArrayAttr>:$res_attrs,
804-
UnitAttr:$no_inline,
805-
UnitAttr:$always_inline,
806-
UnitAttr:$inline_hint);
799+
OptionalAttr<DictArrayAttr>:$res_attrs, UnitAttr:$no_inline,
800+
UnitAttr:$always_inline, UnitAttr:$inline_hint);
807801
// Append the aliasing related attributes defined in LLVM_MemAccessOpBase.
808802
let arguments = !con(args, aliasAttrs);
809803
let results = (outs Optional<LLVM_Type>:$result);

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,6 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
958958
assert(callee && "expected non-null callee in direct call builder");
959959
build(builder, state, results,
960960
/*var_callee_type=*/nullptr, callee, args, /*fastmathFlags=*/nullptr,
961-
/*branch_weights=*/nullptr,
962961
/*CConv=*/nullptr, /*TailCallKind=*/nullptr,
963962
/*memory_effects=*/nullptr,
964963
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
@@ -988,7 +987,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
988987
build(builder, state, getCallOpResultTypes(calleeType),
989988
getCallOpVarCalleeType(calleeType), callee, args,
990989
/*fastmathFlags=*/nullptr,
991-
/*branch_weights=*/nullptr, /*CConv=*/nullptr,
990+
/*CConv=*/nullptr,
992991
/*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
993992
/*convergent=*/nullptr,
994993
/*no_unwind=*/nullptr, /*will_return=*/nullptr,
@@ -1005,7 +1004,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
10051004
build(builder, state, getCallOpResultTypes(calleeType),
10061005
getCallOpVarCalleeType(calleeType),
10071006
/*callee=*/nullptr, args,
1008-
/*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
1007+
/*fastmathFlags=*/nullptr,
10091008
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
10101009
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
10111010
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
@@ -1021,7 +1020,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
10211020
auto calleeType = func.getFunctionType();
10221021
build(builder, state, getCallOpResultTypes(calleeType),
10231022
getCallOpVarCalleeType(calleeType), SymbolRefAttr::get(func), args,
1024-
/*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
1023+
/*fastmathFlags=*/nullptr,
10251024
/*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
10261025
/*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
10271026
/*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},

mlir/test/Target/LLVMIR/llvmir-invalid.mlir

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -451,20 +451,16 @@ llvm.func extern_weak @extern_func()
451451

452452
// -----
453453

454-
llvm.func @fn()
455-
456-
llvm.func @call_branch_weights() {
457-
// expected-error @below{{expects number of branch weights to match number of successors: 1 vs 0}}
458-
llvm.call @fn() {branch_weights = array<i32 : 42>} : () -> ()
459-
llvm.return
460-
}
461-
462-
// -----
463-
464-
llvm.func @fn() -> i32
465-
466-
llvm.func @call_branch_weights() {
467-
// expected-error @below{{expects number of branch weights to match number of successors: 1 vs 0}}
468-
%res = llvm.call @fn() {branch_weights = array<i32 : 42>} : () -> i32
469-
llvm.return
454+
llvm.func @invoke_branch_weights_callee()
455+
llvm.func @__gxx_personality_v0(...) -> i32
456+
457+
llvm.func @invoke_branch_weights() -> i32 attributes {personality = @__gxx_personality_v0} {
458+
%0 = llvm.mlir.constant(1 : i32) : i32
459+
// expected-error @below{{expects number of branch weights to match number of successors: 1 vs 2}}
460+
llvm.invoke @invoke_branch_weights_callee() to ^bb2 unwind ^bb1 {branch_weights = array<i32 : 42>} : () -> ()
461+
^bb1: // pred: ^bb0
462+
%1 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
463+
llvm.br ^bb2
464+
^bb2: // 2 preds: ^bb0, ^bb1
465+
llvm.return %0 : i32
470466
}

0 commit comments

Comments
 (0)