diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 7fa83a5999df..e269ca83fab7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -10245,10 +10245,13 @@ SDValue TargetLowering::LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA, ArgListTy Args; ArgListEntry Entry; - std::string NameString = ("__emutls_v." + GA->getGlobal()->getName()).str(); - Module *VariableModule = const_cast<Module*>(GA->getGlobal()->getParent()); + const GlobalValue *GV = + cast<GlobalValue>(GA->getGlobal()->stripPointerCastsAndAliases()); + SmallString<32> NameString("__emutls_v."); + NameString += GV->getName(); StringRef EmuTlsVarName(NameString); - GlobalVariable *EmuTlsVar = VariableModule->getNamedGlobal(EmuTlsVarName); + const GlobalVariable *EmuTlsVar = + GV->getParent()->getNamedGlobal(EmuTlsVarName); assert(EmuTlsVar && "Cannot find EmuTlsVar "); Entry.Node = DAG.getGlobalAddress(EmuTlsVar, dl, PtrVT); Entry.Ty = VoidPtrType; |
