gollvm: use vector to record "discovered" temps

Change the code that looks for newly "discovered" temporary variables
within the control flow generation walk to record the temps in a
vector, not a hash set (so as to insure that order of the final
alloca's in the function is not dependent on hash set iteration order,
which is dependent on pointer values).

Change-Id: I7ae116db28d99b8b87076c651d8290a3fa06dce5
Reviewed-on: https://go-review.googlesource.com/46550
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/llvm-gofrontend/go-llvm-bfunction.cpp b/llvm-gofrontend/go-llvm-bfunction.cpp
index 2bddea9..37e3b18 100644
--- a/llvm-gofrontend/go-llvm-bfunction.cpp
+++ b/llvm-gofrontend/go-llvm-bfunction.cpp
@@ -420,7 +420,7 @@
 }
 
 void Bfunction::fixupProlog(llvm::BasicBlock *entry,
-                            const std::set<llvm::AllocaInst *> &temps)
+                            const std::vector<llvm::AllocaInst *> &temps)
 {
   // Make sure that each parameter variable has an initializer (this is
   // needed for debug generation. In the case of by-reference vars,
diff --git a/llvm-gofrontend/go-llvm-bfunction.h b/llvm-gofrontend/go-llvm-bfunction.h
index 7488ae7..0194fe9 100644
--- a/llvm-gofrontend/go-llvm-bfunction.h
+++ b/llvm-gofrontend/go-llvm-bfunction.h
@@ -98,7 +98,7 @@
   // the the entry BB for the function, and "temps" is a set of temporary
   // variables that need to be adopted into the function.
   void fixupProlog(llvm::BasicBlock *entry,
-                   const std::set<llvm::AllocaInst *> &temps);
+                   const std::vector<llvm::AllocaInst *> &temps);
 
   // Create code to return a function value from this fcn, following ABI rules.
   llvm::Value *genReturnSequence(Bexpression *toRet,
diff --git a/llvm-gofrontend/go-llvm.cpp b/llvm-gofrontend/go-llvm.cpp
index 2a4f6f4..1603103 100644
--- a/llvm-gofrontend/go-llvm.cpp
+++ b/llvm-gofrontend/go-llvm.cpp
@@ -3531,6 +3531,7 @@
   std::map<LabelId, llvm::BasicBlock *> labelmap_;
   std::vector<llvm::BasicBlock*> padBlockStack_;
   std::set<llvm::AllocaInst *> temporariesDiscovered_;
+  std::vector<llvm::AllocaInst *> newTemporaries_;
   llvm::BasicBlock* finallyBlock_;
   Bstatement *cachedReturn_;
   bool emitOrphanedCode_;
@@ -3562,7 +3563,7 @@
 
 void GenBlocks::finishFunction(llvm::BasicBlock *entry)
 {
-  function_->fixupProlog(entry, temporariesDiscovered_);
+  function_->fixupProlog(entry, newTemporaries_);
   if (createDebugMetaData_)
     dibuildhelper().endFunction(function_);
 }
@@ -3648,6 +3649,7 @@
       Bvariable *tvar = be_->nodeBuilder().adoptTemporaryVariable(ai);
       if (tvar) {
         temporariesDiscovered_.insert(ai);
+        newTemporaries_.push_back(ai);
         delete tvar;
       }
     }
diff --git a/unittests/BackendCore/BackendExprTests.cpp b/unittests/BackendCore/BackendExprTests.cpp
index 847ad31..f439893 100644
--- a/unittests/BackendCore/BackendExprTests.cpp
+++ b/unittests/BackendCore/BackendExprTests.cpp
@@ -1029,12 +1029,12 @@
     %tmp.8 = alloca { double, double }
     %tmp.7 = alloca { double, double }
     %tmp.6 = alloca { double, double }
+    %tmp.5 = alloca { double, double }
     %tmp.4 = alloca { double, double }
     %tmp.3 = alloca { double, double }
     %tmp.2 = alloca { double, double }
-    %tmp.5 = alloca { double, double }
-    %tmp.0 = alloca { double, double }
     %tmp.1 = alloca { double, double }
+    %tmp.0 = alloca { double, double }
     %x = alloca { double, double }
     %y = alloca { double, double }
     %z = alloca { double, double }