New Defects reported by Coverity Scan for llvm

Hi,

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

2 new defect(s) introduced to llvm found with Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)

** CID 1506387: (AUTO_CAUSES_COPY)
/llvm/lib/IR/ReplaceConstant.cpp: 146 in llvm::expandUser(llvm::Instruction *, llvm::Constant *)()
/llvm/lib/IR/ReplaceConstant.cpp: 152 in llvm::expandUser(llvm::Instruction *, llvm::Constant *)()


*** CID 1506387: (AUTO_CAUSES_COPY)
/llvm/lib/IR/ReplaceConstant.cpp: 146 in llvm::expandUser(llvm::Instruction *, llvm::Constant *)()
140
141 static Instruction *expandUser(Instruction *InsertPt, Constant *C) {
142 if (auto *CE = dyn_cast(C)) {
143 return CE->getAsInstruction(InsertPt);
144 } else if (isa(C) || isa(C)) {
145 Value *V = PoisonValue::get(C->getType());

CID 1506387:    (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type result_pair.

146 for (auto [Idx, Op] : enumerate(C->operands()))
147 V = InsertValueInst::Create(V, Op, Idx, “”, InsertPt);
148 return cast(V);
149 } else if (isa(C)) {
150 Type *IdxTy = Type::getInt32Ty(C->getContext());
151 Value *V = PoisonValue::get(C->getType());
/llvm/lib/IR/ReplaceConstant.cpp: 152 in llvm::expandUser(llvm::Instruction *, llvm::Constant *)()
146 for (auto [Idx, Op] : enumerate(C->operands()))
147 V = InsertValueInst::Create(V, Op, Idx, “”, InsertPt);
148 return cast(V);
149 } else if (isa(C)) {
150 Type *IdxTy = Type::getInt32Ty(C->getContext());
151 Value *V = PoisonValue::get(C->getType());

CID 1506387:    (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type result_pair.

152 for (auto [Idx, Op] : enumerate(C->operands()))
153 V = InsertElementInst::Create(V, Op, ConstantInt::get(IdxTy, Idx), “”,
154 InsertPt);
155 return cast(V);
156 } else {
157 llvm_unreachable(“Not an expandable user”);

** CID 1506386: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/IR/PatternMatch.cpp: 275 in mlir::RewriterBase::replaceOp(mlir::Operation *, mlir::ValueRange)()


*** CID 1506386: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/IR/PatternMatch.cpp: 275 in mlir::RewriterBase::replaceOp(mlir::Operation *, mlir::ValueRange)()
269
270 // Notify the listener that we’re about to remove this op.
271 if (auto *rewriteListener = dyn_cast_if_present(listener))
272 rewriteListener->notifyOperationReplaced(op, newValues);
273
274 // Replace results one-by-one. Also notifies the listener of modifications.

CID 1506386:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type tuple.

275 for (auto it : llvm::zip(op->getResults(), newValues))
276 replaceAllUsesWith(std::get<0>(it), std::get<1>(it));
277
278 if (auto *rewriteListener = dyn_cast_if_present(listener))
279 rewriteListener->notifyOperationRemoved(op);
280 op->erase();


To view the defects in Coverity Scan visit, Coverity Scan - Sign in