[LLVM-C]Add LLVMAddMetadataToInst, deprecated LLVMSetInstDebugLocation.

IRBuilder has been updated to support preserving metdata in a more
general manner. This patch adds `LLVMAddMetadataToInst` and
deprecates `LLVMSetInstDebugLocation` in favor of the more
general function.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D93454
This commit is contained in:
Florian Hahn 2021-10-22 11:00:23 +01:00
parent eda2ebd780
commit d465315679
No known key found for this signature in database
GPG Key ID: 61D7554B5CECDC0D
4 changed files with 17 additions and 2 deletions

View File

@ -128,7 +128,8 @@ Changes to the OCaml bindings
Changes to the C API Changes to the C API
-------------------- --------------------
* ... * ``LLVMSetInstDebugLocation`` has been deprecated in favor of the more general
``LLVMAddMetadataToInst``.
Changes to the Go bindings Changes to the Go bindings
-------------------------- --------------------------

View File

@ -3611,10 +3611,20 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Builder, LLVMMetadataRef Loc);
* current debug location for the given builder. If the builder has no current * current debug location for the given builder. If the builder has no current
* debug location, this function is a no-op. * debug location, this function is a no-op.
* *
* @deprecated LLVMSetInstDebugLocation is deprecated in favor of the more general
* LLVMAddMetadataToInst.
*
* @see llvm::IRBuilder::SetInstDebugLocation() * @see llvm::IRBuilder::SetInstDebugLocation()
*/ */
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst);
/**
* Adds the metadata registered with the given builder to the given instruction.
*
* @see llvm::IRBuilder::AddMetadataToInst()
*/
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst);
/** /**
* Get the dafult floating-point math metadata for a given builder. * Get the dafult floating-point math metadata for a given builder.
* *

View File

@ -3133,6 +3133,10 @@ void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {
unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst)); unwrap(Builder)->SetInstDebugLocation(unwrap<Instruction>(Inst));
} }
void LLVMAddMetadataToInst(LLVMBuilderRef Builder, LLVMValueRef Inst) {
unwrap(Builder)->AddMetadataToInst(unwrap<Instruction>(Inst));
}
void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder, void LLVMBuilderSetDefaultFPMathTag(LLVMBuilderRef Builder,
LLVMMetadataRef FPMathTag) { LLVMMetadataRef FPMathTag) {

View File

@ -856,7 +856,7 @@ struct FunCloner {
LLVMSetMetadata(Dst, Kind, LLVMMetadataAsValue(Ctx, MD)); LLVMSetMetadata(Dst, Kind, LLVMMetadataAsValue(Ctx, MD));
} }
LLVMDisposeValueMetadataEntries(AllMetadata); LLVMDisposeValueMetadataEntries(AllMetadata);
LLVMSetInstDebugLocation(Builder, Dst); LLVMAddMetadataToInst(Builder, Dst);
check_value_kind(Dst, LLVMInstructionValueKind); check_value_kind(Dst, LLVMInstructionValueKind);
return VMap[Src] = Dst; return VMap[Src] = Dst;