diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp --- a/llvm/lib/Transforms/IPO/IROutliner.cpp +++ b/llvm/lib/Transforms/IPO/IROutliner.cpp @@ -169,7 +169,15 @@ for (auto &VtoBB : Map) SortedKeys.push_back(VtoBB.first); + // Here we expect to have either 1 value that is void (nullptr) or multiple + // values that are all constant integers. + if (SortedKeys.size() == 1) { + assert(!SortedKeys[0] && "Expected a single void value."); + return; + } + stable_sort(SortedKeys, [](const Value *LHS, const Value *RHS) { + assert(LHS && RHS && "Expected non void values."); const ConstantInt *LHSC = dyn_cast(LHS); const ConstantInt *RHSC = dyn_cast(RHS); assert(RHSC && "Not a constant integer in return value?");