mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 02:26:07 +00:00

As reported in https://llvm.org/PR30955, `.balign` with a fill-value of 0 did not actually align using zeroes, on non-x86 targets. This is because the check of whether to use the code alignment routines or whether to just use the fill value was checking whether the fill value was equal to `TextAlignFillValue`, which has not been changed from its default of 0 on most targets (it has been changed for x86). However, most targets do not set the fill value because it doesn't entirely make sense -- i.e. on AArch64 there's no reasonable byte value to use for alignment, as instructions are word-sized and have to be well-aligned. I think the check at the end `AsmParser::parseDirectiveAlign` is suspicious even on x86 - if you use `.balign <align>, 0x90` in a code section, you don't end up with a block of `0x90` repeated, you end up with a block of NOPs of various widths. This functionality is never tested. The fix here is to modify the check to ignore the default text align fill value when choosing to do code alignment or not. Fixes #30303
22 lines
785 B
LLVM
22 lines
785 B
LLVM
; REQUIRES: x86
|
|
; RUN: llvm-as %s -o %t.obj
|
|
|
|
; RUN: lld-link %t.obj -noentry -nodefaultlib -out:%t.dll -dll
|
|
; RUN: llvm-objdump -d --section=".text" --no-leading-addr --no-show-raw-insn %t.dll | FileCheck %s
|
|
; CHECK: nop{{$}}
|
|
|
|
; RUN: lld-link -mllvm:-mcpu=znver1 -noentry -nodefaultlib %t.obj -out:%t.znver1.dll -dll
|
|
; RUN: llvm-objdump -d --section=".text" --no-leading-addr --no-show-raw-insn %t.znver1.dll | FileCheck --check-prefix=ZNVER1 %s
|
|
; ZNVER1: nopw
|
|
|
|
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-pc-windows-msvc19.14.26433"
|
|
|
|
define dllexport void @foo() #0 {
|
|
entry:
|
|
call void asm sideeffect ".p2align 4", "~{dirflag},~{fpsr},~{flags}"()
|
|
ret void
|
|
}
|
|
|
|
attributes #0 = { "frame-pointer"="all" }
|