[llvm] r275079 - Fix the assertion failure caused by http://reviews.llvm.org/D22118

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 10:36:02 PDT 2016


Author: dehao
Date: Mon Jul 11 12:36:02 2016
New Revision: 275079

URL: http://llvm.org/viewvc/llvm-project?rev=275079&view=rev
Log:
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

Modified:
    llvm/trunk/lib/IR/MDBuilder.cpp
    llvm/trunk/lib/IR/Metadata.cpp

Modified: llvm/trunk/lib/IR/MDBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/MDBuilder.cpp?rev=275079&r1=275078&r2=275079&view=diff
==============================================================================
--- llvm/trunk/lib/IR/MDBuilder.cpp (original)
+++ llvm/trunk/lib/IR/MDBuilder.cpp Mon Jul 11 12:36:02 2016
@@ -40,7 +40,7 @@ MDNode *MDBuilder::createBranchWeights(u
 }
 
 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");

Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=275079&r1=275078&r2=275079&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Mon Jul 11 12:36:02 2016
@@ -1315,7 +1315,8 @@ bool Instruction::extractProfMetadata(ui
 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;




More information about the llvm-commits mailing list