From abd0136ee6f46abb69ae34fa08b14caae0a149f9 Mon Sep 17 00:00:00 2001 From: Zhanlue Yang Date: Fri, 6 May 2022 12:07:30 +0800 Subject: [PATCH] [build] Warning Suppression PR #2: Fixed codebase warnings (#4909) --- taichi/backends/vulkan/vulkan_device.cpp | 5 +---- taichi/backends/vulkan/vulkan_device_creator.cpp | 2 +- taichi/backends/wasm/codegen_wasm.cpp | 2 +- taichi/codegen/spirv/spirv_codegen.cpp | 1 - taichi/program/async_engine.cpp | 8 +++++++- taichi/program/state_flow_graph.cpp | 2 +- taichi/util/io.h | 6 +++++- tests/cpp/ir/ir_type_promotion_test.cpp | 2 +- tests/cpp/transforms/alg_simp_test.cpp | 3 ++- 9 files changed, 19 insertions(+), 12 deletions(-) diff --git a/taichi/backends/vulkan/vulkan_device.cpp b/taichi/backends/vulkan/vulkan_device.cpp index 83c278a0bd058..62b1b4fe6b865 100644 --- a/taichi/backends/vulkan/vulkan_device.cpp +++ b/taichi/backends/vulkan/vulkan_device.cpp @@ -1396,9 +1396,8 @@ void VulkanDevice::dealloc_memory(DeviceAllocation handle) { TI_ASSERT_INFO(map_pair != allocations_.end(), "Invalid handle (double free?) {}", handle.alloc_id); - AllocationInternal &alloc = map_pair->second; - #ifdef TI_VULKAN_DEBUG_ALLOCATIONS + AllocationInternal &alloc = map_pair->second; TI_TRACE("Dealloc VK buffer {}, alloc_id={}", (void *)alloc.buffer, handle.alloc_id); #endif @@ -1831,8 +1830,6 @@ void VulkanDevice::destroy_image(DeviceAllocation handle) { TI_ASSERT_INFO(map_pair != image_allocations_.end(), "Invalid handle (double free?) {}", handle.alloc_id); - ImageAllocInternal &alloc_int = map_pair->second; - image_allocations_.erase(handle.alloc_id); } diff --git a/taichi/backends/vulkan/vulkan_device_creator.cpp b/taichi/backends/vulkan/vulkan_device_creator.cpp index 030398947b2d8..4cbce62120532 100644 --- a/taichi/backends/vulkan/vulkan_device_creator.cpp +++ b/taichi/backends/vulkan/vulkan_device_creator.cpp @@ -455,7 +455,7 @@ void VulkanDeviceCreator::create_logical_device() { bool has_swapchain = false; - bool portability_subset_enabled = false; + [[maybe_unused]] bool portability_subset_enabled = false; for (auto &ext : extension_properties) { TI_TRACE("Vulkan device extension {} ({})", ext.extensionName, diff --git a/taichi/backends/wasm/codegen_wasm.cpp b/taichi/backends/wasm/codegen_wasm.cpp index bba625393ecf8..7170eab5e1779 100644 --- a/taichi/backends/wasm/codegen_wasm.cpp +++ b/taichi/backends/wasm/codegen_wasm.cpp @@ -31,7 +31,7 @@ class CodeGenLLVMWASM : public CodeGenLLVM { } void create_offload_range_for(OffloadedStmt *stmt) override { - int step = 1; + [[maybe_unused]] int step = 1; // In parallel for-loops reversing the order doesn't make sense. // However, we may need to support serial offloaded range for's in the diff --git a/taichi/codegen/spirv/spirv_codegen.cpp b/taichi/codegen/spirv/spirv_codegen.cpp index 0d841a94e2b27..b8901c20c4dde 100644 --- a/taichi/codegen/spirv/spirv_codegen.cpp +++ b/taichi/codegen/spirv/spirv_codegen.cpp @@ -474,7 +474,6 @@ class TaskCodegen : public IRVisitor { void visit(GlobalStoreStmt *stmt) override { TI_ASSERT(stmt->width() == 1); - const auto dt = stmt->val->element_type(); spirv::Value val = ir_->query_value(stmt->val->raw_name()); diff --git a/taichi/program/async_engine.cpp b/taichi/program/async_engine.cpp index a8e644ef610f2..ffd4cae24d199 100644 --- a/taichi/program/async_engine.cpp +++ b/taichi/program/async_engine.cpp @@ -325,8 +325,14 @@ void AsyncEngine::debug_sfg(const std::string &stage) { std::ofstream dot_file(dot_fn + ".dot"); dot_file << dot; } - std::system( + + int return_code = std::system( fmt::format("dot -Tpdf -o {}.pdf {}.dot", dot_fn, dot_fn).c_str()); + if (return_code != 0) { + throw std::runtime_error( + fmt::format("Unable to convert {dot_fn}.dot into {dot_fn}.pdf") + .c_str()); + } } TLANG_NAMESPACE_END diff --git a/taichi/program/state_flow_graph.cpp b/taichi/program/state_flow_graph.cpp index aa4e6a1ae9e3b..b1354b644c8ef 100644 --- a/taichi/program/state_flow_graph.cpp +++ b/taichi/program/state_flow_graph.cpp @@ -447,7 +447,7 @@ bool StateFlowGraph::optimize_listgen() { for (int i = i_start; i < listgens.size(); i++) { auto node_a = listgens[i]; - bool erased_any = false; + [[maybe_unused]] bool erased_any = false; auto new_i = i; diff --git a/taichi/util/io.h b/taichi/util/io.h index e3e372e90a63f..df95671738d79 100644 --- a/taichi/util/io.h +++ b/taichi/util/io.h @@ -22,7 +22,11 @@ inline void create_directories(const std::string &dir) { #if defined(TI_PLATFORM_WINDOWS) std::filesystem::create_directories(dir); #else - std::system(fmt::format("mkdir -p {}", dir).c_str()); + int return_code = std::system(fmt::format("mkdir -p {}", dir).c_str()); + if (return_code != 0) { + throw std::runtime_error( + fmt::format("Unable to create directory at: {dir}").c_str()); + } #endif } diff --git a/tests/cpp/ir/ir_type_promotion_test.cpp b/tests/cpp/ir/ir_type_promotion_test.cpp index 6f444763d7bd0..b4b71b5044092 100644 --- a/tests/cpp/ir/ir_type_promotion_test.cpp +++ b/tests/cpp/ir/ir_type_promotion_test.cpp @@ -13,7 +13,7 @@ TEST(IRTypePromotionTest, ShiftOp) { // (u8)x << (i32)1 -> (u8)res auto *lhs = builder.create_arg_load(0, get_data_type(), false); - auto *res = builder.create_shl(lhs, builder.get_int32(1)); + builder.create_shl(lhs, builder.get_int32(1)); auto ir = builder.extract_ir(); ASSERT_TRUE(ir->is()); diff --git a/tests/cpp/transforms/alg_simp_test.cpp b/tests/cpp/transforms/alg_simp_test.cpp index 469e40b34c371..a8e8f2b850ac6 100644 --- a/tests/cpp/transforms/alg_simp_test.cpp +++ b/tests/cpp/transforms/alg_simp_test.cpp @@ -96,7 +96,8 @@ TEST_F(AlgebraicSimplicationTest, SimplifyMultiplyZeroFastMath) { auto add = block->push_back(BinaryOpType::add, mul, one); auto global_store_addr = block->push_back( 4, TypeFactory::create_vector_or_scalar_type(1, PrimitiveType::i32)); - auto global_store = block->push_back(global_store_addr, add); + [[maybe_unused]] auto global_store = + block->push_back(global_store_addr, add); CompileConfig config_without_fast_math; config_without_fast_math.fast_math = false;