Fix PR2112: don't run loop aligner if target doesn't have a TargetLowering object.
authorEvan Cheng <evan.cheng@apple.com>
Fri, 29 Feb 2008 17:52:15 +0000 (17:52 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 29 Feb 2008 17:52:15 +0000 (17:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47755 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LoopAligner.cpp

index a40bb50565d3863bc520d726ea4bab6e06beaf9a..1888391d5e7145aed221d3565e5ee657e85adc25 100644 (file)
@@ -24,8 +24,6 @@ using namespace llvm;
 
 namespace {
   class LoopAligner : public MachineFunctionPass {
-    const TargetLowering *TLI;
-
   public:
     static char ID;
     LoopAligner() : MachineFunctionPass((intptr_t)&ID) {}
@@ -51,7 +49,11 @@ bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
   if (MLI->begin() == MLI->end())
     return false;  // No loops.
 
-  unsigned Align = MF.getTarget().getTargetLowering()->getPrefLoopAlignment();
+  const TargetLowering *TLI = MF.getTarget().getTargetLowering();
+  if (!TLI)
+    return false;
+
+  unsigned Align = TLI->getPrefLoopAlignment();
   if (!Align)
     return false;  // Don't care about loop alignment.