1 ; RUN: llc < %s -mtriple=avr -filetype=asm | FileCheck %s -check-prefix=CHECK-ASM
2 ; RUN: llc < %s -mtriple=avr -filetype=obj | llvm-objdump -Dr - \
3 ; RUN: | FileCheck %s -check-prefix=CHECK-OBJ
5 ; Somewhat pruned test case from rustc using trait objects
7 %TraitObjectA = type {}
9 ; CHECK-ASM-LABEL: vtable.0:
10 ; CHECK-ASM-NEXT: .short pm(drop_in_place2)
11 ; CHECK-ASM-NEXT: .short 0
12 ; CHECK-ASM-NEXT: .short 1
13 ; CHECK-ASM-NEXT: .short pm(trait_fn2)
15 ; CHECK-OBJ-LABEL: <vtable.0>:
16 ; CHECK-OBJ-NEXT: 00 00
17 ; CHECK-OBJ-NEXT: R_AVR_16_PM .text
18 ; CHECK-OBJ-NEXT: 00 00
19 ; CHECK-OBJ-NEXT: 01 00 00 00
20 ; CHECK-OBJ-NEXT: R_AVR_16_PM .text
21 @vtable.0 = private constant {
35 ; CHECK-ASM-LABEL: vtable.1:
36 ; CHECK-ASM-NEXT: .short pm(drop_in_place1)
37 ; CHECK-ASM-NEXT: .short 0
38 ; CHECK-ASM-NEXT: .short 1
39 ; CHECK-ASM-NEXT: .short pm(trait_fn1)
41 ; CHECK-OBJ-LABEL: <vtable.1>:
42 ; CHECK-OBJ-NEXT: 00 00
43 ; CHECK-OBJ-NEXT: R_AVR_16_PM .text
44 ; CHECK-OBJ-NEXT: 00 00
45 ; CHECK-OBJ-NEXT: 01 00 00 00
46 ; CHECK-OBJ-NEXT: R_AVR_16_PM .text
47 @vtable.1 = private constant {
61 define internal fastcc i8 @TraitObjectA_method(i1 zeroext %choice) addrspace(1) {
63 %b = alloca %TraitObjectA, align 1
65 %c = select i1 %choice, ptr @vtable.0,
67 %b2 = bitcast ptr %b to ptr
69 %res = call fastcc addrspace(1) i8 @call_trait_object(ptr nonnull align 1 %b2, ptr noalias readonly align 1 dereferenceable(6) %c)
73 define internal fastcc i8 @call_trait_object(ptr nonnull align 1 %a, ptr noalias nocapture readonly align 1 dereferenceable(6) %b) addrspace(1) {
75 %b2 = getelementptr inbounds [3 x i16], ptr %b, i16 0, i16 3
76 %c = bitcast ptr %b2 to ptr
77 %d = load ptr addrspace(1), ptr %c, align 1, !invariant.load !1, !nonnull !1
78 %res = tail call addrspace(1) i8 %d(ptr nonnull align 1 %a)
82 define internal void @drop_in_place1(ptr nocapture %a) addrspace(1) {
87 define internal i8 @trait_fn1(ptr noalias nocapture nonnull readonly align 1 %self) addrspace(1) {
92 define internal void @drop_in_place2(ptr nocapture %a) addrspace(1) {
97 define internal i8 @trait_fn2(ptr noalias nocapture nonnull readonly align 1 %self) addrspace(1) {