================ @@ -1686,7 +1686,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore( DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare( unwrap(Storage), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), - unwrap<Instruction>(Instr)); + Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator()) + : nullptr); ---------------- hvdijk wrote:
You're right. Previously, a call with `!Instr` would result in a call to `insertDeclare(..., /*InsertBefore=*/nullptr)` which results in `insertDeclare(..., /*InsertBB=*/nullptr->getParent(), /*InsertBefore=*/nullptr)`, so it would (on typical systems) result in a crash already. At the same time, previously, `insertLabel(..., /*InsertBefore=*/nullptr)` would result in `insertLabel(..., /*InsertBB=*/nullptr, /*InsertBefore=*/nullptr)` which specifically does not insert anything. And `insertDbgValueIntrinsic(..., /*InsertBefore=*/nullptr)` is special-cased to call `insertDbgValueIntrinsic(..., /*InsertBB=*/nullptr, /*InsertBefore=*/nullptr)` the same way, *but* the latter calls `insertDbgVariableRecord` unconditionally and hits the existing `assert(InsertBefore || InsertBB);` assert. This is a messy situation and in this PR I tried to just keep that exactly the same. What previously worked should still work. What previously didn't work should still not work. https://github.com/llvm/llvm-project/pull/126059 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits