[llvm] 4dba596 - [ARM] prologue instructions emitted for naked function with >64 byte argument
Simon Wallis via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 03:33:28 PDT 2020
Author: Simon Wallis
Date: 2020-06-09T11:33:03+01:00
New Revision: 4dba59689d008df7be37733de4bb537b2911d3ad
URL: https://github.com/llvm/llvm-project/commit/4dba59689d008df7be37733de4bb537b2911d3ad
DIFF: https://github.com/llvm/llvm-project/commit/4dba59689d008df7be37733de4bb537b2911d3ad.diff
LOG: [ARM] prologue instructions emitted for naked function with >64 byte argument
Summary:
The naked function attribute is meant to suppress all function
prologue/epilogue instructions.
On ARM, some are still emitted if an argument greater than 64 bytes in size
(the threshold for using the byval attribute in IR) is passed partially
in registers.
Perform the check for Attribute::Naked and early exit in
SelectionDAGISel::LowerArguments().
Checking in ARMFrameLowering::determineCalleeSaves() is too late.
A test case is included.
Reviewers: llvm-commits, olista01, danielkiss
Reviewed By: danielkiss
Subscribers: kristof.beyls, hiraditya, danielkiss
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80715
Change-Id: Icedecf2a4ad31bc3c35ab0df7489a9d346e1f7cc
Added:
llvm/test/CodeGen/ARM/naked-no-prolog.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 612df693459b..51b03aee92ec 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -9607,6 +9607,10 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
const DataLayout &DL = DAG.getDataLayout();
SmallVector<ISD::InputArg, 16> Ins;
+ // In Naked functions we aren't going to save any registers.
+ if (F.hasFnAttribute(Attribute::Naked))
+ return;
+
if (!FuncInfo->CanLowerReturn) {
// Put in an sret pointer parameter before all the other parameters.
SmallVector<EVT, 1> ValueVTs;
diff --git a/llvm/test/CodeGen/ARM/naked-no-prolog.ll b/llvm/test/CodeGen/ARM/naked-no-prolog.ll
new file mode 100644
index 000000000000..2e9226d2527a
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/naked-no-prolog.ll
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple=arm-eabi -mcpu=cortex-a7 -verify-machineinstrs %s -o - | FileCheck %s
+
+%struct.S = type { [65 x i8] }
+
+define void @naked_no_prologue(%struct.S* byval(%struct.S) align 4 %0) naked noinline nounwind optnone {
+; CHECK-NOT: stm
+; CHECK-NOT: str
+
+entry:
+ ret void
+ unreachable
+}
+
More information about the llvm-commits
mailing list