Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 7 additions & 7 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.13
- uses: DoozyX/clang-format-lint-action@v0.14
with:
source: '.'
extensions: 'h,c,cpp'
clangFormatVersion: 13
clangFormatVersion: 14
check_clang_tidy:
name: Check clang-tidy
runs-on: ubuntu-20.04
Expand All @@ -30,14 +30,14 @@ jobs:
# from apt.llvm.org
# wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
sudo apt-add-repository "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-13 main"
sudo apt-add-repository "deb https://apt.llvm.org/$(lsb_release -sc)/ llvm-toolchain-$(lsb_release -sc)-14 main"
sudo apt-get update
sudo apt-get install llvm-13 clang-13 liblld-13-dev libclang-13-dev clang-tidy-13 ninja-build
sudo apt-get install llvm-14 clang-14 liblld-14-dev libclang-14-dev clang-tidy-14 ninja-build
- name: Run clang-tidy
run: |
export CC=clang-13
export CXX=clang++-13
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-13
export CC=clang-14
export CXX=clang++-14
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-14
./run-clang-tidy.sh
check_cmake_file_lists:
name: Check CMake file lists
Expand Down
14 changes: 7 additions & 7 deletions run-clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ set -e

ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# We are currently standardized on using LLVM/Clang13 for this script.
# We are currently standardized on using LLVM/Clang14 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM13 installed,
# are using to build Halide itself. If you don't have LLVM14 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-13 clang-13 libclang-13-dev clang-tidy-13
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-13
# sudo apt-get install llvm-14 clang-14 libclang-14-dev clang-tidy-14
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-14

[ -z "$CLANG_FORMAT_LLVM_INSTALL_DIR" ] && echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_FORMAT_LLVM_INSTALL_DIR = ${CLANG_FORMAT_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_FORMAT_LLVM_INSTALL_DIR}/bin/clang-format --version)
if [[ ${VERSION} =~ .*version\ 13.* ]]
if [[ ${VERSION} =~ .*version\ 14.* ]]
then
echo "clang-format version 13 found."
echo "clang-format version 14 found."
else
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 13 install!"
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 14 install!"
exit 1
fi

Expand Down
14 changes: 7 additions & 7 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

FIX=$1

# We are currently standardized on using LLVM/Clang12 for this script.
# We are currently standardized on using LLVM/Clang14 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM12 installed,
# are using to build Halide itself. If you don't have LLVM14 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-13 clang-13 libclang-13-dev clang-tidy-13
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-13
# sudo apt-get install llvm-14 clang-14 libclang-14-dev clang-tidy-14
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-14

[ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ] && echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy --version)
if [[ ${VERSION} =~ .*version\ 13.* ]]
if [[ ${VERSION} =~ .*version\ 14.* ]]
then
echo "clang-tidy version 13 found."
echo "clang-tidy version 14 found."
else
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 13 install!"
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 14 install!"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion src/BoundsInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ class BoundsInference : public IRMutator {

