diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2025-07-18 13:26:00 -0700 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2025-07-18 13:26:00 -0700 |
| commit | 9bf3524731070cadc6175707314f3b6ca37190d5 (patch) | |
| tree | 86dcab7604336b01ae938fe81062c29ff69efba8 /mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp | |
| parent | 3a84c15cc13b6daf8e812592898ab6c7f19091a9 (diff) | |
| parent | 4f43f0606c3d7e1ce6d069583b5e59f036e112ce (diff) | |
Created using spr 1.3.6-beta.1
Diffstat (limited to 'mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp')
| -rw-r--r-- | mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp index 88a8b7fb185c..13a084407e53 100644 --- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp +++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp @@ -138,11 +138,12 @@ struct BranchOpLowering : public ConvertOpToLLVMPattern<cf::BranchOp> { TypeRange(adaptor.getOperands())); if (failed(convertedBlock)) return failure(); + DictionaryAttr attrs = op->getAttrDictionary(); Operation *newOp = rewriter.replaceOpWithNewOp<LLVM::BrOp>( op, adaptor.getOperands(), *convertedBlock); // TODO: We should not just forward all attributes like that. But there are // existing Flang tests that depend on this behavior. - newOp->setAttrs(op->getAttrDictionary()); + newOp->setAttrs(attrs); return success(); } }; @@ -166,18 +167,14 @@ struct CondBranchOpLowering : public ConvertOpToLLVMPattern<cf::CondBranchOp> { TypeRange(adaptor.getFalseDestOperands())); if (failed(convertedFalseBlock)) return failure(); + DictionaryAttr attrs = op->getAttrDictionary(); auto newOp = rewriter.replaceOpWithNewOp<LLVM::CondBrOp>( - op, adaptor.getCondition(), *convertedTrueBlock, - adaptor.getTrueDestOperands(), *convertedFalseBlock, - adaptor.getFalseDestOperands()); - ArrayRef<int32_t> weights = op.getWeights(); - if (!weights.empty()) { - newOp.setWeights(weights); - op.removeBranchWeightsAttr(); - } + op, adaptor.getCondition(), adaptor.getTrueDestOperands(), + adaptor.getFalseDestOperands(), op.getBranchWeightsAttr(), + *convertedTrueBlock, *convertedFalseBlock); // TODO: We should not just forward all attributes like that. But there are // existing Flang tests that depend on this behavior. - newOp->setAttrs(op->getAttrDictionary()); + newOp->setAttrs(attrs); return success(); } }; |
