Right now we handle each CsectGroup(ProgramCodeCsects, BSSCsects) individually when assigning indices, writing symbol table, and writing section raw data. However, there is already a pattern there, and we could common up those actions for every CsectGroup. This will make adding new CsectGroup(Read Write data, Read only data, TC/TOC, mergeable string) easier, and less error prone.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/MC/XCOFFObjectWriter.cpp | ||
---|---|---|
121 | Should we specify this relative to XCOFF::N_DEBUG? |
llvm/lib/MC/XCOFFObjectWriter.cpp | ||
---|---|---|
83 | Minor nit: I believe right now we are always emitting a label def for csects that support them even if it could be skipped, however there has been discussion to skip them when appropriate. UseLabelDefinition to me sounds like its saying implying yes to both the global and local criteria. In that light maybe enum values of 'LabelDefSupported' and 'LabelDefUnsupported' are more appropriate. (Or we can adjust the names when we implement the selective label def emission). | |
166–168 | Minor nit: IIUC this is all the sections, as opposed to the non-empty sections. We can determine if a section is non-empty when it has been assigned a valid section index. | |
329 | Should we maintain CurrentAddressLocation across groups to make sure there is no padding between groups? | |
573 | I think we should consider using llvm::all_of to check if all the groups are empty and continue if they are. Then the section initialization can be done before processing any of the csects, without having to gate the initialization on if its section index is already valid , as well as adjust the size after processing the csects without an addition check to see if the section was initialized or not. | |
586 | I think a fatal error would be more appropriate. Minor nit: should we be creating a named constant for readability/documentation. |
Address Sean's comment.
llvm/lib/MC/XCOFFObjectWriter.cpp | ||
---|---|---|
83 | Agree. | |
329 | Do you mean maintain CurrentAddressLocation across Sections? Since it's currently already maintained across groups. | |
573 | I still need a guard for But I do think using a specific guard for that is better than just comparing UninitializedIndex everywhere. |
llvm/lib/MC/XCOFFObjectWriter.cpp | ||
---|---|---|
121 | It might be Okay depending on how we write our code later. But there is a chance we could run into risks of needing differentiate a special section number with a truely uninitialized section. So I would prefer to pick a section number that's not used to represent other things. | |
573 | Thanks. I will address. |
@DiggerLin @daltenty @sfertile
Ping.
I believe I have addressed the comments you put.
Seems this commit broke the buildbot http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/6795
Minor nit:
We have a 2 stage problem when deciding to use label defs or not:
Global: Does the type of csect allow/support labels defs.
Local: If label defs are supported in the csect type, can we omit the label defs for this specific csect.
I believe right now we are always emitting a label def for csects that support them even if it could be skipped, however there has been discussion to skip them when appropriate. UseLabelDefinition to me sounds like its saying implying yes to both the global and local criteria. In that light maybe enum values of 'LabelDefSupported' and 'LabelDefUnsupported' are more appropriate. (Or we can adjust the names when we implement the selective label def emission).