From 5c1735a4dfb3e50cbd800645382ff78e9edb813a Mon Sep 17 00:00:00 2001 From: Julien Lerouge Date: Sun, 10 Jan 2010 01:07:22 +0000 Subject: [PATCH] Fix nondeterministic behavior. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93093 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/CodeExtractor.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index cc3b9a1052a..b2084948530 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -45,7 +45,7 @@ AggregateArgsOpt("aggregate-extracted-args", cl::Hidden, namespace { class CodeExtractor { - typedef std::vector Values; + typedef SetVector Values; SetVector BlocksToExtract; DominatorTree* DT; bool AggregateArgs; @@ -216,13 +216,13 @@ void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs) { // instruction is used outside the region, it's an output. for (User::op_iterator O = I->op_begin(), E = I->op_end(); O != E; ++O) if (definedInCaller(*O)) - inputs.push_back(*O); + inputs.insert(*O); // Consider uses of this instruction (outputs). for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) if (!definedInRegion(*UI)) { - outputs.push_back(I); + outputs.insert(I); break; } } // for: insts @@ -235,12 +235,6 @@ void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs) { } // for: basic blocks NumExitBlocks = ExitBlocks.size(); - - // Eliminate duplicates. - std::sort(inputs.begin(), inputs.end()); - inputs.erase(std::unique(inputs.begin(), inputs.end()), inputs.end()); - std::sort(outputs.begin(), outputs.end()); - outputs.erase(std::unique(outputs.begin(), outputs.end()), outputs.end()); } /// constructFunction - make a function based on inputs and outputs, as follows: