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.
This commit is contained in:
Tim Northover 2022-07-29 14:39:44 +01:00
parent e208bab55f
commit b586dc21a7
2 changed files with 3 additions and 0 deletions

View File

@ -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) {

View File

@ -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 {