[PATCH] D45560: [RISCV] Change function alignment to 4 bytes, and 2 bytes for RVC

Kito Cheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 12 02:28:23 PDT 2018


kito-cheng updated this revision to Diff 142136.
kito-cheng added a comment.

Changes:

- Add test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D45560

Files:
  lib/Target/RISCV/RISCVISelLowering.cpp
  test/CodeGen/RISCV/align.ll


Index: test/CodeGen/RISCV/align.ll
===================================================================
--- /dev/null
+++ test/CodeGen/RISCV/align.ll
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv32 -mattr=+c -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32C
+
+define void @foo() {
+;RV32I: .p2align 2
+;RV32I: foo:
+;RV32C: .p2align 1
+;RV32C: foo:
+entry:
+  ret void
+}
Index: lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- lib/Target/RISCV/RISCVISelLowering.cpp
+++ lib/Target/RISCV/RISCVISelLowering.cpp
@@ -142,8 +142,9 @@
   setBooleanContents(ZeroOrOneBooleanContent);
 
   // Function alignments (log2).
-  setMinFunctionAlignment(3);
-  setPrefFunctionAlignment(3);
+  unsigned FunctionAlignment = Subtarget.hasStdExtC() ? 1 : 2;
+  setMinFunctionAlignment(FunctionAlignment);
+  setPrefFunctionAlignment(FunctionAlignment);
 
   // Effectively disable jump table generation.
   setMinimumJumpTableEntries(INT_MAX);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45560.142136.patch
Type: text/x-patch
Size: 1114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180412/3ae44bf1/attachment.bin>


More information about the llvm-commits mailing list