diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-05-02 19:34:44 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-05-02 19:34:44 +0000 | 
| commit | 6b943ff3a3f8617113ecbf611cf0f8957e4e19d2 (patch) | |
| tree | fc5f365fb9035b2d0c622bbf06c9bbe8627d7279 /lib/CodeGen/StackProtector.cpp | |
| parent | d0e4e96dc17a6c1c6de3340842c80f0e187ba349 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/StackProtector.cpp')
| -rw-r--r-- | lib/CodeGen/StackProtector.cpp | 12 | 
1 files changed, 5 insertions, 7 deletions
| diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp index fcaee4208ba32..f0a44abaf5cda 100644 --- a/lib/CodeGen/StackProtector.cpp +++ b/lib/CodeGen/StackProtector.cpp @@ -153,7 +153,6 @@ bool StackProtector::InsertStackProtectors() {    for (Function::iterator I = F->begin(), E = F->end(); I != E; ) {      BasicBlock *BB = I++; -      ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator());      if (!RI) continue; @@ -191,8 +190,6 @@ bool StackProtector::InsertStackProtectors() {        // Create the basic block to jump to when the guard check fails.        FailBB = CreateFailBB(); -      if (DT) -        FailBBDom = DT->isReachableFromEntry(BB) ? BB : 0;      }      // For each block with a return instruction, convert this: @@ -219,9 +216,10 @@ bool StackProtector::InsertStackProtectors() {      // Split the basic block before the return instruction.      BasicBlock *NewBB = BB->splitBasicBlock(RI, "SP_return"); -    if (DT) { -      DT->addNewBlock(NewBB, DT->isReachableFromEntry(BB) ? BB : 0); -      FailBBDom = DT->findNearestCommonDominator(FailBBDom, BB); + +    if (DT && DT->isReachableFromEntry(BB)) { +      DT->addNewBlock(NewBB, BB); +      FailBBDom = FailBBDom ? DT->findNearestCommonDominator(FailBBDom, BB) :BB;      }      // Remove default branch instruction to the new BB. @@ -242,7 +240,7 @@ bool StackProtector::InsertStackProtectors() {    // statements in the function.    if (!FailBB) return false; -  if (DT) +  if (DT && FailBBDom)      DT->addNewBlock(FailBB, FailBBDom);    return true; | 
