More range checks when compile_expressions = 1

This commit is contained in:
Alexey Milovidov 2020-08-26 19:49:19 +03:00
parent 65ee7dcb18
commit 5dbdd8ea3d
4 changed files with 17 additions and 0 deletions

View File

@ -1209,6 +1209,9 @@ public:
#if USE_EMBEDDED_COMPILER
bool isCompilableImpl(const DataTypes & arguments) const override
{
if (2 != arguments.size())
return false;
return castBothTypes(arguments[0].get(), arguments[1].get(), [&](const auto & left, const auto & right)
{
using LeftDataType = std::decay_t<decltype(left)>;
@ -1226,6 +1229,8 @@ public:
llvm::Value * compileImpl(llvm::IRBuilderBase & builder, const DataTypes & types, ValuePlaceholders values) const override
{
assert(2 == types.size() && 2 == values.size());
llvm::Value * result = nullptr;
castBothTypes(types[0].get(), types[1].get(), [&](const auto & left, const auto & right)
{

View File

@ -216,6 +216,9 @@ public:
#if USE_EMBEDDED_COMPILER
bool isCompilableImpl(const DataTypes & arguments) const override
{
if (1 != arguments.size())
return false;
return castType(arguments[0].get(), [&](const auto & type)
{
using DataType = std::decay_t<decltype(type)>;
@ -228,6 +231,8 @@ public:
llvm::Value * compileImpl(llvm::IRBuilderBase & builder, const DataTypes & types, ValuePlaceholders values) const override
{
assert(1 == types.size() && 1 == values.size());
llvm::Value * result = nullptr;
castType(types[0].get(), [&](const auto & type)
{

View File

@ -1272,6 +1272,9 @@ public:
#if USE_EMBEDDED_COMPILER
bool isCompilableImpl(const DataTypes & types) const override
{
if (2 != types.size())
return false;
auto isBigInteger = &typeIsEither<DataTypeInt64, DataTypeUInt64, DataTypeUUID>;
auto isFloatingPoint = &typeIsEither<DataTypeFloat32, DataTypeFloat64>;
if ((isBigInteger(*types[0]) && isFloatingPoint(*types[1]))
@ -1284,6 +1287,8 @@ public:
llvm::Value * compileImpl(llvm::IRBuilderBase & builder, const DataTypes & types, ValuePlaceholders values) const override
{
assert(2 == types.size() && 2 == values.size());
auto & b = static_cast<llvm::IRBuilder<> &>(builder);
auto * x = values[0]();
auto * y = values[1]();

View File

@ -161,6 +161,8 @@ public:
llvm::Value * compileImpl(llvm::IRBuilderBase & builder, const DataTypes & types, ValuePlaceholders values) const override
{
assert(!types.empty() && !values.empty());
auto & b = static_cast<llvm::IRBuilder<> &>(builder);
if constexpr (!Impl::isSaturable())
{