[IRBuilder] Delete copy constructor
D73835 will make IRBuilder no longer trivially copyable. This patch
deletes the copy constructor in advance, to separate out the breakage.
Currently, the IRBuilder copy constructor is usually used by accident,
not by intention. In rG7c362b25d7a9 I've fixed a number of cases where
functions accepted IRBuilder rather than IRBuilder &, thus performing
an unnecessary copy. In rG5f7b92b1b4d6 I've fixed cases where an
IRBuilder was copied, while an InsertPointGuard should have been used
instead.
The only non-trivial use of the copy constructor is the
getIRBForDbgInsertion() helper, for which I separated construction and
setting of the insertion point in this patch.
Differential Revision: https://reviews.llvm.org/D74693
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 0fcac7d..6000399 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -895,18 +895,15 @@
return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
}
-/// Return an IRBuilder for inserting dbg.declare and dbg.value intrinsics. This
-/// abstracts over the various ways to specify an insert position.
-static IRBuilder<> getIRBForDbgInsertion(const DILocation *DL,
- BasicBlock *InsertBB,
- Instruction *InsertBefore) {
- IRBuilder<> B(DL->getContext());
+/// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
+/// This abstracts over the various ways to specify an insert position.
+static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
+ BasicBlock *InsertBB, Instruction *InsertBefore) {
if (InsertBefore)
- B.SetInsertPoint(InsertBefore);
+ Builder.SetInsertPoint(InsertBefore);
else if (InsertBB)
- B.SetInsertPoint(InsertBB);
- B.SetCurrentDebugLocation(DL);
- return B;
+ Builder.SetInsertPoint(InsertBB);
+ Builder.SetCurrentDebugLocation(DL);
}
static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
@@ -936,7 +933,8 @@
MetadataAsValue::get(VMContext, VarInfo),
MetadataAsValue::get(VMContext, Expr)};
- IRBuilder<> B = getIRBForDbgInsertion(DL, InsertBB, InsertBefore);
+ IRBuilder<> B(DL->getContext());
+ initIRBuilder(B, DL, InsertBB, InsertBefore);
return B.CreateCall(DeclareFn, Args);
}
@@ -958,7 +956,8 @@
MetadataAsValue::get(VMContext, VarInfo),
MetadataAsValue::get(VMContext, Expr)};
- IRBuilder<> B = getIRBForDbgInsertion(DL, InsertBB, InsertBefore);
+ IRBuilder<> B(DL->getContext());
+ initIRBuilder(B, DL, InsertBB, InsertBefore);
return B.CreateCall(ValueFn, Args);
}
@@ -976,7 +975,8 @@
trackIfUnresolved(LabelInfo);
Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
- IRBuilder<> B = getIRBForDbgInsertion(DL, InsertBB, InsertBefore);
+ IRBuilder<> B(DL->getContext());
+ initIRBuilder(B, DL, InsertBB, InsertBefore);
return B.CreateCall(LabelFn, Args);
}