Skip to content

Commit d51a6f1

Browse files
committed
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. llvm-svn: 83859
1 parent aee0963 commit d51a6f1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Support/Triple.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "llvm/ADT/Triple.h"
1111

12+
#include "llvm/ADT/SmallString.h"
1213
#include "llvm/ADT/Twine.h"
1314
#include <cassert>
1415
#include <cstring>
@@ -326,10 +327,14 @@ void Triple::setOS(OSType Kind) {
326327
}
327328

328329
void Triple::setArchName(const StringRef &Str) {
329-
// Work around a miscompilation bug in gcc 4.0.3.
330-
Twine a = getVendorName() + "-" + getOSAndEnvironmentName();
331-
Twine b = Str + "-" + a;
332-
setTriple(b);
330+
// Work around a miscompilation bug for Twines in gcc 4.0.3.
331+
SmallString<64> Triple;
332+
Triple += Str;
333+
Triple += "-";
334+
Triple += getVendorName();
335+
Triple += "-";
336+
Triple += getOSAndEnvironmentName();
337+
setTriple(Triple.str());
333338
}
334339

335340
void Triple::setVendorName(const StringRef &Str) {

0 commit comments

Comments
 (0)