[llvm] r353129 - [SamplePGO][NFC] Minor improvement to replace a temporary vector with a
Richard Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 4 18:27:06 PST 2019
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
More information about the llvm-commits
mailing list