[llvm-commits] [llvm] r134057 - in /llvm/trunk: include/llvm/BasicBlock.h lib/Transforms/Utils/Local.cpp lib/Transforms/Utils/SimplifyCFG.cpp lib/VMCore/BasicBlock.cpp test/Transforms/SimplifyCFG/lifetime.ll

Chad Rosier mcrosier at apple.com
Wed Jun 29 09:36:04 PDT 2011


Hi Rafael,
I've reverted this in r134071 due to in internal buildbot failure.  Specifically, clang is failing to build due to a segmentation fault.  I'm thinking it's a potential miscompile, but would you mind taking a look?

Here's the error:
llvm[3]: Compiling DebugInfo.cpp for Release build
0  clang             0x0000000100e65fc2 PrintStackTrace(void*) + 34
1  clang             0x00000001003104d9 SignalHandler(int) + 697
2  libSystem.B.dylib 0x00007fff806fd66a _sigtramp + 26
3  libSystem.B.dylib 0x000000010270dde0 _sigtramp + 2181105552
4  clang             0x00000001001db78b llvm::LazyValueInfo::getConstantOnEdge(llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*) + 91
5  clang             0x00000001001c8468 (anonymous namespace)::CorrelatedValuePropagation::runOnFunction(llvm::Function&) + 808
6  clang             0x0000000100090fc1 llvm::FPPassManager::runOnFunction(llvm::Function&) + 321
7  clang             0x000000010008b7c2 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 1490
8  clang             0x0000000100089af6 llvm::MPPassManager::runOnModule(llvm::Module&) + 294
9  clang             0x0000000100089237 llvm::PassManagerImpl::run(llvm::Module&) + 279
10 clang             0x000000010008910d llvm::PassManager::run(llvm::Module&) + 13
11 clang             0x00000001003f6f6b clang::EmitBackendOutput(clang::Diagnostic&, clang::CodeGenOptions const&, clang::TargetOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 4411
12 clang             0x00000001004abcb5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 261
13 clang             0x000000010003ee77 clang::ParseAST(clang::Sema&, bool) + 407
14 clang             0x000000010003e05e clang::CodeGenAction::ExecuteAction() + 686
15 clang             0x0000000100019c6a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 858
16 clang             0x0000000100019848 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2648
17 clang             0x0000000100013efb cc1_main(char const**, char const**, char const*, void*) + 5755
18 clang             0x00000001000033e7 main + 679
19 clang             0x0000000100003134 start + 52
Stack dump:
0.	Program arguments:  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/stage1-install-x86_64/bin/clang -cc1 -triple i386-apple-macosx10.6.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name AsmPrinterDwarf.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -target-cpu yonah -target-linker-version 123.2 -g -coverage-file 
/clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.o -resource-dir /clang.obj/clang-9999.99.roots/clang-9999.99~obj/stage1-install-x86_64/bin/../lib/clang/3.0 -dependency-file /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.d.tmp -MP -MT /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.o -MT /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.d -D NDEBUG -D _GNU_SOURCE -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D DISABLE_DEFAULT_STRICT_ALIASING -D DISABLE_ARM_DARWIN_USE_MOVT -I  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/include -I  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter -I  /clang.src/src/include -I  /clang.src/src/lib/CodeGen/AsmPrinter -O2 -Woverloaded-virtual -Wcast-qual -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -fconst-strings -fdeprecated-macro -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fno-rtti -fno-common -fdiagnostics-show-option -o  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.o -x c++  /clang.src/src/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp -dwarf-debug-flags  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/stage1-install-x86_64/bin/clang -arch i386 -I  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/include -I  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter -I  /clang.src/src/include -I  /clang.src/src/lib/CodeGen/AsmPrinter -D NDEBUG -D _GNU_SOURCE -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -O2 -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual -Wcast-qual -m32 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -D DISABLE_DEFAULT_STRICT_ALIASING -D DISABLE_ARM_DARWIN_USE_MOVT -g -c -MMD -MP -MF  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.d.tmp -MT  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.o -MT  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.d  /clang.src/src/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp -o  /clang.obj/clang-9999.99.roots/clang-9999.99~obj/i386/lib/CodeGen/AsmPrinter/Release/AsmPrinterDwarf.o -mlinker-version=123.2 -mtune=core2 -mmacosx-version-min=10.6 
1.	<eof> parser at end of file
2.	Per-module optimization passes
3.	Running pass 'CallGraph Pass Manager' on module ' /clang.src/src/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp'.
4.	Running pass 'Value Propagation' on function '@_ZNK4llvm10AsmPrinter16EmitEncodingByteEjPKc'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
 Chad

On Jun 28, 2011, at 10:25 PM, Rafael Espindola wrote:

> Author: rafael
> Date: Wed Jun 29 00:25:47 2011
> New Revision: 134057
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=134057&view=rev
> Log:
> Let simplify cfg simplify bb with only debug and lifetime intrinsics.
> 
> Added:
>    llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
> Modified:
>    llvm/trunk/include/llvm/BasicBlock.h
>    llvm/trunk/lib/Transforms/Utils/Local.cpp
>    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
>    llvm/trunk/lib/VMCore/BasicBlock.cpp
> 
> Modified: llvm/trunk/include/llvm/BasicBlock.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=134057&r1=134056&r2=134057&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/BasicBlock.h (original)
> +++ llvm/trunk/include/llvm/BasicBlock.h Wed Jun 29 00:25:47 2011
> @@ -138,6 +138,12 @@
>     return const_cast<BasicBlock*>(this)->getFirstNonPHIOrDbg();
>   }
> 
> +  // Same as above, but also skip lifetime intrinsics.
> +  Instruction* getFirstNonPHIOrDbgOrLifetime();
> +  const Instruction* getFirstNonPHIOrDbgOrLifetime() const {
> +    return const_cast<BasicBlock*>(this)->getFirstNonPHIOrDbgOrLifetime();
> +  }
> +
>   /// removeFromParent - This method unlinks 'this' from the containing
>   /// function, but does not delete it.
>   ///
> 
> Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=134057&r1=134056&r2=134057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Jun 29 00:25:47 2011
> @@ -536,9 +536,9 @@
> 
> /// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
> /// unconditional branch, and contains no instructions other than PHI nodes,
> -/// potential debug intrinsics and the branch.  If possible, eliminate BB by
> -/// rewriting all the predecessors to branch to the successor block and return
> -/// true.  If we can't transform, return false.
> +/// potential side-effect free intrinsics and the branch.  If possible,
> +/// eliminate BB by rewriting all the predecessors to branch to the successor
> +/// block and return true.  If we can't transform, return false.
> bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB) {
>   assert(BB != &BB->getParent()->getEntryBlock() &&
>          "TryToSimplifyUncondBranchFromEmptyBlock called on entry block!");
> @@ -613,13 +613,15 @@
>     }
>   }
> 
> -  while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
> -    if (Succ->getSinglePredecessor()) {
> -      // BB is the only predecessor of Succ, so Succ will end up with exactly
> -      // the same predecessors BB had.
> -      Succ->getInstList().splice(Succ->begin(),
> -                                 BB->getInstList(), BB->begin());
> -    } else {
> +  if (Succ->getSinglePredecessor()) {
> +    // BB is the only predecessor of Succ, so Succ will end up with exactly
> +    // the same predecessors BB had.
> +
> +    // Copy over any phi, debug or lifetime instruction.
> +    BB->getTerminator()->eraseFromParent();
> +    Succ->getInstList().splice(Succ->begin(), BB->getInstList());
> +  } else {
> +    while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
>       // We explicitly check for such uses in CanPropagatePredecessorsForPHIs.
>       assert(PN->use_empty() && "There shouldn't be any uses here!");
>       PN->eraseFromParent();
> 
> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=134057&r1=134056&r2=134057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jun 29 00:25:47 2011
> @@ -2604,7 +2604,7 @@
>   BasicBlock *BB = BI->getParent();
> 
>   // If the Terminator is the only non-phi instruction, simplify the block.
> -  BasicBlock::iterator I = BB->getFirstNonPHIOrDbg();
> +  BasicBlock::iterator I = BB->getFirstNonPHIOrDbgOrLifetime();
>   if (I->isTerminator() && BB != &BB->getParent()->getEntryBlock() &&
>       TryToSimplifyUncondBranchFromEmptyBlock(BB))
>     return true;
> 
> Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=134057&r1=134056&r2=134057&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/BasicBlock.cpp (original)
> +++ llvm/trunk/lib/VMCore/BasicBlock.cpp Wed Jun 29 00:25:47 2011
> @@ -147,6 +147,26 @@
>   return &*i;
> }
> 
> +Instruction* BasicBlock::getFirstNonPHIOrDbgOrLifetime() {
> +  // All valid basic blocks should have a terminator,
> +  // which is not a PHINode. If we have an invalid basic
> +  // block we'll get an assertion failure when dereferencing
> +  // a past-the-end iterator.
> +  BasicBlock::iterator i = begin();
> +  for (;; ++i) {
> +    if (isa<PHINode>(i) || isa<DbgInfoIntrinsic>(i))
> +      continue;
> +
> +    const IntrinsicInst *II = dyn_cast<IntrinsicInst>(i);
> +    if (!II)
> +      break;
> +    if (II->getIntrinsicID() != Intrinsic::lifetime_start &&
> +        II->getIntrinsicID() != Intrinsic::lifetime_end)
> +      break;
> +  }
> +  return &*i;
> +}
> +
> void BasicBlock::dropAllReferences() {
>   for(iterator I = begin(), E = end(); I != E; ++I)
>     I->dropAllReferences();
> 
> Added: llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll?rev=134057&view=auto
> ==============================================================================
> --- llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll (added)
> +++ llvm/trunk/test/Transforms/SimplifyCFG/lifetime.ll Wed Jun 29 00:25:47 2011
> @@ -0,0 +1,29 @@
> +; RUN: opt < %s -simplifycfg -S | FileCheck %s
> +
> +; Test that a lifetime intrinsic doesn't prevent us from simplifying this.
> +
> +; CHECK: foo
> +; CHECK: entry:
> +; CHECK-NOT: bb0:
> +; CHECK-NOT: bb1:
> +; CHECK: ret
> +define void @foo(i1 %x) {
> +entry:
> +  %a = alloca i8
> +  call void @llvm.lifetime.start(i64 -1, i8* %a) nounwind
> +  br i1 %x, label %bb0, label %bb1
> +
> +bb0:
> +  call void @llvm.lifetime.end(i64 -1, i8* %a) nounwind
> +  br label %bb1
> +
> +bb1:
> +  call void @f()
> +  ret void
> +}
> +
> +declare void @f()
> +
> +declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind
> +
> +declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110629/c548763c/attachment.html>


More information about the llvm-commits mailing list