[MachineOutliner] Add optsize markings to outlined functions.

It doesn't matter much this late in the pipeline, but one place that
does check for it is the function alignment code.

Differential Revision: https://reviews.llvm.org/D46373



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332415 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2018-05-15 23:36:46 +00:00
parent 27b0d8a762
commit b79d2cf940
2 changed files with 11 additions and 1 deletions

View File

@ -1253,6 +1253,14 @@ MachineOutliner::createOutlinedFunction(Module &M, const OutlinedFunction &OF,
F->setLinkage(GlobalValue::InternalLinkage);
F->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
// FIXME: Set nounwind, so we don't generate eh_frame? Haven't verified it's
// necessary.
// Set optsize/minsize, so we don't insert padding between outlined
// functions.
F->addFnAttr(Attribute::OptimizeForSize);
F->addFnAttr(Attribute::MinSize);
// Save F so that we can add debug info later if we need to.
CreatedIRFunctions.push_back(F);

View File

@ -1,4 +1,5 @@
; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-apple-darwin < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -enable-machine-outliner -mtriple=aarch64-apple-darwin -mcpu=cortex-a53 -enable-misched=false < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -enable-machine-outliner -enable-linkonceodr-outlining -mtriple=aarch64-apple-darwin < %s | FileCheck %s -check-prefix=ODR
define linkonce_odr void @fish() #0 {
@ -67,7 +68,8 @@ define void @dog() #0 {
}
; ODR: [[OUTLINED]]:
; CHECK: [[OUTLINED]]:
; CHECK: .p2align 2
; CHECK-NEXT: [[OUTLINED]]:
; CHECK-DAG: orr w8, wzr, #0x1
; CHECK-NEXT: stp w8, wzr, [sp, #8]
; CHECK-NEXT: orr w8, wzr, #0x2