This is an archive of the discontinued LLVM Phabricator instance.

[XCOFF][AIX] Differentiate usage of label symbol and csect symbol
ClosedPublic

Authored by jasonliu on Oct 30 2019, 12:33 PM.

Details

Summary

We are using symbols to represent label and csect interchangeably before, and that could be a problem.
There are cases we would need to add storage mapping class to the symbol if that symbol is actually the name of a csect, but it's hard for us to figure out whether that symbol is a label or csect.

This patch intend to do the following:

  1. Construct a QualName (A name include the storage mapping class) MCSymbolXCOFF for every MCSectionXCOFF.
  2. Keep a pointer to that QualName inside of MCSectionXCOFF.
  3. Use that QualName whenever we need a symbol refers to that MCSectionXCOFF.
  4. Adapt the snowball effect from the above changes in XCOFFObjectWriter.cpp.

Diff Detail

Event Timeline

jasonliu created this revision.Oct 30 2019, 12:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 30 2019, 12:33 PM
DiggerLin added inline comments.Nov 5 2019, 8:11 AM
llvm/include/llvm/MC/MCSectionXCOFF.h
46

I think the name of the QualName is always same as Section Name, I am prefer to create the QualName inside the construct of the MCSectionXCOFF.

otherwise we have to write a code which created a Qualname first. and then call the new MCSectionXCOFF(......) very time.

llvm/lib/MC/MCContext.cpp
562

the name of section is same as Qualname, if the the Qualname is created in the MCSectionXCOFF , we do not need the code MCSymbol *QualName = getOrCreateSymbol(

CachedName + "[" + XCOFF::getMappingClassString(SMC) + "]");

here.

jasonliu marked 2 inline comments as done.Nov 5 2019, 8:34 AM
jasonliu added inline comments.
llvm/include/llvm/MC/MCSectionXCOFF.h
46

Section Name here is not the same as QualName. The Section name is without mapping class.

You need to create a new MCSymbol using "getOrCreateSymbol", which is inside MCContext. I don't think it's viable to do that inside of MCSection. (MCSection is not supposed to hold a MCContext object).

llvm/lib/MC/MCContext.cpp
562

I don't think you can create that QualName inside of MCSectionXCOFF. How do you call getOrCreateSymbol inside of MCSectionXCOFF?

DiggerLin added inline comments.Nov 5 2019, 2:06 PM
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
1768

what about GVKind.isBSSExtern() ?
I think we need to deal with as .comm output

jasonliu marked an inline comment as done.Nov 5 2019, 3:12 PM
jasonliu added inline comments.
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
1768

I don't think it's in the scope of this patch.
This patch is aiming for existing infrastructure.

If we know when we generate that GVKind, we should handle it in a separate patch.

DiggerLin accepted this revision.Nov 7 2019, 10:06 AM

LGTM

llvm/include/llvm/MC/MCSectionXCOFF.h
46

yes, agree with there is not MCContext in the NCSection.

llvm/lib/MC/MCContext.cpp
562

yes, there is not MCContext in the MCSectionXCOFF

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
1768

please ignore the comment (I think we need to deal with as .comm output) I think GVKind.isBSSExtern maybe need to put in the data section.

This revision is now accepted and ready to land.Nov 7 2019, 10:06 AM
daltenty accepted this revision.Nov 8 2019, 6:25 AM

LGTM

This revision was automatically updated to reflect the committed changes.