[Mlir-commits] [llvm] [mlir] [IRBuilder] Remove insertion block (PR #234245)
Ramkumar Ramachandra
llvmlistbot at llvm.org
Thu Oct 22 01:03:58 PDT 2026
================
@@ -171,42 +168,39 @@ class IRBuilderBase {
/// Clear the insertion point: created instructions will not be
/// inserted into a block.
- void ClearInsertionPoint() {
- BB = nullptr;
- InsertPt = BasicBlock::iterator();
- }
+ void ClearInsertionPoint() { InsertPt = BasicBlock::iterator(); }
- BasicBlock *GetInsertBlock() const { return BB; }
+ BasicBlock *GetInsertBlock() const {
+ return InsertPt.isValid() ? InsertPt.getNodeParent() : nullptr;
+ }
BasicBlock::iterator GetInsertPoint() const { return InsertPt; }
LLVMContext &getContext() const { return Context; }
/// Get data layout. Requires that an insertion point is set and connected
/// to a module.
const DataLayout &getDataLayout() const {
- assert(BB && "Must have insertion point to get data layout");
- return BB->getDataLayout();
+ assert(InsertPt.isValid() &&
+ "Must have insertion point to get data layout");
+ return InsertPt.getNodeParent()->getDataLayout();
}
/// Get the module. Requires that an insertion point is set and connected
/// to a module.
Module *getModule() const {
- assert(BB && "Must have insertion point to get module");
- return BB->getModule();
+ assert(InsertPt.isValid() && "Must have insertion point to get module");
+ return InsertPt.getNodeParent()->getModule();
}
/// This specifies that created instructions should be appended to the
/// end of the specified block.
- void SetInsertPoint(BasicBlock *TheBB) {
- BB = TheBB;
- InsertPt = BB->end();
- }
+ void SetInsertPoint(BasicBlock *TheBB) { InsertPt = TheBB->end(); }
/// This specifies that created instructions should be inserted before
/// the specified instruction.
void SetInsertPoint(Instruction *I) {
- BB = I->getParent();
InsertPt = I->getIterator();
- assert(InsertPt != BB->end() && "Can't read debug loc from end()");
+ assert(InsertPt != I->getParent()->end() &&
+ "Can't read debug loc from end()");
----------------
artagnon wrote:
```suggestion
assert(InsertPt.isValid() &&
"Insert point must be a valid");
```
?
https://github.com/llvm/llvm-project/pull/234245
More information about the Mlir-commits
mailing list