[PATCH] D80715: [ARM] prologue instructions emitted for naked function with >64 byte argument

Simon Wallis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 05:57:31 PDT 2020


simonwallis2 created this revision.
simonwallis2 added reviewers: llvm-commits, olista01.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80715

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/ARM/naked-no-prolog.ll


Index: llvm/test/CodeGen/ARM/naked-no-prolog.ll
===================================================================
--- /dev/null
+++ 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
+}
+
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -9603,6 +9603,10 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80715.266825.patch
Type: text/x-patch
Size: 1126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200528/2cf18d59/attachment.bin>


More information about the llvm-commits mailing list