A R_REF relocation as a non-relocating reference is required to prevent garbage collection (by the binder) of the ref symbol in object generation.
Details
- Reviewers
shchenz DiggerLin hubert.reinterpretcast stephenpeckham - Group Reviewers
Restricted Project - Commits
- rG49dcd08c3d96: [XCOFF] support the ref directive for object generation.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
---|---|---|
88 | This would be very strange directly calling to XCOFFObjectWriter and skipping the abstract MC layer. For example, with this implementation I think you can not get the MCFixups for the refs in the MCAssembler dumping? Is it possible to just create a MCFixup here and use existing logic to handle the relocations? With this method I think you don't need the std::vector<std::pair<const MCSymbol *, const MCFragment *>> RefSymbolInfo in the XCOFFObjectWriter.cpp, the MCFixups should all be attached to the MCFragment of the MCSection. | |
llvm/test/CodeGen/PowerPC/pgo-ref-directive.ll | ||
104 | We also need a case that has R_REF relocation for .text section. |
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
---|---|---|
89 | The fixup_ppc_nofixup is defined in llvm/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h, and it looks inappropriate to include that in llvm/lib/MC? |
llvm/lib/MC/MCXCOFFStreamer.cpp | ||
---|---|---|
89 | yes, I think you would need an interface in class MCAsmBackend and override this interface in class XCOFFPPCAsmBackend. FK_NONE is not a good choice, it is for relocation types that are defined in targets and bigger FirstLiteralRelocationKind(Although now PPC does not have any fixup kind bigger than FirstLiteralRelocationKind, but we really should not break this common design.). See PPCAsmBackend::getFixupKindInfo(). |
Looks good to me except one nit.
llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp | ||
---|---|---|
280 | nit: although we don't have user for other fixup kinds, for functionality complete, could we add other cases as well? This is what other targets do. |
llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp | ||
---|---|---|
280 | I don't really agree with adding other cases that are not used in this patch, because we will neither assurance its features for these cases nor test them. |
llvm/lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp | ||
---|---|---|
280 | OK |
This would be very strange directly calling to XCOFFObjectWriter and skipping the abstract MC layer. For example, with this implementation I think you can not get the MCFixups for the refs in the MCAssembler dumping?
Is it possible to just create a MCFixup here and use existing logic to handle the relocations? With this method I think you don't need the std::vector<std::pair<const MCSymbol *, const MCFragment *>> RefSymbolInfo in the XCOFFObjectWriter.cpp, the MCFixups should all be attached to the MCFragment of the MCSection.