We need to handle the MCSA_LGlobal case in emitSymbolAttribute for functions marked internal in the IR so that the
appropriate storage class is emitted on the function descriptor csect. As part of this we need to make sure that external
labels are not emitted into the symbol table, so we don't emit the descriptor label in the object writing path.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | I understand this is to make the object writing case and assembly case to be equivalent. | |
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
16 | Do we need this include at all? | |
llvm/test/CodeGen/PowerPC/aix-internal.ll | ||
8 | Remove #0 | |
21 | Without the present of SymbolType, I'm not sure what are we testing here. Are we expecting a label or a csect, or both? |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | Hmm, I do agree this does diverge from the original design intent, though I'm not sure that is avoidable for reasons outlined below. With regard to whether it actually makes sense to have a label in the symbol table that is not external, this seems to be the entire intent of the the .lgobl directive. The directive seems to be for statics that need to be kept in the symbol table (I'm assuming for relocation and other purposes). For that reason, I don't think it makes sense to eliminate them in the XCOFFObjectWriter as proposed. Given that we can't just eliminate them in the XCOFFObjectWriter. I think we have two options:
|
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | The two options listed are more like a workaround to the problem. .csect a[xx] Label b does not appear in the symbol table. .globl/.lglobl/.weak/.extern b b should appear in the symbol table. But right now, I don't think we could handle that. And we might want to fix this instead. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | Yes, your understanding is correct. Omitting function descriptor label symbol when it's a static function is an optimization. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | I agree this is the underlying issue. Ideally, we should be able to handle this with MCSymbol which are Temporary. That seems to be how other targets handle user written assembler temporaries. In this case the label here would be marked as Temporary and we would not emit it naturally in the symbol table. This would require some major restructuring of how this symbol gets created however, since this property can only be set at creation time currently. However, we have another bit of an issue with this approach. It looks like other assembly dialects use a prefix to indicate this, and set the attribute when the symbol is created, where we use a directive so we cannot know this at the time the symbol is created. So we'd need a mechanism to set it afterwards anyway. |
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | ||
---|---|---|
688 | Summarizing offline discussion: We will use the external attribute to determine if the label should be emitted into the symbol table. In a follow on patch we will have to set that appropriately for the assembly parsing case when encountering .lgobl and family directives. |
- Use external to determine if we should emit the symbol table entry
- Revert to not emitting linkage on the descriptor if it's a static
- Update test to refer to csect
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
---|---|---|
16 | This should probably be here to include what we use. |
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
---|---|---|
13 | Per the style guide, a "Main Module Header" should come first in the include list. This is where clang-format will place it. |
I understand this is to make the object writing case and assembly case to be equivalent.
But I think this changes the original design intent. The intent was when it is a static function, we do not need an label in the symbol table at all. (@Xiangling_L Correct me if I'm wrong.) Also I'm not sure if it actually make sense to have a label in the symbol table that is not external.
So in order to not change the design intent, I think the way to fix is the other way around. i.e although we registered a symbol, but if it is a label and is C_HIDEXT, do not add the symbol into csect's symbol list. So that we do not need to emit the internal label in the object file generation.