]> granicus.if.org Git - llvm/commitdiff
Fix the assertion failure caused by http://reviews.llvm.org/D22118
authorDehao Chen <dehao@google.com>
Mon, 11 Jul 2016 17:36:02 +0000 (17:36 +0000)
committerDehao Chen <dehao@google.com>
Mon, 11 Jul 2016 17:36:02 +0000 (17:36 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275079 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/MDBuilder.cpp
lib/IR/Metadata.cpp

index 4ce3ea2e9c04131c5be509d1eb735e623c002df8..a5a4cd06db09e37acab27a025e0fc83852de3ed6 100644 (file)
@@ -40,7 +40,7 @@ MDNode *MDBuilder::createBranchWeights(uint32_t TrueWeight,
 }
 
 MDNode *MDBuilder::createBranchWeights(ArrayRef<uint32_t> Weights) {
-  assert(Weights.size() >= 2 && "Need at least two branch weights!");
+  assert(Weights.size() >= 1 && "Need at least one branch weights!");
 
   SmallVector<Metadata *, 4> Vals(Weights.size() + 1);
   Vals[0] = createString("branch_weights");
index 24817b331429c62019b2844ec3184fcd5f4b0a69..5201c2ecce6ae0e34d9d68c64c20d139d8a1352d 100644 (file)
@@ -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;