diff options
author | Dmitry Polukhin <dmitry.polukhin@gmail.com> | 2016-04-07 12:32:19 +0000 |
---|---|---|
committer | Dmitry Polukhin <dmitry.polukhin@gmail.com> | 2016-04-07 12:32:19 +0000 |
commit | a1feff7024b552b579f302fea0030aaaa14624b3 (patch) | |
tree | bc5cbda70333854512705e91da81598e4368a052 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | |
parent | 79cb643b201bfa1acba9a1afef7395f3be3f60e6 (diff) | |
download | bcm5719-llvm-a1feff7024b552b579f302fea0030aaaa14624b3.tar.gz bcm5719-llvm-a1feff7024b552b579f302fea0030aaaa14624b3.zip |
[GCC] Attribute ifunc support in llvm
This patch add support for GCC attribute((ifunc("resolver"))) for
targets that use ELF as object file format. In general ifunc is a
special kind of function alias with type @gnu_indirect_function. Patch
for Clang http://reviews.llvm.org/D15524
Differential Revision: http://reviews.llvm.org/D15525
llvm-svn: 265667
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 216cab7b30e..32efab094e0 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1069,12 +1069,15 @@ void AsmPrinter::emitGlobalIndirectSymbol(Module &M, else if (GIS.hasWeakLinkage() || GIS.hasLinkOnceLinkage()) OutStreamer->EmitSymbolAttribute(Name, MCSA_WeakReference); else - assert(GIS.hasLocalLinkage() && "Invalid alias linkage"); + assert(GIS.hasLocalLinkage() && "Invalid alias or ifunc linkage"); // Set the symbol type to function if the alias has a function type. // This affects codegen when the aliasee is not a function. - if (GIS.getType()->getPointerElementType()->isFunctionTy()) + if (GIS.getType()->getPointerElementType()->isFunctionTy()) { OutStreamer->EmitSymbolAttribute(Name, MCSA_ELF_TypeFunction); + if (isa<GlobalIFunc>(GIS)) + OutStreamer->EmitSymbolAttribute(Name, MCSA_ELF_TypeIndFunction); + } EmitVisibility(Name, GIS.getVisibility()); @@ -1209,6 +1212,8 @@ bool AsmPrinter::doFinalization(Module &M) { emitGlobalIndirectSymbol(M, *AncestorAlias); AliasStack.clear(); } + for (const auto &IFunc : M.ifuncs()) + emitGlobalIndirectSymbol(M, IFunc); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); assert(MI && "AsmPrinter didn't require GCModuleInfo?"); |