Kyriakos
Kyriakos

Reputation: 757

Removing metadata from an instruction LLVM

Does anyone have any idea how to remove metadata from an instruction in LLVM-IR?

Upvotes: 1

Views: 1697

Answers (1)

Oak
Oak

Reputation: 26878

To remove a specifc kind of metadata from an instruction, use setMetadata(kind, NULL). To remove all the metadata, call getAllMetadata first, then iterate over the kinds in the returned collection and remove them via the first method.

Keep in mind that this will not remove the actual MDNode and will not remove any dbg.declare or dbg.value calls if that's what interests you.

Upvotes: 2

Related Questions