diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -123,7 +123,9 @@ Changes to the C API -------------------- -* ... +* ``LLVMSetInstDebugLocation`` has been removed, because + ``IRBuilder::SetInstDebugLocation`` has been removed. The more general + ``LLVMAddMetadataToInst`` can be used instead. Changes to the Go bindings -------------------------- diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -3607,13 +3607,11 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc); /** - * Attempts to set the debug location for the given instruction using the - * current debug location for the given builder. If the builder has no current - * debug location, this function is a no-op. + * Adds the metadata registered with the given builder to the given instruction. * - * @see llvm::IRBuilder::SetInstDebugLocation() + * @see llvm::IRBuilder::AddMetadataToInst() */ -void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); +void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst); /** * Get the dafult floating-point math metadata for a given builder. diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -227,16 +227,6 @@ return {}; } - /// If this builder has a current debug location, set it on the - /// specified instruction. - void SetInstDebugLocation(Instruction *I) const { - for (const auto &KV : MetadataToCopy) - if (KV.first == LLVMContext::MD_dbg) { - I->setDebugLoc(DebugLoc(KV.second)); - return; - } - } - /// Add all entries in MetadataToCopy to \p I. void AddMetadataToInst(Instruction *I) const { for (auto &KV : MetadataToCopy) diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -3129,8 +3129,8 @@ Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode())); } -void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) { - unwrap(Builder)->SetInstDebugLocation(unwrap(Inst)); +void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst) { + unwrap(Builder)->AddMetadataToInst(unwrap(Inst)); } void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp --- a/llvm/tools/llvm-c-test/echo.cpp +++ b/llvm/tools/llvm-c-test/echo.cpp @@ -855,7 +855,7 @@ LLVMSetMetadata(Dst, Kind, LLVMMetadataAsValue(Ctx, MD)); } LLVMDisposeValueMetadataEntries(AllMetadata); - LLVMSetInstDebugLocation(Builder, Dst); + LLVMAddMetadataToInst(Builder, Dst); check_value_kind(Dst, LLVMInstructionValueKind); return VMap[Src] = Dst;