[CodeGen] Avoid access after runtime
authorVitaly Buka <vitalybuka@google.com>
Wed, 30 Mar 2022 01:35:55 +0000 (18:35 -0700)
committerVitaly Buka <vitalybuka@google.com>
Wed, 30 Mar 2022 09:08:13 +0000 (02:08 -0700)
Insts must be destroyd before xParent
or it can read it with stack like this:
   0 in llvm::MachineInstr::getMF() const MachineInstr.cpp:637:3
   1 in getMF MachineInstr.h:302:50
   2 in removeNodeFromList MachineBasicBlock.cpp:163:32

llvm/include/llvm/CodeGen/MachineBasicBlock.h

index b730e63..7d9a9ac 100644 (file)
@@ -109,10 +109,10 @@ public:
 private:
   using Instructions = ilist<MachineInstr, ilist_sentinel_tracking<true>>;
 
-  Instructions Insts;
   const BasicBlock *BB;
   int Number;
   MachineFunction *xParent;
+  Instructions Insts;
 
   /// Keep track of the predecessor / successor basic blocks.
   std::vector<MachineBasicBlock *> Predecessors;