1 ; Test to ensure no inlining is allowed into a caller with fewer nobuiltin attributes.
2 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -S -inline | FileCheck %s
3 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -S -passes='cgscc(inline)' | FileCheck %s
5 ; Make sure we don't inline callees into a caller with a superset of the
6 ; no builtin attributes when -inline-caller-superset-nobuiltin=false.
7 ; RUN: opt < %s -inline-caller-superset-nobuiltin=false -mtriple=x86_64-unknown-linux-gnu -S -passes='cgscc(inline)' | FileCheck %s --check-prefix=NOSUPERSET
9 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
10 target triple = "x86_64-unknown-linux-gnu"
12 define i32 @allbuiltins() {
14 %call = call i32 (...) @externalfunc()
16 ; CHECK-LABEL: allbuiltins
17 ; CHECK: call i32 (...) @externalfunc()
19 declare i32 @externalfunc(...)
21 ; We can inline a function that allows all builtins into one with a single
23 define i32 @nobuiltinmemcpy() #0 {
25 %call = call i32 @allbuiltins()
27 ; CHECK-LABEL: nobuiltinmemcpy
28 ; CHECK-NOT: call i32 @allbuiltins()
29 ; NOSUPERSET-LABEL: nobuiltinmemcpy
30 ; NOSUPERSET: call i32 @allbuiltins()
33 ; We can inline a function that allows all builtins into one with all
35 define i32 @nobuiltins() #1 {
37 %call = call i32 @allbuiltins()
39 ; CHECK-LABEL: nobuiltins
40 ; CHECK-NOT: call i32 @allbuiltins()
41 ; NOSUPERSET-LABEL: nobuiltins
42 ; NOSUPERSET: call i32 @allbuiltins()
45 ; We can inline a function with a single nobuiltin into one with all nobuiltins.
46 define i32 @nobuiltins2() #1 {
48 %call = call i32 @nobuiltinmemcpy()
50 ; CHECK-LABEL: nobuiltins2
51 ; CHECK-NOT: call i32 @nobuiltinmemcpy()
52 ; NOSUPERSET-LABEL: nobuiltins2
53 ; NOSUPERSET: call i32 @nobuiltinmemcpy()
56 ; We can't inline a function with any given nobuiltin into one that allows all
58 define i32 @allbuiltins2() {
60 %call = call i32 @nobuiltinmemcpy()
62 ; CHECK-LABEL: allbuiltins2
63 ; CHECK: call i32 @nobuiltinmemcpy()
64 ; NOSUPERSET-LABEL: allbuiltins2
65 ; NOSUPERSET: call i32 @nobuiltinmemcpy()
68 ; We can't inline a function with all nobuiltins into one that allows all
70 define i32 @allbuiltins3() {
72 %call = call i32 @nobuiltins()
74 ; CHECK-LABEL: allbuiltins3
75 ; CHECK: call i32 @nobuiltins()
76 ; NOSUPERSET-LABEL: allbuiltins3
77 ; NOSUPERSET: call i32 @nobuiltins()
80 ; We can't inline a function with a specific nobuiltin into one with a
81 ; different specific nobuiltin.
82 define i32 @nobuiltinmemset() #2 {
84 %call = call i32 @nobuiltinmemcpy()
86 ; CHECK-LABEL: nobuiltinmemset
87 ; CHECK: call i32 @nobuiltinmemcpy()
88 ; NOSUPERSET-LABEL: nobuiltinmemset
89 ; NOSUPERSET: call i32 @nobuiltinmemcpy()
92 attributes #0 = { "no-builtin-memcpy" }
93 attributes #1 = { "no-builtins" }
94 attributes #2 = { "no-builtin-memset" }