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