[llvm] 173ec72 - [SystemZ] Fix a bug introduced by #135767 (#138280)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 10:01:20 PDT 2025
Author: Dominik Steenken
Date: 2025-05-02T19:01:13+02:00
New Revision: 173ec728d287f989053bd77521b3497b069c98a2
URL: https://github.com/llvm/llvm-project/commit/173ec728d287f989053bd77521b3497b069c98a2
DIFF: https://github.com/llvm/llvm-project/commit/173ec728d287f989053bd77521b3497b069c98a2.diff
LOG: [SystemZ] Fix a bug introduced by #135767 (#138280)
Commit `083b4a3d66` introduced a store-and-load pair around the `BRASL`
call to mcount. That load instruction did not properly declare its
target register as defined, leading to a bad machine instruction.
This commit fixes this by explicitly labeling `%r14` on the load as
`def`.
Added:
Modified:
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/test/CodeGen/SystemZ/mcount.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 5b6b8773e6c58..d24a94ab25ff3 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -13,6 +13,7 @@
#include "SystemZRegisterInfo.h"
#include "SystemZSubtarget.h"
#include "llvm/CodeGen/LivePhysRegs.h"
+#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RegisterScavenging.h"
@@ -584,7 +585,7 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
// Reload return address from 8 bytes above stack pointer.
BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LG))
- .addReg(SystemZ::R14D)
+ .addReg(SystemZ::R14D, RegState::Define)
.addReg(SystemZ::R15D)
.addImm(8)
.addReg(0);
diff --git a/llvm/test/CodeGen/SystemZ/mcount.ll b/llvm/test/CodeGen/SystemZ/mcount.ll
index 01bd34548f125..61d00e70f1314 100644
--- a/llvm/test/CodeGen/SystemZ/mcount.ll
+++ b/llvm/test/CodeGen/SystemZ/mcount.ll
@@ -1,6 +1,6 @@
; Test proper insertion of mcount instrumentation
;
-; RUN: llc < %s -mtriple=s390x-linux-gnu -o - | FileCheck %s
+; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs -o - | FileCheck %s
;
; CHECK: # %bb.0:
; CHECK-NEXT: stg %r14, 8(%r15)
More information about the llvm-commits
mailing list