[llvm] f908135 - [MCP] Use MachineInstr::all_defs instead of MachineInstr::defs in hasOverlappingMultipleDef. (#86889)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 08:37:23 PDT 2024
Author: Craig Topper
Date: 2024-03-28T08:37:19-07:00
New Revision: f90813543b57a9753c549ac0aac083b879b94230
URL: https://github.com/llvm/llvm-project/commit/f90813543b57a9753c549ac0aac083b879b94230
DIFF: https://github.com/llvm/llvm-project/commit/f90813543b57a9753c549ac0aac083b879b94230.diff
LOG: [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.
Added:
llvm/test/CodeGen/X86/pr86880.mir
Modified:
llvm/lib/CodeGen/MachineCopyPropagation.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 9a0ab300b21b7a..65c067e4874b17 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -640,7 +640,7 @@ bool MachineCopyPropagation::hasImplicitOverlap(const MachineInstr &MI,
/// The umull instruction is unpredictable unless RdHi and RdLo are
diff erent.
bool MachineCopyPropagation::hasOverlappingMultipleDef(
const MachineInstr &MI, const MachineOperand &MODef, Register Def) {
- for (const MachineOperand &MIDef : MI.defs()) {
+ for (const MachineOperand &MIDef : MI.all_defs()) {
if ((&MIDef != &MODef) && MIDef.isReg() &&
TRI->regsOverlap(Def, MIDef.getReg()))
return true;
diff --git a/llvm/test/CodeGen/X86/pr86880.mir b/llvm/test/CodeGen/X86/pr86880.mir
new file mode 100644
index 00000000000000..92ebf9a265bb95
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr86880.mir
@@ -0,0 +1,21 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
+# RUN: llc -mtriple=x86_64-- -run-pass=machine-cp -o - %s | FileCheck %s
+
+---
+name: foo
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $eax
+
+ ; CHECK-LABEL: name: foo
+ ; CHECK: liveins: $eax
+ ; CHECK-NEXT: {{ $}}
+ ; 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)
+ ; CHECK-NEXT: renamable $ecx = COPY killed renamable $r15d
+ ; CHECK-NEXT: NOOP implicit $ecx
+ 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)
+ renamable $ecx = COPY killed renamable $r15d
+ NOOP implicit $ecx
+
+...
More information about the llvm-commits
mailing list