[llvm] [ARM] Add a method to clear registers (PR #69659)
Bill Wendling via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 19 16:13:19 PDT 2023
https://github.com/bwendling created https://github.com/llvm/llvm-project/pull/69659
This allows us to clear registers in target-independent code. The first
use will be for clearing the stack protector from registers before
returning.
>From 52667928de837bcd8cb1b90d5e123b01505a3e03 Mon Sep 17 00:00:00 2001
From: Bill Wendling <morbo at google.com>
Date: Wed, 18 Oct 2023 14:05:47 -0700
Subject: [PATCH] [ARM] Add a method to clear registers
This allows us to clear registers in target-independent code. The first
use will be for clearing the stack protector from registers before
returning.
---
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 10 ++++++++++
llvm/lib/Target/ARM/ARMBaseInstrInfo.h | 5 +++++
2 files changed, 15 insertions(+)
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 1ffdde0360cf623..a07504aaedbc4da 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -6735,6 +6735,16 @@ MachineBasicBlock::iterator ARMBaseInstrInfo::insertOutlinedCall(
return CallPt;
}
+void ARMBaseInstrInfo::buildClearRegister(Register DstReg,
+ MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator Iter,
+ DebugLoc &DL,
+ bool AllowSideEffects) const {
+ unsigned Opc = Subtarget.isThumb2() ? ARM::t2MOVi32imm : ARM::MOVi32imm;
+ BuildMI(MBB, Iter, DL, get(Opc), DstReg)
+ .addImm(0);
+}
+
bool ARMBaseInstrInfo::shouldOutlineFromFunctionByDefault(
MachineFunction &MF) const {
return Subtarget.isMClass() && MF.getFunction().hasMinSize();
diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
index 5efcc1a0d9fc073..44b3e528c0c242e 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h
@@ -363,6 +363,11 @@ class ARMBaseInstrInfo : public ARMGenInstrInfo {
MachineBasicBlock::iterator &It, MachineFunction &MF,
outliner::Candidate &C) const override;
+ void buildClearRegister(Register Reg, MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator Iter,
+ DebugLoc &DL,
+ bool AllowSideEffects = true) const override;
+
/// Enable outlining by default at -Oz.
bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override;
More information about the llvm-commits
mailing list