<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 27, 2022, 9:23 PM Fangrui Song <<a href="mailto:i@maskray.me">i@maskray.me</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jun 27, 2022 at 6:01 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" rel="noreferrer">dblaikie@gmail.com</a>> wrote:<br>
><br>
> Sorry, didn't see this earlier, but came across it looking at a<br>
> similar change recently - could you add a definition of this instead<br>
> of a cast, so it's not a trip-hazard for future development?<br>
<br>
Do you mean something like D.6 Redeclaration of static constexpr data<br>
members [depr.static.constexpr] ?<br>
The usage is deprecated from C++17 onwards.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yep, that. So long as we're building in C++14 mode that's the suitable thing to do. In 17 onwards we can remove them without them being a trap for new code to trip over like this.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
><br>
> On Tue, Mar 8, 2022 at 2:35 PM Fangrui Song via llvm-commits<br>
> <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" rel="noreferrer">llvm-commits@lists.llvm.org</a>> wrote:<br>
> ><br>
> ><br>
> > Author: Fangrui Song<br>
> > Date: 2022-03-08T14:34:53-08:00<br>
> > New Revision: 48c74bb2e2a72830f1068823bfc2f6fd4b53d427<br>
> ><br>
> > URL: <a href="https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427</a><br>
> > DIFF: <a href="https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427.diff" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/48c74bb2e2a72830f1068823bfc2f6fd4b53d427.diff</a><br>
> ><br>
> > LOG: [SampleProfileInference] Work around odr-use of const non-inline static data member to fix -O0 builds after D120508<br>
> ><br>
> > MinBaseDistance may be odr-used by std::max, leading to an undefined symbol linker error:<br>
> ><br>
> > ```<br>
> > ld.lld: error: undefined symbol: (anonymous namespace)::MinCostMaxFlow::MinBaseDistance<br>
> > >>> referenced by SampleProfileInference.cpp:744 (/home/ray/llvm-project/llvm/lib/Transforms/Utils/SampleProfileInference.cpp:744)<br>
> > >>>               lib/Transforms/Utils/CMakeFiles/LLVMTransformUtils.dir/SampleProfileInference.cpp.o:((anonymous namespace)::FlowAdjuster::jumpDistance(llvm::FlowJump*) const)<br>
> > ```<br>
> ><br>
> > Since llvm-project is still using C++ 14, workaround it with a cast.<br>
> ><br>
> > Added:<br>
> ><br>
> ><br>
> > Modified:<br>
> >     llvm/lib/Transforms/Utils/SampleProfileInference.cpp<br>
> ><br>
> > Removed:<br>
> ><br>
> ><br>
> ><br>
> > ################################################################################<br>
> > diff  --git a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp<br>
> > index 298c36b7ecd3d..6f56f1c432c2e 100644<br>
> > --- a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp<br>
> > +++ b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp<br>
> > @@ -741,7 +741,7 @@ class FlowAdjuster {<br>
> >    /// parts to a multiple of 1 / BaseDistance.<br>
> >    int64_t jumpDistance(FlowJump *Jump) const {<br>
> >      uint64_t BaseDistance =<br>
> > -        std::max(MinCostMaxFlow::MinBaseDistance,<br>
> > +        std::max(static_cast<uint64_t>(MinCostMaxFlow::MinBaseDistance),<br>
> >                   std::min(Func.Blocks[Func.Entry].Flow,<br>
> >                            MinCostMaxFlow::AuxCostUnlikely / NumBlocks()));<br>
> >      if (Jump->IsUnlikely)<br>
> ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > llvm-commits mailing list<br>
> > <a href="mailto:llvm-commits@lists.llvm.org" target="_blank" rel="noreferrer">llvm-commits@lists.llvm.org</a><br>
> > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div></div>