summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-28 16:56:46 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-28 16:56:46 +0000
commitf611ae40fdd3815367dd8244fff037f68110fae0 (patch)
tree800da7065a895621b41cb4b2d6124542bbb9bd72 /include
parent7e82200a05d9f8f7d37f3078a40f31ab1be5bf67 (diff)
downloadllvm-f611ae40fdd3815367dd8244fff037f68110fae0.tar.gz
llvm-f611ae40fdd3815367dd8244fff037f68110fae0.tar.bz2
llvm-f611ae40fdd3815367dd8244fff037f68110fae0.tar.xz
Fix pr14893.
When simplifycfg moves an instruction, it must drop metadata it doesn't know is still valid with the preconditions changes. In particular, it must drop the range and tbaa metadata. The patch implements this with an utility function to drop all metadata not in a white list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/IR/Instruction.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h
index 5721d8f2f3..0a245483ff 100644
--- a/include/llvm/IR/Instruction.h
+++ b/include/llvm/IR/Instruction.h
@@ -15,6 +15,7 @@
#ifndef LLVM_IR_INSTRUCTION_H
#define LLVM_IR_INSTRUCTION_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/IR/User.h"
#include "llvm/Support/DebugLoc.h"
@@ -171,6 +172,21 @@ public:
void setMetadata(unsigned KindID, MDNode *Node);
void setMetadata(StringRef Kind, MDNode *Node);
+ /// \brief Drop unknown metadata.
+ /// Passes are required to drop metadata they don't understand. This is a
+ /// convenience method for passes to do so.
+ void dropUnknownMetadata(ArrayRef<unsigned> KnownIDs);
+ void dropUnknownMetadata() {
+ return dropUnknownMetadata(ArrayRef<unsigned>());
+ }
+ void dropUnknownMetadata(unsigned ID1) {
+ return dropUnknownMetadata(makeArrayRef(ID1));
+ }
+ void dropUnknownMetadata(unsigned ID1, unsigned ID2) {
+ unsigned IDs[] = {ID1, ID2};
+ return dropUnknownMetadata(IDs);
+ }
+
/// setDebugLoc - Set the debug location information for this instruction.
void setDebugLoc(const DebugLoc &Loc) { DbgLoc = Loc; }