[PATCH] D94668: [debug-info] [NFC] add is-a(isa<>) support for MCStreamer

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 02:42:34 PST 2021


shchenz added a comment.

In D94668#2553568 <https://reviews.llvm.org/D94668#2553568>, @ikudrin wrote:

> In D94668#2553464 <https://reviews.llvm.org/D94668#2553464>, @shchenz wrote:
>
>> Do you have any idea about how to do this? @ikudrin  My requirement here is: I need to add the `endSymbol` for asm streamer at the end of .text section to indicate the end of the text section.
>> Object streamer can easily do this by calling `MCSymbol *endSection(Section)` in `emitDwarfLineTable`, but this does not work for asm streamer. When we are generating assembly output for .debug_line section, we can not go back to .text section and emit an end symbol there. I think this is not supported.
>
> Does that mean that `endSection()` does not work for your target? In that case, you need to fix it first, no?

This seems not like a target specific problem. It should be by design, we can not call `changeSection` when we generate assembly output?. 
`endSection()` will call `changeSection` and `changeSection` of `MCAsmStreamer` will call `PrintSwitchToSection` if target does not create a target-specific streamer.

  void MCAsmStreamer::changeSection(MCSection *Section,
                                    const MCExpr *Subsection) {
    assert(Section && "Cannot switch to a null section!");
    if (MCTargetStreamer *TS = getTargetStreamer()) {
      TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
    } else {
      Section->PrintSwitchToSection(
          *MAI, getContext().getObjectFileInfo()->getTargetTriple(), OS,
          Subsection);
    }
  }

In `PrintSwitchToSection` of `MCSectionXCOFF::PrintSwitchToSection`, we only generate some section headers in the assembly output, so I guess we can not switch to .text section and then emit a text end there, if we do so, we get pseudo assembly code like:

  .text
  
  .dwabbrev
  ...
  .dwline
  ...
  .text  #switch to .text
  .text_end
  .dwline_end #switch back to .dwline

I guess this is not allowed? `MCSectionELF::PrintSwitchToSection` also has same issue.

I have made some changes in D95518 <https://reviews.llvm.org/D95518>, and now the cast operation is not needed anymore. So this patch can be abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94668



More information about the llvm-commits mailing list