[llvm] [BOLT][RISCV] Set minimum function alignment to 2 for RVC (PR #69837)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 21 04:38:34 PDT 2023


================
@@ -490,6 +491,10 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
     assert(Second.getOpcode() == RISCV::JALR);
     return true;
   }
+
+  uint16_t getMinFunctionAlignment() const override {
+    return STI->getFeatureBits()[RISCV::FeatureStdExtC] ? 2 : 4;
----------------
asb wrote:

I think `STI->hasFeature(RISCV::FeatureStdExtC)` would be clearer. C || Zca would also be consistent with the logic we use elsewhere in LLVM. It's a shame none of it is directly reusable - TargetLowering has `getMinFunctionAlignment` (and even better, `getPrefFunctionAlignment`!) but is a no-go for bolt it seems, while for RISC-V at least the text section alignment is equal to the min function alignment (`RISCVMCObjectFileInto::getTextSectionAlignment`) but that isn't true in general for other targets.

https://github.com/llvm/llvm-project/pull/69837


More information about the llvm-commits mailing list