[PATCH] D130775: Outliner: add "target-cpu" feature from source function to outlined

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 06:47:06 PDT 2022


t.p.northover created this revision.
t.p.northover added a reviewer: paquette.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
t.p.northover requested review of this revision.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130775

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


Index: llvm/test/CodeGen/AArch64/machine-outliner.ll
===================================================================
--- llvm/test/CodeGen/AArch64/machine-outliner.ll
+++ 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 {
Index: llvm/lib/CodeGen/TargetInstrInfo.cpp
===================================================================
--- llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -1411,6 +1411,8 @@
   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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130775.448618.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/0acf9bed/attachment.bin>


More information about the llvm-commits mailing list