Skip to content

Commit 0c5a3a6

Browse files
committed
Fixups
1 parent 0121d99 commit 0c5a3a6

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ static llvm::Value *emitModfBuiltin(CodeGenFunction &CGF, const CallExpr *E,
872872

873873
QualType DestPtrType = E->getArg(1)->getType()->getPointeeType();
874874
LValue IntegralLV = CGF.MakeNaturalAlignAddrLValue(IntPartDest, DestPtrType);
875-
CGF.Builder.CreateStore(IntegralResult, IntegralLV.getAddress());
875+
CGF.EmitStoreOfScalar(IntegralResult, IntegralLV);
876876

877877
return FractionalResult;
878878
}
@@ -3277,14 +3277,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
32773277
return RValue::get(Builder.CreateFRem(Arg1, Arg2, "fmod"));
32783278
}
32793279

3280-
case Builtin::BImodf:
3281-
case Builtin::BImodff:
3282-
case Builtin::BImodfl:
3283-
case Builtin::BI__builtin_modf:
3284-
case Builtin::BI__builtin_modff:
3285-
case Builtin::BI__builtin_modfl:
3286-
return RValue::get(emitModfBuiltin(*this, E, Intrinsic::modf));
3287-
32883280
case Builtin::BIlog:
32893281
case Builtin::BIlogf:
32903282
case Builtin::BIlogl:
@@ -4122,6 +4114,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
41224114
case Builtin::BI__builtin_frexpf128:
41234115
case Builtin::BI__builtin_frexpf16:
41244116
return RValue::get(emitFrexpBuiltin(*this, E, Intrinsic::frexp));
4117+
case Builtin::BImodf:
4118+
case Builtin::BImodff:
4119+
case Builtin::BImodfl:
4120+
case Builtin::BI__builtin_modf:
4121+
case Builtin::BI__builtin_modff:
4122+
case Builtin::BI__builtin_modfl:
4123+
return RValue::get(emitModfBuiltin(*this, E, Intrinsic::modf));
41254124
case Builtin::BI__builtin_isgreater:
41264125
case Builtin::BI__builtin_isgreaterequal:
41274126
case Builtin::BI__builtin_isless:

clang/test/CodeGen/X86/math-builtins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
161161
// NO__ERRNO: declare { float, float } @llvm.modf.f32(float) [[READNONE_INTRINSIC]]
162162
// NO__ERRNO: declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80) [[READNONE_INTRINSIC]]
163163
// NO__ERRNO: declare fp128 @modff128(fp128 noundef, ptr noundef) [[NOT_READNONE:#[0-9]+]]
164-
// HAS_ERRNO: declare double @modf(double noundef, ptr noundef) [[NOT_READNONE]]
165-
// HAS_ERRNO: declare float @modff(float noundef, ptr noundef) [[NOT_READNONE]]
166-
// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80 noundef, ptr noundef) [[NOT_READNONE]]
164+
// HAS_ERRNO: declare { double, double } @llvm.modf.f64(double) [[READNONE_INTRINSIC]]
165+
// HAS_ERRNO: declare { float, float } @llvm.modf.f32(float) [[READNONE_INTRINSIC]]
166+
// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80) [[READNONE_INTRINSIC]]
167167
// HAS_ERRNO: declare fp128 @modff128(fp128 noundef, ptr noundef) [[NOT_READNONE]]
168168

169169
__builtin_nan(c); __builtin_nanf(c); __builtin_nanl(c); __builtin_nanf128(c);

clang/test/CodeGen/builtin-attributes.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: arm-registered-target
2-
// RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -fmath-errno -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s
33

44
int printf(const char *, ...);
55
void exit(int);
@@ -24,6 +24,11 @@ char* f2(char* a, char* b) {
2424
return __builtin_strstr(a, b);
2525
}
2626

27+
// Note: Use asm label to disable intrinsic lowering of modf.
28+
double modf(double x, double*) asm("modf");
29+
float modff(float x, float*) asm("modff");
30+
long double modfl(long double x, long double*) asm("modfl");
31+
2732
// frexp is NOT readnone. It writes to its pointer argument.
2833
//
2934
// CHECK: f3
@@ -55,9 +60,9 @@ int f3(double x) {
5560
frexp(x, &e);
5661
frexpf(x, &e);
5762
frexpl(x, &e);
58-
__builtin_modf(x, &e);
59-
__builtin_modff(x, &e);
60-
__builtin_modfl(x, &e);
63+
modf(x, &e);
64+
modff(x, &e);
65+
modfl(x, &e);
6166
__builtin_remquo(x, x, &e);
6267
__builtin_remquof(x, x, &e);
6368
__builtin_remquol(x, x, &e);

clang/test/CodeGen/math-builtins-long.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void foo(long double f, long double *l, int *i, const char *c) {
5858
// PPCF128: call fp128 @ldexpf128(fp128 noundef %{{.+}}, {{(signext)?.+}})
5959
__builtin_ldexpl(f,f);
6060

61-
// F80: call x86_fp80 @modfl(x86_fp80 noundef %{{.+}}, ptr noundef %{{.+}})
62-
// PPC: call ppc_fp128 @modfl(ppc_fp128 noundef %{{.+}}, ptr noundef %{{.+}})
63-
// X86F128: call fp128 @modfl(fp128 noundef %{{.+}}, ptr noundef %{{.+}})
61+
// F80: call { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80 %{{.+}})
62+
// PPC: call { ppc_fp128, ppc_fp128 } @llvm.modf.ppcf128(ppc_fp128 %{{.+}})
63+
// X86F128: call { fp128, fp128 } @llvm.modf.f128(fp128 %{{.+}})
6464
// PPCF128: call fp128 @modff128(fp128 noundef %{{.+}}, ptr noundef %{{.+}})
6565
__builtin_modfl(f,l);
6666

clang/test/CodeGen/math-libcalls.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
8686
// NO__ERRNO: declare { double, double } @llvm.modf.f64(double) [[READNONE_INTRINSIC]]
8787
// NO__ERRNO: declare { float, float } @llvm.modf.f32(float) [[READNONE_INTRINSIC]]
8888
// NO__ERRNO: declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80) [[READNONE_INTRINSIC]]
89-
// HAS_ERRNO: declare double @modf(double noundef, ptr noundef) [[NOT_READNONE]]
90-
// HAS_ERRNO: declare float @modff(float noundef, ptr noundef) [[NOT_READNONE]]
91-
// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80 noundef, ptr noundef) [[NOT_READNONE]]
89+
// HAS_ERRNO: declare { double, double } @llvm.modf.f64(double) [[READNONE_INTRINSIC]]
90+
// HAS_ERRNO: declare { float, float } @llvm.modf.f32(float) [[READNONE_INTRINSIC]]
91+
// HAS_ERRNO: declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80) [[READNONE_INTRINSIC]]
9292
// HAS_MAYTRAP: declare { double, double } @llvm.modf.f64(double) [[READNONE_INTRINSIC]]
9393
// HAS_MAYTRAP: declare { float, float } @llvm.modf.f32(float) [[READNONE_INTRINSIC]]
9494
// HAS_MAYTRAP: declare { x86_fp80, x86_fp80 } @llvm.modf.f80(x86_fp80) [[READNONE_INTRINSIC]]

0 commit comments

Comments
 (0)