// Do any pure inlining (TODO: This is currently slow)
for (size_t i = f.size(); i > 0; i--) {
Function func = f[i - 1];
const Function &func = f[i - 1];
if (inlined[i - 1]) {
for (auto &s : stages) {
for (auto &cond_val : s.exprs) {
Expand Down
3 changes: 1 addition & 2 deletions src/CodeGen_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ class TypeInfoGatherer : public IRGraphVisitor {
} // namespace

CodeGen_C::CodeGen_C(ostream &s, const Target &t, OutputKind output_kind, const std::string &guard)
: IRPrinter(s), id("$$ BAD ID $$"), target(t), output_kind(output_kind),
extern_c_open(false), inside_atomic_mutex_node(false), emit_atomic_stores(false), using_vector_typedefs(false) {
: IRPrinter(s), id("$$ BAD ID $$"), target(t), output_kind(output_kind) {

if (is_header()) {
// If it's a header, emit an include guard.
Expand Down
8 changes: 4 additions & 4 deletions src/CodeGen_C.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CodeGen_C : public IRPrinter {
bool have_user_context;

/** Track current calling convention scope. */
bool extern_c_open;
bool extern_c_open = false;

/** True if at least one gpu-based for loop is used. */
bool uses_gpu_for_loops;
Expand Down Expand Up @@ -259,13 +259,13 @@ class CodeGen_C : public IRPrinter {

/** Are we inside an atomic node that uses mutex locks?
This is used for detecting deadlocks from nested atomics. */
bool inside_atomic_mutex_node;
bool inside_atomic_mutex_node = false;

/** Emit atomic store instructions? */
bool emit_atomic_stores;
bool emit_atomic_stores = false;

/** true if add_vector_typedefs() has been called. */
bool using_vector_typedefs;
bool using_vector_typedefs = false;

void emit_argv_wrapper(const std::string &function_name,
const std::vector<LoweredArgument> &args);
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGen_GPU_Dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class IsBufferConstant : public IRVisitor {
}

public:
bool result;
bool result = true;
const std::string &buffer;

IsBufferConstant(const std::string &b)
: result(true), buffer(b) {
: buffer(b) {
}
};
} // namespace
Expand Down
24 changes: 2 additions & 22 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,7 @@ llvm::GlobalValue::LinkageTypes llvm_linkage(LinkageType t) {
} // namespace

CodeGen_LLVM::CodeGen_LLVM(const Target &t)
: function(nullptr), context(nullptr),
builder(nullptr),
value(nullptr),
very_likely_branch(nullptr),
default_fp_math_md(nullptr),
strict_fp_math_md(nullptr),
target(t),
void_t(nullptr), i1_t(nullptr), i8_t(nullptr),
i16_t(nullptr), i32_t(nullptr), i64_t(nullptr),
f16_t(nullptr), f32_t(nullptr), f64_t(nullptr),
halide_buffer_t_type(nullptr),
metadata_t_type(nullptr),
argument_t_type(nullptr),
scalar_value_t_type(nullptr),
device_interface_t_type(nullptr),
pseudostack_slot_t_type(nullptr),
: target(t),

wild_u1x_(Variable::make(UInt(1, 0), "*")),
wild_i8x_(Variable::make(Int(8, 0), "*")),
Expand All @@ -215,13 +200,8 @@ CodeGen_LLVM::CodeGen_LLVM(const Target &t)
wild_f32_(Variable::make(Float(32), "*")),
wild_f64_(Variable::make(Float(64), "*")),

inside_atomic_mutex_node(false),
emit_atomic_stores(false),

destructor_block(nullptr),
strict_float(t.has_feature(Target::StrictFloat)),
llvm_large_code_model(t.has_feature(Target::LLVMLargeCodeModel)),
effective_vscale(0) {
llvm_large_code_model(t.has_feature(Target::LLVMLargeCodeModel)) {
initialize_llvm();
}

Expand Down
42 changes: 21 additions & 21 deletions src/CodeGen_LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ class CodeGen_LLVM : public IRVisitor {
virtual Type upgrade_type_for_argument_passing(const Type &) const;

std::unique_ptr<llvm::Module> module;
llvm::Function *function;
llvm::LLVMContext *context;
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter> *builder;
llvm::Value *value;
llvm::MDNode *very_likely_branch;
llvm::MDNode *default_fp_math_md;
llvm::MDNode *strict_fp_math_md;
llvm::Function *function = nullptr;
llvm::LLVMContext *context = nullptr;
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter> *builder = nullptr;
llvm::Value *value = nullptr;
llvm::MDNode *very_likely_branch = nullptr;
llvm::MDNode *default_fp_math_md = nullptr;
llvm::MDNode *strict_fp_math_md = nullptr;
std::vector<LoweredArgument> current_function_args;
//@}

Expand Down Expand Up @@ -208,16 +208,16 @@ class CodeGen_LLVM : public IRVisitor {

/** Some useful llvm types */
// @{
llvm::Type *void_t, *i1_t, *i8_t, *i16_t, *i32_t, *i64_t, *f16_t, *f32_t, *f64_t;
llvm::StructType *halide_buffer_t_type,
*type_t_type,
*dimension_t_type,
*metadata_t_type,
*argument_t_type,
*scalar_value_t_type,
*device_interface_t_type,
*pseudostack_slot_t_type,
*semaphore_t_type;
llvm::Type *void_t = nullptr, *i1_t = nullptr, *i8_t = nullptr, *i16_t = nullptr, *i32_t = nullptr, *i64_t = nullptr, *f16_t = nullptr, *f32_t = nullptr, *f64_t = nullptr;
llvm::StructType *halide_buffer_t_type = nullptr,
*type_t_type,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's currently benign, but it would be good to initialize all of these to null instead of just some of them.

*dimension_t_type,
*metadata_t_type = nullptr,
*argument_t_type = nullptr,
*scalar_value_t_type = nullptr,
*device_interface_t_type = nullptr,
*pseudostack_slot_t_type = nullptr,
*semaphore_t_type;

// @}

Expand Down Expand Up @@ -508,10 +508,10 @@ class CodeGen_LLVM : public IRVisitor {

/** Are we inside an atomic node that uses mutex locks?
This is used for detecting deadlocks from nested atomics & illegal vectorization. */
bool inside_atomic_mutex_node;
bool inside_atomic_mutex_node = false;

/** Emit atomic store instructions? */
bool emit_atomic_stores;
bool emit_atomic_stores = false;

/** Can we call this operation with float16 type?
This is used to avoid "emulated" equivalent code-gen in case target has FP16 feature **/
Expand Down Expand Up @@ -542,7 +542,7 @@ class CodeGen_LLVM : public IRVisitor {
/** A basic block to branch to on error that triggers all
* destructors. As destructors are registered, code gets added
* to this block. */
llvm::BasicBlock *destructor_block;
llvm::BasicBlock *destructor_block = nullptr;

/** Turn off all unsafe math flags in scopes while this is set. */
bool strict_float;
Expand All @@ -553,7 +553,7 @@ class CodeGen_LLVM : public IRVisitor {
/** Cache the result of target_vscale from architecture specific implementation
* as this is used on every Halide to LLVM type conversion.
*/
int effective_vscale;
int effective_vscale = 0;

/** Embed an instance of halide_filter_metadata_t in the code, using
* the given name (by convention, this should be ${FUNCTIONNAME}_metadata)
Expand Down
4 changes: 2 additions & 2 deletions src/Deinterleave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StoreCollector : public IRMutator {
StoreCollector(const std::string &name, int stride, int ms,
std::vector<Stmt> &lets, std::vector<Stmt> &ss)
: store_name(name), store_stride(stride), max_stores(ms),
let_stmts(lets), stores(ss), collecting(true) {
let_stmts(lets), stores(ss) {
}

private:
Expand Down Expand Up @@ -57,7 +57,7 @@ class StoreCollector : public IRMutator {
return op;
}

bool collecting;
bool collecting = true;
// These are lets that we've encountered since the last collected
// store. If we collect another store, these "potential" lets
// become lets used by the collected stores.
Expand Down
4 changes: 2 additions & 2 deletions src/ExprUsesVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ class ExprUsesVars : public IRGraphVisitor {

public:
ExprUsesVars(const Scope<T> &v, const Scope<Expr> *s = nullptr)
: vars(v), result(false) {
: vars(v) {
scope.set_containing_scope(s);
}
bool result;
bool result = false;
};

/** Test if a statement or expression references or defines any of the
Expand Down
5 changes: 2 additions & 3 deletions src/Func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2811,10 +2811,9 @@ Func::operator Stage() const {
namespace {
class CountImplicitVars : public Internal::IRGraphVisitor {
public:
int count;
int count = 0;

CountImplicitVars(const vector<Expr> &exprs)
: count(0) {
CountImplicitVars(const vector<Expr> &exprs) {
for (const auto &e : exprs) {
e.accept(this);
}
Expand Down
19 changes: 8 additions & 11 deletions src/FuseGPUThreadLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class NormalizeDimensionality : public IRMutator {
const ExtractBlockSize &block_size;
const DeviceAPI device_api;

int depth;
int max_depth;
int depth = 0;
int max_depth = 0;

Stmt wrap(Stmt s) {
if (depth != 0) {
Expand Down Expand Up @@ -181,7 +181,7 @@ class NormalizeDimensionality : public IRMutator {

public:
NormalizeDimensionality(const ExtractBlockSize &e, DeviceAPI device_api)
: block_size(e), device_api(device_api), depth(0), max_depth(0) {
: block_size(e), device_api(device_api) {
}
};

Expand Down Expand Up @@ -293,9 +293,9 @@ class ExtractSharedAndHeapAllocations : public IRMutator {
private:
map<string, SharedAllocation *> shared;

bool in_threads;
bool in_threads = false;

int barrier_stage;
int barrier_stage = 0;

const DeviceAPI device_api;

Expand Down Expand Up @@ -1022,9 +1022,7 @@ class ExtractSharedAndHeapAllocations : public IRMutator {
}

ExtractSharedAndHeapAllocations(DeviceAPI d)
: in_threads(false),
barrier_stage(0),
device_api(d),
: device_api(d),
thread_id_var_name(unique_name('t')),
num_threads_var_name(unique_name('t')),
may_merge_allocs_of_different_type(device_api != DeviceAPI::OpenGLCompute &&
Expand Down Expand Up @@ -1201,7 +1199,7 @@ class ExtractRegisterAllocations : public IRMutator {
};

class InjectThreadBarriers : public IRMutator {
bool in_threads, injected_barrier;
bool in_threads = false, injected_barrier;

using IRMutator::visit;

Expand Down Expand Up @@ -1349,8 +1347,7 @@ class InjectThreadBarriers : public IRMutator {

public:
InjectThreadBarriers(ExtractSharedAndHeapAllocations &sha, ExtractRegisterAllocations &ra)
: in_threads(false),
block_allocs(sha),
: block_allocs(sha),
register_allocs(ra) {
}
};
Expand Down
Loading