Skip to content

[AArch64] Disable loop alignment for Windows targets #67894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/MC/MCWin64EH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info,
// here, but we'd have to emit the pdata, the xdata header, and the
// epilogue scopes later, since they depend on whether the we need to
// split the unwind data.
//
// If this is fixed, remove code in AArch64ISelLowering.cpp that
// disables loop alignment on Windows.
RawFuncLength = GetAbsDifference(streamer, info->FuncletOrFuncEnd,
info->Begin);
}
Expand Down
7 changes: 6 additions & 1 deletion llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,12 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
// Set required alignment.
setMinFunctionAlignment(Align(4));
// Set preferred alignments.
setPrefLoopAlignment(STI.getPrefLoopAlignment());

// Don't align loops on Windows. The SEH unwind info generation needs to
// know the exact length of functions before the alignments have been
// expanded.
if (!Subtarget->isTargetWindows())
setPrefLoopAlignment(STI.getPrefLoopAlignment());
setMaxBytesForAlignment(STI.getMaxBytesForLoopAlignment());
setPrefFunctionAlignment(STI.getPrefFunctionAlignment());

Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/AArch64/sched-loop-align.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; RUN: llc < %s -mtriple=aarch64-windows | FileCheck %s --check-prefix=WINDOWS
; RUN: llc < %s -mtriple=aarch64-linux | FileCheck %s --check-prefix=LINUX

define dso_local void @b() #0 {
entry:
br label %for.cond

for.cond:
tail call void @a()
br label %for.cond
}

declare dso_local void @a(...)

attributes #0 = { noreturn nounwind uwtable "tune-cpu"="cortex-a53" }

; LINUX-LABEL: b:
; LINUX: .p2align 4

; WINDOWS-LABEL: b:
; WINDOWS-NOT: .p2align