From 71021cdf474939ce92b8d220feebd4fb2a8c3dc4 Mon Sep 17 00:00:00 2001 From: Dehao Chen Date: Mon, 11 Jul 2016 17:36:02 +0000 Subject: [PATCH] Fix the assertion failure caused by http://reviews.llvm.org/D22118 Summary: http://reviews.llvm.org/D22118 uses metadata to store the call count, which makes it possible to have branch weight to have only one elements. Also fix the assertion failure in inliner when checking the instruction type to include "invoke" instruction. Reviewers: mkuper, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22228 llvm-svn: 275079 --- llvm/lib/IR/MDBuilder.cpp | 2 +- llvm/lib/IR/Metadata.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp index 4ce3ea2..a5a4cd0 100644 --- a/llvm/lib/IR/MDBuilder.cpp +++ b/llvm/lib/IR/MDBuilder.cpp @@ -40,7 +40,7 @@ MDNode *MDBuilder::createBranchWeights(uint32_t TrueWeight, } MDNode *MDBuilder::createBranchWeights(ArrayRef Weights) { - assert(Weights.size() >= 2 && "Need at least two branch weights!"); + assert(Weights.size() >= 1 && "Need at least one branch weights!"); SmallVector Vals(Weights.size() + 1); Vals[0] = createString("branch_weights"); diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index 24817b3..5201c2e 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -1315,7 +1315,8 @@ bool Instruction::extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) { bool Instruction::extractProfTotalWeight(uint64_t &TotalVal) { assert((getOpcode() == Instruction::Br || getOpcode() == Instruction::Select || - getOpcode() == Instruction::Call) && + getOpcode() == Instruction::Call || + getOpcode() == Instruction::Invoke) && "Looking for branch weights on something besides branch"); TotalVal = 0; -- 2.7.4