294 lines · c
1// REQUIRES: amdgpu-registered-target2// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature3// RUN: %clang_cc1 -cc1 -std=c23 -triple amdgcn-amd-amdhsa -emit-llvm -O1 %s -o - | FileCheck %s4 5void sink_0(...);6void sink_1(int, ...);7void sink_2(double, int, ...);8 9// Simple scalar values10 11// CHECK-LABEL: define {{[^@]+}}@zero_varargs12// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {13// CHECK-NEXT: entry:14// CHECK-NEXT: tail call void (...) @sink_0() #[[ATTR2:[0-9]+]]15// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]]) #[[ATTR2]]16// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]]) #[[ATTR2]]17// CHECK-NEXT: ret void18//19void zero_varargs(int f0, double f1)20{21 sink_0();22 sink_1(f0);23 sink_2(f1, f0);24}25 26// CHECK-LABEL: define {{[^@]+}}@one_i3227// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i32 noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {28// CHECK-NEXT: entry:29// CHECK-NEXT: tail call void (...) @sink_0(i32 noundef [[V0]]) #[[ATTR2]]30// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], i32 noundef [[V0]]) #[[ATTR2]]31// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], i32 noundef [[V0]]) #[[ATTR2]]32// CHECK-NEXT: ret void33//34void one_i32(int f0, double f1, int v0)35{36 sink_0(v0);37 sink_1(f0, v0);38 sink_2(f1, f0, v0);39}40 41// CHECK-LABEL: define {{[^@]+}}@one_ptr42// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], ptr noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {43// CHECK-NEXT: entry:44// CHECK-NEXT: tail call void (...) @sink_0(ptr noundef [[V0]]) #[[ATTR2]]45// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], ptr noundef [[V0]]) #[[ATTR2]]46// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], ptr noundef [[V0]]) #[[ATTR2]]47// CHECK-NEXT: ret void48//49void one_ptr(int f0, double f1, void* v0)50{51 sink_0(v0);52 sink_1(f0, v0);53 sink_2(f1, f0, v0);54}55 56// CHECK-LABEL: define {{[^@]+}}@one_f6457// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], double noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {58// CHECK-NEXT: entry:59// CHECK-NEXT: tail call void (...) @sink_0(double noundef [[V0]]) #[[ATTR2]]60// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], double noundef [[V0]]) #[[ATTR2]]61// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], double noundef [[V0]]) #[[ATTR2]]62// CHECK-NEXT: ret void63//64void one_f64(int f0, double f1, double v0)65{66 sink_0(v0);67 sink_1(f0, v0);68 sink_2(f1, f0, v0);69}70 71 72// C has various type promotion rules for variadics73 74// CHECK-LABEL: define {{[^@]+}}@one_i875// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i8 noundef signext [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {76// CHECK-NEXT: entry:77// CHECK-NEXT: [[CONV:%.*]] = sext i8 [[V0]] to i3278// CHECK-NEXT: tail call void (...) @sink_0(i32 noundef [[CONV]]) #[[ATTR2]]79// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], i32 noundef [[CONV]]) #[[ATTR2]]80// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], i32 noundef [[CONV]]) #[[ATTR2]]81// CHECK-NEXT: ret void82//83void one_i8(int f0, double f1, char v0)84{85 sink_0(v0);86 sink_1(f0, v0);87 sink_2(f1, f0, v0);88}89 90// CHECK-LABEL: define {{[^@]+}}@one_i1691// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i16 noundef signext [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {92// CHECK-NEXT: entry:93// CHECK-NEXT: [[CONV:%.*]] = sext i16 [[V0]] to i3294// CHECK-NEXT: tail call void (...) @sink_0(i32 noundef [[CONV]]) #[[ATTR2]]95// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], i32 noundef [[CONV]]) #[[ATTR2]]96// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], i32 noundef [[CONV]]) #[[ATTR2]]97// CHECK-NEXT: ret void98//99void one_i16(int f0, double f1, short v0)100{101 sink_0(v0);102 sink_1(f0, v0);103 sink_2(f1, f0, v0);104}105 106// CHECK-LABEL: define {{[^@]+}}@one_f32107// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], float noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {108// CHECK-NEXT: entry:109// CHECK-NEXT: [[CONV:%.*]] = fpext float [[V0]] to double110// CHECK-NEXT: tail call void (...) @sink_0(double noundef [[CONV]]) #[[ATTR2]]111// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], double noundef [[CONV]]) #[[ATTR2]]112// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], double noundef [[CONV]]) #[[ATTR2]]113// CHECK-NEXT: ret void114//115void one_f32(int f0, double f1, float v0)116{117 sink_0(v0);118 sink_1(f0, v0);119 sink_2(f1, f0, v0);120}121 122 123// Various half types. _Float16 is passed as half and __fp16 as double124 125// CHECK-LABEL: define {{[^@]+}}@one_f16a126// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], half noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {127// CHECK-NEXT: entry:128// CHECK-NEXT: tail call void (...) @sink_0(half noundef [[V0]]) #[[ATTR2]]129// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], half noundef [[V0]]) #[[ATTR2]]130// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], half noundef [[V0]]) #[[ATTR2]]131// CHECK-NEXT: ret void132//133void one_f16a(int f0, double f1, _Float16 v0)134{135 sink_0(v0);136 sink_1(f0, v0);137 sink_2(f1, f0, v0);138}139 140// CHECK-LABEL: define {{[^@]+}}@one_f16b141// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], half noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {142// CHECK-NEXT: entry:143// CHECK-NEXT: [[CONV:%.*]] = fpext half [[V0]] to double144// CHECK-NEXT: tail call void (...) @sink_0(double noundef [[CONV]]) #[[ATTR2]]145// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], double noundef [[CONV]]) #[[ATTR2]]146// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], double noundef [[CONV]]) #[[ATTR2]]147// CHECK-NEXT: ret void148//149void one_f16b(int f0, double f1, __fp16 v0)150{151 sink_0(v0);152 sink_1(f0, v0);153 sink_2(f1, f0, v0);154}155 156// CHECK-LABEL: define {{[^@]+}}@one_f16c157// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], bfloat noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {158// CHECK-NEXT: entry:159// CHECK-NEXT: tail call void (...) @sink_0(bfloat noundef [[V0]]) #[[ATTR2]]160// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], bfloat noundef [[V0]]) #[[ATTR2]]161// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], bfloat noundef [[V0]]) #[[ATTR2]]162// CHECK-NEXT: ret void163//164void one_f16c(int f0, double f1, __bf16 v0)165{166 sink_0(v0);167 sink_1(f0, v0);168 sink_2(f1, f0, v0);169}170 171// Simple composites172 173typedef struct174{175 double x0;176 double x1;177} pair_f64;178 179// CHECK-LABEL: define {{[^@]+}}@one_pair_f64180// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], double [[V0_COERCE0:%.*]], double [[V0_COERCE1:%.*]]) local_unnamed_addr #[[ATTR0]] {181// CHECK-NEXT: entry:182// CHECK-NEXT: [[DOTFCA_0_INSERT:%.*]] = insertvalue [[STRUCT_PAIR_F64:%.*]] poison, double [[V0_COERCE0]], 0183// CHECK-NEXT: [[DOTFCA_1_INSERT:%.*]] = insertvalue [[STRUCT_PAIR_F64]] [[DOTFCA_0_INSERT]], double [[V0_COERCE1]], 1184// CHECK-NEXT: tail call void (...) @sink_0([[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]]) #[[ATTR2]]185// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], [[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]]) #[[ATTR2]]186// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], [[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]]) #[[ATTR2]]187// CHECK-NEXT: ret void188//189void one_pair_f64(int f0, double f1, pair_f64 v0)190{191 sink_0(v0);192 sink_1(f0, v0);193 sink_2(f1, f0, v0);194}195 196typedef double v2f64 __attribute__((ext_vector_type(2)));197 198// CHECK-LABEL: define {{[^@]+}}@one_pair_v2f64199// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], <2 x double> noundef [[V0:%.*]]) local_unnamed_addr #[[ATTR0]] {200// CHECK-NEXT: entry:201// CHECK-NEXT: tail call void (...) @sink_0(<2 x double> noundef [[V0]]) #[[ATTR2]]202// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], <2 x double> noundef [[V0]]) #[[ATTR2]]203// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], <2 x double> noundef [[V0]]) #[[ATTR2]]204// CHECK-NEXT: ret void205//206void one_pair_v2f64(int f0, double f1, v2f64 v0)207{208 sink_0(v0);209 sink_1(f0, v0);210 sink_2(f1, f0, v0);211}212 213typedef union214{215 float x0;216 int x1;217} union_f32_i32;218 219// CHECK-LABEL: define {{[^@]+}}@one_pair_union_f32_i32220// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i32 [[V0_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {221// CHECK-NEXT: entry:222// CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 [[V0_COERCE]] to float223// CHECK-NEXT: [[DOTFCA_0_INSERT:%.*]] = insertvalue [[UNION_UNION_F32_I32:%.*]] poison, float [[TMP0]], 0224// CHECK-NEXT: tail call void (...) @sink_0([[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]225// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], [[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]226// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], [[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]227// CHECK-NEXT: ret void228//229void one_pair_union_f32_i32(int f0, double f1, union_f32_i32 v0)230{231 sink_0(v0);232 sink_1(f0, v0);233 sink_2(f1, f0, v0);234}235 236typedef union237{238 int x0;239 float x1;240} transparent_union_f32_i32 __attribute__((transparent_union));241 242// CHECK-LABEL: define {{[^@]+}}@one_pair_transparent_union_f32_i32243// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i32 [[V0_COERCE:%.*]]) local_unnamed_addr #[[ATTR0]] {244// CHECK-NEXT: entry:245// CHECK-NEXT: [[DOTFCA_0_INSERT:%.*]] = insertvalue [[UNION_TRANSPARENT_UNION_F32_I32:%.*]] poison, i32 [[V0_COERCE]], 0246// CHECK-NEXT: tail call void (...) @sink_0([[UNION_TRANSPARENT_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]247// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], [[UNION_TRANSPARENT_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]248// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], [[UNION_TRANSPARENT_UNION_F32_I32]] [[DOTFCA_0_INSERT]]) #[[ATTR2]]249// CHECK-NEXT: ret void250//251void one_pair_transparent_union_f32_i32(int f0, double f1, transparent_union_f32_i32 v0)252{253 sink_0(v0);254 sink_1(f0, v0);255 sink_2(f1, f0, v0);256}257 258// Passing multiple values in the variadic pack259 260// CHECK-LABEL: define {{[^@]+}}@multiple_one261// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], i32 noundef [[V0:%.*]], double noundef [[V1:%.*]]) local_unnamed_addr #[[ATTR0]] {262// CHECK-NEXT: entry:263// CHECK-NEXT: tail call void (...) @sink_0(i32 noundef [[V0]], double noundef [[V1]]) #[[ATTR2]]264// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], i32 noundef [[V0]], double noundef [[V1]]) #[[ATTR2]]265// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], i32 noundef [[V0]], double noundef [[V1]]) #[[ATTR2]]266// CHECK-NEXT: ret void267//268void multiple_one(int f0, double f1, int v0, double v1)269{270 sink_0(v0, v1);271 sink_1(f0, v0, v1);272 sink_2(f1, f0, v0, v1);273}274 275// CHECK-LABEL: define {{[^@]+}}@multiple_two276// CHECK-SAME: (i32 noundef [[F0:%.*]], double noundef [[F1:%.*]], double [[V0_COERCE0:%.*]], double [[V0_COERCE1:%.*]], float noundef [[V1:%.*]], i32 [[V2_COERCE:%.*]], i32 noundef [[V3:%.*]]) local_unnamed_addr #[[ATTR0]] {277// CHECK-NEXT: entry:278// CHECK-NEXT: [[TMP0:%.*]] = bitcast i32 [[V2_COERCE]] to float279// CHECK-NEXT: [[CONV:%.*]] = fpext float [[V1]] to double280// CHECK-NEXT: [[DOTFCA_0_INSERT16:%.*]] = insertvalue [[STRUCT_PAIR_F64:%.*]] poison, double [[V0_COERCE0]], 0281// CHECK-NEXT: [[DOTFCA_1_INSERT:%.*]] = insertvalue [[STRUCT_PAIR_F64]] [[DOTFCA_0_INSERT16]], double [[V0_COERCE1]], 1282// CHECK-NEXT: [[DOTFCA_0_INSERT:%.*]] = insertvalue [[UNION_UNION_F32_I32:%.*]] poison, float [[TMP0]], 0283// CHECK-NEXT: tail call void (...) @sink_0([[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]], double noundef [[CONV]], [[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]], i32 noundef [[V3]]) #[[ATTR2]]284// CHECK-NEXT: tail call void (i32, ...) @sink_1(i32 noundef [[F0]], [[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]], double noundef [[CONV]], [[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]], i32 noundef [[V3]]) #[[ATTR2]]285// CHECK-NEXT: tail call void (double, i32, ...) @sink_2(double noundef [[F1]], i32 noundef [[F0]], [[STRUCT_PAIR_F64]] [[DOTFCA_1_INSERT]], double noundef [[CONV]], [[UNION_UNION_F32_I32]] [[DOTFCA_0_INSERT]], i32 noundef [[V3]]) #[[ATTR2]]286// CHECK-NEXT: ret void287//288void multiple_two(int f0, double f1, pair_f64 v0, float v1, union_f32_i32 v2, int v3)289{290 sink_0(v0, v1, v2, v3);291 sink_1(f0, v0, v1, v2, v3);292 sink_2(f1, f0, v0, v1, v2, v3);293}294