From 6d5f0029fc06dbb9968c770a5101e109ddfa63f7 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 11 Sep 2019 20:29:22 +0000 Subject: [llvm-reduce] Fix a bug, improve error handling when running test llvm::sys::ExecuteAndWait can report errors, so let's make use of that. Second, while iterating uses of functions to remove, a call can appear multiple times. Use a SetVector so we don't attempt to erase such a call twice. llvm-svn: 371653 --- llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/tools/llvm-reduce/deltas') diff --git a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp b/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp index 450f78c39bb..84dc842d972 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp @@ -14,6 +14,7 @@ #include "ReduceFunctions.h" #include "Delta.h" +#include "llvm/ADT/SetVector.h" #include using namespace llvm; @@ -35,13 +36,13 @@ static void extractFunctionsFromModule(const std::vector &ChunksToKeep, // Delete out-of-chunk functions, and replace their calls with undef std::vector FuncsToRemove; - std::vector CallsToRemove; + SetVector CallsToRemove; for (auto &F : *Program) if (!FuncsToKeep.count(&F)) { for (auto U : F.users()) if (auto *Call = dyn_cast(U)) { Call->replaceAllUsesWith(UndefValue::get(Call->getType())); - CallsToRemove.push_back(Call); + CallsToRemove.insert(Call); } F.replaceAllUsesWith(UndefValue::get(F.getType())); FuncsToRemove.push_back(&F); -- cgit v1.2.3