[CodeGen][BasicBlockSections] Fix wrong alignment directive placement in
authorSinan Lin <sinan.lin@linux.alibaba.com>
Thu, 17 Nov 2022 06:55:38 +0000 (14:55 +0800)
committerSinan Lin <sinan.lin@linux.alibaba.com>
Thu, 17 Nov 2022 07:01:57 +0000 (15:01 +0800)
commit4ad8952d2d89243c776a40039dc4d54c8cd43e8d
tree0457c571508383ee975856d809e95b0122eabafe
parent605355f0dc6a8079687539971b91bef7cae6cc38
[CodeGen][BasicBlockSections] Fix wrong alignment directive placement in
basic block section cases

MachineBlockPlacement pass sets an alignment attribute to the loop
header MBB and this attribute will lead to an alignment directive during
emitting asm. In the case of the basic block section, the alignment
directive is put before the section label, and thus the alignment is set
to the predecessor of the loop header, which is not what we expect and
increases the code size (both inserting nop and set section alignment).

Reviewed By: rahmanl

Differential Revision: https://reviews.llvm.org/D137535
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/X86/align-basic-block-sections.mir [new file with mode: 0644]