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 {
22 void (%TraitObjectA*) addrspace(1)*,
25 i8 (%TraitObjectA*) addrspace(1)*
27 void (%TraitObjectA*) addrspace(1)*
31 i8 (%TraitObjectA*) addrspace(1)*
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 {
48 void (%TraitObjectA*) addrspace(1)*,
51 i8 (%TraitObjectA*) addrspace(1)*
53 void (%TraitObjectA*) addrspace(1)*
57 i8 (%TraitObjectA*) addrspace(1)*
61 define internal fastcc i8 @TraitObjectA_method(i1 zeroext %choice) addrspace(1) {
63 %b = alloca %TraitObjectA, align 1
65 %c = select i1 %choice, [3 x i16]* bitcast ({
66 void (%TraitObjectA*) addrspace(1)*,
69 i8 (%TraitObjectA*) addrspace(1)*
70 }* @vtable.0 to [3 x i16]*),
72 void (%TraitObjectA*) addrspace(1)*,
75 i8 (%TraitObjectA*) addrspace(1)*
76 }* @vtable.1 to [3 x i16]*)
77 %b2 = bitcast %TraitObjectA* %b to {}*
79 %res = call fastcc addrspace(1) i8 @call_trait_object({}* nonnull align 1 %b2, [3 x i16]* noalias readonly align 1 dereferenceable(6) %c)
83 define internal fastcc i8 @call_trait_object({}* nonnull align 1 %a, [3 x i16]* noalias nocapture readonly align 1 dereferenceable(6) %b) addrspace(1) {
85 %b2 = getelementptr inbounds [3 x i16], [3 x i16]* %b, i16 0, i16 3
86 %c = bitcast i16* %b2 to i8 ({}*) addrspace(1)**
87 %d = load i8 ({}*) addrspace(1)*, i8 ({}*) addrspace(1)** %c, align 1, !invariant.load !1, !nonnull !1
88 %res = tail call addrspace(1) i8 %d({}* nonnull align 1 %a)
92 define internal void @drop_in_place1(%TraitObjectA* nocapture %a) addrspace(1) {
97 define internal i8 @trait_fn1(%TraitObjectA* noalias nocapture nonnull readonly align 1 %self) addrspace(1) {
102 define internal void @drop_in_place2(%TraitObjectA* nocapture %a) addrspace(1) {
107 define internal i8 @trait_fn2(%TraitObjectA* noalias nocapture nonnull readonly align 1 %self) addrspace(1) {