[PATCH] D27841: [LLC][MIPS] Fix crash after enabling LLVM_ENABLE_EXPENSIVE_CHECKS

Nitesh Jain via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 22:48:39 PST 2016

nitesh.jain created this revision.
nitesh.jain added a reviewer: sdardis.
nitesh.jain added subscribers: jaydeep, llvm-commits, slthakur.
nitesh.jain set the repository for this revision to rL LLVM.
Herald added a reviewer: vkalintiris.

With the LLVM_ENABLE_EXPENSIVE_CHECKS enabled, following sequence of passes are executed:

  Dominator Tree Construction
  Basic Alias Analysis (stateless AA impl)
  Function Alias Analysis Results
  Natural Loop Information
  Branch Probability Analysis
  MIPS DAG->DAG Pattern Instruction Selection
  Branch Probability Analysis
  MIPS DAG->DAG Pattern Instruction Selection
  Expand ISel Pseudo-instructions
  Tail Duplication

The Dominator tree is the indirect require dependency of "MIPS DAG->DAG Pattern Instruction Selection" pass. The dominator tree construction pass is freed before the second pass of "MIPS DAG->DAG Pattern Instruction Selection". This causes code to crash when it verify the preserved analysis after the second pass is executed




Index: lib/Target/Mips/MipsSEISelDAGToDAG.h
--- lib/Target/Mips/MipsSEISelDAGToDAG.h
+++ lib/Target/Mips/MipsSEISelDAGToDAG.h
@@ -28,6 +28,8 @@
   bool runOnMachineFunction(MachineFunction &MF) override;
+  void getAnalysisUsage(AnalysisUsage &AU) const override;
   void addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
                              MachineFunction &MF);
Index: lib/Target/Mips/MipsSEISelDAGToDAG.cpp
--- lib/Target/Mips/MipsSEISelDAGToDAG.cpp
+++ lib/Target/Mips/MipsSEISelDAGToDAG.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/IR/Dominators.h"
 using namespace llvm;
 #define DEBUG_TYPE "mips-isel"
@@ -43,6 +44,11 @@
   return MipsDAGToDAGISel::runOnMachineFunction(MF);
+void MipsSEDAGToDAGISel::getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.addRequired<DominatorTreeWrapperPass>();
+  SelectionDAGISel::getAnalysisUsage(AU);
 void MipsSEDAGToDAGISel::addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI,
                                                MachineFunction &MF) {
   MachineInstrBuilder MIB(MF, &MI);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27841.81350.patch
Type: text/x-patch
Size: 1309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161216/5aecbfe2/attachment.bin>

More information about the llvm-commits mailing list