diff options
Diffstat (limited to 'lib/CodeGen/GlobalISel/IRTranslator.cpp')
| -rw-r--r-- | lib/CodeGen/GlobalISel/IRTranslator.cpp | 15 | 
1 files changed, 10 insertions, 5 deletions
| diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index bafb7a05536d..80da50562d32 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -11,6 +11,7 @@  //===----------------------------------------------------------------------===//  #include "llvm/CodeGen/GlobalISel/IRTranslator.h" +#include "llvm/ADT/PostOrderIterator.h"  #include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/ScopeExit.h"  #include "llvm/ADT/SmallSet.h" @@ -33,6 +34,7 @@  #include "llvm/CodeGen/TargetRegisterInfo.h"  #include "llvm/CodeGen/TargetSubtargetInfo.h"  #include "llvm/IR/BasicBlock.h" +#include "llvm/IR/CFG.h"  #include "llvm/IR/Constant.h"  #include "llvm/IR/Constants.h"  #include "llvm/IR/DataLayout.h" @@ -1503,6 +1505,8 @@ bool IRTranslator::translate(const Constant &C, unsigned Reg) {        Ops.push_back(getOrCreateVReg(*CV->getOperand(i)));      }      EntryBuilder.buildMerge(Reg, Ops); +  } else if (auto *BA = dyn_cast<BlockAddress>(&C)) { +    EntryBuilder.buildBlockAddress(Reg, BA);    } else      return false; @@ -1611,19 +1615,20 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {      ArgIt++;    } -  // And translate the function! -  for (const BasicBlock &BB : F) { -    MachineBasicBlock &MBB = getMBB(BB); +  // Need to visit defs before uses when translating instructions. +  ReversePostOrderTraversal<const Function *> RPOT(&F); +  for (const BasicBlock *BB : RPOT) { +    MachineBasicBlock &MBB = getMBB(*BB);      // Set the insertion point of all the following translations to      // the end of this basic block.      CurBuilder.setMBB(MBB); -    for (const Instruction &Inst : BB) { +    for (const Instruction &Inst : *BB) {        if (translate(Inst))          continue;        OptimizationRemarkMissed R("gisel-irtranslator", "GISelFailure", -                                 Inst.getDebugLoc(), &BB); +                                 Inst.getDebugLoc(), BB);        R << "unable to translate instruction: " << ore::NV("Opcode", &Inst);        if (ORE->allowExtraAnalysis("gisel-irtranslator")) { | 
