Dereference loopHeader after checking for null rather than before.
authorDan Gohman <gohman@apple.com>
Wed, 9 Dec 2009 22:55:01 +0000 (22:55 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 9 Dec 2009 22:55:01 +0000 (22:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90990 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index 38d267aa6b8d7aafe723afa9e11675b357e6d0c6..b7adfdc68e4fba5168b7d91ec6359c41bce0bb4c 100644 (file)
@@ -404,12 +404,13 @@ bool LoopUnswitch::IsTrivialUnswitchCondition(Value *Cond, Constant **Val,
 bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
 
   initLoopData();
-  Function *F = loopHeader->getParent();
 
   // If LoopSimplify was unable to form a preheader, don't do any unswitching.
   if (!loopPreheader)
     return false;
 
+  Function *F = loopHeader->getParent();
+
   // If the condition is trivial, always unswitch.  There is no code growth for
   // this case.
   if (!IsTrivialUnswitchCondition(LoopCond)) {