<div dir="ltr"><span style="font-size:12.8px">Clang instrumented with msan (stage2) is building new clang (stage3).</span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Easy but slow reproducer is to go to empty dir and run command below:</span></div><div><span style="font-size:12.8px">BUILDBOT_REVISION=303497 BUILDBOT_CLOBBER=1 <path to llvm checkout>/projects/zorg/zorg/buildbot/builders/sanitizers/buildbot_bootstrap.sh</span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 20, 2017 at 10:02 PM, Sanjoy Das <span dir="ltr"><<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Reverted in r303498<br>
<div class="HOEnZb"><div class="h5"><br>
On Sat, May 20, 2017 at 9:59 PM, Sanjoy Das<br>
<<a href="mailto:sanjoy@playingwithpointers.com">sanjoy@playingwithpointers.<wbr>com</a>> wrote:<br>
> Hi Vitaly,<br>
><br>
> I'm about to revert this change, but I have a question -- what this<br>
> failure seen when the ToT clang (built with a "known good" clang +<br>
> msan) tried to build itself, or when a bootstrapped clang (i.e. a<br>
> clang built with a ToT clang + msan) tried to bootstrap itself?<br>
><br>
> Thanks<br>
> -- Sanjoy<br>
><br>
> On Sat, May 20, 2017 at 9:49 PM, Vitaly Buka <<a href="mailto:vitalybuka@google.com">vitalybuka@google.com</a>> wrote:<br>
>> <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/1379/steps/check-llvm%20check-clang%20stage3%2Fmsan/logs/stdio" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/<wbr>builders/sanitizer-x86_64-<wbr>linux-bootstrap/builds/1379/<wbr>steps/check-llvm%20check-<wbr>clang%20stage3%2Fmsan/logs/<wbr>stdio</a><br>
>><br>
>> FAILED: tools/llvm-xray/CMakeFiles/<wbr>llvm-xray.dir/xray-color-<wbr>helper.cc.o<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm_build_<wbr>msan/bin/clang++<br>
>> -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_GLOBAL_ISEL -D_DEBUG -D_GNU_SOURCE<br>
>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS<br>
>> -Itools/llvm-xray<br>
>> -I/mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>llvm-xray<br>
>> -Iinclude<br>
>> -I/mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/include<br>
>> -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W<br>
>> -Wno-unused-parameter -Wwrite-strings -Wcast-qual<br>
>> -Wmissing-field-initializers -pedantic -Wno-long-long<br>
>> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor<br>
>> -Wstring-conversion -fcolor-diagnostics -ffunction-sections -fdata-sections<br>
>> -O3    -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT<br>
>> tools/llvm-xray/CMakeFiles/<wbr>llvm-xray.dir/xray-color-<wbr>helper.cc.o -MF<br>
>> tools/llvm-xray/CMakeFiles/<wbr>llvm-xray.dir/xray-color-<wbr>helper.cc.o.d -o<br>
>> tools/llvm-xray/CMakeFiles/<wbr>llvm-xray.dir/xray-color-<wbr>helper.cc.o -c<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>llvm-xray/xray-color-helper.cc<br>
>> ==969==WARNING: MemorySanitizer: use-of-uninitialized-value<br>
>>     #0 0x3533258 in<br>
>> llvm::X86InstrInfo::<wbr>AnalyzeBranchImpl(llvm::<wbr>MachineBasicBlock&,<br>
>> llvm::MachineBasicBlock*&, llvm::MachineBasicBlock*&,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineOperand>&,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineInstr*>&, bool) const<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>Target/X86/X86InstrInfo.cpp:<wbr>6093:22<br>
>>     #1 0x353333d in<br>
>> llvm::X86InstrInfo::<wbr>analyzeBranch(llvm::<wbr>MachineBasicBlock&,<br>
>> llvm::MachineBasicBlock*&, llvm::MachineBasicBlock*&,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineOperand>&, bool) const<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>Target/X86/X86InstrInfo.cpp:<wbr>6133:10<br>
>>     #2 0x42fddcc in llvm::TailDuplicator::<wbr>tailDuplicate(bool,<br>
>> llvm::MachineBasicBlock*, llvm::MachineBasicBlock*,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineBasicBlock*>&,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineInstr*>&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/TailDuplicator.cpp:<wbr>837:10<br>
>>     #3 0x42fab3a in llvm::TailDuplicator::<wbr>tailDuplicateAndUpdate(bool,<br>
>> llvm::MachineBasicBlock*, llvm::MachineBasicBlock*,<br>
>> llvm::SmallVectorImpl<llvm::<wbr>MachineBasicBlock*>*, llvm::function_ref<void<br>
>> (llvm::MachineBasicBlock*)>*)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/TailDuplicator.cpp:<wbr>148:8<br>
>>     #4 0x44e921b in (anonymous<br>
>> namespace)::<wbr>MachineBlockPlacement::<wbr>maybeTailDuplicateBlock(llvm::<wbr>MachineBasicBlock*,<br>
>> llvm::MachineBasicBlock*, (anonymous namespace)::BlockChain&,<br>
>> llvm::SmallSetVector<llvm::<wbr>MachineBasicBlock const*, 16u>*,<br>
>> llvm::ilist_iterator<llvm::<wbr>ilist_detail::node_options<<wbr>llvm::MachineBasicBlock,<br>
>> true, false, void>, false, false>&, bool&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineBlockPlacement.<wbr>cpp:2620:11<br>
>>     #5 0x44cef5d in repeatedlyTailDuplicateBlock<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineBlockPlacement.<wbr>cpp:2501:13<br>
>>     #6 0x44cef5d in (anonymous<br>
>> namespace)::<wbr>MachineBlockPlacement::<wbr>buildChain(llvm::<wbr>MachineBasicBlock<br>
>> const*, (anonymous namespace)::BlockChain&,<br>
>> llvm::SmallSetVector<llvm::<wbr>MachineBasicBlock const*, 16u>*)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineBlockPlacement.<wbr>cpp:1699<br>
>>     #7 0x44b6970 in (anonymous<br>
>> namespace)::<wbr>MachineBlockPlacement::<wbr>buildCFGChains()<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineBlockPlacement.<wbr>cpp:2278:3<br>
>>     #8 0x44b14a9 in (anonymous<br>
>> namespace)::<wbr>MachineBlockPlacement::<wbr>runOnMachineFunction(llvm::<wbr>MachineFunction&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineBlockPlacement.<wbr>cpp:2696:3<br>
>>     #9 0x3f6dcac in<br>
>> llvm::MachineFunctionPass::<wbr>runOnFunction(llvm::Function&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/<wbr>CodeGen/MachineFunctionPass.<wbr>cpp:62:13<br>
>>     #10 0x48e2bee in llvm::FPPassManager::<wbr>runOnFunction(llvm::Function&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/IR/<wbr>LegacyPassManager.cpp:1519:27<br>
>>     #11 0x48e32b4 in llvm::FPPassManager::<wbr>runOnModule(llvm::Module&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/IR/<wbr>LegacyPassManager.cpp:1540:16<br>
>>     #12 0x48e45d3 in runOnModule<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/IR/<wbr>LegacyPassManager.cpp:1596:27<br>
>>     #13 0x48e45d3 in llvm::legacy::PassManagerImpl:<wbr>:run(llvm::Module&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/lib/IR/<wbr>LegacyPassManager.cpp:1699<br>
>>     #14 0x5d3e27e in EmitAssembly<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/CodeGen/BackendUtil.<wbr>cpp:792:19<br>
>>     #15 0x5d3e27e in clang::EmitBackendOutput(<wbr>clang::DiagnosticsEngine&,<br>
>> clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,<br>
>> clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout<br>
>> const&, llvm::Module*, clang::BackendAction,<br>
>> std::__1::unique_ptr<llvm::<wbr>raw_pwrite_stream,<br>
>> std::__1::default_delete<llvm:<wbr>:raw_pwrite_stream> >)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/CodeGen/BackendUtil.<wbr>cpp:1101<br>
>>     #16 0x74dfefe in<br>
>> clang::BackendConsumer::<wbr>HandleTranslationUnit(clang::<wbr>ASTContext&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/CodeGen/<wbr>CodeGenAction.cpp:258:7<br>
>>     #17 0x848e176 in clang::ParseAST(clang::Sema&, bool, bool)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/Parse/ParseAST.cpp:<wbr>159:13<br>
>>     #18 0x69f82ba in clang::FrontendAction::<wbr>Execute()<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/Frontend/<wbr>FrontendAction.cpp:837:8<br>
>>     #19 0x693a02c in<br>
>> clang::CompilerInstance::<wbr>ExecuteAction(clang::<wbr>FrontendAction&)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/Frontend/<wbr>CompilerInstance.cpp:970:11<br>
>>     #20 0x6bc3705 in<br>
>> clang::<wbr>ExecuteCompilerInvocation(<wbr>clang::CompilerInstance*)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/lib/FrontendTool/<wbr>ExecuteCompilerInvocation.cpp:<wbr>249:25<br>
>>     #21 0x976e25 in cc1_main(llvm::ArrayRef<char const*>, char const*,<br>
>> void*)<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/tools/driver/cc1_main.<wbr>cpp:221:13<br>
>>     #22 0x970ce7 in ExecuteCC1Tool<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/tools/driver/driver.cpp:<wbr>299:12<br>
>>     #23 0x970ce7 in main<br>
>> /mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm/tools/<wbr>clang/tools/driver/driver.cpp:<wbr>380<br>
>>     #24 0x7f561ec5c82f in __libc_start_main<br>
>> (/lib/x86_64-linux-gnu/libc.<wbr>so.6+0x2082f)<br>
>>     #25 0x8f0d38 in _start<br>
>> (/mnt/b/sanitizer-buildbot2/<wbr>sanitizer-x86_64-linux-<wbr>bootstrap/build/llvm_build_<wbr>msan/bin/clang-5.0+0x8f0d38)<br>
>><br>
>><br>
>> On Sat, May 20, 2017 at 6:47 PM, Sanjoy Das via llvm-commits<br>
>> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> Author: sanjoy<br>
>>> Date: Sat May 20 20:47:50 2017<br>
>>> New Revision: 303497<br>
>>><br>
>>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303497&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=303497&view=rev</a><br>
>>> Log:<br>
>>> [SCEV] Clarify behavior around max backedge taken count<br>
>>><br>
>>> This change makes the split between the "exact" backedge taken count<br>
>>> and the "maximum" backedge taken count a bit more obvious.  Both of<br>
>>> these are upper bounds on the number of times the loop header<br>
>>> executes (since SCEV does not account for most kinds of abnormal<br>
>>> control flow), but the latter is guaranteed to be a constant.<br>
>>><br>
>>> There were a few places where the max backedge taken count *was* a<br>
>>> non-constant; I've changed those to compute constants instead.<br>
>>><br>
>>> At this point, I'm not sure if the constant max backedge count can be<br>
>>> computed by calling `getUnsignedRange(Exact).<wbr>getUnsignedMax()` without<br>
>>> losing precision.  If it can, we can simplify even further by making<br>
>>> `getMaxBackedgeTakenCount` a thin wrapper around<br>
>>> `getBackedgeTakenCount` and `getUnsignedRange`.<br>
>>><br>
>>> Modified:<br>
>>>     llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h<br>
>>>     llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp<br>
>>>     llvm/trunk/test/Analysis/<wbr>ScalarEvolution/nsw.ll<br>
>>>     llvm/trunk/test/Analysis/<wbr>ScalarEvolution/trip-count-<wbr>pow2.ll<br>
>>><br>
>>> Modified: llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h<br>
>>> URL:<br>
>>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=303497&r1=303496&r2=303497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/Analysis/ScalarEvolution.<wbr>h?rev=303497&r1=303496&r2=<wbr>303497&view=diff</a><br>
>>><br>
>>> ==============================<wbr>==============================<wbr>==================<br>
>>> --- llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h (original)<br>
>>> +++ llvm/trunk/include/llvm/<wbr>Analysis/ScalarEvolution.h Sat May 20 20:47:50<br>
>>> 2017<br>
>>> @@ -656,10 +656,12 @@ private:<br>
>>>      /// Test whether this BackedgeTakenInfo contains complete<br>
>>> information.<br>
>>>      bool hasFullInfo() const { return isComplete(); }<br>
>>><br>
>>> -    /// Return an expression indicating the exact backedge-taken count of<br>
>>> the<br>
>>> -    /// loop if it is known or SCEVCouldNotCompute otherwise. This is the<br>
>>> -    /// number of times the loop header can be guaranteed to execute,<br>
>>> minus<br>
>>> -    /// one.<br>
>>> +    /// Return an expression indicating the exact *backedge-taken*<br>
>>> +    /// count of the loop if it is known or SCEVCouldNotCompute<br>
>>> +    /// otherwise.  If execution makes it to the backedge on every<br>
>>> +    /// iteration (i.e. there are no abnormal exists like exception<br>
>>> +    /// throws and thread exits) then this is the number of times the<br>
>>> +    /// loop header will execute minus one.<br>
>>>      ///<br>
>>>      /// If the SCEV predicate associated with the answer can be different<br>
>>>      /// from AlwaysTrue, we must add a (non null) Predicates argument.<br>
>>> @@ -1398,11 +1400,11 @@ public:<br>
>>>    const SCEV *getExitCount(const Loop *L, BasicBlock *ExitingBlock);<br>
>>><br>
>>>    /// If the specified loop has a predictable backedge-taken count,<br>
>>> return it,<br>
>>> -  /// otherwise return a SCEVCouldNotCompute object. The backedge-taken<br>
>>> count<br>
>>> -  /// is the number of times the loop header will be branched to from<br>
>>> within<br>
>>> -  /// the loop. This is one less than the trip count of the loop, since<br>
>>> it<br>
>>> -  /// doesn't count the first iteration, when the header is branched to<br>
>>> from<br>
>>> -  /// outside the loop.<br>
>>> +  /// otherwise return a SCEVCouldNotCompute object. The backedge-taken<br>
>>> count is<br>
>>> +  /// the number of times the loop header will be branched to from within<br>
>>> the<br>
>>> +  /// loop, assuming there are no abnormal exists like exception throws.<br>
>>> This is<br>
>>> +  /// one less than the trip count of the loop, since it doesn't count<br>
>>> the first<br>
>>> +  /// iteration, when the header is branched to from outside the loop.<br>
>>>    ///<br>
>>>    /// Note that it is not valid to call this method on a loop without a<br>
>>>    /// loop-invariant backedge-taken count (see<br>
>>> @@ -1417,8 +1419,10 @@ public:<br>
>>>    const SCEV *<wbr>getPredicatedBackedgeTakenCoun<wbr>t(const Loop *L,<br>
>>>                                                SCEVUnionPredicate<br>
>>> &Predicates);<br>
>>><br>
>>> -  /// Similar to getBackedgeTakenCount, except return the least SCEV<br>
>>> value<br>
>>> -  /// that is known never to be less than the actual backedge taken<br>
>>> count.<br>
>>> +  /// When successful, this returns a SCEVConstant that is greater than<br>
>>> or equal<br>
>>> +  /// to (i.e. a "conservative over-approximation") of the value returend<br>
>>> by<br>
>>> +  /// getBackedgeTakenCount.  If such a value cannot be computed, it<br>
>>> returns the<br>
>>> +  /// SCEVCouldNotCompute object.<br>
>>>    const SCEV *getMaxBackedgeTakenCount(<wbr>const Loop *L);<br>
>>><br>
>>>    /// Return true if the backedge taken count is either the value<br>
>>> returned by<br>
>>><br>
>>> Modified: llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp<br>
>>> URL:<br>
>>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=303497&r1=303496&r2=303497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Analysis/ScalarEvolution.cpp?<wbr>rev=303497&r1=303496&r2=<wbr>303497&view=diff</a><br>
>>><br>
>>> ==============================<wbr>==============================<wbr>==================<br>
>>> --- llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp (original)<br>
>>> +++ llvm/trunk/lib/Analysis/<wbr>ScalarEvolution.cpp Sat May 20 20:47:50 2017<br>
>>> @@ -5947,6 +5947,8 @@ ScalarEvolution::<wbr>BackedgeTakenInfo::getM<br>
>>>    if (any_of(ExitNotTaken, PredicateNotAlwaysTrue) || !getMax())<br>
>>>      return SE->getCouldNotCompute();<br>
>>><br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(getMax()) ||<br>
>>> isa<SCEVConstant>(getMax())) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>>    return getMax();<br>
>>>  }<br>
>>><br>
>>> @@ -5972,7 +5974,11 @@ bool ScalarEvolution::<wbr>BackedgeTakenInfo:<br>
>>>  }<br>
>>><br>
>>>  ScalarEvolution::ExitLimit::<wbr>ExitLimit(const SCEV *E)<br>
>>> -    : ExactNotTaken(E), MaxNotTaken(E), MaxOrZero(false) {}<br>
>>> +    : ExactNotTaken(E), MaxNotTaken(E), MaxOrZero(false) {<br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(<wbr>MaxNotTaken) ||<br>
>>> +          isa<SCEVConstant>(MaxNotTaken)<wbr>) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>> +}<br>
>>><br>
>>>  ScalarEvolution::ExitLimit::<wbr>ExitLimit(<br>
>>>      const SCEV *E, const SCEV *M, bool MaxOrZero,<br>
>>> @@ -5981,6 +5987,9 @@ ScalarEvolution::ExitLimit::<wbr>ExitLimit(<br>
>>>    assert((isa<<wbr>SCEVCouldNotCompute>(<wbr>ExactNotTaken) ||<br>
>>>            !isa<SCEVCouldNotCompute>(<wbr>MaxNotTaken)) &&<br>
>>>           "Exact is not allowed to be less precise than Max");<br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(<wbr>MaxNotTaken) ||<br>
>>> +          isa<SCEVConstant>(MaxNotTaken)<wbr>) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>>    for (auto *PredSet : PredSetList)<br>
>>>      for (auto *P : *PredSet)<br>
>>>        addPredicate(P);<br>
>>> @@ -5989,11 +5998,19 @@ ScalarEvolution::ExitLimit::<wbr>ExitLimit(<br>
>>>  ScalarEvolution::ExitLimit::<wbr>ExitLimit(<br>
>>>      const SCEV *E, const SCEV *M, bool MaxOrZero,<br>
>>>      const SmallPtrSetImpl<const SCEVPredicate *> &PredSet)<br>
>>> -    : ExitLimit(E, M, MaxOrZero, {&PredSet}) {}<br>
>>> +    : ExitLimit(E, M, MaxOrZero, {&PredSet}) {<br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(<wbr>MaxNotTaken) ||<br>
>>> +          isa<SCEVConstant>(MaxNotTaken)<wbr>) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>> +}<br>
>>><br>
>>>  ScalarEvolution::ExitLimit::<wbr>ExitLimit(const SCEV *E, const SCEV *M,<br>
>>>                                        bool MaxOrZero)<br>
>>> -    : ExitLimit(E, M, MaxOrZero, None) {}<br>
>>> +    : ExitLimit(E, M, MaxOrZero, None) {<br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(<wbr>MaxNotTaken) ||<br>
>>> +          isa<SCEVConstant>(MaxNotTaken)<wbr>) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>> +}<br>
>>><br>
>>>  /// Allocate memory for BackedgeTakenInfo and copy the not-taken count of<br>
>>> each<br>
>>>  /// computable exit into a persistent ExitNotTakenInfo array.<br>
>>> @@ -6018,6 +6035,8 @@ ScalarEvolution::<wbr>BackedgeTakenInfo::Back<br>
>>><br>
>>>          return ExitNotTakenInfo(ExitBB, EL.ExactNotTaken,<br>
>>> std::move(Predicate));<br>
>>>        });<br>
>>> +  assert((isa<<wbr>SCEVCouldNotCompute>(MaxCount) ||<br>
>>> isa<SCEVConstant>(MaxCount)) &&<br>
>>> +         "No point in having a non-constant max backedge taken count!");<br>
>>>  }<br>
>>><br>
>>>  /// Invalidate this result and free the ExitNotTakenInfo array.<br>
>>> @@ -6279,7 +6298,7 @@ ScalarEvolution::ExitLimit ScalarEvoluti<br>
>>>        // to not.<br>
>>>        if (isa<SCEVCouldNotCompute>(<wbr>MaxBECount) &&<br>
>>>            !isa<SCEVCouldNotCompute>(<wbr>BECount))<br>
>>> -        MaxBECount = BECount;<br>
>>> +        MaxBECount =<br>
>>> getConstant(getUnsignedRange(<wbr>BECount).getUnsignedMax());<br>
>>><br>
>>>        return ExitLimit(BECount, MaxBECount, false,<br>
>>>                         {&EL0.Predicates, &EL1.Predicates});<br>
>>> @@ -7583,13 +7602,20 @@ ScalarEvolution::howFarToZero(<wbr>const SCEV<br>
>>>        loopHasNoAbnormalExits(AddRec-<wbr>>getLoop())) {<br>
>>>      const SCEV *Exact =<br>
>>>          getUDivExpr(Distance, CountDown ? getNegativeSCEV(Step) : Step);<br>
>>> -    return ExitLimit(Exact, Exact, false, Predicates);<br>
>>> +    const SCEV *Max =<br>
>>> +        Exact == getCouldNotCompute()<br>
>>> +            ? Exact<br>
>>> +            : getConstant(getUnsignedRange(<wbr>Exact).getUnsignedMax());<br>
>>> +    return ExitLimit(Exact, Max, false, Predicates);<br>
>>>    }<br>
>>><br>
>>>    // Solve the general equation.<br>
>>> -  const SCEV *E = SolveLinEquationWithOverflow(<br>
>>> -      StepC->getAPInt(), getNegativeSCEV(Start), *this);<br>
>>> -  return ExitLimit(E, E, false, Predicates);<br>
>>> +  const SCEV *E = SolveLinEquationWithOverflow(<wbr>StepC->getAPInt(),<br>
>>> +                                               getNegativeSCEV(Start),<br>
>>> *this);<br>
>>> +  const SCEV *M = E == getCouldNotCompute()<br>
>>> +                      ? E<br>
>>> +                      :<br>
>>> getConstant(getUnsignedRange(<wbr>E).getUnsignedMax());<br>
>>> +  return ExitLimit(E, M, false, Predicates);<br>
>>>  }<br>
>>><br>
>>>  ScalarEvolution::ExitLimit<br>
>>> @@ -9218,8 +9244,9 @@ ScalarEvolution::<wbr>howManyLessThans(const<br>
>>>                                  getConstant(<wbr>StrideForMaxBECount), false);<br>
>>>    }<br>
>>><br>
>>> -  if (isa<SCEVCouldNotCompute>(<wbr>MaxBECount))<br>
>>> -    MaxBECount = BECount;<br>
>>> +  if (isa<SCEVCouldNotCompute>(<wbr>MaxBECount) &&<br>
>>> +      !isa<SCEVCouldNotCompute>(<wbr>BECount))<br>
>>> +    MaxBECount = getConstant(getUnsignedRange(<wbr>BECount).getUnsignedMax());<br>
>>><br>
>>>    return ExitLimit(BECount, MaxBECount, MaxOrZero, Predicates);<br>
>>>  }<br>
>>><br>
>>> Modified: llvm/trunk/test/Analysis/<wbr>ScalarEvolution/nsw.ll<br>
>>> URL:<br>
>>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/nsw.ll?rev=303497&r1=303496&r2=303497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Analysis/ScalarEvolution/nsw.<wbr>ll?rev=303497&r1=303496&r2=<wbr>303497&view=diff</a><br>
>>><br>
>>> ==============================<wbr>==============================<wbr>==================<br>
>>> --- llvm/trunk/test/Analysis/<wbr>ScalarEvolution/nsw.ll (original)<br>
>>> +++ llvm/trunk/test/Analysis/<wbr>ScalarEvolution/nsw.ll Sat May 20 20:47:50<br>
>>> 2017<br>
>>> @@ -102,7 +102,7 @@ for.body.i.i:<br>
>>>    %cmp.i.i = icmp eq i32* %ptrincdec.i.i, %end<br>
>>>    br i1 %cmp.i.i, label %_ZSt4fillIPiiEvT_S1_RKT0_.<wbr>exit, label<br>
>>> %for.body.i.i<br>
>>>  ; CHECK: Loop %for.body.i.i: backedge-taken count is ((-4 + (-1 * %begin)<br>
>>> + %end) /u 4)<br>
>>> -; CHECK: Loop %for.body.i.i: max backedge-taken count is ((-4 + (-1 *<br>
>>> %begin) + %end) /u 4)<br>
>>> +; CHECK: Loop %for.body.i.i: max backedge-taken count is<br>
>>> 4611686018427387903<br>
>>>  _ZSt4fillIPiiEvT_S1_RKT0_.<wbr>exit:                   ; preds =<br>
>>> %for.body.i.i, %entry<br>
>>>    ret void<br>
>>>  }<br>
>>><br>
>>> Modified: llvm/trunk/test/Analysis/<wbr>ScalarEvolution/trip-count-<wbr>pow2.ll<br>
>>> URL:<br>
>>> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/trip-count-pow2.ll?rev=303497&r1=303496&r2=303497&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Analysis/ScalarEvolution/trip-<wbr>count-pow2.ll?rev=303497&r1=<wbr>303496&r2=303497&view=diff</a><br>
>>><br>
>>> ==============================<wbr>==============================<wbr>==================<br>
>>> --- llvm/trunk/test/Analysis/<wbr>ScalarEvolution/trip-count-<wbr>pow2.ll (original)<br>
>>> +++ llvm/trunk/test/Analysis/<wbr>ScalarEvolution/trip-count-<wbr>pow2.ll Sat May 20<br>
>>> 20:47:50 2017<br>
>>> @@ -14,7 +14,7 @@ exit:<br>
>>><br>
>>>  ; CHECK-LABEL: @test1<br>
>>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (96 * %n)) /u 32)<br>
>>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (96 * %n)) /u<br>
>>> 32)<br>
>>> +; CHECK: Loop %loop: max backedge-taken count is 134217727<br>
>>>  }<br>
>>><br>
>>>  ; PR19183<br>
>>> @@ -32,7 +32,7 @@ exit:<br>
>>><br>
>>>  ; CHECK-LABEL: @test2<br>
>>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * (%n /u 32)))<br>
>>> /u 32)<br>
>>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (32 * (%n /u<br>
>>> 32))) /u 32)<br>
>>> +; CHECK: Loop %loop: max backedge-taken count is 134217727<br>
>>>  }<br>
>>><br>
>>>  define void @test3(i32 %n) {<br>
>>> @@ -49,7 +49,7 @@ exit:<br>
>>><br>
>>>  ; CHECK-LABEL: @test3<br>
>>>  ; CHECK: Loop %loop: backedge-taken count is ((-32 + (32 * %n)) /u 32)<br>
>>> -; CHECK: Loop %loop: max backedge-taken count is ((-32 + (32 * %n)) /u<br>
>>> 32)<br>
>>> +; CHECK: Loop %loop: max backedge-taken count is 134217727<br>
>>>  }<br>
>>><br>
>>>  define void @test4(i32 %n) {<br>
>>> @@ -66,7 +66,7 @@ exit:<br>
>>><br>
>>>  ; CHECK-LABEL: @test4<br>
>>>  ; CHECK: Loop %loop: backedge-taken count is ((-4 + (-1431655764 * %n))<br>
>>> /u 4)<br>
>>> -; CHECK: Loop %loop: max backedge-taken count is ((-4 + (-1431655764 *<br>
>>> %n)) /u 4)<br>
>>> +; CHECK: Loop %loop: max backedge-taken count is 1073741823<br>
>>>  }<br>
>>><br>
>>>  define void @test5(i32 %n) {<br>
>>> @@ -83,5 +83,5 @@ exit:<br>
>>><br>
>>>  ; CHECK-LABEL: @test5<br>
>>>  ; CHECK: Loop %loop: backedge-taken count is ((-4 + (4 * %n)) /u 4)<br>
>>> -; CHECK: Loop %loop: max backedge-taken count is ((-4 + (4 * %n)) /u 4)<br>
>>> +; CHECK: Loop %loop: max backedge-taken count is 1073741823<br>
>>>  }<br>
>>><br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> llvm-commits mailing list<br>
>>> <a href="mailto:llvm-commits@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-commits</a><br>
>><br>
>><br>
</div></div></blockquote></div><br></div>