[llvm] r239808 - [llvm-mc] The object form of the GNU triple should be the same as the string form.

Daniel Sanders daniel.sanders at imgtec.com
Tue Jun 16 02:57:39 PDT 2015


Author: dsanders
Date: Tue Jun 16 04:57:38 2015
New Revision: 239808

URL: http://llvm.org/viewvc/llvm-project?rev=239808&view=rev
Log:
[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

Modified:
    llvm/trunk/test/MC/Sparc/sparc-little-endian.s
    llvm/trunk/tools/llvm-mc/llvm-mc.cpp

Modified: llvm/trunk/test/MC/Sparc/sparc-little-endian.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Sparc/sparc-little-endian.s?rev=239808&r1=239807&r2=239808&view=diff
==============================================================================
--- llvm/trunk/test/MC/Sparc/sparc-little-endian.s (original)
+++ llvm/trunk/test/MC/Sparc/sparc-little-endian.s Tue Jun 16 04:57:38 2015
@@ -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:

Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=239808&r1=239807&r2=239808&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Tue Jun 16 04:57:38 2015
@@ -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<std::unique_ptr<MemoryBuffer>> BufferPtr =
       MemoryBuffer::getFileOrSTDIN(InputFilename);





More information about the llvm-commits mailing list