================ @@ -46,21 +48,71 @@ extern "C" double foo_fabs (double num[]) { // CHECK-NEXT: [[ENTRY:.*:]] // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 80 // CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8]] -// CHECK-NEXT: [[CALL:%.*]] = tail call double @remainder(double noundef [[TMP0]], double noundef [[A]]) #[[ATTR4]], !tbaa [[TBAA6]] +// CHECK-NEXT: [[CALL:%.*]] = tail call double @remainder(double noundef [[TMP0]], double noundef [[A]]) #[[ATTR9]], !tbaa [[TBAA6]] // CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP0]], [[CALL]] // CHECK-NEXT: ret double [[MUL]] // -extern "C" double foo_remainder (double num[], double a) { +double foo_remainder (double num[], double a) { const double expm2 = remainder(num[10], a); // Emit TBAA metadata double tmp = expm2 * num[10]; return tmp; } +// +// Negative test: frexp is not subject to any errors. +// CHECK-LABEL: define dso_local double @foo_frexp( +// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], double noundef [[A:%.*]]) local_unnamed_addr #[[ATTR5:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[E:%.*]] = alloca i32, align 4 +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[E]]) #[[ATTR9]] +// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 16 +// CHECK-NEXT: [[TMP0:%.*]] = load double, ptr [[ARRAYIDX]], align 8, !tbaa [[TBAA8]] +// CHECK-NEXT: [[CALL:%.*]] = call double @frexp(double noundef [[TMP0]], ptr noundef nonnull [[E]]) #[[ATTR9]] +// CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP0]], [[CALL]] +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr nonnull [[E]]) #[[ATTR9]] +// CHECK-NEXT: ret double [[MUL]] +// +double foo_frexp (double num[], double a) { + int e; + double expm2 = frexp(num[2], &e); // Don't emit TBAA metadata + double tmp = expm2 * num[2]; + return tmp; +} + +// +// Negative test: sincos is a library function, but is not a builtin function +// checked in CodeGenFunction::EmitCallExpr. +// CHECK-LABEL: define dso_local float @foo_sincos( +// CHECK-SAME: ptr nocapture noundef readonly [[NUM:%.*]], float noundef [[A:%.*]]) local_unnamed_addr #[[ATTR7:[0-9]+]] { +// CHECK-NEXT: [[ENTRY:.*:]] +// CHECK-NEXT: [[SIN:%.*]] = alloca float, align 4 +// CHECK-NEXT: [[COS:%.*]] = alloca float, align 4 +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[SIN]]) #[[ATTR9]] +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[COS]]) #[[ATTR9]] +// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[NUM]], i64 8 +// CHECK-NEXT: [[TMP0:%.*]] = load float, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]] +// CHECK-NEXT: call void @sincos(float noundef [[TMP0]], ptr noundef nonnull [[SIN]], ptr noundef nonnull [[COS]]) #[[ATTR9]] ---------------- arsenm wrote:
sincos can set errno, so I'm not sure how this managed to skip the tbaa check https://github.com/llvm/llvm-project/pull/100302 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits