[llvm] r353129 - [SamplePGO][NFC] Minor improvement to replace a temporary vector with a
Wei Mi via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 4 18:40:13 PST 2019
Sorry, I only verified in release build and it didn't complain. Thanks
rtrieu to fix it.
On Mon, Feb 4, 2019 at 6:27 PM Richard Smith <richard at metafoo.co.uk> wrote:
> Hi,
>
> On Mon, 4 Feb 2019 at 16:57, Wei Mi via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > Author: wmi
> > Date: Mon Feb 4 16:57:50 2019
> > New Revision: 353129
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=353129&view=rev
> > Log:
> > [SamplePGO][NFC] Minor improvement to replace a temporary vector with a
> > brace-enclosed init list.
> >
> > Differential Revision: https://reviews.llvm.org/D57726
> >
> > Modified:
> > llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
> >
> > Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=353129&r1=353128&r2=353129&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
> > +++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Mon Feb 4 16:57:50
> 2019
> > @@ -1327,9 +1327,8 @@ void SampleProfileLoader::propagateWeigh
> > SortedCallTargets, Sum,
> IPVK_IndirectCallTarget,
> > SortedCallTargets.size());
> > } else if (!dyn_cast<IntrinsicInst>(&I)) {
> > - SmallVector<uint32_t, 1> Weights;
> > - Weights.push_back(BlockWeights[BB]);
> > - I.setMetadata(LLVMContext::MD_prof,
> MDB.createBranchWeights(Weights));
> > + I.setMetadata(LLVMContext::MD_prof,
> > + MDB.createBranchWeights({BlockWeights[BB]}));
>
> This breaks the build with:
>
> lib/Transforms/IPO/SampleProfile.cpp:1331:50: error:
> non-constant-expression cannot be narrowed from type 'unsigned long'
> to 'unsigned int' in initializer list [-Wc++11-narrowing]
> MDB.createBranchWeights({BlockWeights[BB]}));
> ^~~~~~~~~~~~~~~~
> lib/Transforms/IPO/SampleProfile.cpp:1331:50: note: insert an explicit
> cast to silence this issue
> MDB.createBranchWeights({BlockWeights[BB]}));
> ^~~~~~~~~~~~~~~~
> static_cast<unsigned
> int>( )
>
> This looks like it might be a real bug: BlockWeights allows 64-bit
> weights, whereas createBranchWeights only allows 32-bit weights, so
> there might be data loss here.
>
> > }
> > }
> > }
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190204/f2242b06/attachment.html>
More information about the llvm-commits
mailing list