[llvm] r257555 - AsmPrinter: Fix wrong OS X versions being emitted for darwin triples

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 17:18:13 PST 2016


Author: matze
Date: Tue Jan 12 19:18:13 2016
New Revision: 257555

URL: http://llvm.org/viewvc/llvm-project?rev=257555&view=rev
Log:
AsmPrinter: Fix wrong OS X versions being emitted for darwin triples

The version numbers of the darwin kernel are different from the version
numbers of OS X, so we need adjustments if we had "*-*-darwin" triples.
Use the existing utility functions in TargetTriple for this.

Fixes rdar://22056966

Differential Revision: http://reviews.llvm.org/D14601

Added:
    llvm/trunk/test/CodeGen/X86/version_directive.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/test/CodeGen/X86/2008-11-03-F80VAARG.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=257555&r1=257554&r2=257555&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Jan 12 19:18:13 2016
@@ -192,22 +192,26 @@ bool AsmPrinter::doInitialization(Module
   // use the directive, where it would need the same conditionalization
   // anyway.
   Triple TT(getTargetTriple());
-  if (TT.isOSDarwin()) {
+  // If there is a version specified, Major will be non-zero.
+  if (TT.isOSDarwin() && TT.getOSMajorVersion() != 0) {
     unsigned Major, Minor, Update;
-    TT.getOSVersion(Major, Minor, Update);
-    // If there is a version specified, Major will be non-zero.
-    if (Major) {
-      MCVersionMinType VersionType;
-      if (TT.isWatchOS())
-        VersionType = MCVM_WatchOSVersionMin;
-      else if (TT.isTvOS())
-        VersionType = MCVM_TvOSVersionMin;
-      else if (TT.isMacOSX())
-        VersionType = MCVM_OSXVersionMin;
-      else
-        VersionType = MCVM_IOSVersionMin;
-      OutStreamer->EmitVersionMin(VersionType, Major, Minor, Update);
+    MCVersionMinType VersionType;
+    if (TT.isWatchOS()) {
+      VersionType = MCVM_WatchOSVersionMin;
+      TT.getWatchOSVersion(Major, Minor, Update);
+    } else if (TT.isTvOS()) {
+      VersionType = MCVM_TvOSVersionMin;
+      TT.getiOSVersion(Major, Minor, Update);
+    } else if (TT.isMacOSX()) {
+      VersionType = MCVM_OSXVersionMin;
+      if (!TT.getMacOSXVersion(Major, Minor, Update))
+        Major = 0;
+    } else {
+      VersionType = MCVM_IOSVersionMin;
+      TT.getiOSVersion(Major, Minor, Update);
     }
+    if (Major != 0)
+      OutStreamer->EmitVersionMin(VersionType, Major, Minor, Update);
   }
 
   // Allow the target to emit any magic that it wants at the start of the file.

Modified: llvm/trunk/test/CodeGen/X86/2008-11-03-F80VAARG.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-11-03-F80VAARG.ll?rev=257555&r1=257554&r2=257555&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2008-11-03-F80VAARG.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2008-11-03-F80VAARG.ll Tue Jan 12 19:18:13 2016
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=x86 -o - | not grep 10
+; RUN: llc < %s -march=x86 -o - | FileCheck %s
 
 declare void @llvm.va_start(i8*) nounwind
 
@@ -6,6 +6,8 @@ declare void @llvm.va_copy(i8*, i8*) nou
 
 declare void @llvm.va_end(i8*) nounwind
 
+; CHECK-LABEL: test:
+; CHECK-NOT: 10
 define x86_fp80 @test(...) nounwind {
 	%ap = alloca i8*		; <i8**> [#uses=3]
 	%v1 = bitcast i8** %ap to i8*		; <i8*> [#uses=1]

Added: llvm/trunk/test/CodeGen/X86/version_directive.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/version_directive.ll?rev=257555&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/version_directive.ll (added)
+++ llvm/trunk/test/CodeGen/X86/version_directive.ll Tue Jan 12 19:18:13 2016
@@ -0,0 +1,4 @@
+; RUN: llc -mtriple x86_64-apple-darwin15.0.0 -o - /dev/null | FileCheck %s
+; RUN: llc -mtriple x86_64-apple-macosx10.11.0 -o - /dev/null | FileCheck %s
+
+; CHECK: .macosx_version_min 10, 11




More information about the llvm-commits mailing list