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

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 05:31:36 PST 2020


fhahn created this revision.
fhahn added reviewers: dblaikie, dexonsmith, nicholas, craig.topper.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

IRBuilder has been updated to support preserving metdata in a more
general manner. SetInstDebugLocation has been removed in favor of
AddMetadataToInst. This patch updates the C API to reflect this.

Existing users should be able to update their code to just call
LLVMAddMetadataToInst instead of LLVMSetInstDebugLocation.


Repository:
  rG LLVM Github Monorepo

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
@@ -850,7 +850,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
@@ -3091,8 +3091,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
@@ -3576,13 +3576,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
@@ -155,6 +155,10 @@
 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.312463.patch
Type: text/x-patch
Size: 3134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201217/3e6f8daa/attachment.bin>


More information about the llvm-commits mailing list