mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-11 21:24:33 +00:00
Handle aliases to tls variables in all architectures, not just x86.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159058 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -11,7 +11,9 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "llvm/GlobalAlias.h"
|
||||||
#include "llvm/GlobalValue.h"
|
#include "llvm/GlobalValue.h"
|
||||||
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCCodeGenInfo.h"
|
#include "llvm/MC/MCCodeGenInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
@ -76,11 +78,17 @@ CodeModel::Model TargetMachine::getCodeModel() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
|
TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
|
||||||
bool isLocal = GV->hasLocalLinkage();
|
// If GV is an alias then use the aliasee for determining
|
||||||
bool isDeclaration = GV->isDeclaration();
|
// thread-localness.
|
||||||
|
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
|
||||||
|
GV = GA->resolveAliasedGlobal(false);
|
||||||
|
const GlobalVariable *Var = cast<GlobalVariable>(GV);
|
||||||
|
|
||||||
|
bool isLocal = Var->hasLocalLinkage();
|
||||||
|
bool isDeclaration = Var->isDeclaration();
|
||||||
// FIXME: what should we do for protected and internal visibility?
|
// FIXME: what should we do for protected and internal visibility?
|
||||||
// For variables, is internal different from hidden?
|
// For variables, is internal different from hidden?
|
||||||
bool isHidden = GV->hasHiddenVisibility();
|
bool isHidden = Var->hasHiddenVisibility();
|
||||||
|
|
||||||
if (getRelocationModel() == Reloc::PIC_ &&
|
if (getRelocationModel() == Reloc::PIC_ &&
|
||||||
!Options.PositionIndependentExecutable) {
|
!Options.PositionIndependentExecutable) {
|
||||||
|
@ -7419,11 +7419,6 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
|
|||||||
const GlobalValue *GV = GA->getGlobal();
|
const GlobalValue *GV = GA->getGlobal();
|
||||||
|
|
||||||
if (Subtarget->isTargetELF()) {
|
if (Subtarget->isTargetELF()) {
|
||||||
// If GV is an alias then use the aliasee for determining
|
|
||||||
// thread-localness.
|
|
||||||
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
|
|
||||||
GV = GA->resolveAliasedGlobal(false);
|
|
||||||
|
|
||||||
TLSModel::Model model = getTargetMachine().getTLSModel(GV);
|
TLSModel::Model model = getTargetMachine().getTLSModel(GV);
|
||||||
|
|
||||||
switch (model) {
|
switch (model) {
|
||||||
|
10
test/CodeGen/Mips/tls-alias.ll
Normal file
10
test/CodeGen/Mips/tls-alias.ll
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
|
||||||
|
|
||||||
|
@foo = thread_local global i32 42
|
||||||
|
@bar = hidden alias i32* @foo
|
||||||
|
|
||||||
|
define i32* @zed() {
|
||||||
|
; CHECK: __tls_get_addr
|
||||||
|
; CHECK-NEXT: %tlsgd(bar)
|
||||||
|
ret i32* @bar
|
||||||
|
}
|
Reference in New Issue
Block a user