Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions base/base/AlignedUnion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <algorithm>

template<std::size_t len, class... Types>
struct AlignedUnion
{
static constexpr std::size_t alignment_value = std::max({alignof(Types)...});
struct Type
{
alignas(alignment_value) char s[std::max({len, sizeof(Types)...})];
};
};

template<std::size_t len, class... Types>
using AlignedUnionT = typename AlignedUnion<len, Types...>::Type;
1 change: 1 addition & 0 deletions base/poco/Foundation/include/Poco/UUID.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Poco/Foundation.h"
#include <Poco/Types.h>

#include <array>

namespace Poco
{
Expand Down
2 changes: 1 addition & 1 deletion contrib/llvm-project
2 changes: 1 addition & 1 deletion contrib/llvm-project-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set (LLVM_INCLUDE_DIRS
set (LLVM_LIBRARY_DIRS "${ClickHouse_BINARY_DIR}/contrib/llvm-project/llvm")
# NOTE: You should not remove this line since otherwise it will use default 20,
# and llvm cannot be compiled with bundled libcxx and 20 standard.
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD 17)

if (ARCH_AMD64)
set (LLVM_TARGETS_TO_BUILD "X86" CACHE INTERNAL "")
Expand Down
2 changes: 1 addition & 1 deletion contrib/rocksdb
3 changes: 2 additions & 1 deletion src/AggregateFunctions/SingleValueData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Columns/ColumnDecimal.h>
#include <DataTypes/DataTypeDate.h>
#include <DataTypes/DataTypeDateTime.h>
#include <base/AlignedUnion.h>
#include <base/StringRef.h>

namespace DB
Expand Down Expand Up @@ -374,7 +375,7 @@ createAggregateFunctionSingleValue(const String & name, const DataTypes & argume
/// Helper to allocate enough memory to store any derived class
struct SingleValueDataBaseMemoryBlock
{
std::aligned_union_t<
AlignedUnionT<
SingleValueDataBase::MAX_STORAGE_SIZE,
SingleValueDataNumeric<Decimal256>, /// We check all types in generateSingleValueFromTypeIndex
SingleValueDataString,
Expand Down
2 changes: 1 addition & 1 deletion src/Common/BSONCXXHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static bsoncxx::types::bson_value::value fieldAsBSONValue(const Field & field, c
case TypeIndex::DateTime:
return bsoncxx::types::b_date{std::chrono::seconds{field.safeGet<UInt32 &>()}};
case TypeIndex::UUID:
return bsoncxx::types::b_string{static_cast<String>(formatUUID(field.safeGet<UUID &>()))};
return bsoncxx::types::b_string{String{formatUUID(field.safeGet<UUID &>()).data()}};
case TypeIndex::Tuple: {
auto arr = array();
for (const auto & elem : field.safeGet<Tuple &>())
Expand Down
2 changes: 1 addition & 1 deletion src/Common/GWPAsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void printReport([[maybe_unused]] uintptr_t fault_address)
{
const auto logger = getLogger("GWPAsan");
const auto * state = GuardedAlloc.getAllocatorState();
if (uintptr_t internal_error_ptr = __gwp_asan_get_internal_crash_address(state); internal_error_ptr)
if (uintptr_t internal_error_ptr = __gwp_asan_get_internal_crash_address(state, fault_address); internal_error_ptr)
fault_address = internal_error_ptr;

const gwp_asan::AllocationMetadata * allocation_meta = __gwp_asan_get_metadata(state, GuardedAlloc.getMetadataRegion(), fault_address);
Expand Down
2 changes: 1 addition & 1 deletion src/Common/HashTable/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ struct ZeroValueStorage<true, Cell>
{
private:
bool has_zero = false;
std::aligned_storage_t<sizeof(Cell), alignof(Cell)> zero_value_storage; /// Storage of element with zero key.
alignas(Cell) std::byte zero_value_storage[sizeof(Cell)]; /// Storage of element with zero key.

public:
bool hasZero() const { return has_zero; }
Expand Down
2 changes: 1 addition & 1 deletion src/Common/HashTable/StringHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ struct StringHashTableEmpty
using Self = StringHashTableEmpty;

bool has_zero = false;
std::aligned_storage_t<sizeof(Cell), alignof(Cell)> zero_value_storage; /// Storage of element with zero key.
alignas(Cell) std::byte zero_value_storage[sizeof(Cell)]; /// Storage of element with zero key.

public:
bool hasZero() const { return has_zero; }
Expand Down
1 change: 1 addition & 0 deletions src/Common/MatchGenerator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <base/types.h>
#include <functional>
#include <memory>

namespace re2
Expand Down
2 changes: 2 additions & 0 deletions src/Common/ZooKeeper/KeeperFeatureFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <Coordination/KeeperConstants.h>

#include <memory>

namespace Poco
{
class Logger;
Expand Down
1 change: 1 addition & 0 deletions src/Coordination/Changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <unordered_map>
#include <unordered_set>
#include <future>
#include <vector>

namespace nuraft
{
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <type_traits>
#include <functional>

#include <base/AlignedUnion.h>
#include <Core/CompareHelper.h>
#include <Core/Defines.h>
#include <Core/Types.h>
Expand Down Expand Up @@ -301,7 +302,6 @@ concept not_field_or_bool_or_stringlike
*/
static constexpr auto DBMS_MIN_FIELD_SIZE = 32;


/** Discriminated union of several types.
* Made for replacement of `boost::variant`
* is not generalized,
Expand Down Expand Up @@ -672,7 +672,7 @@ class Field
static Field restoreFromDump(std::string_view dump_);

private:
std::aligned_union_t<DBMS_MIN_FIELD_SIZE - sizeof(Types::Which),
AlignedUnionT<DBMS_MIN_FIELD_SIZE - sizeof(Types::Which),
Null, UInt64, UInt128, UInt256, Int64, Int128, Int256, UUID, IPv4, IPv6, Float64, String, Array, Tuple, Map,
DecimalField<Decimal32>, DecimalField<Decimal64>, DecimalField<Decimal128>, DecimalField<Decimal256>,
AggregateFunctionStateData, CustomType
Expand Down
3 changes: 2 additions & 1 deletion src/Core/QualifiedTableName.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

#include <base/types.h>

#include <optional>
#include <string>
#include <tuple>
#include <optional>
#include <vector>

namespace DB
{
Expand Down
1 change: 1 addition & 0 deletions src/Formats/MarkInCompressedFile.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <tuple>
#include <unordered_map>

#include <base/types.h>
#include <Common/PODArray.h>
Expand Down
1 change: 1 addition & 0 deletions src/Formats/ReadSchemaUtils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <IO/ReadBuffer.h>
#include <Formats/FormatSettings.h>
#include <Storages/Cache/SchemaCache.h>
#include <Storages/ColumnsDescription.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/ClusterProxy/executeQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ void executeQueryWithParallelReplicas(
context, query_ast, storage_id.database_name, storage_id.table_name, /*remote_table_function_ptr*/ nullptr);
auto header = InterpreterSelectQuery(modified_query_ast, context, SelectQueryOptions(processed_stage).analyze()).getSampleBlock();

executeQueryWithParallelReplicas(query_plan, storage_id, header, processed_stage, modified_query_ast, context, storage_limits);
executeQueryWithParallelReplicas(query_plan, storage_id, header, processed_stage, modified_query_ast, context, storage_limits, nullptr);
}

void executeQueryWithParallelReplicasCustomKey(
Expand Down
2 changes: 1 addition & 1 deletion src/Interpreters/ClusterProxy/executeQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void executeQueryWithParallelReplicas(
const ASTPtr & query_ast,
ContextPtr context,
std::shared_ptr<const StorageLimitsList> storage_limits,
QueryPlanStepPtr read_from_merge_tree = nullptr);
QueryPlanStepPtr read_from_merge_tree);

void executeQueryWithParallelReplicas(
QueryPlan & query_plan,
Expand Down
45 changes: 20 additions & 25 deletions src/Interpreters/JIT/CHJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

#include <boost/noncopyable.hpp>

#include <llvm/Analysis/CGSCCPassManager.h>
#include <llvm/Analysis/TargetTransformInfo.h>
#include <llvm/Analysis/LoopAnalysisManager.h>
#include <llvm/Passes/PassBuilder.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/DataLayout.h>
#include <llvm/IR/DerivedTypes.h>
Expand Down Expand Up @@ -483,29 +486,21 @@ std::string CHJIT::getMangledName(const std::string & name_to_mangle) const

void CHJIT::runOptimizationPassesOnModule(llvm::Module & module) const
{
llvm::PassManagerBuilder pass_manager_builder;
llvm::legacy::PassManager mpm;
llvm::legacy::FunctionPassManager fpm(&module);
pass_manager_builder.OptLevel = 3;
pass_manager_builder.SLPVectorize = true;
pass_manager_builder.LoopVectorize = true;
pass_manager_builder.RerollLoops = true;
pass_manager_builder.VerifyInput = true;
pass_manager_builder.VerifyOutput = true;
machine->adjustPassManager(pass_manager_builder);

fpm.add(llvm::createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis()));
mpm.add(llvm::createTargetTransformInfoWrapperPass(machine->getTargetIRAnalysis()));

pass_manager_builder.populateFunctionPassManager(fpm);
pass_manager_builder.populateModulePassManager(mpm);

fpm.doInitialization();
for (auto & function : module)
fpm.run(function);
fpm.doFinalization();

mpm.run(module);
llvm::LoopAnalysisManager lam;
llvm::FunctionAnalysisManager fam;
llvm::CGSCCAnalysisManager cgam;
llvm::ModuleAnalysisManager mam;

llvm::PassBuilder pb;

pb.registerModuleAnalyses(mam);
pb.registerCGSCCAnalyses(cgam);
pb.registerFunctionAnalyses(fam);
pb.registerLoopAnalyses(lam);
pb.crossRegisterProxies(lam, fam, cgam, mam);

llvm::ModulePassManager mpm = pb.buildPerModuleDefaultPipeline(llvm::OptimizationLevel::O3);
mpm.run(module, mam);
}

std::unique_ptr<llvm::TargetMachine> CHJIT::getTargetMachine()
Expand Down Expand Up @@ -538,8 +533,8 @@ std::unique_ptr<llvm::TargetMachine> CHJIT::getTargetMachine()
cpu,
features.getString(),
options,
llvm::None,
llvm::None,
std::nullopt,
std::nullopt,
llvm::CodeGenOpt::Aggressive,
jit);

Expand Down
3 changes: 2 additions & 1 deletion src/Planner/findParallelReplicasQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ JoinTreeQueryPlan buildQueryPlanForParallelReplicas(
processed_stage,
modified_query_ast,
context,
storage_limits);
storage_limits,
nullptr);

auto converting = ActionsDAG::makeConvertingActions(
header.getColumnsWithTypeAndName(),
Expand Down
4 changes: 2 additions & 2 deletions src/Processors/Formats/Impl/DWARFBlockInputFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void DWARFBlockInputFormat::parseRanges(
uint64_t offset, bool form_rnglistx, const UnitState & unit, const ColumnVector<UInt64>::MutablePtr & col_ranges_start,
const ColumnVector<UInt64>::MutablePtr & col_ranges_end) const
{
llvm::Optional<llvm::object::SectionedAddress> base_addr;
std::optional<llvm::object::SectionedAddress> base_addr;
if (unit.base_address != UINT64_MAX)
base_addr = llvm::object::SectionedAddress{.Address = unit.base_address};

Expand Down Expand Up @@ -882,7 +882,7 @@ void DWARFBlockInputFormat::parseRanges(
if (err)
throw Exception(ErrorCodes::CANNOT_PARSE_DWARF, "Error parsing .debug_rnglists list: {}", llvm::toString(std::move(err)));

auto lookup_addr = [&](uint32_t idx) -> llvm::Optional<llvm::object::SectionedAddress>
auto lookup_addr = [&](uint32_t idx) -> std::optional<llvm::object::SectionedAddress>
{
uint64_t addr = fetchFromDebugAddr(unit.debug_addr_base, idx);
return llvm::object::SectionedAddress{.Address = addr};
Expand Down
1 change: 1 addition & 0 deletions src/Storages/MergeTree/IDataPartStorage.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include <IO/WriteSettings.h>
#include <IO/WriteBufferFromFileBase.h>
#include <IO/ReadBufferFromFileBase.h>
#include <base/types.h>
#include <Core/NamesAndTypes.h>
#include <Interpreters/TransactionVersionMetadata.h>
Expand Down
2 changes: 2 additions & 0 deletions src/Storages/TableZnodeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Storages/RenamingRestrictions.h>
#include <Databases/LoadingStrictnessLevel.h>

#include <memory>

namespace zkutil
{
class ZooKeeper;
Expand Down
Loading