[PATCH] D120694: [BOLT] Enable tail duplication const/copy propagation

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 20:46:28 PST 2022


Amir created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: maksfb.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Re-enable const/copy propagation after tail duplication.
Add tail-dup-peephole.s XFAIL test triggered by taildup.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120694

Files:
  bolt/lib/Passes/TailDuplication.cpp
  bolt/test/X86/tail-dup-peephole.s


Index: bolt/test/X86/tail-dup-peephole.s
===================================================================
--- /dev/null
+++ bolt/test/X86/tail-dup-peephole.s
@@ -0,0 +1,45 @@
+# This reproduces a bug in double-jumps peephole triggered by tail duplication.
+# XFAIL: *
+# REQUIRES: system-linux
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
+# RUN: link_fdata %s %t.o %t.fdata
+# RUN: llvm-strip --strip-unneeded %t.o
+# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
+# RUN: llvm-bolt %t.exe -o %t.out -data %t.fdata -relocs -lite=0 -funcs=main \
+# RUN:   -reorder-blocks=cache -peepholes=double-jumps -tail-duplication=1
+
+  .globl main
+main:
+	.cfi_startproc
+a:
+	je	b
+# FDATA: 1 main #a# 1 main #b# 1 2
+	movq	0, %r11
+	testq	%r11, %r11
+c:
+	jmp	d
+e:
+	je	f
+# FDATA: 1 main #e# 1 main #f# 1 4
+d:
+	cmpl	%esi, %edi
+	leaq	0, %rsi
+	movq	%r12, %rdx
+	movq	0, %rdi
+	leaq	0, %r15
+	addq	8, %r15
+	cmpq	%r15, %rdi
+	je	g
+	movq	8, %r13
+h:
+	jne	g
+# FDATA: 1 main #h# 1 main #i# 0 3
+i:
+	leaq	0, %rdi
+f:
+	cmpw	$0xae, 0x20(%rdi)
+b:
+	jmp	c
+g:
+	jmp	h
+	.cfi_endproc
Index: bolt/lib/Passes/TailDuplication.cpp
===================================================================
--- bolt/lib/Passes/TailDuplication.cpp
+++ bolt/lib/Passes/TailDuplication.cpp
@@ -44,7 +44,7 @@
 static cl::opt<bool> TailDuplicationConstCopyPropagation(
     "tail-duplication-const-copy-propagation",
     cl::desc("enable const and copy propagation after tail duplication"),
-    cl::ReallyHidden, cl::init(false), cl::cat(BoltOptCategory));
+    cl::ReallyHidden, cl::init(true), cl::cat(BoltOptCategory));
 
 } // namespace opts
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120694.411955.patch
Type: text/x-patch
Size: 1652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220301/6974cf17/attachment.bin>


More information about the llvm-commits mailing list