[llvm] [LLVM-C] Add bindings to `Instruction::getDbgRecordRange()` (PR #107802)
Michal Rostecki via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 09:21:08 PDT 2024
================
@@ -224,14 +235,46 @@ int llvm_test_dibuilder(void) {
LLVMPositionBuilderBeforeInstrAndDbgRecords(Builder, InsertPos);
LLVMValueRef Phi1 = LLVMBuildPhi(Builder, I64, "p1");
LLVMAddIncoming(Phi1, &Zero, &FooEntryBlock, 1);
+
// Do the same again using the other position-setting function.
LLVMPositionBuilderBeforeDbgRecords(Builder, FooVarBlock, InsertPos);
LLVMValueRef Phi2 = LLVMBuildPhi(Builder, I64, "p2");
LLVMAddIncoming(Phi2, &Zero, &FooEntryBlock, 1);
+
// Insert a non-phi before the `ret` but not before the debug records to
// test that works as expected.
LLVMPositionBuilder(Builder, FooVarBlock, Ret);
- LLVMBuildAdd(Builder, Phi1, Phi2, "a");
+ LLVMValueRef Add = LLVMBuildAdd(Builder, Phi1, Phi2, "a");
+
+ // Iterate over debug records in the add instruction. There should be two.
+ // Iterate with a for loop.
+ LLVMDbgRecordRef DbgRec;
+ for (DbgRec = LLVMGetFirstDbgRecord(Add); DbgRec;
+ DbgRec = LLVMGetNextDbgRecord(DbgRec)) {
+ assert(DbgRec != NULL);
----------------
vadorovsky wrote:
Now should be pushed, sorry
https://github.com/llvm/llvm-project/pull/107802
More information about the llvm-commits
mailing list