Skip to content

Commit b1682ac

Browse files
committed
Allow KILL MI with dangling MMO in MachineVerifier.
1 parent 05b6c2e commit b1682ac

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
22712271

22722272
// Check the MachineMemOperands for basic consistency.
22732273
for (MachineMemOperand *Op : MI->memoperands()) {
2274-
if (Op->isLoad() && !MI->mayLoad())
2274+
if (Op->isLoad() && (!MI->mayLoad() && !MI->isKill()))
22752275
report("Missing mayLoad flag", MI);
22762276
if (Op->isStore() && !MI->mayStore())
22772277
report("Missing mayStore flag", MI);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z16 -disable-machine-dce \
2+
; RUN: -verify-machineinstrs -O3
3+
;
4+
; Test that this passes the verifier even though a KILL instruction with a
5+
; dangling memory operand emerges.
6+
7+
define void @fun(ptr %Src, ptr %Dst) {
8+
br label %2
9+
10+
2:
11+
%3 = load i32, ptr %Src, align 4
12+
%4 = freeze i32 %3
13+
%5 = icmp eq i32 %4, 0
14+
%6 = load i32, ptr poison, align 4
15+
%7 = select i1 %5, i32 0, i32 %6
16+
%8 = load i32, ptr %Src, align 4
17+
%9 = freeze i32 %8
18+
%10 = icmp eq i32 %9, 0
19+
%11 = load i32, ptr poison, align 4
20+
%12 = select i1 %10, i32 0, i32 %11
21+
br label %13
22+
23+
13:
24+
%14 = phi i32 [ %12, %13 ], [ %7, %2 ]
25+
%15 = icmp slt i32 %14, 5
26+
%16 = zext i1 %15 to i64
27+
%17 = xor i64 poison, %16
28+
store i64 %17, ptr %Dst, align 8
29+
br label %13
30+
}

0 commit comments

Comments
 (0)