From a55fce998eea665d29fd632c5acba587bfc89bd9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 1 May 2009 16:29:14 +0000 Subject: [PATCH] Fix some code to work if TargetLowering is not available. llvm-svn: 70546 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 2dc62823ec4..89429b6731d 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -794,10 +794,14 @@ static bool fitsInAddressMode(const SCEVHandle &V, const Type *UseTy, if (const SCEVUnknown *SU = dyn_cast(V)) if (GlobalValue *GV = dyn_cast(SU->getValue())) { - TargetLowering::AddrMode AM; - AM.BaseGV = GV; - AM.HasBaseReg = HasBaseReg; - return TLI->isLegalAddressingMode(AM, UseTy); + if (TLI) { + TargetLowering::AddrMode AM; + AM.BaseGV = GV; + AM.HasBaseReg = HasBaseReg; + return TLI->isLegalAddressingMode(AM, UseTy); + } else { + // Default: assume global addresses are not legal. + } } return false;