Skip to content

Commit 7183771

Browse files
authored
[InitUndef] Also handle inline asm (#108951)
InitUndef should also handle early-clobber / undef conflicts in inline asm operands. Do this by iterating over all_defs() instead of defs(). The newly added ARM test was generating an "unpredictable STXP instruction, status is also a source" error prior to this change. Fixes #106380.
1 parent 4c50112 commit 7183771

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

llvm/lib/CodeGen/InitUndef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ INITIALIZE_PASS(InitUndef, DEBUG_TYPE, INIT_UNDEF_NAME, false, false)
9898
char &llvm::InitUndefID = InitUndef::ID;
9999

100100
static bool isEarlyClobberMI(MachineInstr &MI) {
101-
return llvm::any_of(MI.defs(), [](const MachineOperand &DefMO) {
101+
return llvm::any_of(MI.all_defs(), [](const MachineOperand &DefMO) {
102102
return DefMO.isReg() && DefMO.isEarlyClobber();
103103
});
104104
}

llvm/test/CodeGen/AArch64/arm64-ldxr-stxr.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,19 @@ define dso_local i32 @test_stxp_undef(ptr %p, i64 %x) nounwind {
364364
ret i32 %res
365365
}
366366

367+
; Same as previous test, but using inline asm.
368+
define dso_local i32 @test_stxp_undef_inline_asm(ptr %p, i64 %x) nounwind {
369+
; CHECK-LABEL: test_stxp_undef_inline_asm:
370+
; CHECK: // %bb.0:
371+
; CHECK-NEXT: //APP
372+
; CHECK-NEXT: stxp w8, x9, x1, [x0]
373+
; CHECK-NEXT: //NO_APP
374+
; CHECK-NEXT: mov w0, w8
375+
; CHECK-NEXT: ret
376+
%res = call i32 asm sideeffect "stxp ${0:w}, ${2}, ${3}, [${1}]", "=&r,r,r,r,~{memory}"(ptr %p, i64 undef, i64 %x)
377+
ret i32 %res
378+
}
379+
367380
declare i32 @llvm.aarch64.stlxr.p0(i64, ptr) nounwind
368381
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
369382
; FALLBACK: {{.*}}

llvm/test/CodeGen/Thumb2/mve-intrinsics/vcaddq.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,19 @@ entry:
710710
ret <4 x i32> %0
711711
}
712712

713+
define arm_aapcs_vfpcc <4 x i32> @test_vhcaddq_rot270_s32_undef_inline_asm() {
714+
; CHECK-LABEL: test_vhcaddq_rot270_s32_undef_inline_asm:
715+
; CHECK: @ %bb.0: @ %entry
716+
; CHECK-NEXT: @APP
717+
; CHECK-NEXT: vhcadd.s32 q{{[0-9]+}}, q{{[0-9]+}}, q{{[0-9]+}}, #270
718+
; CHECK-NOT: vhcadd.s32 q[[REG:[0-9]+]], q{{[0-9]+}}, q[[REG]], #270
719+
; CHECK-NEXT: @NO_APP
720+
; CHECK-NEXT: bx lr
721+
entry:
722+
%0 = call <4 x i32> asm sideeffect "vhcadd.s32 ${0}, ${1}, ${2}, #270", "=&w,w,w,~{memory}"(<4 x i32> undef, <4 x i32> undef)
723+
ret <4 x i32> %0
724+
}
725+
713726
define arm_aapcs_vfpcc <16 x i8> @test_vhcaddq_rot90_x_s8(<16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
714727
; CHECK-LABEL: test_vhcaddq_rot90_x_s8:
715728
; CHECK: @ %bb.0: @ %entry

0 commit comments

Comments
 (0)