From: Anton Korobeynikov Date: Tue, 11 Mar 2008 22:38:53 +0000 (+0000) Subject: Correctly propagate thread-local flag from aliasee to alias. This fixes PR2137 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4d86e2a6b8edc814165a3e63f55bfaea0b8f224d;p=oota-llvm.git Correctly propagate thread-local flag from aliasee to alias. This fixes PR2137 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48257 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 59fd79650a0..6e15318a16a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -13,6 +13,7 @@ #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Constants.h" +#include "llvm/GlobalAlias.h" #include "llvm/GlobalVariable.h" #include "llvm/Intrinsics.h" #include "llvm/DerivedTypes.h" @@ -814,12 +815,20 @@ SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT, SDOperand SelectionDAG::getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT, int Offset, bool isTargetGA) { - const GlobalVariable *GVar = dyn_cast(GV); unsigned Opc; + + const GlobalVariable *GVar = dyn_cast(GV); + if (!GVar) { + // If GV is an alias - use aliasee for determing thread-localness + if (const GlobalAlias *GA = dyn_cast(GV)) + GVar = dyn_cast_or_null(GA->resolveAliasedGlobal()); + } + if (GVar && GVar->isThreadLocal()) Opc = isTargetGA ? ISD::TargetGlobalTLSAddress : ISD::GlobalTLSAddress; else Opc = isTargetGA ? ISD::TargetGlobalAddress : ISD::GlobalAddress; + FoldingSetNodeID ID; AddNodeIDNode(ID, Opc, getVTList(VT), 0, 0); ID.AddPointer(GV); diff --git a/lib/Target/X86/X86ATTAsmPrinter.cpp b/lib/Target/X86/X86ATTAsmPrinter.cpp index b9770fef182..4fef3827e3f 100644 --- a/lib/Target/X86/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/X86ATTAsmPrinter.cpp @@ -279,8 +279,14 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool needCloseParen = false; - GlobalValue *GV = MO.getGlobal(); - GlobalVariable *GVar = dyn_cast(GV); + const GlobalValue *GV = MO.getGlobal(); + const GlobalVariable *GVar = dyn_cast(GV); + if (!GVar) { + // If GV is an alias - use aliasee for determing thread-localness + if (const GlobalAlias *GA = dyn_cast(GV)) + GVar = dyn_cast_or_null(GA->resolveAliasedGlobal()); + } + bool isThreadLocal = GVar && GVar->isThreadLocal(); std::string Name = Mang->getValueName(GV);