brintos

brintos / llvm-project-archived public Read only

0
0
Text · 10.0 KiB · 59581b4 Raw
231 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,LINUX2// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,DARWIN3// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS4 5struct S {6  int __attribute__((target("sse4.2"))) foo(int) { return 0; }7  int __attribute__((target("arch=sandybridge"))) foo(int);8  int __attribute__((target("arch=ivybridge"))) foo(int) { return 1; }9  int __attribute__((target("default"))) foo(int) { return 2; }10 11  S &__attribute__((target("arch=ivybridge"))) operator=(const S &) {12    return *this;13  }14  S &__attribute__((target("default"))) operator=(const S &) {15    return *this;16  }17};18 19struct ConvertTo {20  __attribute__((target("arch=ivybridge"))) operator S() const {21    return S{};22  }23  __attribute__((target("default"))) operator S() const {24    return S{};25  }26};27 28int bar() {29  S s;30  S s2;31  s2 = s;32 33  ConvertTo C;34  s2 = static_cast<S>(C);35 36  return s.foo(0);37}38 39struct S2 {40  int __attribute__((target("sse4.2"))) foo(int);41  int __attribute__((target("arch=sandybridge"))) foo(int);42  int __attribute__((target("arch=ivybridge"))) foo(int);43  int __attribute__((target("default"))) foo(int);44};45 46int bar2() {47  S2 s;48  return s.foo(0);49}50 51int __attribute__((target("sse4.2"))) S2::foo(int) { return 0; }52int __attribute__((target("arch=ivybridge"))) S2::foo(int) { return 1; }53int __attribute__((target("default"))) S2::foo(int) { return 2; }54 55template<typename T>56struct templ {57  int __attribute__((target("sse4.2"))) foo(int) { return 0; }58  int __attribute__((target("arch=sandybridge"))) foo(int);59  int __attribute__((target("arch=ivybridge"))) foo(int) { return 1; }60  int __attribute__((target("default"))) foo(int) { return 2; }61};62 63int templ_use() {64  templ<int> a;65  templ<double> b;66  return a.foo(1) + b.foo(2);67}68 69// DARWIN-NOT: comdat70 71// ITANIUM: @_ZN1SaSERKS_.ifunc = weak_odr ifunc ptr (ptr, ptr), ptr @_ZN1SaSERKS_.resolver72// ITANIUM: @_ZNK9ConvertTocv1SEv.ifunc = weak_odr ifunc void (ptr), ptr @_ZNK9ConvertTocv1SEv.resolver73// ITANIUM: @_ZN1S3fooEi.ifunc = weak_odr ifunc i32 (ptr, i32), ptr @_ZN1S3fooEi.resolver74// ITANIUM: @_ZN2S23fooEi.ifunc = weak_odr ifunc i32 (ptr, i32), ptr @_ZN2S23fooEi.resolver75// Templates:76// ITANIUM: @_ZN5templIiE3fooEi.ifunc = weak_odr ifunc i32 (ptr, i32), ptr @_ZN5templIiE3fooEi.resolver77// ITANIUM: @_ZN5templIdE3fooEi.ifunc = weak_odr ifunc i32 (ptr, i32), ptr @_ZN5templIdE3fooEi.resolver78 79// ITANIUM: define{{.*}} i32 @_Z3barv()80// ITANIUM: %s = alloca %struct.S, align 181// ITANIUM: %s2 = alloca %struct.S, align 182// ITANIUM: %C = alloca %struct.ConvertTo, align 183// ITANIUM: call noundef nonnull align 1 dereferenceable(1) ptr @_ZN1SaSERKS_.ifunc(ptr {{[^,]*}} %s284// ITANIUM: call void @_ZNK9ConvertTocv1SEv.ifunc(ptr {{[^,]*}} %C)85// ITANIUM: call noundef nonnull align 1 dereferenceable(1) ptr @_ZN1SaSERKS_.ifunc(ptr {{[^,]*}} %s286// ITANIUM: call noundef i32 @_ZN1S3fooEi.ifunc(ptr {{[^,]*}} %s, i32 noundef 0)87 88// WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"()89// WINDOWS: %s = alloca %struct.S, align 190// WINDOWS: %s2 = alloca %struct.S, align 191// WINDOWS: %C = alloca %struct.ConvertTo, align 192// WINDOWS: call noundef nonnull align 1 dereferenceable(1) ptr @"??4S@@QEAAAEAU0@AEBU0@@Z.resolver"(ptr {{[^,]*}} %s293// WINDOWS: call void @"??BConvertTo@@QEBA?AUS@@XZ.resolver"(ptr {{[^,]*}} %C94// WINDOWS: call noundef nonnull align 1 dereferenceable(1) ptr @"??4S@@QEAAAEAU0@AEBU0@@Z.resolver"(ptr {{[^,]*}} %s295// WINDOWS: call noundef i32 @"?foo@S@@QEAAHH@Z.resolver"(ptr {{[^,]*}} %s, i32 noundef 0)96 97// ITANIUM: define weak_odr ptr @_ZN1SaSERKS_.resolver()98// LINUX-SAME: comdat99// ITANIUM: ret ptr @_ZN1SaSERKS_.arch_ivybridge100// ITANIUM: ret ptr @_ZN1SaSERKS_101 102// WINDOWS: define weak_odr dso_local ptr @"??4S@@QEAAAEAU0@AEBU0@@Z.resolver"(ptr %0, ptr %1)103// WINDOWS: call ptr @"??4S@@QEAAAEAU0@AEBU0@@Z.arch_ivybridge"104// WINDOWS: call ptr @"??4S@@QEAAAEAU0@AEBU0@@Z"105 106// ITANIUM: define weak_odr ptr @_ZNK9ConvertTocv1SEv.resolver()107// LINUX-SAME: comdat108// ITANIUM: ret ptr @_ZNK9ConvertTocv1SEv.arch_ivybridge109// ITANIUM: ret ptr @_ZNK9ConvertTocv1SEv110 111// WINDOWS: define weak_odr dso_local void @"??BConvertTo@@QEBA?AUS@@XZ.resolver"(ptr %0, ptr %1)112// WINDOWS: call void @"??BConvertTo@@QEBA?AUS@@XZ.arch_ivybridge"113// WINDOWS: call void @"??BConvertTo@@QEBA?AUS@@XZ"114 115// ITANIUM: define weak_odr ptr @_ZN1S3fooEi.resolver()116// LINUX-SAME: comdat117// ITANIUM: ret ptr @_ZN1S3fooEi.arch_sandybridge118// ITANIUM: ret ptr @_ZN1S3fooEi.arch_ivybridge119// ITANIUM: ret ptr @_ZN1S3fooEi.sse4.2120// ITANIUM: ret ptr @_ZN1S3fooEi121 122// WINDOWS: define weak_odr dso_local i32 @"?foo@S@@QEAAHH@Z.resolver"(ptr %0, i32 %1)123// WINDOWS: call i32 @"?foo@S@@QEAAHH@Z.arch_sandybridge"124// WINDOWS: call i32 @"?foo@S@@QEAAHH@Z.arch_ivybridge"125// WINDOWS: call i32 @"?foo@S@@QEAAHH@Z.sse4.2"126// WINDOWS: call i32 @"?foo@S@@QEAAHH@Z"127 128// ITANIUM: define{{.*}} i32 @_Z4bar2v()129// ITANIUM: call noundef i32 @_ZN2S23fooEi.ifunc130 131// WINDOWS: define dso_local noundef i32 @"?bar2@@YAHXZ"()132// WINDOWS: call noundef i32 @"?foo@S2@@QEAAHH@Z.resolver"133 134// ITANIUM: define weak_odr ptr @_ZN2S23fooEi.resolver()135// LINUX-SAME: comdat136// ITANIUM: ret ptr @_ZN2S23fooEi.arch_sandybridge137// ITANIUM: ret ptr @_ZN2S23fooEi.arch_ivybridge138// ITANIUM: ret ptr @_ZN2S23fooEi.sse4.2139// ITANIUM: ret ptr @_ZN2S23fooEi140 141// WINDOWS: define weak_odr dso_local i32 @"?foo@S2@@QEAAHH@Z.resolver"(ptr %0, i32 %1)142// WINDOWS: call i32 @"?foo@S2@@QEAAHH@Z.arch_sandybridge"143// WINDOWS: call i32 @"?foo@S2@@QEAAHH@Z.arch_ivybridge"144// WINDOWS: call i32 @"?foo@S2@@QEAAHH@Z.sse4.2"145// WINDOWS: call i32 @"?foo@S2@@QEAAHH@Z"146 147// ITANIUM: define{{.*}} i32 @_ZN2S23fooEi.sse4.2(ptr {{[^,]*}} %this, i32 noundef %0)148// ITANIUM: define{{.*}} i32 @_ZN2S23fooEi.arch_ivybridge(ptr {{[^,]*}} %this, i32 noundef %0)149// ITANIUM: define{{.*}} i32 @_ZN2S23fooEi(ptr {{[^,]*}} %this, i32 noundef %0)150 151// WINDOWS: define dso_local noundef i32 @"?foo@S2@@QEAAHH@Z.sse4.2"(ptr {{[^,]*}} %this, i32 noundef %0)152// WINDOWS: define dso_local noundef i32 @"?foo@S2@@QEAAHH@Z.arch_ivybridge"(ptr {{[^,]*}} %this, i32 noundef %0)153// WINDOWS: define dso_local noundef i32 @"?foo@S2@@QEAAHH@Z"(ptr {{[^,]*}} %this, i32 noundef %0)154 155// ITANIUM: define{{.*}} i32 @_Z9templ_usev()156// ITANIUM: call noundef i32 @_ZN5templIiE3fooEi.ifunc157// ITANIUM: call noundef i32 @_ZN5templIdE3fooEi.ifunc158 159// WINDOWS: define dso_local noundef i32 @"?templ_use@@YAHXZ"()160// WINDOWS: call noundef i32 @"?foo@?$templ@H@@QEAAHH@Z.resolver"161// WINDOWS: call noundef i32 @"?foo@?$templ@N@@QEAAHH@Z.resolver"162 163// ITANIUM: define weak_odr ptr @_ZN5templIiE3fooEi.resolver()164// LINUX-SAME: comdat165// ITANIUM: ret ptr @_ZN5templIiE3fooEi.arch_sandybridge166// ITANIUM: ret ptr @_ZN5templIiE3fooEi.arch_ivybridge167// ITANIUM: ret ptr @_ZN5templIiE3fooEi.sse4.2168// ITANIUM: ret ptr @_ZN5templIiE3fooEi169 170// WINDOWS: define weak_odr dso_local i32 @"?foo@?$templ@H@@QEAAHH@Z.resolver"(ptr %0, i32 %1)171// WINDOWS: call i32 @"?foo@?$templ@H@@QEAAHH@Z.arch_sandybridge"172// WINDOWS: call i32 @"?foo@?$templ@H@@QEAAHH@Z.arch_ivybridge"173// WINDOWS: call i32 @"?foo@?$templ@H@@QEAAHH@Z.sse4.2"174// WINDOWS: call i32 @"?foo@?$templ@H@@QEAAHH@Z"175 176// ITANIUM: define weak_odr ptr @_ZN5templIdE3fooEi.resolver()177// LINUX-SAME: comdat178// ITANIUM: ret ptr @_ZN5templIdE3fooEi.arch_sandybridge179// ITANIUM: ret ptr @_ZN5templIdE3fooEi.arch_ivybridge180// ITANIUM: ret ptr @_ZN5templIdE3fooEi.sse4.2181// ITANIUM: ret ptr @_ZN5templIdE3fooEi182 183// WINDOWS: define weak_odr dso_local i32 @"?foo@?$templ@N@@QEAAHH@Z.resolver"(ptr %0, i32 %1) 184// WINDOWS-SAME: comdat185// WINDOWS: call i32 @"?foo@?$templ@N@@QEAAHH@Z.arch_sandybridge"186// WINDOWS: call i32 @"?foo@?$templ@N@@QEAAHH@Z.arch_ivybridge"187// WINDOWS: call i32 @"?foo@?$templ@N@@QEAAHH@Z.sse4.2"188// WINDOWS: call i32 @"?foo@?$templ@N@@QEAAHH@Z"189 190// ITANIUM: define linkonce_odr noundef i32 @_ZN1S3fooEi.sse4.2(ptr {{[^,]*}} %this, i32 noundef %0)191// ITANIUM: ret i32 0192 193// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@S@@QEAAHH@Z.sse4.2"(ptr {{[^,]*}} %this, i32 noundef %0)194// WINDOWS: ret i32 0195 196// ITANIUM: declare noundef i32 @_ZN1S3fooEi.arch_sandybridge(ptr {{[^,]*}}, i32 noundef)197 198// WINDOWS: declare dso_local noundef i32 @"?foo@S@@QEAAHH@Z.arch_sandybridge"(ptr {{[^,]*}}, i32 noundef)199 200// ITANIUM: define linkonce_odr noundef i32 @_ZN1S3fooEi.arch_ivybridge(ptr {{[^,]*}} %this, i32 noundef %0)201// ITANIUM: ret i32 1202 203// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@S@@QEAAHH@Z.arch_ivybridge"(ptr {{[^,]*}} %this, i32 noundef %0)204// WINDOWS: ret i32 1205 206// ITANIUM: define linkonce_odr noundef i32 @_ZN1S3fooEi(ptr {{[^,]*}} %this, i32 noundef %0)207// ITANIUM: ret i32 2208 209// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@S@@QEAAHH@Z"(ptr {{[^,]*}} %this, i32 noundef %0)210// WINDOWS: ret i32 2211 212// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIiE3fooEi.sse4.2213// ITANIUM: declare noundef i32 @_ZN5templIiE3fooEi.arch_sandybridge214// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIiE3fooEi.arch_ivybridge215// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIiE3fooEi216 217// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@H@@QEAAHH@Z.sse4.2"218// WINDOWS: declare dso_local noundef i32 @"?foo@?$templ@H@@QEAAHH@Z.arch_sandybridge"219// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@H@@QEAAHH@Z.arch_ivybridge"220// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@H@@QEAAHH@Z"221 222// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIdE3fooEi.sse4.2223// ITANIUM: declare noundef i32 @_ZN5templIdE3fooEi.arch_sandybridge224// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIdE3fooEi.arch_ivybridge225// ITANIUM: define linkonce_odr noundef i32 @_ZN5templIdE3fooEi226 227// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@N@@QEAAHH@Z.sse4.2"228// WINDOWS: declare dso_local noundef i32 @"?foo@?$templ@N@@QEAAHH@Z.arch_sandybridge"229// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@N@@QEAAHH@Z.arch_ivybridge"230// WINDOWS: define linkonce_odr dso_local noundef i32 @"?foo@?$templ@N@@QEAAHH@Z"231