[llvm] b586dc2 - Outliner: add "target-cpu" feature from source function to outlined

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 2 01:33:34 PDT 2022


Author: Tim Northover
Date: 2022-08-02T09:33:29+01:00
New Revision: b586dc21a7e8154a20fdf99da231c79dd762048f

URL: https://github.com/llvm/llvm-project/commit/b586dc21a7e8154a20fdf99da231c79dd762048f
DIFF: https://github.com/llvm/llvm-project/commit/b586dc21a7e8154a20fdf99da231c79dd762048f.diff

LOG: Outliner: add "target-cpu" feature from source function to outlined

The CPU is used to determine which inline asm instructions are allowed, so
needs to be copied across in case the outlined function contains any.

Added: 
    

Modified: 
    llvm/lib/CodeGen/TargetInstrInfo.cpp
    llvm/test/CodeGen/AArch64/machine-outliner.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 4116231c005f0..0c0fdf72b90d1 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -1411,6 +1411,8 @@ void TargetInstrInfo::mergeOutliningCandidateAttributes(
   const Function &ParentFn = FirstCand.getMF()->getFunction();
   if (ParentFn.hasFnAttribute("target-features"))
     F.addFnAttr(ParentFn.getFnAttribute("target-features"));
+  if (ParentFn.hasFnAttribute("target-cpu"))
+    F.addFnAttr(ParentFn.getFnAttribute("target-cpu"));
 
   // Set nounwind, so we don't generate eh_frame.
   if (llvm::all_of(Candidates, [](const outliner::Candidate &C) {

diff  --git a/llvm/test/CodeGen/AArch64/machine-outliner.ll b/llvm/test/CodeGen/AArch64/machine-outliner.ll
index 3d1c7357b9678..1ae905b497923 100644
--- a/llvm/test/CodeGen/AArch64/machine-outliner.ll
+++ b/llvm/test/CodeGen/AArch64/machine-outliner.ll
@@ -11,6 +11,7 @@
 ; TARGET_FEATURES-SAME: minsize
 ; TARGET_FEATURES-SAME: nounwind
 ; TARGET_FEATURES-SAME: optsize
+; TARGET_FEATURES-SAME: "target-cpu"="cyclone"
 ; TARGET_FEATURES-SAME: "target-features"="+sse"
 
 define linkonce_odr void @fish() #0 {


        


More information about the llvm-commits mailing list