[llvm] [BOLT] Enable hugify for AArch64 (PR #117158)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 05:21:19 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 56c091ea7106507b36015297ee9005c9d5fab0bf 813ccfaf3873dc5133d800c073f686573932ab60 --extensions h,c,cpp -- bolt/test/runtime/AArch64/hugify.c bolt/test/runtime/AArch64/user-func-reorder.c bolt/lib/Rewrite/RewriteInstance.cpp bolt/runtime/common.h bolt/runtime/hugify.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 5345d90c4e..f3ae2c2054 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -584,9 +584,10 @@ Error RewriteInstance::discoverStorage() {
   // weird ASLR mapping addresses (4KB aligned)
   if (opts::Hugify && !BC->HasFixedLoadAddress) {
     NextAvailableAddress += BC->PageAlign;
-    BC->outs() << "BOLT-INFO: Hugify, Additional huge page from left side due to"
-               << "weird ASLR mapping addresses(4KB aligned): " << NextAvailableAddress
-               << '\n';
+    BC->outs()
+        << "BOLT-INFO: Hugify, Additional huge page from left side due to"
+        << "weird ASLR mapping addresses(4KB aligned): " << NextAvailableAddress
+        << '\n';
   }
 
   if (!opts::UseGnuStack && !BC->IsLinuxKernel) {
@@ -5727,11 +5728,13 @@ void RewriteInstance::rewriteFile() {
   // Write all allocatable sections - reloc-mode text is written here as well
   for (BinarySection &Section : BC->allocatableSections()) {
     if (!Section.isFinalized() || !Section.getOutputData()) {
-      BC->outs() << "BOLT: new section is finalized or !getOutputData, skip " << Section.getName() << '\n';
+      BC->outs() << "BOLT: new section is finalized or !getOutputData, skip "
+                 << Section.getName() << '\n';
       continue;
     }
     if (Section.isLinkOnly()) {
-      BC->outs() << "BOLT: new section is link only, skip " << Section.getName() << '\n';
+      BC->outs() << "BOLT: new section is link only, skip " << Section.getName()
+                 << '\n';
       continue;
     }
 
@@ -5740,8 +5743,8 @@ void RewriteInstance::rewriteFile() {
                  << "\n data at 0x"
                  << Twine::utohexstr(Section.getAllocAddress()) << "\n of size "
                  << Section.getOutputSize() << "\n at offset "
-                 << Section.getOutputFileOffset()
-                 << " with content size " << Section.getOutputContents().size() << '\n';
+                 << Section.getOutputFileOffset() << " with content size "
+                 << Section.getOutputContents().size() << '\n';
     OS.seek(Section.getOutputFileOffset());
     Section.write(OS);
   }
diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h
index 593b7b91d2..838e64f55f 100644
--- a/bolt/runtime/common.h
+++ b/bolt/runtime/common.h
@@ -156,7 +156,7 @@ struct timespec {
 #elif defined(__x86_64__)
 #include "sys_x86_64.h"
 #else
- exit(1);
+exit(1);
 #endif
 
 constexpr uint32_t BufSize = 10240;
diff --git a/bolt/runtime/hugify.cpp b/bolt/runtime/hugify.cpp
index 901a2d61e9..eb5382d8b7 100644
--- a/bolt/runtime/hugify.cpp
+++ b/bolt/runtime/hugify.cpp
@@ -6,9 +6,8 @@
 //
 //===---------------------------------------------------------------------===//
 
-#if defined(__x86_64__) \
-    || ( defined(__aarch64__) || defined(__arm64__) )  \
-    && !defined(__APPLE__)
+#if defined(__x86_64__) ||                                                     \
+    (defined(__aarch64__) || defined(__arm64__)) && !defined(__APPLE__)
 
 #include "common.h"
 
@@ -76,8 +75,7 @@ static bool hasPagecacheTHPSupport() {
     return false;
 
   if (!strStr(Buf, "[always]") && !strStr(Buf, "[madvise]")) {
-    DEBUG(report(
-              "[hugify] THP support is not enabled.\n");)
+    DEBUG(report("[hugify] THP support is not enabled.\n");)
     return false;
   }
 
@@ -173,14 +171,15 @@ extern "C" void __bolt_hugify_self_impl() {
 extern "C" __attribute((naked)) void __bolt_hugify_self() {
 #if defined(__x86_64__)
   __asm__ __volatile__(SAVE_ALL "call __bolt_hugify_self_impl\n" RESTORE_ALL
-                                "jmp __bolt_hugify_start_program\n"
-                                :::);
+                                "jmp __bolt_hugify_start_program\n" ::
+                                    :);
 #elif defined(__aarch64__) || defined(__arm64__)
-  __asm__ __volatile__(SAVE_ALL "bl __bolt_hugify_self_impl\n" RESTORE_ALL
-                                "adrp x16, __bolt_hugify_start_program\n"
-                                "add x16, x16, #:lo12:__bolt_hugify_start_program\n"
-                                "br x16\n"
-                                :::);
+  __asm__ __volatile__(SAVE_ALL
+                       "bl __bolt_hugify_self_impl\n" RESTORE_ALL
+                       "adrp x16, __bolt_hugify_start_program\n"
+                       "add x16, x16, #:lo12:__bolt_hugify_start_program\n"
+                       "br x16\n" ::
+                           :);
 #else
   __exit(1);
 #endif
diff --git a/bolt/test/runtime/AArch64/hugify.c b/bolt/test/runtime/AArch64/hugify.c
index a54b8952c7..c16e8589eb 100644
--- a/bolt/test/runtime/AArch64/hugify.c
+++ b/bolt/test/runtime/AArch64/hugify.c
@@ -7,7 +7,6 @@ int g2;
 static int sg1 = 1;
 static int sg2;
 
-
 int main(int argc, char **argv) {
   printf("Hello world %p = %d , %p = %d\n", &g1, g1, &sg1, sg1);
   printf("%p = %d , %p = %d\n", &g2, g2, &sg2, sg2);
diff --git a/bolt/test/runtime/AArch64/user-func-reorder.c b/bolt/test/runtime/AArch64/user-func-reorder.c
index fcb92bca16..3f144f5f80 100644
--- a/bolt/test/runtime/AArch64/user-func-reorder.c
+++ b/bolt/test/runtime/AArch64/user-func-reorder.c
@@ -5,9 +5,7 @@
  */
 #include <stdio.h>
 
-int foo(int x) {
-  return x + 1;
-}
+int foo(int x) { return x + 1; }
 
 int fib(int x) {
   if (x < 2)
@@ -15,9 +13,7 @@ int fib(int x) {
   return fib(x - 1) + fib(x - 2);
 }
 
-int bar(int x) {
-  return x - 1;
-}
+int bar(int x) { return x - 1; }
 
 int main(int argc, char **argv) {
   printf("fib(%d) = %d\n", argc, fib(argc));

``````````

</details>


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


More information about the llvm-commits mailing list