<div dir="ltr">Fixed in r258661.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 24, 2016 at 6:30 AM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It crashes LTO. <a href="http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/9251" target="_blank">http://bb.pgr.jp/builders/clang-3stage-x86_64-linux/builds/9251</a><br><br>A reduced testcase attached. Reproducible with "opt -ipsccp".<div><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Sun, Jan 24, 2016 at 3:30 PM David Majnemer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sun Jan 24 00:26:47 2016<br>
New Revision: 258654<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=258654&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=258654&view=rev</a><br>
Log:<br>
[SCCP] Remove duplicate code<br>
<br>
SCCP has code identical to changeToUnreachable's behavior, switch it<br>
over to just call changeToUnreachable.<br>
<br>
No functionality change intended.<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Transforms/Utils/Local.h<br>
llvm/trunk/lib/Transforms/Scalar/SCCP.cpp<br>
llvm/trunk/lib/Transforms/Utils/Local.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=258654&r1=258653&r2=258654&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=258654&r1=258653&r2=258654&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original)<br>
+++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Sun Jan 24 00:26:47 2016<br>
@@ -295,7 +295,7 @@ unsigned removeAllNonTerminatorAndEHPadI<br>
<br>
/// \brief Insert an unreachable instruction before the specified<br>
/// instruction, making it and the rest of the code in the block dead.<br>
-void changeToUnreachable(Instruction *I, bool UseLLVMTrap);<br>
+unsigned changeToUnreachable(Instruction *I, bool UseLLVMTrap);<br>
<br>
/// Replace 'BB's terminator with one that does not have an unwind successor<br>
/// block. Rewrites `invoke` to `call`, etc. Updates any PHIs in unwind<br>
<br>
Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=258654&r1=258653&r2=258654&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=258654&r1=258653&r2=258654&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Sun Jan 24 00:26:47 2016<br>
@@ -1564,14 +1564,6 @@ FunctionPass *llvm::createSCCPPass() {<br>
return new SCCP();<br>
}<br>
<br>
-static void DeleteInstructionInBlock(BasicBlock *BB) {<br>
- DEBUG(dbgs() << " BasicBlock Dead:" << *BB);<br>
- ++NumDeadBlocks;<br>
-<br>
- unsigned NumRemovedInBB = removeAllNonTerminatorAndEHPadInstructions(BB);<br>
- NumInstRemoved += NumRemovedInBB;<br>
-}<br>
-<br>
// runOnFunction() - Run the Sparse Conditional Constant Propagation algorithm,<br>
// and return true if the function was modified.<br>
//<br>
@@ -1608,7 +1600,11 @@ bool SCCP::runOnFunction(Function &F) {<br>
<br>
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {<br>
if (!Solver.isBlockExecutable(&*BB)) {<br>
- DeleteInstructionInBlock(&*BB);<br>
+ DEBUG(dbgs() << " BasicBlock Dead:" << *BB);<br>
+<br>
+ ++NumDeadBlocks;<br>
+ NumInstRemoved += removeAllNonTerminatorAndEHPadInstructions(BB);<br>
+<br>
MadeChanges = true;<br>
continue;<br>
}<br>
@@ -1806,18 +1802,13 @@ bool IPSCCP::runOnModule(Module &M) {<br>
<br>
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {<br>
if (!Solver.isBlockExecutable(&*BB)) {<br>
- DeleteInstructionInBlock(&*BB);<br>
- MadeChanges = true;<br>
+ DEBUG(dbgs() << " BasicBlock Dead:" << *BB);<br>
<br>
- TerminatorInst *TI = BB->getTerminator();<br>
- for (BasicBlock *Succ : TI->successors()) {<br>
- if (!Succ->empty() && isa<PHINode>(Succ->begin()))<br>
- Succ->removePredecessor(&*BB);<br>
- }<br>
- if (!TI->use_empty())<br>
- TI->replaceAllUsesWith(UndefValue::get(TI->getType()));<br>
- TI->eraseFromParent();<br>
- new UnreachableInst(M.getContext(), &*BB);<br>
+ ++NumDeadBlocks;<br>
+ NumInstRemoved +=<br>
+ changeToUnreachable(&*BB->begin(), /*UseLLVMTrap=*/false);<br>
+<br>
+ MadeChanges = true;<br>
<br>
if (&*BB != &F->front())<br>
BlocksToErase.push_back(&*BB);<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=258654&r1=258653&r2=258654&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=258654&r1=258653&r2=258654&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sun Jan 24 00:26:47 2016<br>
@@ -1243,7 +1243,7 @@ unsigned llvm::removeAllNonTerminatorAnd<br>
return NumDeadInst;<br>
}<br>
<br>
-void llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap) {<br>
+unsigned llvm::changeToUnreachable(Instruction *I, bool UseLLVMTrap) {<br>
BasicBlock *BB = I->getParent();<br>
// Loop over all of the successors, removing BB's entry from any PHI<br>
// nodes.<br>
@@ -1261,12 +1261,15 @@ void llvm::changeToUnreachable(Instructi<br>
new UnreachableInst(I->getContext(), I);<br>
<br>
// All instructions after this are dead.<br>
+ unsigned NumInstrsRemoved = 0;<br>
BasicBlock::iterator BBI = I->getIterator(), BBE = BB->end();<br>
while (BBI != BBE) {<br>
if (!BBI->use_empty())<br>
BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));<br>
BB->getInstList().erase(BBI++);<br>
+ ++NumInstrsRemoved;<br>
}<br>
+ return NumInstrsRemoved;<br>
}<br>
<br>
/// changeToCall - Convert the specified invoke into a normal call.<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div></div>
</blockquote></div><br></div>