diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -1612,6 +1612,7 @@ PredictableSelectIsExpensive = Subtarget->getSchedModel().isOutOfOrder(); setPrefLoopAlignment(Align(1ULL << Subtarget->getPrefLoopLogAlignment())); + setPrefFunctionAlignment(Align(1ULL << Subtarget->getPrefLoopLogAlignment())); setMinFunctionAlignment(Subtarget->isThumb() ? Align(2) : Align(4)); diff --git a/llvm/test/CodeGen/ARM/preferred-function-alignment.ll b/llvm/test/CodeGen/ARM/preferred-function-alignment.ll --- a/llvm/test/CodeGen/ARM/preferred-function-alignment.ll +++ b/llvm/test/CodeGen/ARM/preferred-function-alignment.ll @@ -1,20 +1,22 @@ -; RUN: llc -mtriple=arm-none-eabi -mcpu=generic < %s | FileCheck --check-prefixes=ALIGN-GENERIC,CHECK %s -; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m23 < %s | FileCheck --check-prefixes=ALIGN,CHECK %s -; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m33 < %s | FileCheck --check-prefixes=ALIGN,CHECK %s -; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m55 < %s | FileCheck --check-prefixes=ALIGN,CHECK %s -; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m85 < %s | FileCheck --check-prefixes=ALIGN,CHECK %s +; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m85 < %s | FileCheck --check-prefixes=CHECK,ALIGN-16,ALIGN-CS-16 %s +; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m23 < %s | FileCheck --check-prefixes=CHECK,ALIGN-16,ALIGN-CS-16 %s + +; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-a5 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-32 %s +; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m33 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-16 %s +; RUN: llc -mtriple=arm-none-eabi -mcpu=cortex-m55 < %s | FileCheck --check-prefixes=CHECK,ALIGN-32,ALIGN-CS-16 %s + ; CHECK-LABEL: test -; ALIGN-GENERIC: .p2align 2 -; ALIGN: .p2align 1 +; ALIGN-16: .p2align 1 +; ALIGN-32: .p2align 2 define void @test() { ret void } ; CHECK-LABEL: test_optsize -; ALIGN-GENERIC: .p2align 2 -; ALIGN: .p2align 1 +; ALIGN-CS-16: .p2align 1 +; ALIGN-CS-32: .p2align 2 define void @test_optsize() optsize { ret void