Skip to content

Commit 173ec72

Browse files
[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`.
1 parent cb068dc commit 173ec72

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "SystemZRegisterInfo.h"
1414
#include "SystemZSubtarget.h"
1515
#include "llvm/CodeGen/LivePhysRegs.h"
16+
#include "llvm/CodeGen/MachineInstrBuilder.h"
1617
#include "llvm/CodeGen/MachineModuleInfo.h"
1718
#include "llvm/CodeGen/MachineRegisterInfo.h"
1819
#include "llvm/CodeGen/RegisterScavenging.h"
@@ -584,7 +585,7 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
584585

585586
// Reload return address from 8 bytes above stack pointer.
586587
BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LG))
587-
.addReg(SystemZ::R14D)
588+
.addReg(SystemZ::R14D, RegState::Define)
588589
.addReg(SystemZ::R15D)
589590
.addImm(8)
590591
.addReg(0);

llvm/test/CodeGen/SystemZ/mcount.ll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Test proper insertion of mcount instrumentation
22
;
3-
; RUN: llc < %s -mtriple=s390x-linux-gnu -o - | FileCheck %s
3+
; RUN: llc < %s -mtriple=s390x-linux-gnu -verify-machineinstrs -o - | FileCheck %s
44
;
55
; CHECK: # %bb.0:
66
; CHECK-NEXT: stg %r14, 8(%r15)

0 commit comments

Comments
 (0)