diff options
author | Anton Korobeynikov <anton@korobeynikov.info> | 2019-01-17 15:21:55 +0000 |
---|---|---|
committer | Anton Korobeynikov <anton@korobeynikov.info> | 2019-01-17 15:21:55 +0000 |
commit | 81cff31ccf3e1b7dd35653c964ea25d1733ba409 (patch) | |
tree | 8a9faf08b7378de5784a08df362401bc6eb79eb2 /clang/lib/CodeGen/CGBuiltin.cpp | |
parent | ce5b5b486a71939913b1a0909498f216b5528401 (diff) | |
download | bcm5719-llvm-81cff31ccf3e1b7dd35653c964ea25d1733ba409.tar.gz bcm5719-llvm-81cff31ccf3e1b7dd35653c964ea25d1733ba409.zip |
CodeGen: Cast llvm.flt.rounds result to match __builtin_flt_rounds
llvm.flt.rounds returns an i32, but the builtin expects an integer.
On targets where integers are not 32-bits clang tries to bitcast the result, causing an assertion failure.
The patch enables newlib build for msp430.
Patch by Edward Jones!
Differential Revision: https://reviews.llvm.org/D24461
llvm-svn: 351449
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 34bf194be2f..6954d32549a 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2130,6 +2130,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); } + case Builtin::BI__builtin_flt_rounds: { + Value *F = CGM.getIntrinsic(Intrinsic::flt_rounds); + + llvm::Type *ResultType = ConvertType(E->getType()); + Value *Result = Builder.CreateCall(F); + if (Result->getType() != ResultType) + Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, + "cast"); + return RValue::get(Result); + } + case Builtin::BI__builtin_fpclassify: { Value *V = EmitScalarExpr(E->getArg(5)); llvm::Type *Ty = ConvertType(E->getArg(5)->getType()); |