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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168176 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 4c14aa698fb78c7531630d31b29ca0f2c821d135..6c34eed13d6d68e1c479b82086d012208633b4d5 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