SimplifyCFG: Don't assume non-null ScalarTargetTransformInfo.
authorHans Wennborg <hans@hanshq.net>
Fri, 16 Nov 2012 18:22:08 +0000 (18:22 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 16 Nov 2012 18:22:08 +0000 (18:22 +0000)
Patch by Pekka Jääskeläinen!

llvm-svn: 168176

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

index 4c14aa6..6c34eed 100644 (file)
@@ -3539,7 +3539,8 @@ static bool SwitchToLookupTable(SwitchInst *SI,
   assert(SI->getNumCases() > 1 && "Degenerate switch?");
 
   // Only build lookup table when we have a target that supports it.
-  if (!TTI || !TTI->getScalarTargetTransformInfo()->shouldBuildLookupTables())
+  if (!TTI || !TTI->getScalarTargetTransformInfo() ||
+      !TTI->getScalarTargetTransformInfo()->shouldBuildLookupTables())
     return false;
 
   // FIXME: If the switch is too sparse for a lookup table, perhaps we could