[PATCH] D64888: Use the MachineBasicBlock symbol for a callbr target
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 16:16:30 PDT 2019
nickdesaulniers added inline comments.
================
Comment at: lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp:435
+ const MachineFunction *MF = MI->getParent()->getParent();
+ for (auto I = MF->begin(), E = MF->end(); I != E; ++I)
+ if (BB == I->getBasicBlock()) {
----------------
void wrote:
> nickdesaulniers wrote:
> > void wrote:
> > > nickdesaulniers wrote:
> > > > range based for?
> > > > ```
> > > > for (const MachineBasicBlock& MBB : MF)
> > > > ...
> > > > ```
> > > >
> > > > might even be able to replace `MF` with the expression above and still fit on 80 lines.
> > > I tried that, but never was able to get the compiler to believe that MF had a "begin()" and "end()". Eventually just gave up... I'll try again though.
> > maybe `*MF`?
> That gives me this error *sigh*:
>
> ```
> error: use of deleted function ‘llvm::MachineBasicBlock::MachineBasicBlock(const llvm::MachineBasicBlock&)’
> ```
That sounds like you forgot to make the iteration variable a reference, so a deleted copy constructor is being invoked.
```
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
index 7721e996aca5..692877bdeb84 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -429,6 +429,10 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
// PrintAsmOperand?
if (Modifier[0] == 'l') { // Labels are target independent.
if (MI->getOperand(OpNo).isBlockAddress()) {
+ const MachineFunction *MF = MI->getParent()->getParent();
+ for (const MachineBasicBlock& MBB : *MF) {
+ errs() << "XXX\n";
+ }
```
compiles just fine for me.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64888/new/
https://reviews.llvm.org/D64888
More information about the llvm-commits
mailing list