brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · ba96798 Raw
36 lines · c
1// This verifies that structs returned from functions by value are passed2// correctly according to their attributes and the ABI.3// SEE: PR38354 5// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s6 7typedef int T0;8typedef struct { int a[16]; } T1;9 10T0 __attribute__((const)) f0(void);11T0 __attribute__((pure)) f1(void);12T1 __attribute__((const)) f2(void);13T1 __attribute__((pure)) f3(void);14int __attribute__((const)) f4(T1 a);15int __attribute__((pure)) f5(T1 a);16 17// NOTE: The int parameters verifies non-ptr parameters are not a problem18T1 __attribute__((const)) f6(void*, int);19T1 __attribute__((pure)) f7(void*, int);20 21void *ps[] = { f0, f1, f2, f3, f4, f5, f6, f7 };22 23// CHECK: declare i32 @f0() [[RN:#[0-9]+]]24// CHECK: declare i32 @f1() [[RO:#[0-9]+]]25// CHECK: declare void @f2(ptr {{[^,]*}} sret({{[^)]*}}) align 4) [[RNRW:#[0-9]+]]26// CHECK: declare void @f3(ptr {{[^,]*}} sret({{[^)]*}}) align 4) [[RORW:#[0-9]+]]27// CHECK: declare i32 @f4(ptr {{[^,]*}} byval({{[^)]*}}) align 4) [[RNRW:#[0-9]+]]28// CHECK: declare i32 @f5(ptr {{[^,]*}} byval({{[^)]*}}) align 4) [[RORW:#[0-9]+]]29// CHECK: declare void @f6(ptr {{[^,]*}} sret({{[^)]*}}) align 4, ptr {{[^,]*}} readnone, i32 {{[^,]*}}) [[RNRW:#[0-9]+]]30// CHECK: declare void @f7(ptr {{[^,]*}} sret({{[^)]*}}) align 4, ptr {{[^,]*}} readonly, i32 {{[^,]*}}) [[RORW:#[0-9]+]]31 32// CHECK: attributes [[RN]] = { nounwind willreturn memory(none){{.*}} }33// CHECK: attributes [[RO]] = { nounwind willreturn memory(read){{.*}} }34// CHECK: attributes [[RNRW]] = { nounwind willreturn memory(argmem: readwrite){{.*}} }35// CHECK: attributes [[RORW]] = { nounwind willreturn memory(read, argmem: readwrite){{.*}} }36