From 96f962fdffab615f196ea6b66ea736ca2c601548 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 28 Mar 2011 23:02:18 +0000 Subject: [PATCH] In some cases, the "fail BB dominator" may be null after the BB was split (and becomes reachable when before it wasn't). Check to make sure that it's not null before trying to use it. llvm-svn: 128434 --- llvm/lib/CodeGen/StackProtector.cpp | 3 ++- llvm/test/CodeGen/X86/crash.ll | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 02d8fd6dea96..1a588e25d6e3 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -221,7 +221,8 @@ bool StackProtector::InsertStackProtectors() { BasicBlock *NewBB = BB->splitBasicBlock(RI, "SP_return"); if (DT && DT->isReachableFromEntry(BB)) { DT->addNewBlock(NewBB, BB); - FailBBDom = DT->findNearestCommonDominator(FailBBDom, BB); + if (FailBBDom) + FailBBDom = DT->findNearestCommonDominator(FailBBDom, BB); } // Remove default branch instruction to the new BB. diff --git a/llvm/test/CodeGen/X86/crash.ll b/llvm/test/CodeGen/X86/crash.ll index 2d8e63e31342..7c4e64cdf6f2 100644 --- a/llvm/test/CodeGen/X86/crash.ll +++ b/llvm/test/CodeGen/X86/crash.ll @@ -189,7 +189,7 @@ for.inc44: ; preds = %for.body } ; PR9028 -define void @f(i64 %A) nounwind { +define void @func_60(i64 %A) nounwind { entry: %0 = zext i64 %A to i160 %1 = shl i160 %0, 64 @@ -199,3 +199,19 @@ entry: store i576 %4, i576* undef, align 8 ret void } + +; +define fastcc void @func_61() nounwind sspreq { +entry: + %t1 = tail call i64 @llvm.objectsize.i64(i8* undef, i1 false) + %t2 = icmp eq i64 %t1, -1 + br i1 %t2, label %bb2, label %bb1 + +bb1: + ret void + +bb2: + ret void +} + +declare i64 @llvm.objectsize.i64(i8*, i1) nounwind readnone