2020-06-10 20:53:54 +08:00
|
|
|
# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2020-06-10 21:52:25 +08:00
|
|
|
# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=true -start-after=finalize-isel | FileCheck %s
|
2020-06-10 20:53:54 +08:00
|
|
|
|
|
|
|
--- |
|
|
|
|
; ModuleID = 'test/CodeGen/X86/statepoint-vreg.ll'
|
|
|
|
source_filename = "test/CodeGen/X86/statepoint-vreg.ll"
|
|
|
|
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-pc-linux-gnu"
|
|
|
|
|
|
|
|
declare void @bar()
|
|
|
|
|
|
|
|
define i32 @test_basic(i32 addrspace(1)* %obj1, i32 addrspace(1)* %obj2) gc "statepoint-example" {
|
|
|
|
; CHECK-LABEL: test_basic:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: pushq %r14
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 16
|
|
|
|
; CHECK-NEXT: pushq %rbx
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 24
|
|
|
|
; CHECK-NEXT: pushq %rax
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 32
|
|
|
|
; CHECK-NEXT: .cfi_offset %rbx, -24
|
|
|
|
; CHECK-NEXT: .cfi_offset %r14, -16
|
|
|
|
; CHECK-NEXT: movq %rsi, %r14
|
|
|
|
; CHECK-NEXT: movq %rdi, %rbx
|
|
|
|
; CHECK-NEXT: callq bar
|
|
|
|
; CHECK-NEXT: .Ltmp0:
|
|
|
|
; CHECK-NEXT: movl (%rbx), %eax
|
|
|
|
; CHECK-NEXT: addl (%r14), %eax
|
|
|
|
; CHECK-NEXT: addq $8, %rsp
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 24
|
|
|
|
; CHECK-NEXT: popq %rbx
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 16
|
|
|
|
; CHECK-NEXT: popq %r14
|
|
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 8
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @bar, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* %obj1, i32 addrspace(1)* %obj2) ]
|
|
|
|
%rel1 = call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %token, i32 0, i32 0) ; (%obj1, %obj1)
|
|
|
|
%rel2 = call coldcc i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %token, i32 1, i32 1) ; (%obj2, %obj2)
|
|
|
|
%a = load i32, i32 addrspace(1)* %rel1, align 4
|
|
|
|
%b = load i32, i32 addrspace(1)* %rel2, align 4
|
|
|
|
%c = add i32 %a, %b
|
|
|
|
ret i32 %c
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK-LABEL: __LLVM_StackMaps:
|
|
|
|
; CHECK-NEXT: .byte 3
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 1
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .long 1
|
|
|
|
; CHECK-NEXT: .quad test_basic
|
|
|
|
; CHECK-NEXT: .quad 24
|
|
|
|
; CHECK-NEXT: .quad 1
|
|
|
|
; CHECK-NEXT: .quad 2882400000
|
|
|
|
; CHECK-NEXT: .long .Ltmp0-test_basic
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .byte 4
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 4
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 4
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 1
|
|
|
|
; CHECK-NEXT: .byte 4
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 1
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 14
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 1
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 14
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 1
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 3
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .byte 1
|
|
|
|
; CHECK-NEXT: .byte 0
|
|
|
|
; CHECK-NEXT: .short 8
|
|
|
|
; CHECK-NEXT: .short 3
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .long 0
|
|
|
|
; CHECK-NEXT: .p2align 3
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .short 0
|
|
|
|
; CHECK-NEXT: .p2align 3
|
|
|
|
|
|
|
|
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 immarg, i32 immarg, void ()*, i32 immarg, i32 immarg, ...)
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readonly
|
|
|
|
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32 immarg, i32 immarg) #0
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readonly }
|
|
|
|
attributes #1 = { nounwind }
|
|
|
|
|
|
|
|
...
|
|
|
|
---
|
|
|
|
name: test_basic
|
|
|
|
alignment: 16
|
|
|
|
selected: false
|
|
|
|
failedISel: false
|
|
|
|
tracksRegLiveness: true
|
|
|
|
registers:
|
|
|
|
- { id: 0, class: gr64, preferred-register: '' }
|
|
|
|
- { id: 1, class: gr64, preferred-register: '' }
|
|
|
|
- { id: 2, class: gr64, preferred-register: '' }
|
|
|
|
- { id: 3, class: gr64, preferred-register: '' }
|
|
|
|
- { id: 4, class: gr32, preferred-register: '' }
|
|
|
|
- { id: 5, class: gr32, preferred-register: '' }
|
|
|
|
liveins:
|
|
|
|
- { reg: '$rdi', virtual-reg: '%0' }
|
|
|
|
- { reg: '$rsi', virtual-reg: '%1' }
|
|
|
|
fixedStack: []
|
|
|
|
stack: []
|
|
|
|
callSites: []
|
|
|
|
constants: []
|
|
|
|
machineFunctionInfo: {}
|
|
|
|
body: |
|
|
|
|
bb.0 (%ir-block.0):
|
|
|
|
liveins: $rdi, $rsi
|
|
|
|
|
|
|
|
%1:gr64 = COPY $rsi
|
|
|
|
%0:gr64 = COPY $rdi
|
|
|
|
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
|
[Statepoints] Change statepoint machine instr format to better suit VReg lowering.
Current Statepoint MI format is this:
STATEPOINT
<id>, <num patch bytes >, <num call arguments>, <call target>,
[call arguments...],
<StackMaps::ConstantOp>, <calling convention>,
<StackMaps::ConstantOp>, <statepoint flags>,
<StackMaps::ConstantOp>, <num deopt args>, [deopt args...],
<gc base/derived pairs...> <gc allocas...>
Note that GC pointers are listed in pairs <base,derived>.
This causes base pointers to appear many times (at least twice) in
instruction, which is bad for us when VReg lowering is ON.
The problem is that machine operand tiedness is 1-1 relation, so
it might look like this:
%vr2 = STATEPOINT ... %vr1, %vr1(tied-def0)
Since only one instance of %vr1 is tied, that may lead to incorrect
codegen (see PR46917 for more details), so we have to always spill
base pointers. This mostly defeats new VReg lowering scheme.
This patch changes statepoint instruction format so that every
gc pointer appears only once in operand list. That way they all can
be tied. Additional set of operands is added to preserve base-derived
relation required to build stackmap.
New statepoint has following format:
STATEPOINT
<id>, <num patch bytes>, <num call arguments>, <call target>,
[call arguments...],
<StackMaps::ConstantOp>, <calling convention>,
<StackMaps::ConstantOp>, <statepoint flags>,
<StackMaps::ConstantOp>, <num deopt args>, [deopt args...],
<StackMaps::ConstantOp>, <num gc pointers>, [gc pointers...],
<StackMaps::ConstantOp>, <num gc allocas>, [gc allocas...]
<StackMaps::ConstantOp>, <num entries in gc map>, [base/derived indices...]
Changes are:
- every gc pointer is listed only once in a flat length-prefixed list;
- alloca list is prefixed with its length too;
- following alloca list is length-prefixed list of base-derived
indices of pointers from gc pointer list. Note that indices are
logical (number of pointer), not absolute (index of machine operand).
Differential Revision: https://reviews.llvm.org/D87154
2020-09-05 01:45:41 +08:00
|
|
|
%2:gr64, %3:gr64 = STATEPOINT 2882400000, 0, 0, @bar, 2, 0, 2, 0, 2, 1, 2, 0, 2, 2, %1(tied-def 0), %0(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_64, implicit-def $rsp, implicit-def $ssp
|
2020-06-10 20:53:54 +08:00
|
|
|
ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp
|
|
|
|
%4:gr32 = MOV32rm killed %3, 1, $noreg, 0, $noreg :: (load 4 from %ir.rel1, addrspace 1)
|
|
|
|
%5:gr32 = ADD32rm %4, killed %2, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (load 4 from %ir.rel2, addrspace 1)
|
|
|
|
$eax = COPY %5
|
|
|
|
RET 0, $eax
|
|
|
|
|
|
|
|
...
|