[llvm-branch-commits] [llvm-branch] r83859 - /llvm/branches/release_26/lib/Support/Triple.cpp

Tanya Lattner tonic at nondot.org
Mon Oct 12 09:46:56 PDT 2009


Author: tbrethou
Date: Mon Oct 12 11:46:55 2009
New Revision: 83859

URL: http://llvm.org/viewvc/llvm-project?rev=83859&view=rev
Log:
Merge 83417 from mainline.
r83391 was completely broken since Twines keep references to their inputs, and
some of the inputs were temporaries.  Here's a real fix for the miscompilation.
Thanks to sabre for pointing out the problem.

Modified:
    llvm/branches/release_26/lib/Support/Triple.cpp

Modified: llvm/branches/release_26/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_26/lib/Support/Triple.cpp?rev=83859&r1=83858&r2=83859&view=diff

==============================================================================
--- llvm/branches/release_26/lib/Support/Triple.cpp (original)
+++ llvm/branches/release_26/lib/Support/Triple.cpp Mon Oct 12 11:46:55 2009
@@ -9,6 +9,7 @@
 
 #include "llvm/ADT/Triple.h"
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
 #include <cassert>
 #include <cstring>
@@ -326,10 +327,14 @@
 }
 
 void Triple::setArchName(const StringRef &Str) {
-  // Work around a miscompilation bug in gcc 4.0.3.
-  Twine a = getVendorName() + "-" + getOSAndEnvironmentName();
-  Twine b = Str + "-" + a;
-  setTriple(b);
+  // Work around a miscompilation bug for Twines in gcc 4.0.3.
+  SmallString<64> Triple;
+  Triple += Str;
+  Triple += "-";
+  Triple += getVendorName();
+  Triple += "-";
+  Triple += getOSAndEnvironmentName();
+  setTriple(Triple.str());
 }
 
 void Triple::setVendorName(const StringRef &Str) {





More information about the llvm-branch-commits mailing list