Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/X86/slow-indirect-call.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

171 lines
5.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc < %s -mtriple=x86_64-linux -mattr=+slow-indirect-call | FileCheck %s --check-prefix=SLOW
; RUN: llc < %s -mtriple=x86_64-linux -mattr=-slow-indirect-call | FileCheck %s --check-prefix=NON-SLOW
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=znver5 | FileCheck %s --check-prefix=SLOW
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=znver4 | FileCheck %s --check-prefix=NON-SLOW
; RUN: llc < %s -mtriple=x86_64-linux -mcpu=znver6 | FileCheck %s --check-prefix=NON-SLOW
; RUN: llc < %s -mtriple=i686-linux -mattr=+slow-indirect-call | FileCheck %s --check-prefix=SLOW32
; RUN: llc < %s -mtriple=i686-linux -mattr=-slow-indirect-call | FileCheck %s --check-prefix=NON-SLOW32
@vtable = external dso_local global ptr
; Indirect call through a global function pointer. With slow-indirect-call the
; load must not be folded into the call.
define i32 @test_call_global() nounwind {
; SLOW-LABEL: test_call_global:
; SLOW: # %bb.0:
; SLOW-NEXT: pushq %rax
; SLOW-NEXT: movq vtable(%rip), %rax
; SLOW-NEXT: movl $42, %edi
; SLOW-NEXT: callq *%rax
; SLOW-NEXT: popq %rcx
; SLOW-NEXT: retq
;
; NON-SLOW-LABEL: test_call_global:
; NON-SLOW: # %bb.0:
; NON-SLOW-NEXT: pushq %rax
; NON-SLOW-NEXT: movl $42, %edi
; NON-SLOW-NEXT: callq *vtable(%rip)
; NON-SLOW-NEXT: popq %rcx
; NON-SLOW-NEXT: retq
;
; SLOW32-LABEL: test_call_global:
; SLOW32: # %bb.0:
; SLOW32-NEXT: subl $12, %esp
; SLOW32-NEXT: movl vtable, %eax
; SLOW32-NEXT: movl $42, (%esp)
; SLOW32-NEXT: calll *%eax
; SLOW32-NEXT: addl $12, %esp
; SLOW32-NEXT: retl
;
; NON-SLOW32-LABEL: test_call_global:
; NON-SLOW32: # %bb.0:
; NON-SLOW32-NEXT: subl $12, %esp
; NON-SLOW32-NEXT: movl $42, (%esp)
; NON-SLOW32-NEXT: calll *vtable
; NON-SLOW32-NEXT: addl $12, %esp
; NON-SLOW32-NEXT: retl
%fp = load ptr, ptr @vtable, align 8
%ret = call i32 %fp(i32 42)
ret i32 %ret
}
; Vtable dispatch: load vtable pointer, load function from vtable, call.
; The second load (vtable slot) must not be folded into the call.
define i32 @test_call_vtable(ptr %obj) nounwind {
; SLOW-LABEL: test_call_vtable:
; SLOW: # %bb.0:
; SLOW-NEXT: pushq %rax
; SLOW-NEXT: movq (%rdi), %rax
; SLOW-NEXT: movq (%rax), %rax
; SLOW-NEXT: callq *%rax
; SLOW-NEXT: popq %rcx
; SLOW-NEXT: retq
;
; NON-SLOW-LABEL: test_call_vtable:
; NON-SLOW: # %bb.0:
; NON-SLOW-NEXT: pushq %rax
; NON-SLOW-NEXT: movq (%rdi), %rax
; NON-SLOW-NEXT: callq *(%rax)
; NON-SLOW-NEXT: popq %rcx
; NON-SLOW-NEXT: retq
;
; SLOW32-LABEL: test_call_vtable:
; SLOW32: # %bb.0:
; SLOW32-NEXT: subl $12, %esp
; SLOW32-NEXT: movl {{[0-9]+}}(%esp), %eax
; SLOW32-NEXT: movl (%eax), %ecx
; SLOW32-NEXT: movl (%ecx), %ecx
; SLOW32-NEXT: movl %eax, (%esp)
; SLOW32-NEXT: calll *%ecx
; SLOW32-NEXT: addl $12, %esp
; SLOW32-NEXT: retl
;
; NON-SLOW32-LABEL: test_call_vtable:
; NON-SLOW32: # %bb.0:
; NON-SLOW32-NEXT: subl $12, %esp
; NON-SLOW32-NEXT: movl {{[0-9]+}}(%esp), %eax
; NON-SLOW32-NEXT: movl (%eax), %ecx
; NON-SLOW32-NEXT: movl %eax, (%esp)
; NON-SLOW32-NEXT: calll *(%ecx)
; NON-SLOW32-NEXT: addl $12, %esp
; NON-SLOW32-NEXT: retl
%vt = load ptr, ptr %obj, align 8
%fp = load ptr, ptr %vt, align 8
%ret = call i32 %fp(ptr %obj)
ret i32 %ret
}
; With minsize, the load should be folded even with slow-indirect-call.
; The minsize attribute overrides the slow-indirect-call guard during
; register allocation folding.
define i32 @test_call_minsize() nounwind minsize {
; SLOW-LABEL: test_call_minsize:
; SLOW: # %bb.0:
; SLOW-NEXT: pushq %rax
; SLOW-NEXT: pushq $42
; SLOW-NEXT: popq %rdi
; SLOW-NEXT: callq *vtable(%rip)
; SLOW-NEXT: popq %rcx
; SLOW-NEXT: retq
;
; NON-SLOW-LABEL: test_call_minsize:
; NON-SLOW: # %bb.0:
; NON-SLOW-NEXT: pushq %rax
; NON-SLOW-NEXT: pushq $42
; NON-SLOW-NEXT: popq %rdi
; NON-SLOW-NEXT: callq *vtable(%rip)
; NON-SLOW-NEXT: popq %rcx
; NON-SLOW-NEXT: retq
;
; SLOW32-LABEL: test_call_minsize:
; SLOW32: # %bb.0:
; SLOW32-NEXT: subl $12, %esp
; SLOW32-NEXT: movl vtable, %eax
; SLOW32-NEXT: movl $42, (%esp)
; SLOW32-NEXT: calll *%eax
; SLOW32-NEXT: addl $12, %esp
; SLOW32-NEXT: retl
;
; NON-SLOW32-LABEL: test_call_minsize:
; NON-SLOW32: # %bb.0:
; NON-SLOW32-NEXT: subl $12, %esp
; NON-SLOW32-NEXT: movl $42, (%esp)
; NON-SLOW32-NEXT: calll *vtable
; NON-SLOW32-NEXT: addl $12, %esp
; NON-SLOW32-NEXT: retl
%fp = load ptr, ptr @vtable, align 8
%ret = call i32 %fp(i32 42)
ret i32 %ret
}
; Tail calls should not be affected by slow-indirect-call. The load into the
; jump target should still be folded.
define void @test_tail_call(ptr %obj) nounwind {
; SLOW-LABEL: test_tail_call:
; SLOW: # %bb.0:
; SLOW-NEXT: movq (%rdi), %rax
; SLOW-NEXT: jmpq *(%rax) # TAILCALL
;
; NON-SLOW-LABEL: test_tail_call:
; NON-SLOW: # %bb.0:
; NON-SLOW-NEXT: movq (%rdi), %rax
; NON-SLOW-NEXT: jmpq *(%rax) # TAILCALL
;
; SLOW32-LABEL: test_tail_call:
; SLOW32: # %bb.0:
; SLOW32-NEXT: movl {{[0-9]+}}(%esp), %eax
; SLOW32-NEXT: movl (%eax), %eax
; SLOW32-NEXT: jmpl *(%eax) # TAILCALL
;
; NON-SLOW32-LABEL: test_tail_call:
; NON-SLOW32: # %bb.0:
; NON-SLOW32-NEXT: movl {{[0-9]+}}(%esp), %eax
; NON-SLOW32-NEXT: movl (%eax), %eax
; NON-SLOW32-NEXT: jmpl *(%eax) # TAILCALL
%vt = load ptr, ptr %obj, align 8
%fp = load ptr, ptr %vt, align 8
musttail call void %fp(ptr %obj)
ret void
}