xref: /aosp_15_r20/external/llvm/test/Assembler/attribute-builtin.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker
2*9880d681SAndroid Build Coastguard Worker; Make sure that llvm-as/llvm-dis properly assembly/disassembly the 'builtin'
3*9880d681SAndroid Build Coastguard Worker; attribute.
4*9880d681SAndroid Build Coastguard Worker;
5*9880d681SAndroid Build Coastguard Worker; rdar://13727199
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as -disable-verify < %s | \
8*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dis | \
9*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as -disable-verify | \
10*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dis | \
11*9880d681SAndroid Build Coastguard Worker; RUN: FileCheck -check-prefix=CHECK-ASSEMBLES %s
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker; CHECK-ASSEMBLES: declare i8* @foo(i8*) [[NOBUILTIN:#[0-9]+]]
14*9880d681SAndroid Build Coastguard Worker; CHECK-ASSEMBLES: call i8* @foo(i8* %x) [[BUILTIN:#[0-9]+]]
15*9880d681SAndroid Build Coastguard Worker; CHECK-ASSEMBLES: attributes [[NOBUILTIN]] = { nobuiltin }
16*9880d681SAndroid Build Coastguard Worker; CHECK-ASSEMBLES: attributes [[BUILTIN]] = { builtin }
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdeclare i8* @foo(i8*) #1
19*9880d681SAndroid Build Coastguard Workerdefine i8* @bar(i8* %x) {
20*9880d681SAndroid Build Coastguard Worker  %y = call i8* @foo(i8* %x) #0
21*9880d681SAndroid Build Coastguard Worker  ret i8* %y
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker; Make sure that we do not accept the 'builtin' attribute on function
25*9880d681SAndroid Build Coastguard Worker; definitions, function declarations, and on call sites that call functions
26*9880d681SAndroid Build Coastguard Worker; which do not have nobuiltin on them.
27*9880d681SAndroid Build Coastguard Worker; rdar://13727199
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; RUN: not llvm-as <%s 2>&1  | FileCheck -check-prefix=CHECK-BAD %s
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK-BAD: Attribute 'builtin' can only be applied to a callsite.
32*9880d681SAndroid Build Coastguard Worker; CHECK-BAD-NEXT: i8* (i8*)* @car
33*9880d681SAndroid Build Coastguard Worker; CHECK-BAD: Attribute 'builtin' can only be applied to a callsite.
34*9880d681SAndroid Build Coastguard Worker; CHECK-BAD-NEXT: i8* (i8*)* @mar
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerdeclare i8* @lar(i8*)
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerdefine i8* @har(i8* %x) {
39*9880d681SAndroid Build Coastguard Worker  %y = call i8* @lar(i8* %x) #0
40*9880d681SAndroid Build Coastguard Worker  ret i8* %y
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerdefine i8* @car(i8* %x) #0 {
44*9880d681SAndroid Build Coastguard Worker  ret i8* %x
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdeclare i8* @mar(i8*) #0
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerattributes #0 = { builtin }
50*9880d681SAndroid Build Coastguard Workerattributes #1 = { nobuiltin }
51