From c535d93b47c79add08a84917e3dcad1daf0323dd Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 16 Jun 2015 09:57:38 +0000 Subject: [PATCH] [llvm-mc] The object form of the GNU triple should be the same as the string form. Summary: GetTarget() may modify TripleName without also updating TheTriple. This can lead to situations where the MCObjectStreamer has a different triple to the rest of LLVM. This inconsistency caused sparc-little-endian.s to pass on Windows because most of LLVM had sparcel-pc-win32 while MCObjectStreamer had "". I believe the same kind of thing was also true of Darwin. Reviewers: rengolin Reviewed By: rengolin Subscribers: llvm-commits, rengolin, rafael Differential Revision: http://reviews.llvm.org/D10450 llvm-svn: 239808 --- llvm/test/MC/Sparc/sparc-little-endian.s | 4 ++-- llvm/tools/llvm-mc/llvm-mc.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/llvm/test/MC/Sparc/sparc-little-endian.s b/llvm/test/MC/Sparc/sparc-little-endian.s index 18ced35..e9a56eb 100644 --- a/llvm/test/MC/Sparc/sparc-little-endian.s +++ b/llvm/test/MC/Sparc/sparc-little-endian.s @@ -1,5 +1,5 @@ -! RUN: llvm-mc %s -arch=sparcel -show-encoding | FileCheck %s -! RUN: llvm-mc -arch=sparcel -filetype=obj < %s | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-OBJ +! RUN: llvm-mc %s -triple=sparcel-linux-gnu -show-encoding | FileCheck %s +! RUN: llvm-mc -triple=sparcel-linux-gnu -filetype=obj < %s | llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-OBJ ! CHECK-OBJ: .text: .BB0: diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp index 9a9185c..d53596e 100644 --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -383,7 +383,6 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm machine code playground\n"); MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags(); TripleName = Triple::normalize(TripleName); - Triple TheTriple(TripleName); setDwarfDebugFlags(argc, argv); setDwarfDebugProducer(); @@ -392,6 +391,9 @@ int main(int argc, char **argv) { const Target *TheTarget = GetTarget(ProgName); if (!TheTarget) return 1; + // Now that GetTarget() has (potentially) replaced TripleName, it's safe to + // construct the Triple object. + Triple TheTriple(TripleName); ErrorOr> BufferPtr = MemoryBuffer::getFileOrSTDIN(InputFilename); -- 2.7.4