This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinter] Print label if MBB's address is taken
AbandonedPublic

Authored by void on Jul 19 2019, 2:18 AM.

Details

Summary

Make sure that we emit a label for the MBB if its address is taken.

Diff Detail

Event Timeline

void created this revision.Jul 19 2019, 2:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2019, 2:18 AM
lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
438

Make MBB a non-const MachineBasicBlock&, then you can drop the ugly const_cast and then also the & then -> and just use ..

for (MachineBasicBlock& MBB : *MF) {
  ...
  MBB.setLabelMustBeEmitted();
void marked an inline comment as done.Jul 19 2019, 2:44 AM
void added inline comments.
lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
438

The MF is coming from MI which itself is const. There's probably going to be a const_cast somewhere along the line. :-(

Sounds like this may address: https://bugs.llvm.org/show_bug.cgi?id=42309#c1?

lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
438

Ok, is the &+-> still really necessary?

const_cast<MachineBasicBlock>(MBB).setLabelMustBeEmitted();

(I still feel like const_cast is a code smell; if we modify something, then our function signature should really not accept a const param. const parameters are meant to be an agreement between caller and callee that callee doesn't modify the param).

void updated this revision to Diff 210794.Jul 19 2019, 3:32 AM

Cast to reference.

void marked an inline comment as done.Jul 19 2019, 3:38 AM
void added inline comments.
lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
438

I can cast it to a reference.

I don't like const_casts either. We would need to calculate that it should be set long before getting here.

void abandoned this revision.Jul 19 2019, 11:42 AM