[llvm-branch-commits] [llvm-branch] r206050 - Merging r196970:

Tom Stellard thomas.stellard at amd.com
Fri Apr 11 12:35:34 PDT 2014


Author: tstellar
Date: Fri Apr 11 14:35:34 2014
New Revision: 206050

URL: http://llvm.org/viewvc/llvm-project?rev=206050&view=rev
Log:
Merging r196970:

------------------------------------------------------------------------
r196970 | fang | 2013-12-10 16:37:41 -0500 (Tue, 10 Dec 2013) | 3 lines

on darwin<10, fallback to .weak_definition (PPC,X86)
.weak_def_can_be_hidden was not yet supported by the system assembler

------------------------------------------------------------------------

Added:
    llvm/branches/release_34/test/CodeGen/PowerPC/weak_def_can_be_hidden.ll
Modified:
    llvm/branches/release_34/include/llvm/MC/MCAsmInfo.h
    llvm/branches/release_34/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/branches/release_34/lib/MC/MCAsmInfo.cpp
    llvm/branches/release_34/lib/MC/MCAsmInfoDarwin.cpp
    llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
    llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h
    llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
    llvm/branches/release_34/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
    llvm/branches/release_34/test/CodeGen/X86/weak_def_can_be_hidden.ll

Modified: llvm/branches/release_34/include/llvm/MC/MCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/include/llvm/MC/MCAsmInfo.h?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/include/llvm/MC/MCAsmInfo.h (original)
+++ llvm/branches/release_34/include/llvm/MC/MCAsmInfo.h Fri Apr 11 14:35:34 2014
@@ -270,6 +270,10 @@ namespace llvm {
     /// defined symbol.
     bool HasWeakDefDirective;                // Defaults to false.
 
+    /// True if we have a directive to declare a global as being a weak
+    /// defined symbol that can be hidden (unexported).
+    bool HasWeakDefCanBeHiddenDirective;     // Defaults to false.
+
     /// True if we have a .linkonce directive.  This is used on cygwin/mingw.
     bool HasLinkOnceDirective;               // Defaults to false.
 
@@ -501,6 +505,9 @@ namespace llvm {
     bool hasNoDeadStrip() const { return HasNoDeadStrip; }
     const char *getWeakRefDirective() const { return WeakRefDirective; }
     bool hasWeakDefDirective() const { return HasWeakDefDirective; }
+    bool hasWeakDefCanBeHiddenDirective() const {
+      return HasWeakDefCanBeHiddenDirective;
+    }
     bool hasLinkOnceDirective() const { return HasLinkOnceDirective; }
 
     MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr;}

Modified: llvm/branches/release_34/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/branches/release_34/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Apr 11 14:35:34 2014
@@ -228,7 +228,8 @@ void AsmPrinter::EmitLinkage(const Globa
 
       bool CanBeHidden = false;
 
-      if (Linkage == GlobalValue::LinkOnceODRLinkage) {
+      if (Linkage == GlobalValue::LinkOnceODRLinkage &&
+          MAI->hasWeakDefCanBeHiddenDirective()) {
         if (GV->hasUnnamedAddr()) {
           CanBeHidden = true;
         } else {

Modified: llvm/branches/release_34/lib/MC/MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/MC/MCAsmInfo.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/MC/MCAsmInfo.cpp (original)
+++ llvm/branches/release_34/lib/MC/MCAsmInfo.cpp Fri Apr 11 14:35:34 2014
@@ -77,6 +77,7 @@ MCAsmInfo::MCAsmInfo() {
   HasNoDeadStrip = false;
   WeakRefDirective = 0;
   HasWeakDefDirective = false;
+  HasWeakDefCanBeHiddenDirective = false;
   HasLinkOnceDirective = false;
   HiddenVisibilityAttr = MCSA_Hidden;
   HiddenDeclarationVisibilityAttr = MCSA_Hidden;

Modified: llvm/branches/release_34/lib/MC/MCAsmInfoDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/MC/MCAsmInfoDarwin.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/MC/MCAsmInfoDarwin.cpp (original)
+++ llvm/branches/release_34/lib/MC/MCAsmInfoDarwin.cpp Fri Apr 11 14:35:34 2014
@@ -37,6 +37,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
 
   // Directives:
   HasWeakDefDirective = true;
+  HasWeakDefCanBeHiddenDirective = true;
   WeakRefDirective = "\t.weak_reference ";
   ZeroDirective = "\t.space\t";  // ".space N" emits N zeros.
   HasMachoZeroFillDirective = true;  // Uses .zerofill

Modified: llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp (original)
+++ llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp Fri Apr 11 14:35:34 2014
@@ -12,10 +12,14 @@
 //===----------------------------------------------------------------------===//
 
 #include "PPCMCAsmInfo.h"
+#include "llvm/ADT/Triple.h"
+
 using namespace llvm;
 
 void PPCMCAsmInfoDarwin::anchor() { }
 
+/// This version of the constructor is here to maintain ABI compatibility with
+/// LLVM 3.4.0
 PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
   if (is64Bit) {
     PointerSize = CalleeSaveStackSlotSize = 8;
@@ -32,6 +36,28 @@ PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(b
   SupportsDebugInformation= true; // Debug information.
 }
 
+PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const Triple& T) {
+  if (is64Bit) {
+    PointerSize = CalleeSaveStackSlotSize = 8;
+  }
+  IsLittleEndian = false;
+
+  CommentString = ";";
+  ExceptionsType = ExceptionHandling::DwarfCFI;
+
+  if (!is64Bit)
+    Data64bitsDirective = 0;      // We can't emit a 64-bit unit in PPC32 mode.
+
+  AssemblerDialect = 1;           // New-Style mnemonics.
+  SupportsDebugInformation= true; // Debug information.
+
+  // old assembler lacks some directives
+  // FIXME: this should really be a check on the assembler characteristics
+  // rather than OS version
+  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
+    HasWeakDefCanBeHiddenDirective = false;
+}
+
 void PPCLinuxMCAsmInfo::anchor() { }
 
 PPCLinuxMCAsmInfo::PPCLinuxMCAsmInfo(bool is64Bit) {

Modified: llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h (original)
+++ llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.h Fri Apr 11 14:35:34 2014
@@ -18,11 +18,15 @@
 #include "llvm/MC/MCAsmInfoELF.h"
 
 namespace llvm {
+class Triple;
 
   class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin {
     virtual void anchor();
   public:
+    /// This version of the constructor is here to maintain ABI compatibility
+    /// with LLVM 3.4.0.
     explicit PPCMCAsmInfoDarwin(bool is64Bit);
+    explicit PPCMCAsmInfoDarwin(bool is64Bit, const Triple&);
   };
 
   class PPCLinuxMCAsmInfo : public MCAsmInfoELF {

Modified: llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp (original)
+++ llvm/branches/release_34/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp Fri Apr 11 14:35:34 2014
@@ -72,7 +72,7 @@ static MCAsmInfo *createPPCMCAsmInfo(con
 
   MCAsmInfo *MAI;
   if (TheTriple.isOSDarwin())
-    MAI = new PPCMCAsmInfoDarwin(isPPC64);
+    MAI = new PPCMCAsmInfoDarwin(isPPC64, TheTriple);
   else
     MAI = new PPCLinuxMCAsmInfo(isPPC64);
 

Modified: llvm/branches/release_34/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp (original)
+++ llvm/branches/release_34/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp Fri Apr 11 14:35:34 2014
@@ -70,6 +70,12 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(c
   // version in use.  From at least >= ld64-97.17 (Xcode 3.2.6) the abs-ified
   // FDE relocs may be used.
   DwarfFDESymbolsUseAbsDiff = T.isMacOSX() && !T.isMacOSXVersionLT(10, 6);
+
+  // old assembler lacks some directives
+  // FIXME: this should really be a check on the assembler characteristics
+  // rather than OS version
+  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
+    HasWeakDefCanBeHiddenDirective = false;
 }
 
 X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)

Added: llvm/branches/release_34/test/CodeGen/PowerPC/weak_def_can_be_hidden.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/test/CodeGen/PowerPC/weak_def_can_be_hidden.ll?rev=206050&view=auto
==============================================================================
--- llvm/branches/release_34/test/CodeGen/PowerPC/weak_def_can_be_hidden.ll (added)
+++ llvm/branches/release_34/test/CodeGen/PowerPC/weak_def_can_be_hidden.ll Fri Apr 11 14:35:34 2014
@@ -0,0 +1,38 @@
+; taken from X86 version of the same test
+; RUN: llc -mtriple=powerpc-apple-darwin10 -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=powerpc-apple-darwin9 -O0 < %s | FileCheck --check-prefix=CHECK-D89 %s
+; RUN: llc -mtriple=powerpc-apple-darwin8 -O0 < %s | FileCheck --check-prefix=CHECK-D89 %s
+
+ at v1 = linkonce_odr global i32 32
+; CHECK: .globl  _v1
+; CHECK: .weak_def_can_be_hidden _v1
+
+; CHECK-D89: .globl  _v1
+; CHECK-D89: .weak_definition _v1
+
+define i32 @f1() {
+  %x = load i32 * @v1
+  ret i32 %x
+}
+
+ at v2 = linkonce_odr global i32 32
+; CHECK: .globl  _v2
+; CHECK: .weak_definition _v2
+
+; CHECK-D89: .globl  _v2
+; CHECK-D89: .weak_definition _v2
+
+ at v3 = linkonce_odr unnamed_addr global i32 32
+; CHECK: .globl  _v3
+; CHECK: .weak_def_can_be_hidden _v3
+
+; CHECK-D89: .globl  _v3
+; CHECK-D89: .weak_definition _v3
+
+define i32* @f2() {
+  ret i32* @v2
+}
+
+define i32* @f3() {
+  ret i32* @v3
+}

Modified: llvm/branches/release_34/test/CodeGen/X86/weak_def_can_be_hidden.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/test/CodeGen/X86/weak_def_can_be_hidden.ll?rev=206050&r1=206049&r2=206050&view=diff
==============================================================================
--- llvm/branches/release_34/test/CodeGen/X86/weak_def_can_be_hidden.ll (original)
+++ llvm/branches/release_34/test/CodeGen/X86/weak_def_can_be_hidden.ll Fri Apr 11 14:35:34 2014
@@ -1,9 +1,16 @@
-; RUN: llc -mtriple=x86_64-apple-darwin  -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-apple-darwin11 -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-apple-darwin10 -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-apple-darwin9 -O0 < %s | FileCheck --check-prefix=CHECK-D89 %s
+; RUN: llc -mtriple=i686-apple-darwin9 -O0 < %s | FileCheck --check-prefix=CHECK-D89 %s
+; RUN: llc -mtriple=i686-apple-darwin8 -O0 < %s | FileCheck --check-prefix=CHECK-D89 %s
 
 @v1 = linkonce_odr global i32 32
 ; CHECK: .globl  _v1
 ; CHECK: .weak_def_can_be_hidden _v1
 
+; CHECK-D89: .globl  _v1
+; CHECK-D89: .weak_definition _v1
+
 define i32 @f1() {
   %x = load i32 * @v1
   ret i32 %x
@@ -13,10 +20,16 @@ define i32 @f1() {
 ; CHECK: .globl  _v2
 ; CHECK: .weak_definition _v2
 
+; CHECK-D89: .globl  _v2
+; CHECK-D89: .weak_definition _v2
+
 @v3 = linkonce_odr unnamed_addr global i32 32
 ; CHECK: .globl  _v3
 ; CHECK: .weak_def_can_be_hidden _v3
 
+; CHECK-D89: .globl  _v3
+; CHECK-D89: .weak_definition _v3
+
 define i32* @f2() {
   ret i32* @v2
 }





More information about the llvm-branch-commits mailing list