<div dir="ltr">Sorry, I only verified in release build and it didn't complain. Thanks rtrieu to fix it.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 4, 2019 at 6:27 PM Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Mon, 4 Feb 2019 at 16:57, Wei Mi via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: wmi<br>
> Date: Mon Feb  4 16:57:50 2019<br>
> New Revision: 353129<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=353129&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=353129&view=rev</a><br>
> Log:<br>
> [SamplePGO][NFC] Minor improvement to replace a temporary vector with a<br>
> brace-enclosed init list.<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D57726" rel="noreferrer" target="_blank">https://reviews.llvm.org/D57726</a><br>
><br>
> Modified:<br>
>     llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
><br>
> Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=353129&r1=353128&r2=353129&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=353129&r1=353128&r2=353129&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)<br>
> +++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Feb  4 16:57:50 2019<br>
> @@ -1327,9 +1327,8 @@ void SampleProfileLoader::propagateWeigh<br>
>                              SortedCallTargets, Sum, IPVK_IndirectCallTarget,<br>
>                              SortedCallTargets.size());<br>
>          } else if (!dyn_cast<IntrinsicInst>(&I)) {<br>
> -          SmallVector<uint32_t, 1> Weights;<br>
> -          Weights.push_back(BlockWeights[BB]);<br>
> -          I.setMetadata(LLVMContext::MD_prof, MDB.createBranchWeights(Weights));<br>
> +          I.setMetadata(LLVMContext::MD_prof,<br>
> +                        MDB.createBranchWeights({BlockWeights[BB]}));<br>
<br>
This breaks the build with:<br>
<br>
lib/Transforms/IPO/SampleProfile.cpp:1331:50: error:<br>
non-constant-expression cannot be narrowed from type 'unsigned long'<br>
to 'unsigned int' in initializer list [-Wc++11-narrowing]<br>
                        MDB.createBranchWeights({BlockWeights[BB]}));<br>
                                                 ^~~~~~~~~~~~~~~~<br>
lib/Transforms/IPO/SampleProfile.cpp:1331:50: note: insert an explicit<br>
cast to silence this issue<br>
                        MDB.createBranchWeights({BlockWeights[BB]}));<br>
                                                 ^~~~~~~~~~~~~~~~<br>
                                                 static_cast<unsigned int>( )<br>
<br>
This looks like it might be a real bug: BlockWeights allows 64-bit<br>
weights, whereas createBranchWeights only allows 32-bit weights, so<br>
there might be data loss here.<br>
<br>
>          }<br>
>        }<br>
>      }<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>