| 1 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=IFUNC-ELF |
| 2 |
// RUN: %clang_cc1 -triple x86_64-pc-freebsd -emit-llvm %s -o - | FileCheck %s --check-prefix=IFUNC-ELF |
| 3 |
// RUN: %clang_cc1 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,WINDOWS |
| 4 |
// RUN: %clang_cc1 -triple x86_64-linux-musl -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,NO-IFUNC-ELF |
| 5 |
// RUN: %clang_cc1 -triple x86_64-fuchsia -emit-llvm %s -o - | FileCheck %s --check-prefixes=NO-IFUNC,NO-IFUNC-ELF |
| 6 |
// RUN: %clang_cc1 -triple x86_64-apple-macho -emit-llvm %s -o - | FileCheck %s --check-prefix=IFUNC-MACHO |
| 7 |
int __attribute__((target("sse4.2"))) foo(int i, ...) { return 0; } |
| 8 |
int __attribute__((target("arch=sandybridge"))) foo(int i, ...); |
| 9 |
int __attribute__((target("arch=ivybridge"))) foo(int i, ...) {return 1;} |
| 10 |
int __attribute__((target("default"))) foo(int i, ...) { return 2; } |
| 11 |
|
| 12 |
int bar(void) { |
| 13 |
return foo(1, 'a', 1.1) + foo(2, 2.2, "asdf"); |
| 14 |
} |
| 15 |
|
| 16 |
// IFUNC-ELF: @foo.ifunc = weak_odr ifunc i32 (i32, ...), ptr @foo.resolver |
| 17 |
// IFUNC-ELF: define{{.*}} i32 @foo.sse4.2(i32 noundef %i, ...) |
| 18 |
// IFUNC-ELF: ret i32 0 |
| 19 |
// IFUNC-ELF: define{{.*}} i32 @foo.arch_ivybridge(i32 noundef %i, ...) |
| 20 |
// IFUNC-ELF: ret i32 1 |
| 21 |
// IFUNC-ELF: define{{.*}} i32 @foo(i32 noundef %i, ...) |
| 22 |
// IFUNC-ELF: ret i32 2 |
| 23 |
// IFUNC-ELF: define{{.*}} i32 @bar() |
| 24 |
// IFUNC-ELF: call i32 (i32, ...) @foo.ifunc(i32 noundef 1, i32 noundef 97, double |
| 25 |
// IFUNC-ELF: call i32 (i32, ...) @foo.ifunc(i32 noundef 2, double noundef 2.2{{[0-9Ee+]+}}, ptr noundef |
| 26 |
|
| 27 |
// IFUNC-ELF: define weak_odr ptr @foo.resolver() #{{[0-9]+}} comdat |
| 28 |
// IFUNC-ELF: ret ptr @foo.arch_sandybridge |
| 29 |
// IFUNC-ELF: ret ptr @foo.arch_ivybridge |
| 30 |
// IFUNC-ELF: ret ptr @foo.sse4.2 |
| 31 |
// IFUNC-ELF: ret ptr @foo |
| 32 |
// IFUNC-ELF: declare i32 @foo.arch_sandybridge(i32 noundef, ...) |
| 33 |
|
| 34 |
// IFUNC-MACHO: @foo.ifunc = weak_odr ifunc i32 (i32, ...), ptr @foo.resolver |
| 35 |
// IFUNC-MACHO: define{{.*}} i32 @foo.sse4.2(i32 noundef %i, ...) |
| 36 |
// IFUNC-MACHO: ret i32 0 |
| 37 |
// IFUNC-MACHO: define{{.*}} i32 @foo.arch_ivybridge(i32 noundef %i, ...) |
| 38 |
// IFUNC-MACHO: ret i32 1 |
| 39 |
// IFUNC-MACHO: define{{.*}} i32 @foo(i32 noundef %i, ...) |
| 40 |
// IFUNC-MACHO: ret i32 2 |
| 41 |
// IFUNC-MACHO: define{{.*}} i32 @bar() |
| 42 |
// IFUNC-MACHO: call i32 (i32, ...) @foo.ifunc(i32 noundef 1, i32 noundef 97, double |
| 43 |
// IFUNC-MACHO: call i32 (i32, ...) @foo.ifunc(i32 noundef 2, double noundef 2.2{{[0-9Ee+]+}}, ptr noundef |
| 44 |
|
| 45 |
// IFUNC-MACHO: define weak_odr ptr @foo.resolver() #{{[0-9]+}} |
| 46 |
// IFUNC-MACHO: ret ptr @foo.arch_sandybridge |
| 47 |
// IFUNC-MACHO: ret ptr @foo.arch_ivybridge |
| 48 |
// IFUNC-MACHO: ret ptr @foo.sse4.2 |
| 49 |
// IFUNC-MACHO: ret ptr @foo |
| 50 |
// IFUNC-MACHO: declare i32 @foo.arch_sandybridge(i32 noundef, ...) |
| 51 |
|
| 52 |
// NO-IFUNC: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...) |
| 53 |
// NO-IFUNC: ret i32 0 |
| 54 |
// NO-IFUNC: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...) |
| 55 |
// NO-IFUNC: ret i32 1 |
| 56 |
// NO-IFUNC: define dso_local i32 @foo(i32 noundef %i, ...) |
| 57 |
// NO-IFUNC: ret i32 2 |
| 58 |
// NO-IFUNC: define dso_local i32 @bar() |
| 59 |
// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, double |
| 60 |
// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 2.2{{[0-9Ee+]+}}, ptr noundef |
| 61 |
|
| 62 |
// WINDOWS: define weak_odr dso_local i32 @foo.resolver(i32 %0, ...) #{{[0-9]+}} comdat |
| 63 |
// NO-IFUNC-ELF: define weak_odr i32 @foo.resolver(i32 %0, ...) #{{[0-9]+}} comdat |
| 64 |
// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_sandybridge |
| 65 |
// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_ivybridge |
| 66 |
// NO-IFUNC: musttail call i32 (i32, ...) @foo.sse4.2 |
| 67 |
// NO-IFUNC: musttail call i32 (i32, ...) @foo |
| 68 |
// WINDOWS: declare dso_local i32 @foo.arch_sandybridge(i32 noundef, ...) |
| 69 |
// NO-IFUNC-ELF: declare i32 @foo.arch_sandybridge(i32 noundef, ...) |