diff --git a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp @@ -933,12 +933,14 @@ if (!NeedsWinCFI) { // Label used to tie together the PROLOG_LABEL and the MachineMoves. MCSymbol *FrameLabel = MMI.getContext().createTempSymbol(); - // Encode the stack size of the leaf function. - unsigned CFIIndex = MF.addFrameInst( - MCCFIInstruction::createDefCfaOffset(FrameLabel, -NumBytes)); - BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) - .addCFIIndex(CFIIndex) - .setMIFlags(MachineInstr::FrameSetup); + if (needsFrameMoves) { + // Encode the stack size of the leaf function. + unsigned CFIIndex = MF.addFrameInst( + MCCFIInstruction::createDefCfaOffset(FrameLabel, -NumBytes)); + BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION)) + .addCFIIndex(CFIIndex) + .setMIFlags(MachineInstr::FrameSetup); + } } } diff --git a/llvm/test/CodeGen/AArch64/no_cfi.ll b/llvm/test/CodeGen/AArch64/no_cfi.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/no_cfi.ll @@ -0,0 +1,13 @@ +; RUN: llc -mtriple aarch64-arm-linux-fnu -o - %s | FileCheck %s + +; CHECK: a: // @a +; CHECK-NEXT: // %bb.0: +; CHECK-NEXT: sub sp, sp, #16 +; CHECK-NOT: .cfi{{.*}} +; CHECK: ret +define void @a() nounwind { + %1 = alloca i32, align 4 + store i32 1, i32* %1, align 4 + ret void +} +