[llvm-commits] r133708 strikes me again? - the case clang stalls

NAKAMURA Takumi geek4civic at gmail.com
Mon Aug 8 21:05:04 PDT 2011


It seems BasicBlock::replaceSuccessorsPhiUsesWith() might not handle
incomplete successors properly on msvc.

In a case I saw, the successor has no instructions.

John, would it be a possible case for CGCleanup to pass incomplete
Entry Block to llvm?

Jay, would it be assumed?

Workaround is as below;

--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -336,7 +336,9 @@ void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Ne
     return;
   for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
     BasicBlock *Succ = TI->getSuccessor(i);
-    for (iterator II = Succ->begin(); PHINode *PN = dyn_cast<PHINode>(II);
+    PHINode *PN;
+    for (iterator II = Succ->begin(), IE = Succ->end();
+        II != IE && (PN = dyn_cast<PHINode>(II)) != NULL;
          ++II) {
       int i;
       while ((i = PN->getBasicBlockIndex(this)) >= 0)


...Takumi


2011年7月30日11:03 NAKAMURA Takumi <geek4civic at gmail.com>:
> I have met infinite loop in clang since yesterday.
> (r136404 had triggered the case for me but r136404 must be nothing)
>
> Now I can reproduce the infinite loop "RelWithDebInfo" on visual studio 10.
> (But it happens randomly)
> Still I am investigating.
> Lemme know whatever I should check up.
>
> FYI, ...Takumi
>
> The log is as below. Infinite loop in replaceSuccessorsPhiUsesWith().
>
>>       clang.exe!llvm::PHINode::getBasicBlockIndex(const llvm::BasicBlock * BB)  行 2000        C++
>        clang.exe!llvm::BasicBlock::replaceSuccessorsPhiUsesWith(llvm::BasicBlock
> * New)  行 342 + 0x8 バイト C++
>        clang.exe!llvm::Value::replaceAllUsesWith(llvm::Value * New)  行 310
> + 0x8 バイト       C++
>        clang.exe!SimplifyCleanupEntry(clang::CodeGen::CodeGenFunction &
> CGF, llvm::BasicBlock * Entry)  行 426   C++
>        clang.exe!clang::CodeGen::CodeGenFunction::PopCleanupBlock(bool
> FallthroughIsBranchThrough)  行 845 + 0xc バイト    C++
>        clang.exe!clang::CodeGen::CodeGenFunction::PopCleanupBlocks(clang::CodeGen::EHScopeStack::stable_iterator
> Old)  行 372 + 0xb バイト   C++
>        clang.exe!clang::CodeGen::CodeGenFunction::EmitCompoundStmt(const
> clang::CompoundStmt & S, bool GetLast, clang::CodeGen::AggValueSlot
> AggSlot)  行 231 + 0x1c バイト      C++
>        clang.exe!clang::CodeGen::CodeGenFunction::EmitSimpleStmt(const
> clang::Stmt * S)  行 183 C++
>        clang.exe!clang::CodeGen::CodeGenFunction::EmitStmt(const
> clang::Stmt * S)  行 48 + 0xb バイト        C++
>        clang.exe!clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList
> & Args)  行 353 + 0xf バイト        C++
>        clang.exe!clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl
> GD, llvm::Function * Fn, const clang::CodeGen::CGFunctionInfo &
> FnInfo)  行 407  C++
>        clang.exe!clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl
> GD)  行 1517 + 0x26 バイト  C++
>        clang.exe!clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl
> GD)  行 844      C++
>        clang.exe!clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl
> GD)  行 803      C++
>        clang.exe!clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl
> * D)  行 2214    C++
>        clang.exe!`anonymous
> namespace'::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef
> DG)  行 65 + 0xe バイト     C++
>        clang.exe!clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef
> D)  行 92        C++
>        clang.exe!clang::ParseAST(clang::Sema & S, bool PrintStats)  行 84       C++
>        clang.exe!clang::ASTFrontendAction::ExecuteAction()  行 378 + 0x1a バイト   C++
>        clang.exe!clang::CodeGenAction::ExecuteAction()  行 348  C++
>        clang.exe!clang::FrontendAction::Execute()  行 299       C++
>        clang.exe!clang::CompilerInstance::ExecuteAction(clang::FrontendAction
> & Act)  行 615   C++
>        clang.exe!clang::ExecuteCompilerInvocation(clang::CompilerInstance *
> Clang)  行 172   C++
>        clang.exe!cc1_main(const char * * ArgBegin, const char * * ArgEnd,
> const char * Argv0, void * MainAddr)  行 159 + 0x6 バイト   C++
>        clang.exe!main(int argc_, const char * * argv_)  行 354 + 0x15 バイト       C++
>



More information about the llvm-commits mailing list