Don't allow the automatically updated MI flags to be set directly.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 18 Dec 2012 21:36:05 +0000 (21:36 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 18 Dec 2012 21:36:05 +0000 (21:36 +0000)
The bundle-related MI flags need to be kept in sync with the neighboring
instructions. Don't allow the bulk flag-setting setFlags() function to
change them.

Also don't copy MI flags when cloning an instruction. The clone's bundle
flags will be set when it is explicitly inserted into a bundle.

llvm-svn: 170459

llvm/include/llvm/CodeGen/MachineInstr.h
llvm/lib/CodeGen/MachineInstr.cpp

index 320cd0d..c7b8360 100644 (file)
@@ -150,7 +150,9 @@ public:
   }
 
   void setFlags(unsigned flags) {
-    Flags = flags;
+    // Filter out the automatically maintained flags.
+    unsigned Mask = BundledPred | BundledSucc;
+    Flags = (Flags & Mask) | (flags & ~Mask);
   }
 
   /// clearFlag - Clear a MI flag.
index f545a9c..2d4392c 100644 (file)
@@ -556,8 +556,8 @@ MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
   for (unsigned i = 0; i != MI.getNumOperands(); ++i)
     addOperand(MI.getOperand(i));
 
-  // Copy all the flags.
-  Flags = MI.Flags;
+  // Copy all the sensible flags.
+  setFlags(MI.Flags);
 
   // Set parent to null.
   Parent = 0;