[PATCH] D15524: [GCC] Attribute ifunc support in clang

Eric Christopher via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 17 10:36:29 PST 2015


echristo added inline comments.

================
Comment at: lib/CodeGen/CodeGenModule.cpp:2758
@@ +2757,3 @@
+    GA->setIFunc(true);
+    GA->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
+  }
----------------
rjmccall wrote:
> DmitryPolukhin wrote:
> > rjmccall wrote:
> > > Can you explain the purpose of this line?
> > I need it don't allow optimization that use resolver function directly instead of alias. I could patch checks or I can make special linkage in LLVM for ifunc.
> Okay, this ties into the previous comment.  The problem I have with ifuncs just being represented as global aliases with a special flag set is that now every LLVM analysis that sees a global alias has to check the flag before it can correctly interpret it.  It doesn't promote maintainable, conservatively-correct code.  You're working around that by setting a particular kind of linkage, but that's just going to cause other problems.
> 
> A much better fix is to make a new kind of llvm::GlobalValue that represents a dynamically resolved global.  This is a lot less work than you probably think it is — there are very few exhaustive switches over all value kinds in LLVM, and frankly most of those are places you need to be updating for ifuncs anyway.  It might make sense for this to share a common base class with llvm::GlobalAlias, but it shouldn't be a *subclass* of llvm::GlobalAlias.
FWIW I completely agree with this. :)


http://reviews.llvm.org/D15524





More information about the cfe-commits mailing list