OSDN Git Service

[CodeGenPrepare] Fix r265264.
authorPeter Zotov <whitequark@whitequark.org>
Sun, 3 Apr 2016 17:11:53 +0000 (17:11 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Sun, 3 Apr 2016 17:11:53 +0000 (17:11 +0000)
The case where there was no TargetLowering was not handled,
leading to null pointer dereferences.

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

lib/CodeGen/CodeGenPrepare.cpp

index afd37a0..ba68a4e 100644 (file)
@@ -910,8 +910,8 @@ static bool SinkCmpExpression(CmpInst *CI, const TargetLowering &TLI) {
   return MadeChange;
 }
 
-static bool OptimizeCmpExpression(CmpInst *CI, const TargetLowering &TLI) {
-  if (SinkCmpExpression(CI, TLI))
+static bool OptimizeCmpExpression(CmpInst *CI, const TargetLowering *TLI) {
+  if (TLI && SinkCmpExpression(CI, *TLI))
     return true;
 
   if (CombineUAddWithOverflow(CI))
@@ -5177,7 +5177,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, bool& ModifiedDT) {
 
   if (CmpInst *CI = dyn_cast<CmpInst>(I))
     if (!TLI || !TLI->hasMultipleConditionRegisters())
-      return OptimizeCmpExpression(CI, *TLI);
+      return OptimizeCmpExpression(CI, TLI);
 
   if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
     stripInvariantGroupMetadata(*LI);