[llvm] [SystemZ] Fix a bug introduced by #135767 (PR #138280)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 07:08:13 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-systemz

Author: Dominik Steenken (dominik-steenken)

<details>
<summary>Changes</summary>

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`.

---
Full diff: https://github.com/llvm/llvm-project/pull/138280.diff


1 Files Affected:

- (modified) llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp (+2-1) 


``````````diff
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);

``````````

</details>


https://github.com/llvm/llvm-project/pull/138280


More information about the llvm-commits mailing list