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,14 +169,21 @@ for (auto &VtoBB : Map) SortedKeys.push_back(VtoBB.first); - stable_sort(SortedKeys, [](const Value *LHS, const Value *RHS) { - const ConstantInt *LHSC = dyn_cast(LHS); - const ConstantInt *RHSC = dyn_cast(RHS); - assert(RHSC && "Not a constant integer in return value?"); - assert(LHSC && "Not a constant integer in return value?"); - - return LHSC->getLimitedValue() < RHSC->getLimitedValue(); - }); + // 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."); + else { + 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?"); + assert(LHSC && "Not a constant integer in return value?"); + + return LHSC->getLimitedValue() < RHSC->getLimitedValue(); + }); + } } Value *OutlinableRegion::findCorrespondingValueIn(const OutlinableRegion &Other,