Skip to content

Commit f908135

Browse files
authored
[MCP] Use MachineInstr::all_defs instead of MachineInstr::defs in hasOverlappingMultipleDef. (#86889)
defs does not return the defs for inline assembly. We need to use all_defs to find them. Fixes #86880.
1 parent f566b07 commit f908135

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ bool MachineCopyPropagation::hasImplicitOverlap(const MachineInstr &MI,
640640
/// The umull instruction is unpredictable unless RdHi and RdLo are different.
641641
bool MachineCopyPropagation::hasOverlappingMultipleDef(
642642
const MachineInstr &MI, const MachineOperand &MODef, Register Def) {
643-
for (const MachineOperand &MIDef : MI.defs()) {
643+
for (const MachineOperand &MIDef : MI.all_defs()) {
644644
if ((&MIDef != &MODef) && MIDef.isReg() &&
645645
TRI->regsOverlap(Def, MIDef.getReg()))
646646
return true;

llvm/test/CodeGen/X86/pr86880.mir

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2+
# RUN: llc -mtriple=x86_64-- -run-pass=machine-cp -o - %s | FileCheck %s
3+
4+
---
5+
name: foo
6+
tracksRegLiveness: true
7+
body: |
8+
bb.0:
9+
liveins: $eax
10+
11+
; CHECK-LABEL: name: foo
12+
; CHECK: liveins: $eax
13+
; CHECK-NEXT: {{ $}}
14+
; CHECK-NEXT: INLINEASM &"", 0 /* attdialect */, 10 /* regdef */, implicit-def dead $eax, 2686986 /* regdef:GR32_NOREX2 */, def renamable $r15d, 10 /* regdef */, implicit-def dead $ecx, 10 /* regdef */, implicit-def dead $edx, 2147483657 /* reguse tiedto:$0 */, $eax(tied-def 3)
15+
; CHECK-NEXT: renamable $ecx = COPY killed renamable $r15d
16+
; CHECK-NEXT: NOOP implicit $ecx
17+
INLINEASM &"", 0 /* attdialect */, 10 /* regdef */, implicit-def dead $eax, 2686986 /* regdef:GR32_NOREX2 */, def renamable $r15d, 10 /* regdef */, implicit-def dead $ecx, 10 /* regdef */, implicit-def dead $edx, 2147483657 /* reguse tiedto:$0 */, $eax(tied-def 3)
18+
renamable $ecx = COPY killed renamable $r15d
19+
NOOP implicit $ecx
20+
21+
...

0 commit comments

Comments
 (0)