]> granicus.if.org Git - llvm/commitdiff
[SystemZ] Recognize INLINEASM_BR in backend.
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>
Tue, 3 Sep 2019 13:31:22 +0000 (13:31 +0000)
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>
Tue, 3 Sep 2019 13:31:22 +0000 (13:31 +0000)
SystemZInstrInfo::analyzeBranch() needs to check for INLINEASM_BR
instructions, or it will crash.

Review: Ulrich Weigand

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370753 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SystemZ/SystemZInstrInfo.cpp
test/CodeGen/SystemZ/asm-20.ll [new file with mode: 0644]

index da71759cc3f36ac4ae2ee8c1b0ac70cc97b579a2..24a234481d390e54fc7c3a1d3985495f041e2c4e 100644 (file)
@@ -462,8 +462,8 @@ bool SystemZInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
       break;
 
     // A terminator that isn't a branch can't easily be handled by this
-    // analysis.
-    if (!I->isBranch())
+    // analysis.  Asm goto is not understood / optimized.
+    if (!I->isBranch() || I->getOpcode() == SystemZ::INLINEASM_BR)
       return true;
 
     // Can't handle indirect branches.
diff --git a/test/CodeGen/SystemZ/asm-20.ll b/test/CodeGen/SystemZ/asm-20.ll
new file mode 100644 (file)
index 0000000..402c038
--- /dev/null
@@ -0,0 +1,15 @@
+; Test that asm goto can be compiled.
+;
+; RUN: llc < %s -mtriple=s390x-linux-gnu
+
+define i32 @c() {
+entry:
+  callbr void asm sideeffect "", "X"(i8* blockaddress(@c, %d))
+          to label %asm.fallthrough [label %d]
+
+asm.fallthrough:               ; preds = %entry
+  br label %d
+
+d:                             ; preds = %asm.fallthrough, %entry
+  ret i32 undef
+}