[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

Jason Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 08:07:39 PDT 2020


jasonliu added inline comments.


================
Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1500
+      if (cast<MCSymbolXCOFF>(Name)->hasContainingCsect())
+        emitLinkage(&F, Name);
+
----------------
DiggerLin wrote:
> jasonliu wrote:
> > DiggerLin wrote:
> > > jasonliu wrote:
> > > > 1. We need to rebase here, as it is called `hasRepresentedCsectSet()` instead of `hasContainingCsect()` now.
> > > > 2. I'm slightly worried here to rely on `hasRepresentedCsectSet()` to check if a linkage should be emitted. This is based on the assumption that we will not ever change our implementation for `.bl foo` to `.bl foo[PR]`. But in https://reviews.llvm.org/D77080#inline-706207, we discussed about this possibility. So this assumption might not be true in the future. However, I'm not sure if there is another way to check if this function have been called directly. 
> > > > So if there is another way to check, we should pursue the alternative instead. If there is not, then we need to add an assert here, like `assert(Name->getName().equals(cast<MCSymbolXCOFF>(Name)->getUnqualifiedName())` to make sure we don't get a qualname here. 
> > > > 3. 
> > > > Have a comment here and tell people what we are doing here.
> > > > For example, 
> > > > // If there is a direct call to external function, then we need to emit linkage for its function entry point. 
> > > when we implement .bl foo to .bl foo[PR]
> > > the SymbolName will change from .bl[SMC] and check the .bl[SMC]->hasRepresentedCsectSet()
> > Yes, but foo[PR]->hasRepresentedCsectSet() will always return true, because whenever we created a qualname will always have csect set. How will we know if foo() function is called directly then? 
> we only deal with extern function(we do not deal with definition function) here, for extern function, it not always has MCSectionXCOFF, it only create the extern function be called directly in the llvm/lib/CodeGen/MachineModuleInfo.cpp line 108~116, unless we delete the code later. if the code is not changed. for extern function foo , the .foo[PR] -> hasRepresentedCsectSet()  when directly call. otherwise false.
Okk. I think I got what you mean. If .foo[PR] is created then it means there is a direct call. Otherwise, we will not have a .foo[PR], and of course that newly created .foo[PR] will not have a RepresentedCsect.
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932





More information about the cfe-commits mailing list