2018-02-12 10:03:36 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2016-05-05 06:45:31 +08:00
|
|
|
; RUN: llc -verify-machineinstrs < %s -enable-tail-merge=0 -mtriple=x86_64-linux | FileCheck %s --check-prefix=LINUX
|
|
|
|
; RUN: llc -verify-machineinstrs < %s -enable-tail-merge=0 -mtriple=x86_64-linux-gnux32 | FileCheck %s --check-prefix=LINUX-X32
|
|
|
|
; RUN: llc -verify-machineinstrs < %s -enable-tail-merge=0 -mtriple=x86_64-windows | FileCheck %s --check-prefix=WINDOWS
|
2018-02-12 10:03:36 +08:00
|
|
|
; RUN: llc -verify-machineinstrs < %s -enable-tail-merge=0 -mtriple=i686-windows | FileCheck %s --check-prefix=X86 --check-prefix=X86-NOSSE
|
|
|
|
; RUN: llc -verify-machineinstrs < %s -enable-tail-merge=0 -mtriple=i686-windows -mattr=+sse2 | FileCheck %s --check-prefix=X86 --check-prefix=X86-SSE
|
2014-08-30 05:42:08 +08:00
|
|
|
|
|
|
|
; Test that we actually spill and reload all arguments in the variadic argument
|
|
|
|
; pack. Doing a normal call will clobber all argument registers, and we will
|
|
|
|
; spill around it. A simple adjustment should not require any XMM spills.
|
|
|
|
|
2014-12-23 07:58:37 +08:00
|
|
|
declare void @llvm.va_start(i8*) nounwind
|
|
|
|
|
2014-08-30 05:42:08 +08:00
|
|
|
declare void(i8*, ...)* @get_f(i8* %this)
|
|
|
|
|
|
|
|
define void @f_thunk(i8* %this, ...) {
|
2014-12-23 07:58:37 +08:00
|
|
|
; Use va_start so that we exercise the combination.
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-LABEL: f_thunk:
|
|
|
|
; LINUX: # %bb.0:
|
|
|
|
; LINUX-NEXT: pushq %rbp
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 16
|
|
|
|
; LINUX-NEXT: pushq %r15
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 24
|
|
|
|
; LINUX-NEXT: pushq %r14
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 32
|
|
|
|
; LINUX-NEXT: pushq %r13
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 40
|
|
|
|
; LINUX-NEXT: pushq %r12
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 48
|
|
|
|
; LINUX-NEXT: pushq %rbx
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 56
|
|
|
|
; LINUX-NEXT: subq $360, %rsp # imm = 0x168
|
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 416
|
|
|
|
; LINUX-NEXT: .cfi_offset %rbx, -56
|
|
|
|
; LINUX-NEXT: .cfi_offset %r12, -48
|
|
|
|
; LINUX-NEXT: .cfi_offset %r13, -40
|
|
|
|
; LINUX-NEXT: .cfi_offset %r14, -32
|
|
|
|
; LINUX-NEXT: .cfi_offset %r15, -24
|
|
|
|
; LINUX-NEXT: .cfi_offset %rbp, -16
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-NEXT: movaps %xmm7, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm6, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm5, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm4, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm3, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm2, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movaps %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-NEXT: movb %al, {{[-0-9]+}}(%r{{[sb]}}p) # 1-byte Spill
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: movq %r9, %r15
|
|
|
|
; LINUX-NEXT: movq %r8, %r12
|
|
|
|
; LINUX-NEXT: movq %rcx, %r13
|
|
|
|
; LINUX-NEXT: movq %rdx, %rbp
|
|
|
|
; LINUX-NEXT: movq %rsi, %rbx
|
|
|
|
; LINUX-NEXT: movq %rdi, %r14
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-NEXT: movq %rsi, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movq %rdx, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movq %rcx, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movq %r8, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movq %r9, {{[0-9]+}}(%rsp)
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: testb %al, %al
|
|
|
|
; LINUX-NEXT: je .LBB0_2
|
|
|
|
; LINUX-NEXT: # %bb.1:
|
|
|
|
; LINUX-NEXT: movaps %xmm0, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm1, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm2, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm3, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm4, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm5, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm6, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movaps %xmm7, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: .LBB0_2:
|
|
|
|
; LINUX-NEXT: leaq {{[0-9]+}}(%rsp), %rax
|
|
|
|
; LINUX-NEXT: movq %rax, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: leaq {{[0-9]+}}(%rsp), %rax
|
|
|
|
; LINUX-NEXT: movq %rax, {{[0-9]+}}(%rsp)
|
|
|
|
; LINUX-NEXT: movabsq $206158430216, %rax # imm = 0x3000000008
|
|
|
|
; LINUX-NEXT: movq %rax, {{[0-9]+}}(%rsp)
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-NEXT: callq get_f@PLT
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: movq %rax, %r11
|
|
|
|
; LINUX-NEXT: movq %r14, %rdi
|
|
|
|
; LINUX-NEXT: movq %rbx, %rsi
|
|
|
|
; LINUX-NEXT: movq %rbp, %rdx
|
|
|
|
; LINUX-NEXT: movq %r13, %rcx
|
|
|
|
; LINUX-NEXT: movq %r12, %r8
|
|
|
|
; LINUX-NEXT: movq %r15, %r9
|
2018-07-24 11:07:07 +08:00
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm2 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm3 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm4 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm5 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm6 # 16-byte Reload
|
|
|
|
; LINUX-NEXT: movaps {{[-0-9]+}}(%r{{[sb]}}p), %xmm7 # 16-byte Reload
|
2018-10-25 05:09:34 +08:00
|
|
|
; LINUX-NEXT: movb {{[-0-9]+}}(%r{{[sb]}}p), %al # 1-byte Reload
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: addq $360, %rsp # imm = 0x168
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 56
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %rbx
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 48
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %r12
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 40
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %r13
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 32
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %r14
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 24
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %r15
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 16
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: popq %rbp
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-NEXT: .cfi_def_cfa_offset 8
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
;
|
|
|
|
; LINUX-X32-LABEL: f_thunk:
|
|
|
|
; LINUX-X32: # %bb.0:
|
|
|
|
; LINUX-X32-NEXT: pushq %rbp
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 16
|
|
|
|
; LINUX-X32-NEXT: pushq %r15
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 24
|
|
|
|
; LINUX-X32-NEXT: pushq %r14
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 32
|
|
|
|
; LINUX-X32-NEXT: pushq %r13
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 40
|
|
|
|
; LINUX-X32-NEXT: pushq %r12
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 48
|
|
|
|
; LINUX-X32-NEXT: pushq %rbx
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 56
|
|
|
|
; LINUX-X32-NEXT: subl $344, %esp # imm = 0x158
|
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 400
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %rbx, -56
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %r12, -48
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %r13, -40
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %r14, -32
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %r15, -24
|
|
|
|
; LINUX-X32-NEXT: .cfi_offset %rbp, -16
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-X32-NEXT: movaps %xmm7, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm6, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm5, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm4, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm3, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm2, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; LINUX-X32-NEXT: movb %al, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: movq %r9, %r15
|
|
|
|
; LINUX-X32-NEXT: movq %r8, %r12
|
|
|
|
; LINUX-X32-NEXT: movq %rcx, %r13
|
|
|
|
; LINUX-X32-NEXT: movq %rdx, %rbp
|
|
|
|
; LINUX-X32-NEXT: movq %rsi, %rbx
|
2020-12-01 02:51:23 +08:00
|
|
|
; LINUX-X32-NEXT: movq %rdi, %r14
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-X32-NEXT: movq %rsi, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movq %rdx, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movq %rcx, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movq %r8, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movq %r9, {{[0-9]+}}(%esp)
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: testb %al, %al
|
|
|
|
; LINUX-X32-NEXT: je .LBB0_2
|
|
|
|
; LINUX-X32-NEXT: # %bb.1:
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm0, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm1, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm2, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm3, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm4, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm5, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm6, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movaps %xmm7, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: .LBB0_2:
|
|
|
|
; LINUX-X32-NEXT: leal {{[0-9]+}}(%rsp), %eax
|
|
|
|
; LINUX-X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: leal {{[0-9]+}}(%rsp), %eax
|
|
|
|
; LINUX-X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
|
|
|
; LINUX-X32-NEXT: movabsq $206158430216, %rax # imm = 0x3000000008
|
|
|
|
; LINUX-X32-NEXT: movq %rax, {{[0-9]+}}(%esp)
|
2021-02-14 23:34:19 +08:00
|
|
|
; LINUX-X32-NEXT: callq get_f@PLT
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: movl %eax, %r11d
|
2020-12-01 02:51:23 +08:00
|
|
|
; LINUX-X32-NEXT: movq %r14, %rdi
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: movq %rbx, %rsi
|
|
|
|
; LINUX-X32-NEXT: movq %rbp, %rdx
|
|
|
|
; LINUX-X32-NEXT: movq %r13, %rcx
|
|
|
|
; LINUX-X32-NEXT: movq %r12, %r8
|
|
|
|
; LINUX-X32-NEXT: movq %r15, %r9
|
2018-07-24 11:07:07 +08:00
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm2 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm3 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm4 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm5 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm6 # 16-byte Reload
|
|
|
|
; LINUX-X32-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm7 # 16-byte Reload
|
2018-10-25 05:09:34 +08:00
|
|
|
; LINUX-X32-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %al # 1-byte Reload
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: addl $344, %esp # imm = 0x158
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 56
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %rbx
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 48
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %r12
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 40
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %r13
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 32
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %r14
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 24
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %r15
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 16
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: popq %rbp
|
2018-04-24 18:32:08 +08:00
|
|
|
; LINUX-X32-NEXT: .cfi_def_cfa_offset 8
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
;
|
|
|
|
; WINDOWS-LABEL: f_thunk:
|
|
|
|
; WINDOWS: # %bb.0:
|
|
|
|
; WINDOWS-NEXT: pushq %r14
|
2019-08-31 05:23:05 +08:00
|
|
|
; WINDOWS-NEXT: .seh_pushreg %r14
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: pushq %rsi
|
2019-08-31 05:23:05 +08:00
|
|
|
; WINDOWS-NEXT: .seh_pushreg %rsi
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: pushq %rdi
|
2019-08-31 05:23:05 +08:00
|
|
|
; WINDOWS-NEXT: .seh_pushreg %rdi
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: pushq %rbx
|
2019-08-31 05:23:05 +08:00
|
|
|
; WINDOWS-NEXT: .seh_pushreg %rbx
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: subq $72, %rsp
|
|
|
|
; WINDOWS-NEXT: .seh_stackalloc 72
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: .seh_endprologue
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq %r9, %r14
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: movq %r8, %rdi
|
|
|
|
; WINDOWS-NEXT: movq %rdx, %rbx
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq %rcx, %rsi
|
2018-02-28 00:59:10 +08:00
|
|
|
; WINDOWS-NEXT: movq %rdx, {{[0-9]+}}(%rsp)
|
[DAGCombiner] If a TokenFactor would be merged into its user, consider the user later.
Summary:
A number of optimizations are inhibited by single-use TokenFactors not
being merged into the TokenFactor using it. This makes we consider if
we can do the merge immediately.
Most tests changes here are due to the change in visitation causing
minor reorderings and associated reassociation of paired memory
operations.
CodeGen tests with non-reordering changes:
X86/aligned-variadic.ll -- memory-based add folded into stored leaq
value.
X86/constant-combiners.ll -- Optimizes out overlap between stores.
X86/pr40631_deadstore_elision -- folds constant byte store into
preceding quad word constant store.
Reviewers: RKSimon, craig.topper, spatel, efriedma, courbet
Reviewed By: courbet
Subscribers: dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, eraman, hiraditya, kbarton, jrtc27, atanasyan, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59260
llvm-svn: 356068
2019-03-14 01:07:09 +08:00
|
|
|
; WINDOWS-NEXT: movq %r8, {{[0-9]+}}(%rsp)
|
|
|
|
; WINDOWS-NEXT: movq %r9, {{[0-9]+}}(%rsp)
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: leaq {{[0-9]+}}(%rsp), %rax
|
|
|
|
; WINDOWS-NEXT: movq %rax, {{[0-9]+}}(%rsp)
|
|
|
|
; WINDOWS-NEXT: callq get_f
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq %rsi, %rcx
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: movq %rbx, %rdx
|
|
|
|
; WINDOWS-NEXT: movq %rdi, %r8
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq %r14, %r9
|
|
|
|
; WINDOWS-NEXT: addq $72, %rsp
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: popq %rbx
|
|
|
|
; WINDOWS-NEXT: popq %rdi
|
|
|
|
; WINDOWS-NEXT: popq %rsi
|
|
|
|
; WINDOWS-NEXT: popq %r14
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: rex64 jmpq *%rax # TAILCALL
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: .seh_endproc
|
|
|
|
;
|
|
|
|
; X86-NOSSE-LABEL: f_thunk:
|
|
|
|
; X86-NOSSE: # %bb.0:
|
|
|
|
; X86-NOSSE-NEXT: pushl %ebp
|
|
|
|
; X86-NOSSE-NEXT: movl %esp, %ebp
|
|
|
|
; X86-NOSSE-NEXT: pushl %esi
|
|
|
|
; X86-NOSSE-NEXT: andl $-16, %esp
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-NOSSE-NEXT: subl $32, %esp
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-NOSSE-NEXT: movl 8(%ebp), %esi
|
|
|
|
; X86-NOSSE-NEXT: leal 12(%ebp), %eax
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-NOSSE-NEXT: movl %eax, (%esp)
|
|
|
|
; X86-NOSSE-NEXT: pushl %esi
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-NOSSE-NEXT: calll _get_f
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-NOSSE-NEXT: addl $4, %esp
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-NOSSE-NEXT: movl %esi, 8(%ebp)
|
|
|
|
; X86-NOSSE-NEXT: leal -4(%ebp), %esp
|
|
|
|
; X86-NOSSE-NEXT: popl %esi
|
|
|
|
; X86-NOSSE-NEXT: popl %ebp
|
|
|
|
; X86-NOSSE-NEXT: jmpl *%eax # TAILCALL
|
|
|
|
;
|
|
|
|
; X86-SSE-LABEL: f_thunk:
|
|
|
|
; X86-SSE: # %bb.0:
|
|
|
|
; X86-SSE-NEXT: pushl %ebp
|
|
|
|
; X86-SSE-NEXT: movl %esp, %ebp
|
|
|
|
; X86-SSE-NEXT: pushl %esi
|
|
|
|
; X86-SSE-NEXT: andl $-16, %esp
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-SSE-NEXT: subl $80, %esp
|
2018-07-24 11:07:07 +08:00
|
|
|
; X86-SSE-NEXT: movaps %xmm2, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
|
|
|
; X86-SSE-NEXT: movaps %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-SSE-NEXT: movaps %xmm0, (%esp) # 16-byte Spill
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-SSE-NEXT: movl 8(%ebp), %esi
|
|
|
|
; X86-SSE-NEXT: leal 12(%ebp), %eax
|
|
|
|
; X86-SSE-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-SSE-NEXT: pushl %esi
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-SSE-NEXT: calll _get_f
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-SSE-NEXT: addl $4, %esp
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-SSE-NEXT: movl %esi, 8(%ebp)
|
2019-12-03 05:15:30 +08:00
|
|
|
; X86-SSE-NEXT: movaps (%esp), %xmm0 # 16-byte Reload
|
2018-07-24 11:07:07 +08:00
|
|
|
; X86-SSE-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
|
|
|
|
; X86-SSE-NEXT: movaps {{[-0-9]+}}(%e{{[sb]}}p), %xmm2 # 16-byte Reload
|
2018-02-12 10:03:36 +08:00
|
|
|
; X86-SSE-NEXT: leal -4(%ebp), %esp
|
|
|
|
; X86-SSE-NEXT: popl %esi
|
|
|
|
; X86-SSE-NEXT: popl %ebp
|
|
|
|
; X86-SSE-NEXT: jmpl *%eax # TAILCALL
|
2014-12-23 07:58:37 +08:00
|
|
|
%ap = alloca [4 x i8*], align 16
|
|
|
|
%ap_i8 = bitcast [4 x i8*]* %ap to i8*
|
|
|
|
call void @llvm.va_start(i8* %ap_i8)
|
|
|
|
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
%fptr = call void(i8*, ...)*(i8*) @get_f(i8* %this)
|
|
|
|
musttail call void (i8*, ...) %fptr(i8* %this, ...)
|
2014-08-30 05:42:08 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Save and restore 6 GPRs, 8 XMMs, and AL around the call.
|
|
|
|
|
2015-01-13 07:28:23 +08:00
|
|
|
; No regparms on normal x86 conventions.
|
|
|
|
|
2014-08-30 05:42:08 +08:00
|
|
|
; This thunk shouldn't require any spills and reloads, assuming the register
|
|
|
|
; allocator knows what it's doing.
|
|
|
|
|
|
|
|
define void @g_thunk(i8* %fptr_i8, ...) {
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-LABEL: g_thunk:
|
|
|
|
; LINUX: # %bb.0:
|
|
|
|
; LINUX-NEXT: jmpq *%rdi # TAILCALL
|
|
|
|
;
|
|
|
|
; LINUX-X32-LABEL: g_thunk:
|
|
|
|
; LINUX-X32: # %bb.0:
|
2020-12-01 02:51:23 +08:00
|
|
|
; LINUX-X32-NEXT: jmpq *%rdi # TAILCALL
|
2018-02-12 10:03:36 +08:00
|
|
|
;
|
|
|
|
; WINDOWS-LABEL: g_thunk:
|
|
|
|
; WINDOWS: # %bb.0:
|
|
|
|
; WINDOWS-NEXT: rex64 jmpq *%rcx # TAILCALL
|
|
|
|
;
|
|
|
|
; X86-LABEL: g_thunk:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
|
|
|
; X86-NEXT: jmpl *%eax # TAILCALL
|
2014-08-30 05:42:08 +08:00
|
|
|
%fptr = bitcast i8* %fptr_i8 to void (i8*, ...)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
musttail call void (i8*, ...) %fptr(i8* %fptr_i8, ...)
|
2014-08-30 05:42:08 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Do a simple multi-exit multi-bb test.
|
|
|
|
|
|
|
|
%struct.Foo = type { i1, i8*, i8* }
|
|
|
|
|
2020-12-05 05:51:01 +08:00
|
|
|
@g = external dso_local global i32
|
2014-08-30 05:42:08 +08:00
|
|
|
|
|
|
|
define void @h_thunk(%struct.Foo* %this, ...) {
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-LABEL: h_thunk:
|
|
|
|
; LINUX: # %bb.0:
|
|
|
|
; LINUX-NEXT: cmpb $1, (%rdi)
|
|
|
|
; LINUX-NEXT: jne .LBB2_2
|
|
|
|
; LINUX-NEXT: # %bb.1: # %then
|
|
|
|
; LINUX-NEXT: movq 8(%rdi), %r11
|
|
|
|
; LINUX-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
; LINUX-NEXT: .LBB2_2: # %else
|
|
|
|
; LINUX-NEXT: movq 16(%rdi), %r11
|
2021-06-12 04:26:17 +08:00
|
|
|
; LINUX-NEXT: movl $42, g(%rip)
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
;
|
|
|
|
; LINUX-X32-LABEL: h_thunk:
|
|
|
|
; LINUX-X32: # %bb.0:
|
|
|
|
; LINUX-X32-NEXT: cmpb $1, (%edi)
|
|
|
|
; LINUX-X32-NEXT: jne .LBB2_2
|
|
|
|
; LINUX-X32-NEXT: # %bb.1: # %then
|
|
|
|
; LINUX-X32-NEXT: movl 4(%edi), %r11d
|
2020-12-01 02:51:23 +08:00
|
|
|
; LINUX-X32-NEXT: movl %edi, %edi
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
; LINUX-X32-NEXT: .LBB2_2: # %else
|
|
|
|
; LINUX-X32-NEXT: movl 8(%edi), %r11d
|
2021-06-12 04:26:17 +08:00
|
|
|
; LINUX-X32-NEXT: movl $42, g(%rip)
|
2020-12-01 02:51:23 +08:00
|
|
|
; LINUX-X32-NEXT: movl %edi, %edi
|
2018-02-12 10:03:36 +08:00
|
|
|
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
|
|
|
|
;
|
|
|
|
; WINDOWS-LABEL: h_thunk:
|
|
|
|
; WINDOWS: # %bb.0:
|
|
|
|
; WINDOWS-NEXT: cmpb $1, (%rcx)
|
|
|
|
; WINDOWS-NEXT: jne .LBB2_2
|
|
|
|
; WINDOWS-NEXT: # %bb.1: # %then
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq 8(%rcx), %rax
|
|
|
|
; WINDOWS-NEXT: rex64 jmpq *%rax # TAILCALL
|
2018-02-12 10:03:36 +08:00
|
|
|
; WINDOWS-NEXT: .LBB2_2: # %else
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: movq 16(%rcx), %rax
|
2021-06-12 04:26:17 +08:00
|
|
|
; WINDOWS-NEXT: movl $42, g(%rip)
|
2019-11-19 07:31:37 +08:00
|
|
|
; WINDOWS-NEXT: rex64 jmpq *%rax # TAILCALL
|
2018-02-12 10:03:36 +08:00
|
|
|
;
|
|
|
|
; X86-LABEL: h_thunk:
|
|
|
|
; X86: # %bb.0:
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: cmpb $1, (%eax)
|
|
|
|
; X86-NEXT: jne LBB2_2
|
|
|
|
; X86-NEXT: # %bb.1: # %then
|
|
|
|
; X86-NEXT: movl 4(%eax), %ecx
|
|
|
|
; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
|
|
|
; X86-NEXT: jmpl *%ecx # TAILCALL
|
|
|
|
; X86-NEXT: LBB2_2: # %else
|
|
|
|
; X86-NEXT: movl 8(%eax), %ecx
|
|
|
|
; X86-NEXT: movl $42, _g
|
|
|
|
; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
|
|
|
; X86-NEXT: jmpl *%ecx # TAILCALL
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%cond_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 0
|
2015-02-28 05:17:42 +08:00
|
|
|
%cond = load i1, i1* %cond_p
|
2014-08-30 05:42:08 +08:00
|
|
|
br i1 %cond, label %then, label %else
|
|
|
|
|
|
|
|
then:
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%a_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 1
|
2015-02-28 05:17:42 +08:00
|
|
|
%a_i8 = load i8*, i8** %a_p
|
2014-08-30 05:42:08 +08:00
|
|
|
%a = bitcast i8* %a_i8 to void (%struct.Foo*, ...)*
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
musttail call void (%struct.Foo*, ...) %a(%struct.Foo* %this, ...)
|
2014-08-30 05:42:08 +08:00
|
|
|
ret void
|
|
|
|
|
|
|
|
else:
|
[opaque pointer type] Add textual IR support for explicit type parameter to getelementptr instruction
One of several parallel first steps to remove the target type of pointers,
replacing them with a single opaque pointer type.
This adds an explicit type parameter to the gep instruction so that when the
first parameter becomes an opaque pointer type, the type to gep through is
still available to the instructions.
* This doesn't modify gep operators, only instructions (operators will be
handled separately)
* Textual IR changes only. Bitcode (including upgrade) and changing the
in-memory representation will be in separate changes.
* geps of vectors are transformed as:
getelementptr <4 x float*> %x, ...
->getelementptr float, <4 x float*> %x, ...
Then, once the opaque pointer type is introduced, this will ultimately look
like:
getelementptr float, <4 x ptr> %x
with the unambiguous interpretation that it is a vector of pointers to float.
* address spaces remain on the pointer, not the type:
getelementptr float addrspace(1)* %x
->getelementptr float, float addrspace(1)* %x
Then, eventually:
getelementptr float, ptr addrspace(1) %x
Importantly, the massive amount of test case churn has been automated by
same crappy python code. I had to manually update a few test cases that
wouldn't fit the script's model (r228970,r229196,r229197,r229198). The
python script just massages stdin and writes the result to stdout, I
then wrapped that in a shell script to handle replacing files, then
using the usual find+xargs to migrate all the files.
update.py:
import fileinput
import sys
import re
ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))")
def conv(match, line):
if not match:
return line
line = match.groups()[0]
if len(match.groups()[5]) == 0:
line += match.groups()[2]
line += match.groups()[3]
line += ", "
line += match.groups()[1]
line += "\n"
return line
for line in sys.stdin:
if line.find("getelementptr ") == line.find("getelementptr inbounds"):
if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("):
line = conv(re.match(ibrep, line), line)
elif line.find("getelementptr ") != line.find("getelementptr ("):
line = conv(re.match(normrep, line), line)
sys.stdout.write(line)
apply.sh:
for name in "$@"
do
python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
rm -f "$name.tmp"
done
The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh
After that, check-all (with llvm, clang, clang-tools-extra, lld,
compiler-rt, and polly all checked out).
The extra 'rm' in the apply.sh script is due to a few files in clang's test
suite using interesting unicode stuff that my python script was throwing
exceptions on. None of those files needed to be migrated, so it seemed
sufficient to ignore those cases.
Reviewers: rafael, dexonsmith, grosser
Differential Revision: http://reviews.llvm.org/D7636
llvm-svn: 230786
2015-02-28 03:29:02 +08:00
|
|
|
%b_p = getelementptr %struct.Foo, %struct.Foo* %this, i32 0, i32 2
|
2015-02-28 05:17:42 +08:00
|
|
|
%b_i8 = load i8*, i8** %b_p
|
2014-08-30 05:42:08 +08:00
|
|
|
%b = bitcast i8* %b_i8 to void (%struct.Foo*, ...)*
|
|
|
|
store i32 42, i32* @g
|
[opaque pointer type] Add textual IR support for explicit type parameter to the call instruction
See r230786 and r230794 for similar changes to gep and load
respectively.
Call is a bit different because it often doesn't have a single explicit
type - usually the type is deduced from the arguments, and just the
return type is explicit. In those cases there's no need to change the
IR.
When that's not the case, the IR usually contains the pointer type of
the first operand - but since typed pointers are going away, that
representation is insufficient so I'm just stripping the "pointerness"
of the explicit type away.
This does make the IR a bit weird - it /sort of/ reads like the type of
the first operand: "call void () %x(" but %x is actually of type "void
()*" and will eventually be just of type "ptr". But this seems not too
bad and I don't think it would benefit from repeating the type
("void (), void () * %x(" and then eventually "void (), ptr %x(") as has
been done with gep and load.
This also has a side benefit: since the explicit type is no longer a
pointer, there's no ambiguity between an explicit type and a function
that returns a function pointer. Previously this case needed an explicit
type (eg: a function returning a void() function was written as
"call void () () * @x(" rather than "call void () * @x(" because of the
ambiguity between a function returning a pointer to a void() function
and a function returning void).
No ambiguity means even function pointer return types can just be
written alone, without writing the whole function's type.
This leaves /only/ the varargs case where the explicit type is required.
Given the special type syntax in call instructions, the regex-fu used
for migration was a bit more involved in its own unique way (as every
one of these is) so here it is. Use it in conjunction with the apply.sh
script and associated find/xargs commands I've provided in rr230786 to
migrate your out of tree tests. Do let me know if any of this doesn't
cover your cases & we can iterate on a more general script/regexes to
help others with out of tree tests.
About 9 test cases couldn't be automatically migrated - half of those
were functions returning function pointers, where I just had to manually
delete the function argument types now that we didn't need an explicit
function type there. The other half were typedefs of function types used
in calls - just had to manually drop the * from those.
import fileinput
import sys
import re
pat = re.compile(r'((?:=|:|^|\s)call\s(?:[^@]*?))(\s*$|\s*(?:(?:\[\[[a-zA-Z0-9_]+\]\]|[@%](?:(")?[\\\?@a-zA-Z0-9_.]*?(?(3)"|)|{{.*}}))(?:\(|$)|undef|inttoptr|bitcast|null|asm).*$)')
addrspace_end = re.compile(r"addrspace\(\d+\)\s*\*$")
func_end = re.compile("(?:void.*|\)\s*)\*$")
def conv(match, line):
if not match or re.search(addrspace_end, match.group(1)) or not re.search(func_end, match.group(1)):
return line
return line[:match.start()] + match.group(1)[:match.group(1).rfind('*')].rstrip() + match.group(2) + line[match.end():]
for line in sys.stdin:
sys.stdout.write(conv(re.search(pat, line), line))
llvm-svn: 235145
2015-04-17 07:24:18 +08:00
|
|
|
musttail call void (%struct.Foo*, ...) %b(%struct.Foo* %this, ...)
|
2014-08-30 05:42:08 +08:00
|
|
|
ret void
|
|
|
|
}
|