[RISCV] RISCVELFTargetObjectFile: use 2-byte alignment for .text if RVC
authorFangrui Song <i@maskray.me>
Thu, 11 May 2023 20:44:37 +0000 (13:44 -0700)
committerFangrui Song <i@maskray.me>
Thu, 11 May 2023 20:44:37 +0000 (13:44 -0700)
commit3e7eab099766cc92e5930a7883a014d0de8710d9
tree8ba05969704a4d67322d231ae83c89f59296e9c5
parent2895c4c00ff66420a2232f3fcfc341eb7b72ce67
[RISCV] RISCVELFTargetObjectFile: use 2-byte alignment for .text if RVC

For the "C" Standard Extension/Zca, D45560 enabled 2-byte alignment for
assembly output (e.g. `clang -S a.c`) and D102052 enabled 2-byte alignment for
assembly input and object file output (e.g. `clang -c a.s`).

This patch ports the behavior for code generation and object file output by
adding RISCVELFTargetObjectFile::getTextSectionAlignment (e.g. `clang -c a.c`).

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D150240
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCObjectFileInfo.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCObjectFileInfo.h
llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp
llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
llvm/test/CodeGen/RISCV/align.ll