aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov <ivanmorozov@yandex-team.com>2023-01-21 16:38:30 +0300
committerivanmorozov <ivanmorozov@yandex-team.com>2023-01-21 16:38:30 +0300
commit3b28556d63f5dd65bc3287ab9d18bf55e2e7ef8a (patch)
treedf4faee482ab5b331604eeed0d613b2cfefb5dee
parentb78bf978d416289812a7fc33fa068ca6e487afbc (diff)
downloadydb-3b28556d63f5dd65bc3287ab9d18bf55e2e7ef8a.tar.gz
dont allocate useless memory in release mode
-rw-r--r--ydb/library/yql/minikql/comp_nodes/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/minikql/comp_nodes/CMakeLists.linux-aarch64.txt2
-rw-r--r--ydb/library/yql/minikql/comp_nodes/CMakeLists.linux.txt2
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_combine.cpp78
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp11
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_join.cpp10
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp5
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.h58
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_squeeze_to_list.cpp48
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_switch.cpp142
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_todict.cpp72
-rw-r--r--ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp89
-rw-r--r--ydb/library/yql/minikql/computation/mkql_computation_node_impl.h12
-rw-r--r--ydb/library/yql/minikql/perf/mt_param/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/minikql/perf/packer/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/minikql/perf/param/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/parser/pg_wrapper/ut/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/udfs/common/stat/ut/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/udfs/common/topfreq/ut/CMakeLists.darwin.txt2
19 files changed, 379 insertions, 164 deletions
diff --git a/ydb/library/yql/minikql/comp_nodes/CMakeLists.darwin.txt b/ydb/library/yql/minikql/comp_nodes/CMakeLists.darwin.txt
index e4ef7e7237d..a85f5d940d6 100644
--- a/ydb/library/yql/minikql/comp_nodes/CMakeLists.darwin.txt
+++ b/ydb/library/yql/minikql/comp_nodes/CMakeLists.darwin.txt
@@ -22,6 +22,7 @@ target_link_libraries(yql-minikql-comp_nodes PUBLIC
yql-minikql-invoke_builtins
parser-pg_wrapper-interface
library-yql-utils
+ cpp-actors-core
yql-minikql-codegen
llvm12-lib-IR
lib-ExecutionEngine-MCJIT
@@ -95,6 +96,7 @@ target_sources(yql-minikql-comp_nodes PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lazy_list.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_length.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_listfromrange.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_logical.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lookup.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_map.cpp
diff --git a/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux-aarch64.txt b/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux-aarch64.txt
index 07210987639..ae199f0008d 100644
--- a/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux-aarch64.txt
@@ -23,6 +23,7 @@ target_link_libraries(yql-minikql-comp_nodes PUBLIC
yql-minikql-invoke_builtins
parser-pg_wrapper-interface
library-yql-utils
+ cpp-actors-core
yql-minikql-codegen
llvm12-lib-IR
lib-ExecutionEngine-MCJIT
@@ -96,6 +97,7 @@ target_sources(yql-minikql-comp_nodes PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lazy_list.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_length.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_listfromrange.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_logical.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lookup.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_map.cpp
diff --git a/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux.txt b/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux.txt
index 07210987639..ae199f0008d 100644
--- a/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux.txt
+++ b/ydb/library/yql/minikql/comp_nodes/CMakeLists.linux.txt
@@ -23,6 +23,7 @@ target_link_libraries(yql-minikql-comp_nodes PUBLIC
yql-minikql-invoke_builtins
parser-pg_wrapper-interface
library-yql-utils
+ cpp-actors-core
yql-minikql-codegen
llvm12-lib-IR
lib-ExecutionEngine-MCJIT
@@ -96,6 +97,7 @@ target_sources(yql-minikql-comp_nodes PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lazy_list.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_length.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_listfromrange.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_logical.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_lookup.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/comp_nodes/mkql_map.cpp
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_combine.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_combine.cpp
index e57a9b30064..eee24cd08d0 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_combine.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_combine.cpp
@@ -1,4 +1,5 @@
#include "mkql_combine.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h>
#include <ydb/library/yql/minikql/mkql_node_cast.h>
@@ -67,16 +68,16 @@ struct TCombineCoreNodes {
}
};
-class TState : public TComputationValue<TState> {
-using TBase = TComputationValue<TState>;
-using TStateMap = std::unordered_map<
- NUdf::TUnboxedValuePod, NUdf::TUnboxedValuePod,
- THashFunc, TEqualsFunc,
- TMKQLAllocator<std::pair<const NUdf::TUnboxedValuePod, NUdf::TUnboxedValuePod>>>;
+class TState: public TComputationValue<TState> {
+ using TBase = TComputationValue<TState>;
+ using TStateMap = std::unordered_map<
+ NUdf::TUnboxedValuePod, NUdf::TUnboxedValuePod,
+ THashFunc, TEqualsFunc,
+ TMKQLAllocator<std::pair<const NUdf::TUnboxedValuePod, NUdf::TUnboxedValuePod>>>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, const THashFunc& hash, const TEqualsFunc& equal)
- : TBase(memInfo), States(0, hash, equal)
- {
+ : TBase(memInfo), States(0, hash, equal) {
States.max_load_factor(1.2f);
}
@@ -121,6 +122,39 @@ private:
TStateMap States;
};
+#ifndef MKQL_DISABLE_CODEGEN
+class TLLVMFieldsStructureState: public TState::TLLVMBase {
+private:
+ using TBase = typename TState::TLLVMBase;
+ llvm::PointerType* StructPtrType;
+ llvm::IntegerType* StatusType;
+protected:
+ using TBase::Context;
+public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ result.emplace_back(StatusType); // status
+ result.emplace_back(StructPtrType); // map
+
+ return result;
+ }
+
+ llvm::Constant* GetStatus() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
+ }
+
+ llvm::Constant* GetMap() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 1);
+ }
+
+ TLLVMFieldsStructureState(llvm::LLVMContext& context)
+ : TBase(context)
+ , StructPtrType(PointerType::getUnqual(StructType::get(context)))
+ , StatusType(Type::getInt32Ty(context)) {
+ }
+};
+#endif
+
template <bool IsMultiRowState, bool StateContainerOpt, bool TrackRss>
class TCombineCoreFlowWrapper: public std::conditional_t<IsMultiRowState,
TPairStateFlowCodegeneratorNode<TCombineCoreFlowWrapper<IsMultiRowState, StateContainerOpt, TrackRss>>,
@@ -227,15 +261,8 @@ public:
const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- statusType, // status
- structPtrType // map
- });
+ TLLVMFieldsStructureState fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
@@ -290,7 +317,7 @@ public:
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 5)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
@@ -702,15 +729,10 @@ private:
const auto containerType = codegen->GetEffectiveTarget() == NYql::NCodegen::ETarget::Windows ? static_cast<Type*>(ptrValueType) : static_cast<Type*>(valueType);
const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- statusType, // status
- structPtrType // map
- });
+
+ TLLVMFieldsStructureState fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
+
const auto statePtrType = PointerType::getUnqual(stateType);
const auto funcType = IsMultiRowState ?
FunctionType::get(statusType, {PointerType::getUnqual(contextType), containerType, statePtrType, ptrValueType, ptrValueType}, false):
@@ -791,7 +813,7 @@ private:
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 5)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp
index 158b570b97f..fa4520730db 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_grace_join.cpp
@@ -1,5 +1,6 @@
#include "mkql_grace_join.h"
#include "mkql_grace_join_imp.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/public/udf/udf_data_type.h>
#include <ydb/library/yql/public/udf/udf_value.h>
@@ -638,14 +639,8 @@ class TGraceJoinWrapper : public TStatefulWideFlowCodegeneratorNode<TGraceJoinWr
new StoreInst(initV, values, atTop);
new StoreInst(initF, fields, atTop);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- // ....
- });
+ TLLVMFieldsStructure<TComputationValue<TNull>> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_join.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_join.cpp
index d2182bbc236..88682498dd8 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_join.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_join.cpp
@@ -1,4 +1,5 @@
#include "mkql_join.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/computation/mkql_custom_list.h>
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h>
@@ -1186,13 +1187,8 @@ public:
new StoreInst(initV, values, atTop);
new StoreInst(initF, fields, atTop);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- });
+ TLLVMFieldsStructure<TComputationValue<TNull>> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp
new file mode 100644
index 00000000000..6244af1630b
--- /dev/null
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.cpp
@@ -0,0 +1,5 @@
+#include "mkql_llvm_base.h"
+
+namespace NKikimr::NMiniKQL {
+
+}
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.h b/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.h
new file mode 100644
index 00000000000..9b9cf53bb68
--- /dev/null
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_llvm_base.h
@@ -0,0 +1,58 @@
+#pragma once
+#include <ydb/library/yql/minikql/computation/mkql_computation_node_impl.h>
+#include <contrib/libs/llvm12/include/llvm/IR/LLVMContext.h>
+#include <contrib/libs/llvm12/include/llvm/IR/Type.h>
+#include <contrib/libs/llvm12/include/llvm/IR/Constant.h>
+#include <contrib/libs/llvm12/include/llvm/IR/DerivedTypes.h>
+#include <contrib/libs/llvm12/include/llvm/IR/Constants.h>
+
+namespace NKikimr::NMiniKQL {
+template <class T>
+class TLLVMFieldsStructure;
+
+template <class T>
+class TLLVMFieldsStructure<TComputationValue<T>> {
+protected:
+ llvm::LLVMContext& Context;
+ ui32 GetFieldsCount() const {
+ return FieldsCount;
+ }
+ const std::vector<llvm::Type*>& GetFields() const {
+ return Fields;
+ }
+private:
+ llvm::PointerType* StructPtrType;
+ std::vector<llvm::Type*> Fields;
+ const ui32 FieldsCount;
+ std::vector<llvm::Type*> BuildFields() {
+ std::vector<llvm::Type*> result;
+ result.emplace_back(StructPtrType); // vtbl
+ result.emplace_back(llvm::Type::getInt32Ty(Context)); // ref
+ result.emplace_back(llvm::Type::getInt16Ty(Context)); // abi
+ result.emplace_back(llvm::Type::getInt16Ty(Context)); // reserved
+#ifndef NDEBUG
+ result.emplace_back(StructPtrType); // meminfo
+#endif
+ return result;
+ }
+
+public:
+ TLLVMFieldsStructure(llvm::LLVMContext& context)
+ : Context(context)
+ , StructPtrType(llvm::PointerType::getUnqual(llvm::StructType::get(Context)))
+ , Fields(BuildFields())
+ , FieldsCount(Fields.size()) {
+
+ }
+
+ llvm::Constant* This() const {
+ return llvm::ConstantInt::get(llvm::Type::getInt32Ty(Context), 0);
+ }
+
+ const std::vector<llvm::Type*>& GetFieldsArray() const {
+ return Fields;
+ }
+};
+
+
+}
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_squeeze_to_list.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_squeeze_to_list.cpp
index a086074fe98..77a7dbf9ddc 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_squeeze_to_list.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_squeeze_to_list.cpp
@@ -1,5 +1,5 @@
-
#include "mkql_squeeze_to_list.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/mkql_node_cast.h>
#include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h>
@@ -10,21 +10,22 @@ namespace NMiniKQL {
namespace {
-class TSqueezeToListWrapper : public TStatefulFlowCodegeneratorNode<TSqueezeToListWrapper> {
-using TBase = TStatefulFlowCodegeneratorNode<TSqueezeToListWrapper>;
+class TSqueezeToListWrapper: public TStatefulFlowCodegeneratorNode<TSqueezeToListWrapper> {
+ using TBase = TStatefulFlowCodegeneratorNode<TSqueezeToListWrapper>;
public:
- class TState : public TComputationValue<TState> {
+ class TState: public TComputationValue<TState> {
using TBase = TComputationValue<TState>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, ui64 limit)
- : TBase(memInfo), Limit(limit)
- {}
+ : TBase(memInfo), Limit(limit) {
+ }
NUdf::TUnboxedValuePod Pull(TComputationContext& ctx) {
if (Accumulator.empty())
return ctx.HolderFactory.GetEmptyContainer();
- NUdf::TUnboxedValue *items = nullptr;
+ NUdf::TUnboxedValue* items = nullptr;
const auto list = ctx.HolderFactory.CreateDirectArrayHolder(Accumulator.size(), items);
std::move(Accumulator.begin(), Accumulator.end(), items);
Accumulator.clear();
@@ -42,8 +43,8 @@ public:
TSqueezeToListWrapper(TComputationMutables& mutables, IComputationNode* flow, IComputationNode* limit)
: TBase(mutables, flow, EValueRepresentation::Boxed, EValueRepresentation::Any)
- , Flow(flow), Limit(limit)
- {}
+ , Flow(flow), Limit(limit) {
+ }
NUdf::TUnboxedValuePod DoCalculate(NUdf::TUnboxedValue& state, TComputationContext& ctx) const {
if (state.IsFinish()) {
@@ -63,21 +64,34 @@ public:
}
Y_UNREACHABLE();
}
+
#ifndef MKQL_DISABLE_CODEGEN
+ class TLLVMFieldsStructureForState: public TState::TLLVMBase {
+ private:
+ using TBase = typename TState::TLLVMBase;
+ llvm::PointerType* StructPtrType;
+ protected:
+ using TBase::Context;
+ public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ return result;
+ }
+
+ TLLVMFieldsStructureForState(llvm::LLVMContext& context)
+ : TBase(context)
+ , StructPtrType(PointerType::getUnqual(StructType::get(context))) {
+ }
+ };
+
Value* DoGenerateGetValue(const TCodegenContext& ctx, Value* statePtr, BasicBlock*& block) const {
auto& context = ctx.Codegen->GetContext();
const auto valueType = Type::getInt128Ty(context);
const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- structPtrType // accumulator
- });
+ TLLVMFieldsStructureForState fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_switch.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_switch.cpp
index 75dd396cd6b..319effe1a4e 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_switch.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_switch.cpp
@@ -1,4 +1,5 @@
#include "mkql_switch.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h>
#include <ydb/library/yql/minikql/mkql_node_cast.h>
#include <ydb/library/yql/minikql/mkql_stats_registry.h>
@@ -32,6 +33,7 @@ using TSwitchHandlersList = std::vector<TSwitchHandler, TMKQLAllocator<TSwitchHa
class TState : public TComputationValue<TState> {
typedef TComputationValue<TState> TBase;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TComputationValue<TState>>;
TState(TMemoryUsageInfo* memInfo, ui32 size)
: TBase(memInfo), ChildReadIndex(size)
{}
@@ -40,12 +42,57 @@ public:
NUdf::EFetchStatus InputStatus = NUdf::EFetchStatus::Ok;
};
+#ifndef MKQL_DISABLE_CODEGEN
+class TLLVMFieldsStructureForState: public TState::TLLVMBase {
+private:
+ using TBase = TState::TLLVMBase;
+ llvm::IntegerType* IndexType;
+ llvm::IntegerType* StatusType;
+ const ui32 FieldsCount = 0;
+protected:
+ using TBase::Context;
+ ui32 GetFieldsCount() const {
+ return FieldsCount;
+ }
+
+ std::vector<llvm::Type*> GetFields() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ result.emplace_back(IndexType); // index
+ result.emplace_back(StatusType); // status
+
+ return result;
+ }
+
+public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ return GetFields();
+ }
+
+ llvm::Constant* GetIndex() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
+ }
+
+ llvm::Constant* GetStatus() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 1);
+ }
+
+ TLLVMFieldsStructureForState(llvm::LLVMContext& context)
+ : TBase(context)
+ , IndexType(Type::getInt32Ty(context))
+ , StatusType(Type::getInt32Ty(context))
+ , FieldsCount(GetFields().size())
+ {
+ }
+};
+#endif
+
template <bool IsInputVariant, bool TrackRss>
class TSwitchFlowWrapper : public TStatefulFlowCodegeneratorNode<TSwitchFlowWrapper<IsInputVariant, TrackRss>> {
typedef TStatefulFlowCodegeneratorNode<TSwitchFlowWrapper<IsInputVariant, TrackRss>> TBaseComputation;
private:
class TFlowState : public TState {
public:
+ using TLLVMBase = TLLVMFieldsStructureForState;
TFlowState(TMemoryUsageInfo* memInfo, TAlignedPagePool& pool, ui32 size)
: TState(memInfo, size), Buffer(pool)
{}
@@ -178,6 +225,35 @@ public:
}
#ifndef MKQL_DISABLE_CODEGEN
private:
+ class TLLVMFieldsStructureForFlowState: public TFlowState::TLLVMBase {
+ private:
+ using TBase = typename TFlowState::TLLVMBase;
+ llvm::PointerType* StructPtrType;
+ llvm::IntegerType* IndexType;
+ protected:
+ using TBase::Context;
+ public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ result.emplace_back(IndexType); // position
+ result.emplace_back(StructPtrType); // buffer
+ return result;
+ }
+
+ llvm::Constant* GetPosition() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
+ }
+
+ llvm::Constant* GetBuffer() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 1);
+ }
+
+ TLLVMFieldsStructureForFlowState(llvm::LLVMContext& context)
+ : TBase(context)
+ , StructPtrType(PointerType::getUnqual(StructType::get(context)))
+ , IndexType(Type::getInt32Ty(context)) {
+ }
+ };
Function* GenerateHandler(ui32 i, const NYql::NCodegen::ICodegen::TPtr& codegen) const {
auto& module = codegen->GetModule();
auto& context = codegen->GetContext();
@@ -203,17 +279,8 @@ private:
const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
const auto indexType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- indexType, // index
- statusType, // status
- indexType, // position
- structPtrType // buffer
- });
+ TLLVMFieldsStructureForFlowState fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
auto block = main;
@@ -225,7 +292,7 @@ private:
const auto state = new LoadInst(statePtr, "state", block);
const auto half = CastInst::Create(Instruction::Trunc, state, Type::getInt64Ty(context), "half", block);
const auto stateArg = CastInst::Create(Instruction::IntToPtr, half, statePtrType, "state_arg", block);
- const auto posPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(indexType, 0), ConstantInt::get(indexType, 7)}, "pos_ptr", block);
+ const auto posPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetPosition() }, "pos_ptr", block);
const auto loop = BasicBlock::Create(context, "loop", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
@@ -299,17 +366,8 @@ public:
const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
const auto indexType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- indexType, // index
- statusType, // status
- indexType, // position
- structPtrType // buffer
- });
+ TLLVMFieldsStructureForFlowState fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
const auto make = BasicBlock::Create(context, "make", ctx.Func);
@@ -335,7 +393,7 @@ public:
const auto half = CastInst::Create(Instruction::Trunc, state, Type::getInt64Ty(context), "half", block);
const auto stateArg = CastInst::Create(Instruction::IntToPtr, half, statePtrType, "state_arg", block);
- const auto indexPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(indexType, 0), ConstantInt::get(indexType, 5)}, "index_ptr", block);
+ const auto indexPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetIndex() }, "index_ptr", block);
BranchInst::Create(more, block);
@@ -358,7 +416,7 @@ public:
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(indexType, 0), ConstantInt::get(indexType, 6)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
@@ -559,6 +617,8 @@ private:
class TValueBase : public TState {
public:
+ using TLLVMBase = TLLVMFieldsStructureForState;
+
void Add(NUdf::TUnboxedValue&& item) {
Buffer.Add(std::move(item));
}
@@ -705,6 +765,22 @@ private:
}
#ifndef MKQL_DISABLE_CODEGEN
+ class TLLVMFieldsStructureForValueBase: public TValueBase::TLLVMBase {
+ private:
+ using TBase = typename TValueBase::TLLVMBase;
+ protected:
+ using TBase::Context;
+ public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ return result;
+ }
+
+ TLLVMFieldsStructureForValueBase(llvm::LLVMContext& context)
+ : TBase(context) {
+ }
+ };
+
void GenerateFunctions(const NYql::NCodegen::ICodegen::TPtr& codegen) final {
SwitchFunc = GenerateSwitch(codegen);
codegen->ExportSymbol(SwitchFunc);
@@ -730,16 +806,8 @@ private:
const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
const auto indexType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- indexType, // index
- statusType, // status
- structPtrType // buffer
- });
+ TLLVMFieldsStructureForValueBase fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
const auto funcType = FunctionType::get(statusType, {PointerType::getUnqual(contextType), containerType, statePtrType, ptrValueType}, false);
@@ -757,7 +825,7 @@ private:
const auto more = BasicBlock::Create(context, "more", ctx.Func);
auto block = main;
- const auto indexPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 5)}, "index_ptr", block);
+ const auto indexPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetIndex() }, "index_ptr", block);
const auto itemPtr = new AllocaInst(valueType, 0U, "item_ptr", block);
new StoreInst(ConstantInt::get(valueType, 0), itemPtr, block);
@@ -784,7 +852,7 @@ private:
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 6)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { fieldsStruct.This(), fieldsStruct.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_todict.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_todict.cpp
index 8f579b5a473..6814e0e3475 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_todict.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_todict.cpp
@@ -1,4 +1,5 @@
#include "mkql_todict.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/computation/mkql_computation_list_adapter.h>
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h>
@@ -814,6 +815,32 @@ private:
bool UseIHash;
};
+#ifndef MKQL_DISABLE_CODEGEN
+template <class TLLVMBase>
+class TLLVMFieldsStructureStateWithAccum: public TLLVMBase {
+private:
+ using TBase = TLLVMBase;
+ llvm::PointerType* StructPtrType;
+protected:
+ using TBase::Context;
+public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ result.emplace_back(StructPtrType); //accumulator
+ return result;
+ }
+
+ llvm::Constant* GetAccumulator() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
+ }
+
+ TLLVMFieldsStructureStateWithAccum(llvm::LLVMContext& context)
+ : TBase(context)
+ , StructPtrType(PointerType::getUnqual(StructType::get(context))) {
+ }
+};
+#endif
+
template <typename TSetAccumulator>
class TSqueezeSetFlowWrapper : public TStatefulFlowCodegeneratorNode<TSqueezeSetFlowWrapper<TSetAccumulator>> {
using TBase = TStatefulFlowCodegeneratorNode<TSqueezeSetFlowWrapper<TSetAccumulator>>;
@@ -821,6 +848,7 @@ public:
class TState : public TComputationValue<TState> {
using TBase = TComputationValue<TState>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, TSetAccumulator&& setAccum)
: TBase(memInfo), SetAccum(std::move(setAccum)) {}
@@ -879,14 +907,8 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- structPtrType // accumulator
- });
+ TLLVMFieldsStructureStateWithAccum<typename TState::TLLVMBase> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
@@ -1006,6 +1028,7 @@ public:
class TState : public TComputationValue<TState> {
using TBase = TComputationValue<TState>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, TSetAccumulator&& setAccum)
: TBase(memInfo), SetAccum(std::move(setAccum)) {}
@@ -1070,14 +1093,8 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- structPtrType // accumulator
- });
+ TLLVMFieldsStructureStateWithAccum<typename TState::TLLVMBase> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
@@ -1329,6 +1346,7 @@ public:
class TState : public TComputationValue<TState> {
using TBase = TComputationValue<TState>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, TMapAccumulator&& mapAccum)
: TBase(memInfo), MapAccum(std::move(mapAccum)) {}
@@ -1389,15 +1407,8 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto structPtrType = PointerType::getUnqual(StructType::get(context));
-
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- structPtrType // accumulator
- });
+ TLLVMFieldsStructureStateWithAccum<typename TState::TLLVMBase> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
@@ -1522,6 +1533,7 @@ public:
class TState : public TComputationValue<TState> {
using TBase = TComputationValue<TState>;
public:
+ using TLLVMBase = TLLVMFieldsStructure<TBase>;
TState(TMemoryUsageInfo* memInfo, TMapAccumulator&& mapAccum)
: TBase(memInfo), MapAccum(std::move(mapAccum)) {}
@@ -1590,14 +1602,8 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- structPtrType // accumulator
- });
+ TLLVMFieldsStructureStateWithAccum<typename TState::TLLVMBase> fieldsStruct(context);
+ const auto stateType = StructType::get(context, fieldsStruct.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp
index 2d2da5956f3..b2c7698bd2a 100644
--- a/ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp
+++ b/ydb/library/yql/minikql/comp_nodes/mkql_wide_combine.cpp
@@ -1,5 +1,6 @@
#include "mkql_wide_combine.h"
#include "mkql_rh_hash.h"
+#include "mkql_llvm_base.h"
#include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h>
#include <ydb/library/yql/minikql/mkql_node_builder.h>
@@ -150,6 +151,8 @@ struct TCombinerNodes {
class TState : public TComputationValue<TState> {
typedef TComputationValue<TState> TBase;
+public:
+ using TLLVMBase = TLLVMFieldsStructure<TComputationValue<TState>>;
private:
using TStates = TRobinHoodHashSet<NUdf::TUnboxedValuePod*, TEqualsFunc, THashFunc, TMKQLAllocator<char, EMemorySubPool::Temporary>>;
using TRow = std::vector<NUdf::TUnboxedValuePod, TMKQLAllocator<NUdf::TUnboxedValuePod>>;
@@ -280,6 +283,48 @@ private:
TStates States;
};
+#ifndef MKQL_DISABLE_CODEGEN
+class TLLVMFieldsStructureState: public TState::TLLVMBase {
+private:
+ using TBase = TState::TLLVMBase;
+ llvm::IntegerType* ValueType;
+ llvm::PointerType* PtrValueType;
+ llvm::IntegerType* StatusType;
+protected:
+ using TBase::Context;
+public:
+ std::vector<llvm::Type*> GetFieldsArray() {
+ std::vector<llvm::Type*> result = TBase::GetFields();
+ result.emplace_back(StatusType); //status
+ result.emplace_back(PtrValueType); //tongue
+ result.emplace_back(PtrValueType); //throat
+ result.emplace_back(Type::getInt32Ty(Context)); //size
+ result.emplace_back(Type::getInt32Ty(Context)); //size
+ return result;
+ }
+
+ llvm::Constant* GetStatus() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 0);
+ }
+
+ llvm::Constant* GetTongue() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 1);
+ }
+
+ llvm::Constant* GetThroat() {
+ return ConstantInt::get(Type::getInt32Ty(Context), TBase::GetFieldsCount() + 2);
+ }
+
+ TLLVMFieldsStructureState(llvm::LLVMContext& context)
+ : TBase(context)
+ , ValueType(Type::getInt128Ty(Context))
+ , PtrValueType(PointerType::getUnqual(ValueType))
+ , StatusType(Type::getInt32Ty(Context)) {
+
+ }
+};
+#endif
+
template <bool TrackRss>
class TWideCombinerWrapper: public TStatefulWideFlowCodegeneratorNode<TWideCombinerWrapper<TrackRss>>
#ifndef MKQL_DISABLE_CODEGEN
@@ -348,22 +393,10 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto ptrValueType = PointerType::getUnqual(valueType);
- const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- statusType, // status
- ptrValueType, // tongue
- ptrValueType, // throat
- Type::getInt32Ty(context), // size
- Type::getInt32Ty(context), // size
- });
+ TLLVMFieldsStructureState stateFields(context);
+ const auto stateType = StructType::get(context, stateFields.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
@@ -415,7 +448,7 @@ public:
const auto good = BasicBlock::Create(context, "good", ctx.Func);
const auto done = BasicBlock::Create(context, "done", ctx.Func);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 5)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
@@ -456,7 +489,7 @@ public:
items[i] = getres.second[i](ctx, block);
}
- const auto tonguePtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 6)}, "tongue_ptr", block);
+ const auto tonguePtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetTongue() }, "tongue_ptr", block);
const auto tongue = new LoadInst(tonguePtr, "tongue", block);
std::vector<Value*> keyPointers(Nodes.KeyResultNodes.size(), nullptr), keys(Nodes.KeyResultNodes.size(), nullptr);
@@ -487,7 +520,7 @@ public:
const auto next = BasicBlock::Create(context, "next", ctx.Func);
const auto test = BasicBlock::Create(context, "test", ctx.Func);
- const auto throatPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 7)}, "throat_ptr", block);
+ const auto throatPtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetThroat() }, "throat_ptr", block);
const auto throat = new LoadInst(throatPtr, "throat", block);
std::vector<Value*> pointers;
@@ -735,23 +768,11 @@ public:
const auto valueType = Type::getInt128Ty(context);
const auto ptrValueType = PointerType::getUnqual(valueType);
- const auto structPtrType = PointerType::getUnqual(StructType::get(context));
- const auto contextType = GetCompContextType(context);
const auto statusType = Type::getInt32Ty(context);
- const auto stateType = StructType::get(context, {
- structPtrType, // vtbl
- Type::getInt32Ty(context), // ref
- Type::getInt16Ty(context), // abi
- Type::getInt16Ty(context), // reserved
- structPtrType, // meminfo
- statusType, // status
- ptrValueType, // tongue
- ptrValueType, // throat
- Type::getInt32Ty(context), // size
- Type::getInt32Ty(context), // size
- });
+ TLLVMFieldsStructureState stateFields(context);
+ const auto stateType = StructType::get(context, stateFields.GetFieldsArray());
const auto statePtrType = PointerType::getUnqual(stateType);
const auto keys = new AllocaInst(ArrayType::get(valueType, Nodes.KeyResultNodes.size()), 0U, "keys", &ctx.Func->getEntryBlock().back());
@@ -785,7 +806,7 @@ public:
const auto over = BasicBlock::Create(context, "over", ctx.Func);
const auto result = PHINode::Create(statusType, 3U, "result", over);
- const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 5)}, "last", block);
+ const auto statusPtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetStatus() }, "last", block);
const auto last = new LoadInst(statusPtr, "last", block);
const auto finish = CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_EQ, last, ConstantInt::get(last->getType(), static_cast<i32>(EFetchResult::Finish)), "finish", block);
@@ -820,7 +841,7 @@ public:
items[i] = getres.second[i](ctx, block);
}
- const auto tonguePtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 6)}, "tongue_ptr", block);
+ const auto tonguePtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetTongue() }, "tongue_ptr", block);
const auto tongue = new LoadInst(tonguePtr, "tongue", block);
std::vector<Value*> keyPointers(Nodes.KeyResultNodes.size(), nullptr), keys(Nodes.KeyResultNodes.size(), nullptr);
@@ -850,7 +871,7 @@ public:
const auto init = BasicBlock::Create(context, "init", ctx.Func);
const auto next = BasicBlock::Create(context, "next", ctx.Func);
- const auto throatPtr = GetElementPtrInst::CreateInBounds(stateArg, {ConstantInt::get(Type::getInt32Ty(context), 0), ConstantInt::get(Type::getInt32Ty(context), 7)}, "throat_ptr", block);
+ const auto throatPtr = GetElementPtrInst::CreateInBounds(stateArg, { stateFields.This(), stateFields.GetThroat() }, "throat_ptr", block);
const auto throat = new LoadInst(throatPtr, "throat", block);
std::vector<Value*> pointers;
diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h b/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h
index 9eddfed4252..991978740db 100644
--- a/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h
+++ b/ydb/library/yql/minikql/computation/mkql_computation_node_impl.h
@@ -1031,7 +1031,11 @@ private:
using TBase = TComputationValueBase<TDerived, TBaseExt>;
protected:
inline TMemoryUsageInfo* GetMemInfo() const {
+#ifndef NDEBUG
return static_cast<TMemoryUsageInfo*>(M_.MemInfo);
+#else
+ return nullptr;
+#endif
}
using TWithMiniKQLAlloc<MemoryPool>::AllocWithSize;
using TWithMiniKQLAlloc<MemoryPool>::FreeWithSize;
@@ -1039,17 +1043,25 @@ public:
template <typename... Args>
TComputationValueImpl(TMemoryUsageInfo* memInfo, Args&&... args)
: TBase(std::forward<Args>(args)...) {
+#ifndef NDEBUG
M_.MemInfo = memInfo;
MKQL_MEM_TAKE(memInfo, this, sizeof(TDerived), __MKQL_LOCATION__);
+#else
+ Y_UNUSED(memInfo);
+#endif
}
~TComputationValueImpl() {
+#ifndef NDEBUG
MKQL_MEM_RETURN(GetMemInfo(), this, sizeof(TDerived));
+#endif
}
private:
+#ifndef NDEBUG
struct {
void* MemInfo; // used for tracking memory usage during execution
} M_;
+#endif
};
template <typename TDerived, typename TBaseExt = NUdf::IBoxedValue>
diff --git a/ydb/library/yql/minikql/perf/mt_param/CMakeLists.darwin.txt b/ydb/library/yql/minikql/perf/mt_param/CMakeLists.darwin.txt
index eb10899be6d..cb37f7a4032 100644
--- a/ydb/library/yql/minikql/perf/mt_param/CMakeLists.darwin.txt
+++ b/ydb/library/yql/minikql/perf/mt_param/CMakeLists.darwin.txt
@@ -28,6 +28,8 @@ target_link_options(mt_param PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(mt_param PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/perf/mt_param/mt_param.cpp
diff --git a/ydb/library/yql/minikql/perf/packer/CMakeLists.darwin.txt b/ydb/library/yql/minikql/perf/packer/CMakeLists.darwin.txt
index 74e37c6bb37..512e840d1a8 100644
--- a/ydb/library/yql/minikql/perf/packer/CMakeLists.darwin.txt
+++ b/ydb/library/yql/minikql/perf/packer/CMakeLists.darwin.txt
@@ -29,6 +29,8 @@ target_link_options(packer PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(packer PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/perf/packer/packer.cpp
diff --git a/ydb/library/yql/minikql/perf/param/CMakeLists.darwin.txt b/ydb/library/yql/minikql/perf/param/CMakeLists.darwin.txt
index 1251d9b92e7..1b9b4e65e38 100644
--- a/ydb/library/yql/minikql/perf/param/CMakeLists.darwin.txt
+++ b/ydb/library/yql/minikql/perf/param/CMakeLists.darwin.txt
@@ -28,6 +28,8 @@ target_link_options(param PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(param PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/minikql/perf/param/param.cpp
diff --git a/ydb/library/yql/parser/pg_wrapper/ut/CMakeLists.darwin.txt b/ydb/library/yql/parser/pg_wrapper/ut/CMakeLists.darwin.txt
index 7deb330c972..7ff88c8aedc 100644
--- a/ydb/library/yql/parser/pg_wrapper/ut/CMakeLists.darwin.txt
+++ b/ydb/library/yql/parser/pg_wrapper/ut/CMakeLists.darwin.txt
@@ -32,6 +32,8 @@ target_link_options(ydb-library-yql-parser-pg_wrapper-ut PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(ydb-library-yql-parser-pg_wrapper-ut PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/ut/parser_ut.cpp
diff --git a/ydb/library/yql/udfs/common/stat/ut/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/stat/ut/CMakeLists.darwin.txt
index 97cf9a294a5..bb15b59e3a7 100644
--- a/ydb/library/yql/udfs/common/stat/ut/CMakeLists.darwin.txt
+++ b/ydb/library/yql/udfs/common/stat/ut/CMakeLists.darwin.txt
@@ -31,6 +31,8 @@ target_link_options(ydb-library-yql-udfs-common-stat-ut PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(ydb-library-yql-udfs-common-stat-ut PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/udfs/common/stat/stat_udf_ut.cpp
diff --git a/ydb/library/yql/udfs/common/topfreq/ut/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/topfreq/ut/CMakeLists.darwin.txt
index 29180fb9698..6d929104785 100644
--- a/ydb/library/yql/udfs/common/topfreq/ut/CMakeLists.darwin.txt
+++ b/ydb/library/yql/udfs/common/topfreq/ut/CMakeLists.darwin.txt
@@ -31,6 +31,8 @@ target_link_options(ydb-library-yql-udfs-common-topfreq-ut PRIVATE
-Wl,-sdk_version,10.15
-fPIC
-fPIC
+ -framework
+ CoreFoundation
)
target_sources(ydb-library-yql-udfs-common-topfreq-ut PRIVATE
${CMAKE_SOURCE_DIR}/ydb/library/yql/udfs/common/topfreq/topfreq_udf_ut.cpp