Skip to content

Commit b8c7e34

Browse files
[BOLT] Update search to proceed upwards from memcpy call
Search should procced from CallInst to the beginning of BB Patch by Yafet Beyene [email protected]
1 parent 96688d4 commit b8c7e34

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
27582758
BitVector WrittenRegs(RegInfo->getNumRegs());
27592759
const BitVector &SizeRegAliases = getAliases(SizeReg);
27602760

2761-
for (auto InstIt = BB.begin(); InstIt != CallInst; ++InstIt) {
2761+
for (auto InstIt = CallInst; InstIt != BB.begin(); --InstIt) {
27622762
const MCInst &Inst = *InstIt;
27632763
WrittenRegs.reset();
27642764
getWrittenRegs(Inst, WrittenRegs);

bolt/test/runtime/AArch64/inline-memcpy.s

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: llvm-bolt %t.exe --inline-memcpy -o %t.bolt 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
88
# RUN: llvm-objdump -d %t.bolt | FileCheck %s --check-prefix=CHECK-ASM
99

10-
# Verify BOLT reports that it inlined memcpy calls (11 successful inlines out of 16 total calls)
10+
# Verify BOLT reports that it inlined memcpy calls (11 successful inlines out of 17 total calls)
1111
# CHECK-INLINE: BOLT-INFO: inlined 11 memcpy() calls
1212

1313
# Each function should use optimal size-specific instructions and NO memcpy calls
@@ -84,6 +84,9 @@
8484
# CHECK-ASM-LABEL: <test_register_move_negative>:
8585
# CHECK-ASM: bl{{.*}}<memcpy
8686

87+
# CHECK-ASM-LABEL: <test_x2_rewrite_negative>:
88+
# CHECK-ASM: bl{{.*}}<memcpy
89+
8790
# Live-in parameter should NOT be inlined (size unknown at compile time)
8891
# CHECK-ASM-LABEL: <test_live_in_negative>:
8992
# CHECK-ASM: bl{{.*}}<memcpy
@@ -273,6 +276,15 @@ test_register_move_negative:
273276
ret
274277
.size test_register_move_negative, .-test_register_move_negative
275278

279+
.globl test_x2_rewrite_negative
280+
.type test_x2_rewrite_negative,@function
281+
test_x2_rewrite_negative:
282+
mov x2, #8
283+
ldr x2, [sp, #24]
284+
bl memcpy
285+
ret
286+
.size test_x2_rewrite_negative, .-test_x2_rewrite_negative
287+
276288
.globl test_live_in_negative
277289
.type test_live_in_negative,@function
278290
test_live_in_negative:

0 commit comments

Comments
 (0)