[PATCH] D71849: Don't rely on '%l' modifiers to indicate a label reference

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 13:48:29 PST 2020


void updated this revision to Diff 236447.
void added a comment.

Change back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71849

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/test/CodeGen/X86/callbr-asm.ll


Index: llvm/test/CodeGen/X86/callbr-asm.ll
===================================================================
--- llvm/test/CodeGen/X86/callbr-asm.ll
+++ llvm/test/CodeGen/X86/callbr-asm.ll
@@ -53,7 +53,6 @@
   ret i32 1
 }
 
-
 ; Test 3 - asm-goto implements a loop. The loop gets recognized, but many loop
 ; transforms fail due to canonicalization having callbr exceptions. Trivial
 ; blocks at labels 1 and 3 also don't get simplified due to callbr.
@@ -131,3 +130,32 @@
   %1 = load i32, i32* %a.addr, align 4
   ret i32 %1
 }
+
+; Test 4 - asm-goto referenced with the 'l' (ell) modifier and not.
+define void @test4() {
+; CHECK-LABEL: test4:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    #APP
+; CHECK-NOT:     ja .Ltmp50
+; CHECK-NEXT:    ja .Ltmp5
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:  .LBB3_1:
+; CHECK-NEXT:    #APP
+; CHECK-NOT:     ja .Ltmp50
+; CHECK-NEXT:    ja .Ltmp5
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    jmp .LBB3_3
+entry:
+  callbr void asm sideeffect "ja $0", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux))
+          to label %asm.fallthrough [label %quux]
+
+asm.fallthrough:                                  ; preds = %entry
+  callbr void asm sideeffect "ja ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux))
+          to label %cleanup [label %quux]
+
+quux:                                             ; preds = %asm.fallthrough, %entry
+  br label %cleanup
+
+cleanup:                                          ; preds = %asm.fallthrough, %quux
+  ret void
+}
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -456,26 +456,23 @@
 
           // FIXME: Shouldn't arch-independent output template handling go into
           // PrintAsmOperand?
-          if (Modifier[0] == 'l') { // Labels are target independent.
-            if (MI->getOperand(OpNo).isBlockAddress()) {
-              const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
-              MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
-              Sym->print(OS, AP->MAI);
-              MMI->getContext().registerInlineAsmLabel(Sym);
-            } else if (MI->getOperand(OpNo).isMBB()) {
-              const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
-              Sym->print(OS, AP->MAI);
-            } else {
-              Error = true;
-            }
+          // Labels are target independent.
+          if (MI->getOperand(OpNo).isBlockAddress()) {
+            const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
+            MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
+            Sym->print(OS, AP->MAI);
+            MMI->getContext().registerInlineAsmLabel(Sym);
+          } else if (MI->getOperand(OpNo).isMBB()) {
+            const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
+            Sym->print(OS, AP->MAI);
+          } else if (Modifier[0] == 'l') {
+            Error = true;
+          } else if (InlineAsm::isMemKind(OpFlags)) {
+            Error = AP->PrintAsmMemoryOperand(
+                MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
           } else {
-            if (InlineAsm::isMemKind(OpFlags)) {
-              Error = AP->PrintAsmMemoryOperand(
-                  MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
-            } else {
-              Error = AP->PrintAsmOperand(MI, OpNo,
-                                          Modifier[0] ? Modifier : nullptr, OS);
-            }
+            Error = AP->PrintAsmOperand(MI, OpNo,
+                                        Modifier[0] ? Modifier : nullptr, OS);
           }
         }
         if (Error) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71849.236447.patch
Type: text/x-patch
Size: 3814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200106/c1179362/attachment.bin>


More information about the llvm-commits mailing list