[llvm-commits] [llvm] r165759 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Manman Ren mren at apple.com
Thu Oct 11 15:28:34 PDT 2012


Author: mren
Date: Thu Oct 11 17:28:34 2012
New Revision: 165759

URL: http://llvm.org/viewvc/llvm-project?rev=165759&view=rev
Log:
PGO: create metadata for switch only if it has more than one targets.

When all cases of a switch statement are dead, the weights vector only has one
element, and we will get an ssertion failure when calling createBranchWeights.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=165759&r1=165758&r2=165759&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Oct 11 17:28:34 2012
@@ -695,7 +695,7 @@
         SI->removeCase(i);
       }
     }
-    if (HasWeight)
+    if (HasWeight && Weights.size() >= 2)
       SI->setMetadata(LLVMContext::MD_prof,
                       MDBuilder(SI->getParent()->getContext()).
                       createBranchWeights(Weights));





More information about the llvm-commits mailing list