This is an archive of the discontinued LLVM Phabricator instance.

Don't rely on '%l' modifiers to indicate a label reference
ClosedPublic

Authored by void on Dec 23 2019, 5:02 PM.

Details

Summary

It's not necessary to use an '%l' modifier when referencing a label.
Treat block addresses and MBB references as if the modifier is used
anyway. This prevents us from generating references to ficticious
labels.

Diff Detail

Event Timeline

void created this revision.Dec 23 2019, 5:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 23 2019, 5:02 PM

Thanks for the fix. Two minor fixes requested, then should be good to land.

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
470

Would you mind hoisting the expression MI->getOperand(OpNo) into a local variable defined above near the definition of OpNo? It would DRY up this code.

llvm/test/CodeGen/X86/callbr-asm.ll
135

do we require dso_local now? (opt -verify <file> says we don't). Would you mind dropping it?

nickdesaulniers retitled this revision from Don't rely on 'l'(ell) modifiers to indicate a label reference to Don't rely on '%l' modifiers to indicate a label reference.Jan 6 2020, 9:48 AM
nickdesaulniers edited the summary of this revision. (Show Details)
void updated this revision to Diff 236429.Jan 6 2020, 11:48 AM
void marked an inline comment as done.

Remove dso_local which isn't necessary

void marked an inline comment as done.Jan 6 2020, 11:48 AM
void added inline comments.
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
470

The compiler should do this already, because MI is const and getOperand has no side-effects. I think that's who no one has bothered to do it before.

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
470

Technically, here !MI->getOperand(OpNo).isBlockAddress() && !MI->getOperand(OpNo).isMBB() is tautalogically false (due to the earlier checks), so you'd only need to check for l. Maybe a comment like // %l should have been handled by the above conditions already., too would be nice.

470

No doubt, but it's annoying to continually type out the full expression, hence the request to DRY up the code. Please make that change.

void updated this revision to Diff 236441.Jan 6 2020, 12:56 PM

Make temp variable for the machine instruction operand.

nickdesaulniers added inline comments.Jan 6 2020, 1:22 PM
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
437

I feel like the check that OpNo >= MI->getNumOperands() should probably guard any calls to MI->getOperand(OpNo) (or that we should check the output of MI->getOperand(OpNo) for validity. Otherwise, getOperand will assert. This would allow you to hoist the two OpNo >= MI->getNumOperands() guards below.

void updated this revision to Diff 236447.Jan 6 2020, 1:43 PM

Change back.

void marked an inline comment as done.Jan 6 2020, 1:44 PM
void added inline comments.
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
437

This is one of the reasons why I didn't want to hoist the change out. It's more trouble than it's worth and in the end isn't that useful. I'm changing it back.

nickdesaulniers accepted this revision.Jan 6 2020, 2:00 PM
This revision is now accepted and ready to land.Jan 6 2020, 2:00 PM
This revision was automatically updated to reflect the committed changes.