[PATCH] D83699: [Bitcode] Drop invalid branch_weight in BitcodeReader
Adrian Prantl via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 21 13:44:55 PDT 2020
aprantl added inline comments.
================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5397
+ // Check the branch weight on the instructions are correct. If not, drop them.
+ for (auto &I : instructions(F)) {
----------------
Perhaps even more explicit:
`// "Upgrade" older incorrect branch weights by dropping them.`
================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5400
+ if (auto *MD = I.getMetadata(LLVMContext::MD_prof)) {
+ if (MD->getNumOperands() >= 2 || MD->getOperand(0) != nullptr ||
+ isa<MDString>(MD->getOperand(0))) {
----------------
Are the || operators correct here?
I feel like this should be
`MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0)` ?
================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5405
+ // Check consistency of !prof branch_weights metadata.
+ if (ProfName.equals("branch_weights")) {
+ unsigned ExpectedNumOperands = 0;
----------------
if (!ProfName.equals("branch_weights"))
continue;
================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:5420
+
+ // If branch weight doens't match, just strip branch weight.
+ if (MD->getNumOperands() != 1 + ExpectedNumOperands)
----------------
doesn't
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83699/new/
https://reviews.llvm.org/D83699
More information about the llvm-commits
mailing list