[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 03:35:32 PDT 2022
treapster created this revision.
treapster added reviewers: rafaelauler, yavtuk.
Herald added subscribers: ayermolo, kristof.beyls.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
treapster requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Don't fold functions with CIs, don't consider them veneers
Repository:
rG LLVM Github Monorepo
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 --target=aarch64-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.452621.patch
Type: text/x-patch
Size: 2290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220815/b1584be8/attachment.bin>
More information about the llvm-commits
mailing list