mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-03 12:18:00 +00:00
on darwin<10, fallback to .weak_definition (PPC,X86)
.weak_def_can_be_hidden was not yet supported by the system assembler git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196970 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -270,6 +270,10 @@ namespace llvm {
|
|||||||
/// defined symbol.
|
/// defined symbol.
|
||||||
bool HasWeakDefDirective; // Defaults to false.
|
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.
|
/// True if we have a .linkonce directive. This is used on cygwin/mingw.
|
||||||
bool HasLinkOnceDirective; // Defaults to false.
|
bool HasLinkOnceDirective; // Defaults to false.
|
||||||
|
|
||||||
@@ -501,6 +505,9 @@ namespace llvm {
|
|||||||
bool hasNoDeadStrip() const { return HasNoDeadStrip; }
|
bool hasNoDeadStrip() const { return HasNoDeadStrip; }
|
||||||
const char *getWeakRefDirective() const { return WeakRefDirective; }
|
const char *getWeakRefDirective() const { return WeakRefDirective; }
|
||||||
bool hasWeakDefDirective() const { return HasWeakDefDirective; }
|
bool hasWeakDefDirective() const { return HasWeakDefDirective; }
|
||||||
|
bool hasWeakDefCanBeHiddenDirective() const {
|
||||||
|
return HasWeakDefCanBeHiddenDirective;
|
||||||
|
}
|
||||||
bool hasLinkOnceDirective() const { return HasLinkOnceDirective; }
|
bool hasLinkOnceDirective() const { return HasLinkOnceDirective; }
|
||||||
|
|
||||||
MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr;}
|
MCSymbolAttr getHiddenVisibilityAttr() const { return HiddenVisibilityAttr;}
|
||||||
|
@@ -232,7 +232,8 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
|
|||||||
|
|
||||||
bool CanBeHidden = false;
|
bool CanBeHidden = false;
|
||||||
|
|
||||||
if (Linkage == GlobalValue::LinkOnceODRLinkage) {
|
if (Linkage == GlobalValue::LinkOnceODRLinkage &&
|
||||||
|
MAI->hasWeakDefCanBeHiddenDirective()) {
|
||||||
if (GV->hasUnnamedAddr()) {
|
if (GV->hasUnnamedAddr()) {
|
||||||
CanBeHidden = true;
|
CanBeHidden = true;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -77,6 +77,7 @@ MCAsmInfo::MCAsmInfo() {
|
|||||||
HasNoDeadStrip = false;
|
HasNoDeadStrip = false;
|
||||||
WeakRefDirective = 0;
|
WeakRefDirective = 0;
|
||||||
HasWeakDefDirective = false;
|
HasWeakDefDirective = false;
|
||||||
|
HasWeakDefCanBeHiddenDirective = false;
|
||||||
HasLinkOnceDirective = false;
|
HasLinkOnceDirective = false;
|
||||||
HiddenVisibilityAttr = MCSA_Hidden;
|
HiddenVisibilityAttr = MCSA_Hidden;
|
||||||
HiddenDeclarationVisibilityAttr = MCSA_Hidden;
|
HiddenDeclarationVisibilityAttr = MCSA_Hidden;
|
||||||
|
@@ -36,6 +36,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
|||||||
|
|
||||||
// Directives:
|
// Directives:
|
||||||
HasWeakDefDirective = true;
|
HasWeakDefDirective = true;
|
||||||
|
HasWeakDefCanBeHiddenDirective = true;
|
||||||
WeakRefDirective = "\t.weak_reference ";
|
WeakRefDirective = "\t.weak_reference ";
|
||||||
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
|
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
|
||||||
HasMachoZeroFillDirective = true; // Uses .zerofill
|
HasMachoZeroFillDirective = true; // Uses .zerofill
|
||||||
|
@@ -12,11 +12,13 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "PPCMCAsmInfo.h"
|
#include "PPCMCAsmInfo.h"
|
||||||
|
#include "llvm/ADT/Triple.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
void PPCMCAsmInfoDarwin::anchor() { }
|
void PPCMCAsmInfoDarwin::anchor() { }
|
||||||
|
|
||||||
PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
|
PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const Triple& T) {
|
||||||
if (is64Bit) {
|
if (is64Bit) {
|
||||||
PointerSize = CalleeSaveStackSlotSize = 8;
|
PointerSize = CalleeSaveStackSlotSize = 8;
|
||||||
}
|
}
|
||||||
@@ -30,6 +32,12 @@ PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
|
|||||||
|
|
||||||
AssemblerDialect = 1; // New-Style mnemonics.
|
AssemblerDialect = 1; // New-Style mnemonics.
|
||||||
SupportsDebugInformation= true; // Debug information.
|
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() { }
|
void PPCLinuxMCAsmInfo::anchor() { }
|
||||||
|
@@ -18,11 +18,12 @@
|
|||||||
#include "llvm/MC/MCAsmInfoELF.h"
|
#include "llvm/MC/MCAsmInfoELF.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class Triple;
|
||||||
|
|
||||||
class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin {
|
class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin {
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
public:
|
public:
|
||||||
explicit PPCMCAsmInfoDarwin(bool is64Bit);
|
explicit PPCMCAsmInfoDarwin(bool is64Bit, const Triple&);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PPCLinuxMCAsmInfo : public MCAsmInfoELF {
|
class PPCLinuxMCAsmInfo : public MCAsmInfoELF {
|
||||||
|
@@ -72,7 +72,7 @@ static MCAsmInfo *createPPCMCAsmInfo(const MCRegisterInfo &MRI, StringRef TT) {
|
|||||||
|
|
||||||
MCAsmInfo *MAI;
|
MCAsmInfo *MAI;
|
||||||
if (TheTriple.isOSDarwin())
|
if (TheTriple.isOSDarwin())
|
||||||
MAI = new PPCMCAsmInfoDarwin(isPPC64);
|
MAI = new PPCMCAsmInfoDarwin(isPPC64, TheTriple);
|
||||||
else
|
else
|
||||||
MAI = new PPCLinuxMCAsmInfo(isPPC64);
|
MAI = new PPCLinuxMCAsmInfo(isPPC64);
|
||||||
|
|
||||||
|
@@ -65,6 +65,12 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
|||||||
|
|
||||||
// Exceptions handling
|
// Exceptions handling
|
||||||
ExceptionsType = ExceptionHandling::DwarfCFI;
|
ExceptionsType = ExceptionHandling::DwarfCFI;
|
||||||
|
|
||||||
|
// 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)
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
||||||
|
38
test/CodeGen/PowerPC/weak_def_can_be_hidden.ll
Normal file
38
test/CodeGen/PowerPC/weak_def_can_be_hidden.ll
Normal file
@@ -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
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
|
|
||||||
|
@v2 = linkonce_odr global i32 32
|
||||||
|
; 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
|
||||||
|
}
|
||||||
|
|
||||||
|
define i32* @f3() {
|
||||||
|
ret i32* @v3
|
||||||
|
}
|
@@ -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
|
@v1 = linkonce_odr global i32 32
|
||||||
; CHECK: .globl _v1
|
; CHECK: .globl _v1
|
||||||
; CHECK: .weak_def_can_be_hidden _v1
|
; CHECK: .weak_def_can_be_hidden _v1
|
||||||
|
|
||||||
|
; CHECK-D89: .globl _v1
|
||||||
|
; CHECK-D89: .weak_definition _v1
|
||||||
|
|
||||||
define i32 @f1() {
|
define i32 @f1() {
|
||||||
%x = load i32 * @v1
|
%x = load i32 * @v1
|
||||||
ret i32 %x
|
ret i32 %x
|
||||||
@@ -13,10 +20,16 @@ define i32 @f1() {
|
|||||||
; CHECK: .globl _v2
|
; CHECK: .globl _v2
|
||||||
; CHECK: .weak_definition _v2
|
; CHECK: .weak_definition _v2
|
||||||
|
|
||||||
|
; CHECK-D89: .globl _v2
|
||||||
|
; CHECK-D89: .weak_definition _v2
|
||||||
|
|
||||||
@v3 = linkonce_odr unnamed_addr global i32 32
|
@v3 = linkonce_odr unnamed_addr global i32 32
|
||||||
; CHECK: .globl _v3
|
; CHECK: .globl _v3
|
||||||
; CHECK: .weak_def_can_be_hidden _v3
|
; CHECK: .weak_def_can_be_hidden _v3
|
||||||
|
|
||||||
|
; CHECK-D89: .globl _v3
|
||||||
|
; CHECK-D89: .weak_definition _v3
|
||||||
|
|
||||||
define i32* @f2() {
|
define i32* @f2() {
|
||||||
ret i32* @v2
|
ret i32* @v2
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user