[llvm] [ARM] Apply sign-return-address attribute to outlined function (PR #107877)

Benson Chu via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 13:39:56 PDT 2024


https://github.com/pestctrl updated https://github.com/llvm/llvm-project/pull/107877

>From ebcae909c8204314ce4f79f57a732f8be00dffba Mon Sep 17 00:00:00 2001
From: Benson Chu <bensonchu457 at gmail.com>
Date: Fri, 6 Sep 2024 16:09:12 -0500
Subject: [PATCH] [ARM] Apply sign-return-address attribute to outlined
 function

This make checking for whether PAC is necessary simpler when building
the outlined frame.
---
 llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
index 51a5f895f341db..49d1f02a2f6913 100644
--- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
@@ -6207,6 +6207,9 @@ void ARMBaseInstrInfo::mergeOutliningCandidateAttributes(
   if (CFn.hasFnAttribute("branch-target-enforcement"))
     F.addFnAttr(CFn.getFnAttribute("branch-target-enforcement"));
 
+  if (CFn.hasFnAttribute("sign-return-address"))
+    F.addFnAttr(CFn.getFnAttribute("sign-return-address"));
+
   ARMGenInstrInfo::mergeOutliningCandidateAttributes(F, Candidates);
 }
 
@@ -6623,10 +6626,7 @@ void ARMBaseInstrInfo::buildOutlinedFrame(
       MBB.addLiveIn(ARM::LR);
 
     // Insert a save before the outlined region
-    bool Auth = OF.Candidates.front()
-                    .getMF()
-                    ->getInfo<ARMFunctionInfo>()
-                    ->shouldSignReturnAddress(true);
+    bool Auth = MF.getInfo<ARMFunctionInfo>()->shouldSignReturnAddress(true);
     saveLROnStack(MBB, It, true, Auth);
 
     // Fix up the instructions in the range, since we're going to modify the



More information about the llvm-commits mailing list