[llvm-commits] [llvm] r159058 - in /llvm/trunk: lib/Target/TargetMachine.cpp lib/Target/X86/X86ISelLowering.cpp test/CodeGen/Mips/tls-alias.ll
Rafael Espindola
rafael.espindola at gmail.com
Fri Jun 22 17:30:03 PDT 2012
Author: rafael
Date: Fri Jun 22 19:30:03 2012
New Revision: 159058
URL: http://llvm.org/viewvc/llvm-project?rev=159058&view=rev
Log:
Handle aliases to tls variables in all architectures, not just x86.
Added:
llvm/trunk/test/CodeGen/Mips/tls-alias.ll
Modified:
llvm/trunk/lib/Target/TargetMachine.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=159058&r1=159057&r2=159058&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Fri Jun 22 19:30:03 2012
@@ -11,7 +11,9 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/GlobalAlias.h"
#include "llvm/GlobalValue.h"
+#include "llvm/GlobalVariable.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCCodeGenInfo.h"
#include "llvm/Target/TargetMachine.h"
@@ -76,11 +78,17 @@
}
TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
- bool isLocal = GV->hasLocalLinkage();
- bool isDeclaration = GV->isDeclaration();
+ // 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);
+ const GlobalVariable *Var = cast<GlobalVariable>(GV);
+
+ bool isLocal = Var->hasLocalLinkage();
+ bool isDeclaration = Var->isDeclaration();
// FIXME: what should we do for protected and internal visibility?
// For variables, is internal different from hidden?
- bool isHidden = GV->hasHiddenVisibility();
+ bool isHidden = Var->hasHiddenVisibility();
if (getRelocationModel() == Reloc::PIC_ &&
!Options.PositionIndependentExecutable) {
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=159058&r1=159057&r2=159058&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Jun 22 19:30:03 2012
@@ -7419,11 +7419,6 @@
const GlobalValue *GV = GA->getGlobal();
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);
switch (model) {
Added: llvm/trunk/test/CodeGen/Mips/tls-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/tls-alias.ll?rev=159058&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/tls-alias.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/tls-alias.ll Fri Jun 22 19:30:03 2012
@@ -0,0 +1,10 @@
+; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s
+
+ at foo = thread_local global i32 42
+ at bar = hidden alias i32* @foo
+
+define i32* @zed() {
+; CHECK: __tls_get_addr
+; CHECK-NEXT: %tlsgd(bar)
+ ret i32* @bar
+}
More information about the llvm-commits
mailing list