<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">It is a two stage build. The 1st stage is a release assert compiler, which is then used to build the 2nd stage with ThinLTO enabled.<div class=""><br class=""></div><div class="">The cmake arguments for the 1st stage are listed here:</div><div class=""><a href="http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/39273/consoleFull#console-section-15" class="">http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/39273/consoleFull#console-section-15</a></div><div class=""><br class=""></div><div class="">The cmake arguments for the 2nd stage are listed here:</div><div class=""><a href="http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/5938/consoleFull#console-section-18" class="">http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/5938/consoleFull#console-section-18</a></div><div class=""><br class=""></div><div class="">In the meantime, could you please revert the commit to get the bot green again?</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Juergen</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 4, 2017, at 5:28 PM, Xinliang David Li <<a href="mailto:davidxl@google.com" class="">davidxl@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I did a self build with thinLTO (using a debug compiler), but could not reproduce the problem. What is exact build configuration used?<div class=""><br class=""></div><div class="">thanks,</div><div class=""><br class=""></div><div class="">David</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 4, 2017 at 3:22 PM, Xinliang David Li <span dir="ltr" class=""><<a href="mailto:davidxl@google.com" target="_blank" class="">davidxl@google.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Looking ..<span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">David</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 4, 2017 at 3:19 PM, Juergen Ributzka <span dir="ltr" class=""><<a href="mailto:juergen@ributzka.de" target="_blank" class="">juergen@ributzka.de</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi David,<div class=""><br class=""></div><div class="">I think this broke the Green Dragon ThinLTO Bot:</div><div class=""><a href="http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/5938/" target="_blank" class="">http://green.lab.llvm.org/gree<wbr class="">n/job/clang-stage2-Rthinlto/<wbr class="">5938/</a><br class=""></div><div class=""><br class=""></div><div class="">Could you please take a look?</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Juergen</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Oct 4, 2017 at 1:17 PM, Xinliang David Li via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: davidxl<br class="">
Date: Wed Oct 4 13:17:55 2017<br class="">
New Revision: 314928<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314928&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=314928&view=rev</a><br class="">
Log:<br class="">
Recommit r314561 after fixing msan build failure<br class="">
<br class="">
(trial 2) Incoming val defined by terminator instruction which<br class="">
also requires bitcasts can not be handled.<br class="">
<br class="">
<br class="">
Added:<br class="">
llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr1.ll<br class="">
- copied unchanged from r314621, llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr1.ll<br class="">
llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr2.ll<br class="">
- copied unchanged from r314621, llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr2.ll<br class="">
llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr3.ll<br class="">
- copied unchanged from r314621, llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr3.ll<br class="">
llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr4.ll<br class="">
- copied unchanged from r314621, llvm/trunk/test/Transforms/Ins<wbr class="">tCombine/intptr4.ll<br class="">
Modified:<br class="">
llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombineInternal.h<br class="">
llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombinePHI.cpp<br class="">
<br class="">
Modified: llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombineInternal.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h?rev=314928&r1=314927&r2=314928&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/llvm/trunk/lib/Transform<wbr class="">s/InstCombine/InstCombineInter<wbr class="">nal.h?rev=314928&r1=314927&r2=<wbr class="">314928&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombineInternal.h (original)<br class="">
+++ llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombineInternal.h Wed Oct 4 13:17:55 2017<br class="">
@@ -670,6 +670,10 @@ private:<br class="">
Instruction *FoldPHIArgGEPIntoPHI(PHINode &PN);<br class="">
Instruction *FoldPHIArgLoadIntoPHI(PHINode &PN);<br class="">
Instruction *FoldPHIArgZextsIntoPHI(PHINod<wbr class="">e &PN);<br class="">
+ /// If an integer typed PHI has only one use which is an IntToPtr operation,<br class="">
+ /// replace the PHI with an existing pointer typed PHI if it exists. Otherwise<br class="">
+ /// insert a new pointer typed PHI and replace the original one.<br class="">
+ Instruction *FoldIntegerTypedPHI(PHINode &PN);<br class="">
<br class="">
/// Helper function for FoldPHIArgXIntoPHI() to set debug location for the<br class="">
/// folded operation.<br class="">
<br class="">
Modified: llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombinePHI.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=314928&r1=314927&r2=314928&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/llvm/trunk/lib/Transform<wbr class="">s/InstCombine/InstCombinePHI.c<wbr class="">pp?rev=314928&r1=314927&r2=314<wbr class="">928&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombinePHI.cpp (original)<br class="">
+++ llvm/trunk/lib/Transforms/Inst<wbr class="">Combine/InstCombinePHI.cpp Wed Oct 4 13:17:55 2017<br class="">
@@ -40,6 +40,233 @@ void InstCombiner::PHIArgMergedDebu<wbr class="">gLoc(<br class="">
}<br class="">
}<br class="">
<br class="">
+// Replace Integer typed PHI PN if the PHI's value is used as a pointer value.<br class="">
+// If there is an existing pointer typed PHI that produces the same value as PN,<br class="">
+// replace PN and the IntToPtr operation with it. Otherwise, synthesize a new<br class="">
+// PHI node:<br class="">
+//<br class="">
+// Case-1:<br class="">
+// bb1:<br class="">
+// int_init = PtrToInt(ptr_init)<br class="">
+// br label %bb2<br class="">
+// bb2:<br class="">
+// int_val = PHI([int_init, %bb1], [int_val_inc, %bb2]<br class="">
+// ptr_val = PHI([ptr_init, %bb1], [ptr_val_inc, %bb2]<br class="">
+// ptr_val2 = IntToPtr(int_val)<br class="">
+// ...<br class="">
+// use(ptr_val2)<br class="">
+// ptr_val_inc = ...<br class="">
+// inc_val_inc = PtrToInt(ptr_val_inc)<br class="">
+//<br class="">
+// ==><br class="">
+// bb1:<br class="">
+// br label %bb2<br class="">
+// bb2:<br class="">
+// ptr_val = PHI([ptr_init, %bb1], [ptr_val_inc, %bb2]<br class="">
+// ...<br class="">
+// use(ptr_val)<br class="">
+// ptr_val_inc = ...<br class="">
+//<br class="">
+// Case-2:<br class="">
+// bb1:<br class="">
+// int_ptr = BitCast(ptr_ptr)<br class="">
+// int_init = Load(int_ptr)<br class="">
+// br label %bb2<br class="">
+// bb2:<br class="">
+// int_val = PHI([int_init, %bb1], [int_val_inc, %bb2]<br class="">
+// ptr_val2 = IntToPtr(int_val)<br class="">
+// ...<br class="">
+// use(ptr_val2)<br class="">
+// ptr_val_inc = ...<br class="">
+// inc_val_inc = PtrToInt(ptr_val_inc)<br class="">
+// ==><br class="">
+// bb1:<br class="">
+// ptr_init = Load(ptr_ptr)<br class="">
+// br label %bb2<br class="">
+// bb2:<br class="">
+// ptr_val = PHI([ptr_init, %bb1], [ptr_val_inc, %bb2]<br class="">
+// ...<br class="">
+// use(ptr_val)<br class="">
+// ptr_val_inc = ...<br class="">
+// ...<br class="">
+//<br class="">
+Instruction *InstCombiner::FoldIntegerType<wbr class="">dPHI(PHINode &PN) {<br class="">
+ if (!PN.getType()->isIntegerTy())<br class="">
+ return nullptr;<br class="">
+ if (!PN.hasOneUse())<br class="">
+ return nullptr;<br class="">
+<br class="">
+ auto *IntToPtr = dyn_cast<IntToPtrInst>(PN.user<wbr class="">_back());<br class="">
+ if (!IntToPtr)<br class="">
+ return nullptr;<br class="">
+<br class="">
+ // Check if the pointer is actually used as pointer:<br class="">
+ auto HasPointerUse = [](Instruction *IIP) {<br class="">
+ for (User *U : IIP->users()) {<br class="">
+ Value *Ptr = nullptr;<br class="">
+ if (LoadInst *LoadI = dyn_cast<LoadInst>(U)) {<br class="">
+ Ptr = LoadI->getPointerOperand();<br class="">
+ } else if (StoreInst *SI = dyn_cast<StoreInst>(U)) {<br class="">
+ Ptr = SI->getPointerOperand();<br class="">
+ } else if (GetElementPtrInst *GI = dyn_cast<GetElementPtrInst>(U)<wbr class="">) {<br class="">
+ Ptr = GI->getPointerOperand();<br class="">
+ }<br class="">
+<br class="">
+ if (Ptr && Ptr == IIP)<br class="">
+ return true;<br class="">
+ }<br class="">
+ return false;<br class="">
+ };<br class="">
+<br class="">
+ if (!HasPointerUse(IntToPtr))<br class="">
+ return nullptr;<br class="">
+<br class="">
+ if (DL.getPointerSizeInBits(IntTo<wbr class="">Ptr->getAddressSpace()) !=<br class="">
+ DL.getTypeSizeInBits(IntToPtr-<wbr class="">>getOperand(0)->getType()))<br class="">
+ return nullptr;<br class="">
+<br class="">
+ SmallVector<Value *, 4> AvailablePtrVals;<br class="">
+ for (unsigned i = 0; i != PN.getNumIncomingValues(); ++i) {<br class="">
+ Value *Arg = PN.getIncomingValue(i);<br class="">
+<br class="">
+ // First look backward:<br class="">
+ if (auto *PI = dyn_cast<PtrToIntInst>(Arg)) {<br class="">
+ AvailablePtrVals.emplace_back(<wbr class="">PI->getOperand(0));<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
+ // Next look forward:<br class="">
+ Value *ArgIntToPtr = nullptr;<br class="">
+ for (User *U : Arg->users()) {<br class="">
+ if (isa<IntToPtrInst>(U) && U->getType() == IntToPtr->getType() &&<br class="">
+ (DT.dominates(cast<Instruction<wbr class="">>(U), PN.getIncomingBlock(i)) ||<br class="">
+ cast<Instruction>(U)->getPare<wbr class="">nt() == PN.getIncomingBlock(i))) {<br class="">
+ ArgIntToPtr = U;<br class="">
+ break;<br class="">
+ }<br class="">
+ }<br class="">
+<br class="">
+ if (ArgIntToPtr) {<br class="">
+ AvailablePtrVals.emplace_back(<wbr class="">ArgIntToPtr);<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
+ // If Arg is defined by a PHI, allow it. This will also create<br class="">
+ // more opportunities iteratively.<br class="">
+ if (isa<PHINode>(Arg)) {<br class="">
+ AvailablePtrVals.emplace_back(<wbr class="">Arg);<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
+ // For a single use integer load:<br class="">
+ auto *LoadI = dyn_cast<LoadInst>(Arg);<br class="">
+ if (!LoadI)<br class="">
+ return nullptr;<br class="">
+<br class="">
+ if (!LoadI->hasOneUse())<br class="">
+ return nullptr;<br class="">
+<br class="">
+ // Push the integer typed Load instruction into the available<br class="">
+ // value set, and fix it up later when the pointer typed PHI<br class="">
+ // is synthesized.<br class="">
+ AvailablePtrVals.emplace_back(<wbr class="">LoadI);<br class="">
+ }<br class="">
+<br class="">
+ // Now search for a matching PHI<br class="">
+ auto *BB = PN.getParent();<br class="">
+ assert(AvailablePtrVals.size() == PN.getNumIncomingValues() &&<br class="">
+ "Not enough available ptr typed incoming values");<br class="">
+ PHINode *MatchingPtrPHI = nullptr;<br class="">
+ for (auto II = BB->begin(), EI = BasicBlock::iterator(BB->getFi<wbr class="">rstNonPHI());<br class="">
+ II != EI; II++) {<br class="">
+ PHINode *PtrPHI = dyn_cast<PHINode>(II);<br class="">
+ if (!PtrPHI || PtrPHI == &PN || PtrPHI->getType() != IntToPtr->getType())<br class="">
+ continue;<br class="">
+ MatchingPtrPHI = PtrPHI;<br class="">
+ for (unsigned i = 0; i != PtrPHI->getNumIncomingValues()<wbr class="">; ++i) {<br class="">
+ if (AvailablePtrVals[i] != PtrPHI->getIncomingValue(i)) {<br class="">
+ MatchingPtrPHI = nullptr;<br class="">
+ break;<br class="">
+ }<br class="">
+ }<br class="">
+<br class="">
+ if (MatchingPtrPHI)<br class="">
+ break;<br class="">
+ }<br class="">
+<br class="">
+ if (MatchingPtrPHI) {<br class="">
+ assert(MatchingPtrPHI->getType<wbr class="">() == IntToPtr->getType() &&<br class="">
+ "Phi's Type does not match with IntToPtr");<br class="">
+ // The PtrToCast + IntToPtr will be simplified later<br class="">
+ return CastInst::CreateBitOrPointerCa<wbr class="">st(MatchingPtrPHI,<br class="">
+ IntToPtr->getOperand(0)->getTy<wbr class="">pe());<br class="">
+ }<br class="">
+<br class="">
+ // If it requires a conversion for every PHI operand, do not do it.<br class="">
+ if (std::all_of(AvailablePtrVals.<wbr class="">begin(), AvailablePtrVals.end(),<br class="">
+ [&](Value *V) {<br class="">
+ return (V->getType() != IntToPtr->getType()) ||<br class="">
+ isa<IntToPtrInst>(V);<br class="">
+ }))<br class="">
+ return nullptr;<br class="">
+<br class="">
+ // If any of the operand that requires casting is a terminator<br class="">
+ // instruction, do not do it.<br class="">
+ if (std::any_of(AvailablePtrVals.<wbr class="">begin(), AvailablePtrVals.end(),<br class="">
+ [&](Value *V) {<br class="">
+ return (V->getType() != IntToPtr->getType()) &&<br class="">
+ isa<TerminatorInst>(V);<br class="">
+ }))<br class="">
+ return nullptr;<br class="">
+<br class="">
+ PHINode *NewPtrPHI = PHINode::Create(<br class="">
+ IntToPtr->getType(), PN.getNumIncomingValues(), PN.getName() + ".ptr");<br class="">
+<br class="">
+ InsertNewInstBefore(NewPtrPHI, PN);<br class="">
+ for (unsigned i = 0; i != PN.getNumIncomingValues(); ++i) {<br class="">
+ auto *IncomingBB = PN.getIncomingBlock(i);<br class="">
+ auto *IncomingVal = AvailablePtrVals[i];<br class="">
+<br class="">
+ if (IncomingVal->getType() == IntToPtr->getType()) {<br class="">
+ NewPtrPHI->addIncoming(Incomin<wbr class="">gVal, IncomingBB);<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
+#ifndef NDEBUG<br class="">
+ LoadInst *LoadI = dyn_cast<LoadInst>(IncomingVal<wbr class="">);<br class="">
+ assert((isa<PHINode>(IncomingV<wbr class="">al) ||<br class="">
+ IncomingVal->getType()->isPoin<wbr class="">terTy() ||<br class="">
+ (LoadI && LoadI->hasOneUse())) &&<br class="">
+ "Can not replace LoadInst with multiple uses");<br class="">
+#endif<br class="">
+ // Need to insert a BitCast.<br class="">
+ // For an integer Load instruction with a single use, the load + IntToPtr<br class="">
+ // cast will be simplified into a pointer load:<br class="">
+ // %v = load i64, i64* %a.ip, align 8<br class="">
+ // %v.cast = inttoptr i64 %v to float **<br class="">
+ // ==><br class="">
+ // %v.ptrp = bitcast i64 * %a.ip to float **<br class="">
+ // %v.cast = load float *, float ** %v.ptrp, align 8<br class="">
+ auto *CI = CastInst::CreateBitOrPointerCa<wbr class="">st(<br class="">
+ IncomingVal, IntToPtr->getType(), IncomingVal->getName() + ".ptr");<br class="">
+ if (auto *IncomingI = dyn_cast<Instruction>(Incoming<wbr class="">Val)) {<br class="">
+ BasicBlock::iterator InsertPos(IncomingI);<br class="">
+ InsertPos++;<br class="">
+ if (isa<PHINode>(IncomingI))<br class="">
+ InsertPos = IncomingI->getParent()->getFir<wbr class="">stInsertionPt();<br class="">
+ InsertNewInstBefore(CI, *InsertPos);<br class="">
+ } else {<br class="">
+ auto *InsertBB = &IncomingBB->getParent()->getE<wbr class="">ntryBlock();<br class="">
+ InsertNewInstBefore(CI, *InsertBB->getFirstInsertionPt<wbr class="">());<br class="">
+ }<br class="">
+ NewPtrPHI->addIncoming(CI, IncomingBB);<br class="">
+ }<br class="">
+<br class="">
+ // The PtrToCast + IntToPtr will be simplified later<br class="">
+ return CastInst::CreateBitOrPointerCa<wbr class="">st(NewPtrPHI,<br class="">
+ IntToPtr->getOperand(0)->getTy<wbr class="">pe());<br class="">
+}<br class="">
+<br class="">
/// If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the<br class="">
/// adds all have a single use, turn this into a phi and a single binop.<br class="">
Instruction *InstCombiner::FoldPHIArgBinOp<wbr class="">IntoPHI(PHINode &PN) {<br class="">
@@ -903,6 +1130,9 @@ Instruction *InstCombiner::visitPHINode(<br class="">
// this PHI only has a single use (a PHI), and if that PHI only has one use (a<br class="">
// PHI)... break the cycle.<br class="">
if (PN.hasOneUse()) {<br class="">
+ if (Instruction *Result = FoldIntegerTypedPHI(PN))<br class="">
+ return Result;<br class="">
+<br class="">
Instruction *PHIUser = cast<Instruction>(PN.user_back<wbr class="">());<br class="">
if (PHINode *PU = dyn_cast<PHINode>(PHIUser)) {<br class="">
SmallPtrSet<PHINode*, 16> PotentiallyDeadPHIs;<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div>
</blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>