Fix bugs, don't do external methods which causes segv.

llvm-svn: 1414
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index a6e0bd1..3b64756 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -127,7 +127,8 @@
 #ifdef DEBUG
     cerr << IndVars[i];
 #endif
-    if (IV != Cannonical) {  // Don't modify the cannonical indvar
+    // Don't modify the cannonical indvar or unrecognized indvars...
+    if (IV != Cannonical && IV->InductionType != InductionVariable::Unknown) {
       Instruction *Val = IterCount;
       if (!isa<ConstantInt>(IV->Step) ||   // If the step != 1
           !cast<ConstantInt>(IV->Step)->equalsInt(1)) {
@@ -183,6 +184,8 @@
 }
 
 bool InductionVariableSimplify::doit(Method *M) {
+  if (M->isExternal()) return false;
+
   // Figure out the loop structure of the method...
   cfg::LoopInfo Loops(M);