[PATCH] D93454: [LLVM-C] Replace LLVMSetInstDebugLocation with LLVMAddMetadataToInst.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 15 01:44:04 PDT 2021


fhahn updated this revision to Diff 372658.
fhahn added a comment.

Ping :) I just realized that I still had this follow-up to 29077ae860bc <https://reviews.llvm.org/rG29077ae860bcf3c9e9f2ce67ca7dfe691b6fa148> lying around. Rebased.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93454/new/

https://reviews.llvm.org/D93454

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/Core.cpp
  llvm/tools/llvm-c-test/echo.cpp


Index: llvm/tools/llvm-c-test/echo.cpp
===================================================================
--- llvm/tools/llvm-c-test/echo.cpp
+++ 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;
Index: llvm/lib/IR/Core.cpp
===================================================================
--- llvm/lib/IR/Core.cpp
+++ llvm/lib/IR/Core.cpp
@@ -3129,8 +3129,8 @@
       Context, unwrap(Builder)->getCurrentDebugLocation().getAsMDNode()));
 }
 
-void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {
-  unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
+void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst) {
+  unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
 }
 
 void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
Index: llvm/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/include/llvm/IR/IRBuilder.h
+++ 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)
Index: llvm/include/llvm-c/Core.h
===================================================================
--- llvm/include/llvm-c/Core.h
+++ 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.
Index: llvm/docs/ReleaseNotes.rst
===================================================================
--- llvm/docs/ReleaseNotes.rst
+++ 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
 --------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93454.372658.patch
Type: text/x-patch
Size: 3138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210915/054395d2/attachment.bin>


More information about the llvm-commits mailing list