erichkeane added inline comments.

================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2957
+    if (!AliasFunc) {
+      auto *IFunc = cast<llvm::GlobalIFunc>(GetOrCreateLLVMFunction(
+          AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,
----------------
erichkeane wrote:
> I think we want this in GetOrCreateMultiVersionResolver, so that it gets 
> created when the ifunc does.  That way you just need a 
> "FD->isCPUDispatchMultiVersion() || isCPUSpecificMultiVersion()" check inside 
> the supportsIFunc branch.
After discussing this offline, I believe this is the right function to create 
the alias.  The motivating example is:

    // TU1:
    __attribute__((cpu_dispatch(a,b,c))) void foo(void);

    // TU2:
    extern void foo(void);

Currently, TU1 doesn't bother to emit the ifunc, because we've attached 
emitting this to when this is referenced.

We made that choice because we expected TU2 to mark 'foo' as 
cpu_dispatch/cpu_specific in SOME way.  I believe that it is harmless to emit 
the ifunc all the time, which this is attempting to do.  However, this needs to 
change the ifunc to have LinkOnceODR linkage in 
GetOrCreateMultiVersionResolver, otherwise this can cause linker errors.




================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2961
+      auto *GA = llvm::GlobalAlias::create(
+         DeclTy, 0, getFunctionLinkage(GD), AliasName, IFunc, &getModule());
+      const auto *D = GD.getDecl();
----------------
I think the alias always needs LinkOnceODR linkage, to match the (new) IFunc 
linkage.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to