[PATCH] D131881: [BOLT][AArch64] Ignore functions with constant islands during ICF and VeneerElimination

Denis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 04:15:43 PDT 2022


treapster updated this revision to Diff 452626.
treapster added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131881/new/

https://reviews.llvm.org/D131881

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/lib/Core/BinaryFunction.cpp
  bolt/lib/Passes/IdenticalCodeFolding.cpp
  bolt/test/AArch64/prevent-ci-folding.s


Index: bolt/test/AArch64/prevent-ci-folding.s
===================================================================
--- /dev/null
+++ bolt/test/AArch64/prevent-ci-folding.s
@@ -0,0 +1,33 @@
+// This test checks that functions containing Constant Islands are not folded even
+// if they have the same instructions
+
+// RUN: %clang -fuse-ld=lld --target=aarch64-unknown-linux %s -o %t.exe -Wl,-q
+// RUN: llvm-bolt -icf -lite=false %t.exe -o %t.bolt
+// RUN: llvm-objdump -d -j .text %t.bolt | FileCheck %s
+
+// CHECK: <func1>:
+// CHECK: <func2>:
+
+func1:
+    add x0, x0, #1
+    ret
+    .word 0xdeadbeef
+    .word 0xdeadbeef
+.size func1, .-func1
+
+func2:
+    add x0, x0, #1
+    ret
+    .word 0xdeadbeef
+    .word 0xdeadbeef
+.size func2, .-func2
+
+.global        main
+.type  main, %function
+main:
+    mov x0, #0
+    bl     func1
+    bl     func2
+    sub     x0, x0, #2
+    mov     w8, #93
+    svc     #0
Index: bolt/lib/Passes/IdenticalCodeFolding.cpp
===================================================================
--- bolt/lib/Passes/IdenticalCodeFolding.cpp
+++ bolt/lib/Passes/IdenticalCodeFolding.cpp
@@ -162,6 +162,9 @@
   if (A.isMultiEntry() || B.isMultiEntry())
     return false;
 
+  if (A.hasIslandsInfo() || B.hasIslandsInfo())
+    return false;
+
   // Process both functions in either DFS or existing order.
   const BinaryFunction::BasicBlockOrderType OrderA =
       opts::UseDFS
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -4430,7 +4430,7 @@
 }
 
 bool BinaryFunction::isAArch64Veneer() const {
-  if (empty())
+  if (empty() || hasIslandsInfo())
     return false;
 
   BinaryBasicBlock &BB = **BasicBlocks.begin();
Index: bolt/include/bolt/Core/BinaryFunction.h
===================================================================
--- bolt/include/bolt/Core/BinaryFunction.h
+++ bolt/include/bolt/Core/BinaryFunction.h
@@ -2012,7 +2012,9 @@
     return Size;
   }
 
-  bool hasIslandsInfo() const { return !!Islands; }
+  bool hasIslandsInfo() const {
+    return Islands && (hasConstantIsland() || !Islands->Dependency.empty());
+  }
 
   bool hasConstantIsland() const {
     return Islands && !Islands->DataOffsets.empty();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131881.452626.patch
Type: text/x-patch
Size: 2311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220815/6148c829/attachment.bin>


More information about the llvm-commits mailing list