[llvm] 7da2d69 - [LoongArch] Transfer MI flags when expand PseudoCALL
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 17:25:34 PST 2022
Author: wanglei
Date: 2022-11-17T09:25:10+08:00
New Revision: 7da2d69da6a8aa5f1d55284910efe27bf64106b2
URL: https://github.com/llvm/llvm-project/commit/7da2d69da6a8aa5f1d55284910efe27bf64106b2
DIFF: https://github.com/llvm/llvm-project/commit/7da2d69da6a8aa5f1d55284910efe27bf64106b2.diff
LOG: [LoongArch] Transfer MI flags when expand PseudoCALL
When expanding a PseudoCALL, the corresponding flags (e.g. nomerge)
need to be passed to the new instruction.
This patch also adds test for the nomerge attribute.
The `nomerge` attribute was added during `LowerCall`, but was lost
during expand PseudoCALL. Now add it back.
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D137888
Added:
llvm/test/CodeGen/LoongArch/nomerge.ll
Modified:
llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp b/llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp
index 2aa2140b67098..d99b7757166ca 100644
--- a/llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp
@@ -285,6 +285,9 @@ bool LoongArchPreRAExpandPseudo::expandFunctionCALL(
// Transfer implicit operands.
CALL.copyImplicitOps(MI);
+ // Transfer MI flags.
+ CALL.setMIFlags(MI.getFlags());
+
MI.eraseFromParent();
return true;
}
diff --git a/llvm/test/CodeGen/LoongArch/nomerge.ll b/llvm/test/CodeGen/LoongArch/nomerge.ll
new file mode 100644
index 0000000000000..6c69f0d15675a
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/nomerge.ll
@@ -0,0 +1,35 @@
+; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
+
+define void @foo(i32 %i) {
+entry:
+ switch i32 %i, label %if.end3 [
+ i32 5, label %if.then
+ i32 7, label %if.then2
+ ]
+
+if.then:
+ tail call void @bar() #0
+ br label %if.end3
+
+if.then2:
+ tail call void @bar() #0
+ br label %if.end3
+
+if.end3:
+ tail call void @bar() #0
+ ret void
+}
+
+declare void @bar()
+
+attributes #0 = { nomerge }
+
+; CHECK-LABEL: foo:
+; CHECK: # %bb.0: # %entry
+; CHECK: # %bb.1: # %entry
+; CHECK: # %bb.2: # %if.then
+; CHECK-NEXT: bl %plt(bar)
+; CHECK: .LBB0_3: # %if.then2
+; CHECK-NEXT: bl %plt(bar)
+; CHECK: .LBB0_4: # %if.end3
+; CHECK: bl %plt(bar)
More information about the llvm-commits
mailing list