105 lines · cpp
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 62// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,LINUX3// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,DARWIN4// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS5 6 7// Aliases for ifuncs8 9// Overloaded ifuncs10// struct 'C' ifuncs, note the 'float, U' one doesn't get one.11 12//13int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }14 15 16//17int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }18 19 20// LINUX-LABEL: define dso_local void @_Z14use_overloadedv(21// LINUX-SAME: ) #[[ATTR1:[0-9]+]] {22// LINUX-NEXT: [[ENTRY:.*:]]23// LINUX-NEXT: [[CALL:%.*]] = call noundef i32 @_Z10overloadedi(i32 noundef 1)24// LINUX-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z10overloadedPKc(ptr noundef null)25// LINUX-NEXT: ret void26//27// DARWIN-LABEL: define void @_Z14use_overloadedv(28// DARWIN-SAME: ) #[[ATTR1:[0-9]+]] {29// DARWIN-NEXT: [[ENTRY:.*:]]30// DARWIN-NEXT: [[CALL:%.*]] = call noundef i32 @_Z10overloadedi(i32 noundef 1)31// DARWIN-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z10overloadedPKc(ptr noundef null)32// DARWIN-NEXT: ret void33//34void use_overloaded() {35 overloaded(1);36 overloaded(nullptr);37}38 39template<typename T, typename U>40struct C {41int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}42};43template<typename U>44struct C<int, U> {45int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 2;}46};47template<typename U>48struct C<float, U> {49int foo(){ return 2;}50};51template<>52//53struct C<double, float> {54int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 3;}55};56 57// LINUX-LABEL: define dso_local void @_Z16uses_specializedv(58// LINUX-SAME: ) #[[ATTR1]] {59// LINUX-NEXT: [[ENTRY:.*:]]60// LINUX-NEXT: [[C:%.*]] = alloca [[STRUCT_C:%.*]], align 161// LINUX-NEXT: [[C2:%.*]] = alloca [[STRUCT_C_0:%.*]], align 162// LINUX-NEXT: [[C3:%.*]] = alloca [[STRUCT_C_1:%.*]], align 163// LINUX-NEXT: [[C4:%.*]] = alloca [[STRUCT_C_2:%.*]], align 164// LINUX-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN1CIssE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C]])65// LINUX-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZN1CIisE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C2]])66// LINUX-NEXT: [[CALL2:%.*]] = call noundef i32 @_ZN1CIfsE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C3]])67// LINUX-NEXT: [[CALL3:%.*]] = call noundef i32 @_ZN1CIdfE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C4]])68// LINUX-NEXT: ret void69//70// DARWIN-LABEL: define void @_Z16uses_specializedv(71// DARWIN-SAME: ) #[[ATTR1]] {72// DARWIN-NEXT: [[ENTRY:.*:]]73// DARWIN-NEXT: [[C:%.*]] = alloca [[STRUCT_C:%.*]], align 174// DARWIN-NEXT: [[C2:%.*]] = alloca [[STRUCT_C_0:%.*]], align 175// DARWIN-NEXT: [[C3:%.*]] = alloca [[STRUCT_C_1:%.*]], align 176// DARWIN-NEXT: [[C4:%.*]] = alloca [[STRUCT_C_2:%.*]], align 177// DARWIN-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN1CIssE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C]])78// DARWIN-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZN1CIisE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C2]])79// DARWIN-NEXT: [[CALL2:%.*]] = call noundef i32 @_ZN1CIfsE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C3]])80// DARWIN-NEXT: [[CALL3:%.*]] = call noundef i32 @_ZN1CIdfE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C4]])81// DARWIN-NEXT: ret void82//83void uses_specialized() {84 C<short, short> c;85 c.foo();86 C<int, short> c2;87 c2.foo();88 C<float, short> c3;89 c3.foo();90 // Note this is not an ifunc/mv91 C<double, float> c4;92 c4.foo();93}94 95 96 97 98 99 100 101 102//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:103// ITANIUM: {{.*}}104// WINDOWS: {{.*}}105