Index: lib/CodeGen/ShrinkWrap.cpp =================================================================== --- lib/CodeGen/ShrinkWrap.cpp +++ lib/CodeGen/ShrinkWrap.cpp @@ -584,6 +584,11 @@ bool ShrinkWrap::isShrinkWrapEnabled(const MachineFunction &MF) { const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering(); + if (MF.getFunction() + .getFnAttribute("no-shrink-wrap") + .getValueAsString() == "true") + return false; + switch (EnableShrinkWrapOpt) { case cl::BOU_UNSET: return TFI->enableShrinkWrapping(MF) && Index: test/CodeGen/AArch64/no-shrink-wrap.ll =================================================================== --- /dev/null +++ test/CodeGen/AArch64/no-shrink-wrap.ll @@ -0,0 +1,13 @@ +; RUN: llc < %s -mtriple=aarch64-linux-gnu -O3 -o - 2>&1 -debug | FileCheck %s + +; Test the no-shrink-wrap attribute. + +; CHECK-NOT: Nothing to shrink-wrap + +define void @m() #0 { +entry: + ret void +} + +attributes #0 = { "no-shrink-wrap"="true" } +