Skip to content

Commit 7da2d69

Browse files
committed
[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
1 parent 1310aa1 commit 7da2d69

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

llvm/lib/Target/LoongArch/LoongArchExpandPseudoInsts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ bool LoongArchPreRAExpandPseudo::expandFunctionCALL(
285285
// Transfer implicit operands.
286286
CALL.copyImplicitOps(MI);
287287

288+
// Transfer MI flags.
289+
CALL.setMIFlags(MI.getFlags());
290+
288291
MI.eraseFromParent();
289292
return true;
290293
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
; RUN: llc --mtriple=loongarch64 < %s | FileCheck %s
2+
3+
define void @foo(i32 %i) {
4+
entry:
5+
switch i32 %i, label %if.end3 [
6+
i32 5, label %if.then
7+
i32 7, label %if.then2
8+
]
9+
10+
if.then:
11+
tail call void @bar() #0
12+
br label %if.end3
13+
14+
if.then2:
15+
tail call void @bar() #0
16+
br label %if.end3
17+
18+
if.end3:
19+
tail call void @bar() #0
20+
ret void
21+
}
22+
23+
declare void @bar()
24+
25+
attributes #0 = { nomerge }
26+
27+
; CHECK-LABEL: foo:
28+
; CHECK: # %bb.0: # %entry
29+
; CHECK: # %bb.1: # %entry
30+
; CHECK: # %bb.2: # %if.then
31+
; CHECK-NEXT: bl %plt(bar)
32+
; CHECK: .LBB0_3: # %if.then2
33+
; CHECK-NEXT: bl %plt(bar)
34+
; CHECK: .LBB0_4: # %if.end3
35+
; CHECK: bl %plt(bar)

0 commit comments

Comments
 (0)