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 @@ -170,6 +170,15 @@ SortedKeys.push_back(VtoBB.first); stable_sort(SortedKeys, [](const Value *LHS, const Value *RHS) { + // We may be dealing with a return void here in which case Value* will be + // nullptr. Assume that void is < any ConstantInt. + if ((LHS == nullptr) && (RHS == nullptr)) + return false; + if (LHS == nullptr) + return true; + if (RHS == nullptr) + return false; + const ConstantInt *LHSC = dyn_cast(LHS); const ConstantInt *RHSC = dyn_cast(RHS); assert(RHSC && "Not a constant integer in return value?");