Fix a few places to check if TargetData is available before using it.
authorDan Gohman <gohman@apple.com>
Wed, 19 Aug 2009 23:38:22 +0000 (23:38 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 19 Aug 2009 23:38:22 +0000 (23:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79493 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 7a98b482a2ec9ac4966a01297cb0fdbefe41bf29..5fe8ee876c345a42671c05ff232b949fbf9f9ee7 100644 (file)
@@ -478,9 +478,9 @@ isEliminableCastPair(
   // We don't want to form an inttoptr or ptrtoint that converts to an integer
   // type that differs from the pointer size.
   if ((Res == Instruction::IntToPtr &&
-          SrcTy != TD->getIntPtrType(CI->getContext())) ||
+          (!TD || SrcTy != TD->getIntPtrType(CI->getContext()))) ||
       (Res == Instruction::PtrToInt &&
-          DstTy != TD->getIntPtrType(CI->getContext())))
+          (!TD || DstTy != TD->getIntPtrType(CI->getContext()))))
     Res = 0;
   
   return Instruction::CastOps(Res);