File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,29 @@ void DscFileGenerator::Global_Functions(void)
9292 }
9393}
9494
95+ static bool Is_TLS (VarDecl *decl)
96+ {
97+ return decl->getTLSKind () == VarDecl::TLS_None ? false : true ;
98+ }
99+
100+ static bool Is_TLS (const DeclContext::lookup_result &decls)
101+ {
102+ bool is_tls = false ;
103+
104+ for (auto it = decls.begin (); it != decls.end (); ++it) {
105+ if (VarDecl *vdecl = dyn_cast<VarDecl>(*it)) {
106+ is_tls |= Is_TLS (vdecl);
107+ }
108+ }
109+
110+ return is_tls;
111+ }
112+
113+ static std::string Get_TLS_Token (bool predicate)
114+ {
115+ return predicate == true ? " %" : " " ;
116+ }
117+
95118void DscFileGenerator::Local_Symbols (void )
96119{
97120 TranslationUnitDecl *tu = AST->getASTContext ().getTranslationUnitDecl ();
@@ -102,9 +125,11 @@ void DscFileGenerator::Local_Symbols(void)
102125 DeclContext::lookup_result decls = tu->lookup (
103126 DeclarationName (&idtbl.get (entry.NewName )));
104127 if (decls.empty ()) {
105- throw std::runtime_error (" Unable to find symbol " + entry.NewName + " in the AST" );
128+ throw std::runtime_error (" Unable to find symbol " + entry.NewName +
129+ " in the AST" );
106130 }
107- Out << " \n #" << entry.OldName << " :" << entry.NewName ;
131+ Out << " \n #" << Get_TLS_Token (Is_TLS (decls)) << entry.OldName << " :" <<
132+ entry.NewName ;
108133 std::string mod = IA.Get_Symbol_Module (entry.OldName );
109134 if (!mod.empty ())
110135 Out << " :" << mod;
Original file line number Diff line number Diff line change @@ -646,6 +646,12 @@ VarDecl *SymbolExternalizer::Create_Externalized_Var(DeclaratorDecl *decl, const
646646 ret->addAttr (UsedAttr::Create (astctx));
647647 }
648648
649+ /* In case the original Decl has TLS storage, we must copy it to the new
650+ variable as well. */
651+ if (VarDecl *vdecl = dyn_cast<VarDecl>(decl)) {
652+ ret->setTSCSpec (vdecl->getTSCSpec ());
653+ }
654+
649655 /* return node. */
650656 return ret;
651657}
Original file line number Diff line number Diff line change 1+ /* { dg-options "-DCE_EXTRACT_FUNCTIONS=set_errno -DCE_EXPORT_SYMBOLS=__libc_errno" }*/
2+
3+ extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec" )));
4+
5+ void set_errno (int err )
6+ {
7+ __libc_errno = err ;
8+ }
9+
10+ /* { dg-final { scan-tree-dump "__attribute__\(\(used\)\) static __thread int \*klpe___libc_errno;|static __thread int \*klpe___libc_errno __attribute__\(\(used\)\);" } } */
11+ /* { dg-final { scan-tree-dump "\(\*klpe___libc_errno\) = err" } } */
You can’t perform that action at this time.
0 commit comments