diff --git a/static_core/compiler/aot/aot_builder/BUILD.gn b/static_core/compiler/aot/aot_builder/BUILD.gn index ed075b271d..3cd905bc47 100644 --- a/static_core/compiler/aot/aot_builder/BUILD.gn +++ b/static_core/compiler/aot/aot_builder/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_builder/CMakeLists.txt b/static_core/compiler/aot/aot_builder/CMakeLists.txt index c7e0924752..fbdabae79b 100644 --- a/static_core/compiler/aot/aot_builder/CMakeLists.txt +++ b/static_core/compiler/aot/aot_builder/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_builder/aot_builder.cpp b/static_core/compiler/aot/aot_builder/aot_builder.cpp index da0547ba4f..c11beaa3c7 100644 --- a/static_core/compiler/aot/aot_builder/aot_builder.cpp +++ b/static_core/compiler/aot/aot_builder/aot_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_builder/aot_builder.h b/static_core/compiler/aot/aot_builder/aot_builder.h index 821ecd33a1..3a989e6ae0 100644 --- a/static_core/compiler/aot/aot_builder/aot_builder.h +++ b/static_core/compiler/aot/aot_builder/aot_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_builder/elf_builder.h b/static_core/compiler/aot/aot_builder/elf_builder.h index a9f1deff9b..f4df78f8c8 100644 --- a/static_core/compiler/aot/aot_builder/elf_builder.h +++ b/static_core/compiler/aot/aot_builder/elf_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -845,7 +845,7 @@ void ElfBuilder::Write(const std::string &file_name) elf_file.write(reinterpret_cast(data_span.Data()), data_span.Size()); } -static inline void CopyToSpan(Span to, const char *from, size_t size, size_t begin_index) +inline void CopyToSpan(Span to, const char *from, size_t size, size_t begin_index) { ASSERT(begin_index < to.Size()); auto max_size {to.Size() - begin_index}; diff --git a/static_core/compiler/aot/aot_builder/llvm_aot_builder.cpp b/static_core/compiler/aot/aot_builder/llvm_aot_builder.cpp index da59f767fb..5099bcf366 100644 --- a/static_core/compiler/aot/aot_builder/llvm_aot_builder.cpp +++ b/static_core/compiler/aot/aot_builder/llvm_aot_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_builder/llvm_aot_builder.h b/static_core/compiler/aot/aot_builder/llvm_aot_builder.h index bcad76d423..1acbec7d19 100644 --- a/static_core/compiler/aot/aot_builder/llvm_aot_builder.h +++ b/static_core/compiler/aot/aot_builder/llvm_aot_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_file.cpp b/static_core/compiler/aot/aot_file.cpp index 0410c4ccb1..5d490ae169 100644 --- a/static_core/compiler/aot/aot_file.cpp +++ b/static_core/compiler/aot/aot_file.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -40,10 +40,10 @@ static inline Expected LoadSymbol(const panda::os: } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define LOAD_AOT_SYMBOL(name) \ - auto name = LoadSymbol(handle, #name); \ - if (!name) { \ - return Unexpected("Cannot load name section: " + name.Error()); \ +#define LOAD_AOT_SYMBOL(name) \ + auto name = LoadSymbol(handle, (#name)); \ + if (!(name)) { \ + return Unexpected("Cannot load name section: " + (name).Error()); \ } Expected, std::string> AotFile::Open(const std::string &file_name, uint32_t gc_type, diff --git a/static_core/compiler/aot/aot_file.h b/static_core/compiler/aot/aot_file.h index 17ff2c57ab..348de25fc5 100644 --- a/static_core/compiler/aot/aot_file.h +++ b/static_core/compiler/aot/aot_file.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_headers.h b/static_core/compiler/aot/aot_headers.h index 84c1fdd441..e48d067486 100644 --- a/static_core/compiler/aot/aot_headers.h +++ b/static_core/compiler/aot/aot_headers.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_manager.cpp b/static_core/compiler/aot/aot_manager.cpp index eb643c8f57..6431f62f80 100644 --- a/static_core/compiler/aot/aot_manager.cpp +++ b/static_core/compiler/aot/aot_manager.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/aot_manager.h b/static_core/compiler/aot/aot_manager.h index 404b379372..651f9b38ae 100644 --- a/static_core/compiler/aot/aot_manager.h +++ b/static_core/compiler/aot/aot_manager.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/aot/compiled_method.h b/static_core/compiler/aot/compiled_method.h index 66211d0865..ec4493e818 100644 --- a/static_core/compiler/aot/compiled_method.h +++ b/static_core/compiler/aot/compiled_method.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/code_info/code_info.cpp b/static_core/compiler/code_info/code_info.cpp index de1360b472..b2677aac23 100644 --- a/static_core/compiler/code_info/code_info.cpp +++ b/static_core/compiler/code_info/code_info.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -35,7 +35,7 @@ void CodeInfo::Dump(std::ostream &stream, const StackMap &stack_map, Arch arch) stream << "Stackmap #" << stack_map.GetRow() << ": npc=0x" << std::hex << stack_map.GetNativePcUnpacked(arch) << ", bpc=0x" << std::hex << stack_map.GetBytecodePc(); if (stack_map.HasInlineInfoIndex()) { - stream << ", inline_depth=" << GetInlineDepth(stack_map) + 1; + stream << ", inline_depth=" << (GetInlineDepth(stack_map) + 1); } if (stack_map.HasRootsRegMaskIndex() || stack_map.HasRootsStackMaskIndex()) { stream << ", roots=["; diff --git a/static_core/compiler/code_info/code_info.h b/static_core/compiler/code_info/code_info.h index b3cf7af8f0..a1e8a6b4bf 100644 --- a/static_core/compiler/code_info/code_info.h +++ b/static_core/compiler/code_info/code_info.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/code_info/code_info_builder.cpp b/static_core/compiler/code_info/code_info_builder.cpp index 8f8e1d9f17..7ce9cfa1b6 100644 --- a/static_core/compiler/code_info/code_info_builder.cpp +++ b/static_core/compiler/code_info/code_info_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -94,7 +94,7 @@ void CodeInfoBuilder::EndStackMap() void CodeInfoBuilder::DumpCurrentStackMap(std::ostream &stream) const { - stream << "Stackmap #" << stack_maps_.GetRowsCount() - 1 << ": npc=0x" << std::hex + stream << "Stackmap #" << (stack_maps_.GetRowsCount() - 1) << ": npc=0x" << std::hex << StackMap::UnpackAddress(current_stack_map_[StackMap::COLUMN_NATIVE_PC], arch_) << ", bpc=0x" << std::hex << current_stack_map_[StackMap::COLUMN_BYTECODE_PC]; if (current_stack_map_[StackMap::COLUMN_INLINE_INFO_INDEX] != StackMap::NO_VALUE) { diff --git a/static_core/compiler/code_info/code_info_builder.h b/static_core/compiler/code_info/code_info_builder.h index 6d98078b20..6aa6d8b6b9 100644 --- a/static_core/compiler/code_info/code_info_builder.h +++ b/static_core/compiler/code_info/code_info_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/code_info/code_info_tables.h b/static_core/compiler/code_info/code_info_tables.h index 69ac35de75..1b71749457 100644 --- a/static_core/compiler/code_info/code_info_tables.h +++ b/static_core/compiler/code_info/code_info_tables.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/code_info/vreg_info.h b/static_core/compiler/code_info/vreg_info.h index e5f8eec744..2161b46b28 100644 --- a/static_core/compiler/code_info/vreg_info.h +++ b/static_core/compiler/code_info/vreg_info.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/compile_method.cpp b/static_core/compiler/compile_method.cpp index cd031da260..d9bbe022f3 100644 --- a/static_core/compiler/compile_method.cpp +++ b/static_core/compiler/compile_method.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -195,7 +195,6 @@ bool JITCompileMethod(RuntimeInterface *runtime, Method *method, bool is_osr, Co auto arch {Arch::NONE}; bool is_dynamic = panda::panda_file::IsDynamicLanguage(method->GetClass()->GetSourceLang()); - if (!CompileInGraph(runtime, method, is_osr, allocator, local_allocator, is_dynamic, &arch, method_name, &graph, jit_stats)) { return false; diff --git a/static_core/compiler/compile_method.h b/static_core/compiler/compile_method.h index 6ebadb2658..91a5911fc7 100644 --- a/static_core/compiler/compile_method.h +++ b/static_core/compiler/compile_method.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/compiler_logger.cpp b/static_core/compiler/compiler_logger.cpp index dc63468dcc..4bc83e3d4c 100644 --- a/static_core/compiler/compiler_logger.cpp +++ b/static_core/compiler/compiler_logger.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,8 +34,8 @@ void CompilerLogger::SetComponents(const std::vector& args) } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DEF(COMPONENT, NAME) \ - if (NAME == arg) { \ - components_.set(COMPONENT); \ + if ((NAME) == arg) { \ + components_.set(COMPONENT); \ continue; \ } COMPILER_LOG_COMPONENTS(DEF) diff --git a/static_core/compiler/compiler_logger.h b/static_core/compiler/compiler_logger.h index abb7d7f528..ee16a26fab 100644 --- a/static_core/compiler/compiler_logger.h +++ b/static_core/compiler/compiler_logger.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/compiler_options.cpp b/static_core/compiler/compiler_options.cpp index 296777f275..86647aa822 100644 --- a/static_core/compiler/compiler_options.cpp +++ b/static_core/compiler/compiler_options.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/compiler_options.h b/static_core/compiler/compiler_options.h index 24eb72fca1..7752e7882f 100644 --- a/static_core/compiler/compiler_options.h +++ b/static_core/compiler/compiler_options.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -123,7 +123,7 @@ private: } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DEF(FEATURE, NAME) \ - if (NAME == arg) { \ + if ((NAME) == arg) { \ EnableCpuFeature(FEATURE); \ continue; \ } diff --git a/static_core/compiler/intrinsics_can_encode.inl b/static_core/compiler/intrinsics_can_encode.inl index 5f3ae61fbb..502a01d807 100644 --- a/static_core/compiler/intrinsics_can_encode.inl +++ b/static_core/compiler/intrinsics_can_encode.inl @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/static_core/compiler/optimizer/analysis/alias_analysis.cpp b/static_core/compiler/optimizer/analysis/alias_analysis.cpp index 096002234f..ed57092e14 100644 --- a/static_core/compiler/optimizer/analysis/alias_analysis.cpp +++ b/static_core/compiler/optimizer/analysis/alias_analysis.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -308,6 +308,37 @@ AliasType AliasAnalysis::CheckRefAlias(Inst *ref1, Inst *ref2) const return CheckMemAddress(Pointer::CreateObject(ref1), Pointer::CreateObject(ref2)); } +AliasType AliasAnalysis::CheckMemAddressEmptyIntersectionCase(const PointerSet &aliases1, const PointerSet &aliases2, + const Pointer &p1, const Pointer &p2) const +{ + // If at least one set of aliases consists of only local aliases then there is NO_ALIAS + auto is_outer = [](Pointer const &p) { return !p.IsLocal(); }; + if (std::find_if(aliases1.begin(), aliases1.end(), is_outer) == aliases1.end() || + std::find_if(aliases2.begin(), aliases2.end(), is_outer) == aliases2.end()) { + return NO_ALIAS; + } + // Different fields cannot alias each other even if they are not created locally + if (p1.GetType() == OBJECT_FIELD && !p1.HasSameOffset(p2)) { + return NO_ALIAS; + } + if (p1.GetType() == ARRAY_ELEMENT) { + auto equal = IsSameOffsets(p1.GetIdx(), p2.GetIdx()); + // If it is known that indices are different OR Imm indices are different then there is + // no alias. If they are both different we can't certainly say so. + if ((equal == Trilean::FALSE && p1.GetImm() == p2.GetImm()) || + (equal == Trilean::TRUE && p1.GetImm() != p2.GetImm())) { + return NO_ALIAS; + } + } + if (p1.GetType() == DICTIONARY_ELEMENT) { + auto equal = IsSameOffsets(p1.GetIdx(), p2.GetIdx()); + if (equal == Trilean::FALSE && p1.GetImm() == p2.GetImm()) { + return NO_ALIAS; + } + } + return MAY_ALIAS; +} + /** * We have 5 types of pointers: OBJECT, OBJECT_FIELD, POOL_CONSTANT, * STATIC_FIELD and ARRAY_ELEMENT. They correspond to groups of memory storing @@ -362,36 +393,10 @@ AliasType AliasAnalysis::CheckMemAddress(const Pointer &p1, const Pointer &p2) c if (intersection != nullptr && aliases1.size() == 1 && aliases2.size() == 1) { return SingleIntersectionAliasing(p1, p2, intersection); } - // Empty intersection: check that both addresses are not parameters if (intersection == nullptr) { - // If at least one set of aliases consists of only local aliases then there is NO_ALIAS - auto is_outer = [](Pointer const &p) { return !p.IsLocal(); }; - if (std::find_if(aliases1.begin(), aliases1.end(), is_outer) == aliases1.end() || - std::find_if(aliases2.begin(), aliases2.end(), is_outer) == aliases2.end()) { - return NO_ALIAS; - } - // Different fields cannot alias each other even if they are not created locally - if (p1.GetType() == OBJECT_FIELD && !p1.HasSameOffset(p2)) { - return NO_ALIAS; - } - if (p1.GetType() == ARRAY_ELEMENT) { - auto equal = IsSameOffsets(p1.GetIdx(), p2.GetIdx()); - // If it is known that indices are different OR Imm indices are different then there is - // no alias. If they are both different we can't certainly say so. - if ((equal == Trilean::FALSE && p1.GetImm() == p2.GetImm()) || - (equal == Trilean::TRUE && p1.GetImm() != p2.GetImm())) { - return NO_ALIAS; - } - } - if (p1.GetType() == DICTIONARY_ELEMENT) { - auto equal = IsSameOffsets(p1.GetIdx(), p2.GetIdx()); - if (equal == Trilean::FALSE && p1.GetImm() == p2.GetImm()) { - return NO_ALIAS; - } - } + return CheckMemAddressEmptyIntersectionCase(aliases1, aliases2, p1, p2); } - return MAY_ALIAS; } @@ -433,6 +438,62 @@ AliasType AliasAnalysis::SingleIntersectionAliasing(const Pointer &p1, const Poi return MUST_ALIAS; } +void AliasAnalysis::SolveConstraintsMainLoop(Pointer &ref, Pointer &edge, bool &added, PointerSet &sols) +{ + for (auto &alias : points_to_.at(ref)) { + ASSERT(alias.GetBase() == nullptr || alias.GetBase()->GetOpcode() != Opcode::NullCheck); + if (edge.GetType() == OBJECT_FIELD && ref.GetBase() == edge.GetBase()) { + // Propagating from object to fields: A{a} -> A.F{a.f} + if (alias.GetType() == OBJECT) { + Pointer p = Pointer::CreateObjectField(alias.GetBase(), edge.GetImm(), edge.GetTypePtr()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + // In case A{a.g} -> A.F we propagate symbolic name: A{a.g} -> A.F{A.F} + Pointer p = Pointer::CreateObjectField(ref.GetBase(), edge.GetImm(), edge.GetTypePtr()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + if (edge.GetType() == ARRAY_ELEMENT && ref.GetBase() == edge.GetBase()) { + // Propagating from object to elements: A{a} -> A[i]{a[i]} + if (alias.GetType() == OBJECT) { + Pointer p = Pointer::CreateArrayElement(alias.GetBase(), edge.GetIdx(), edge.GetImm()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + // In case A{a[j]} -> A[i] we propagate symbolic name: A{a[j]} -> A[i]{A[i]} + Pointer p = Pointer::CreateArrayElement(ref.GetBase(), edge.GetIdx(), edge.GetImm()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + if (edge.GetType() == DICTIONARY_ELEMENT && ref.GetBase() == edge.GetBase()) { + // Propagating from object to elements: A{a} -> A[i]{a[i]} + if (alias.GetType() == OBJECT) { + Pointer p = Pointer::CreateDictionaryElement(alias.GetBase(), edge.GetIdx()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + // In case A{a[j]} -> A[i] we propagate symbolic name: A{a[j]} -> A[i]{A[i]} + Pointer p = Pointer::CreateDictionaryElement(ref.GetBase(), edge.GetIdx()); + p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + + added |= sols.insert(p).second; + continue; + } + added |= sols.insert(alias).second; + } +} + /** * Here we propagate solutions obtained from direct constraints through copy * constraints e.g: we have a node A with solution {a} and the node A was @@ -482,58 +543,9 @@ void AliasAnalysis::SolveConstraints() ASSERT(edge.GetType() != POOL_CONSTANT); auto &sols = points_to_.try_emplace(edge, GetGraph()->GetAllocator()->Adapter()).first->second; bool added = false; - for (auto &alias : points_to_.at(ref)) { - ASSERT(alias.GetBase() == nullptr || alias.GetBase()->GetOpcode() != Opcode::NullCheck); - if (edge.GetType() == OBJECT_FIELD && ref.GetBase() == edge.GetBase()) { - // Propagating from object to fields: A{a} -> A.F{a.f} - if (alias.GetType() == OBJECT) { - Pointer p = Pointer::CreateObjectField(alias.GetBase(), edge.GetImm(), edge.GetTypePtr()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); - added |= sols.insert(p).second; - continue; - } - // In case A{a.g} -> A.F we propagate symbolic name: A{a.g} -> A.F{A.F} - Pointer p = Pointer::CreateObjectField(ref.GetBase(), edge.GetImm(), edge.GetTypePtr()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); + SolveConstraintsMainLoop(ref, edge, added, sols); - added |= sols.insert(p).second; - continue; - } - if (edge.GetType() == ARRAY_ELEMENT && ref.GetBase() == edge.GetBase()) { - // Propagating from object to elements: A{a} -> A[i]{a[i]} - if (alias.GetType() == OBJECT) { - Pointer p = Pointer::CreateArrayElement(alias.GetBase(), edge.GetIdx(), edge.GetImm()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); - - added |= sols.insert(p).second; - continue; - } - // In case A{a[j]} -> A[i] we propagate symbolic name: A{a[j]} -> A[i]{A[i]} - Pointer p = Pointer::CreateArrayElement(ref.GetBase(), edge.GetIdx(), edge.GetImm()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); - - added |= sols.insert(p).second; - continue; - } - if (edge.GetType() == DICTIONARY_ELEMENT && ref.GetBase() == edge.GetBase()) { - // Propagating from object to elements: A{a} -> A[i]{a[i]} - if (alias.GetType() == OBJECT) { - Pointer p = Pointer::CreateDictionaryElement(alias.GetBase(), edge.GetIdx()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); - - added |= sols.insert(p).second; - continue; - } - // In case A{a[j]} -> A[i] we propagate symbolic name: A{a[j]} -> A[i]{A[i]} - Pointer p = Pointer::CreateDictionaryElement(ref.GetBase(), edge.GetIdx()); - p.SetLocalVolatile(alias.IsLocal(), edge.IsVolatile()); - - added |= sols.insert(p).second; - continue; - } - added |= sols.insert(alias).second; - } if (added && chains_->find(edge) != chains_->end()) { worklist.push(edge); } diff --git a/static_core/compiler/optimizer/analysis/alias_analysis.h b/static_core/compiler/optimizer/analysis/alias_analysis.h index d2a1c2945a..4f96b61b7c 100644 --- a/static_core/compiler/optimizer/analysis/alias_analysis.h +++ b/static_core/compiler/optimizer/analysis/alias_analysis.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -413,7 +413,9 @@ private: static Trilean IsSameOffsets(const Inst *off1, const Inst *off2); static AliasType SingleIntersectionAliasing(const Pointer &p1, const Pointer &p2, const Pointer *intersection); - + AliasType CheckMemAddressEmptyIntersectionCase(const PointerSet &aliases1, const PointerSet &aliases2, + const Pointer &p1, const Pointer &p2) const; + void SolveConstraintsMainLoop(Pointer &ref, Pointer &edge, bool &added, PointerSet &sols); void DumpChains(std::ostream *out) const; private: diff --git a/static_core/compiler/optimizer/analysis/bounds_analysis.cpp b/static_core/compiler/optimizer/analysis/bounds_analysis.cpp index f4259e382f..f395679380 100644 --- a/static_core/compiler/optimizer/analysis/bounds_analysis.cpp +++ b/static_core/compiler/optimizer/analysis/bounds_analysis.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -858,7 +858,6 @@ void BoundsAnalysis::VisitIfImm(GraphVisitor *v, Inst *inst) } auto op0 = compare->GetInput(0).GetInst(); auto op1 = compare->GetInput(1).GetInst(); - if ((DataType::GetCommonType(op0->GetType()) != DataType::INT64 && op0->GetType() != DataType::REFERENCE) || (DataType::GetCommonType(op1->GetType()) != DataType::INT64 && op1->GetType() != DataType::REFERENCE)) { return; diff --git a/static_core/compiler/optimizer/analysis/bounds_analysis.h b/static_core/compiler/optimizer/analysis/bounds_analysis.h index d36bb1ea9a..90b2174987 100644 --- a/static_core/compiler/optimizer/analysis/bounds_analysis.h +++ b/static_core/compiler/optimizer/analysis/bounds_analysis.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/catch_inputs.cpp b/static_core/compiler/optimizer/analysis/catch_inputs.cpp index f94c0302a4..3bb3f00abe 100644 --- a/static_core/compiler/optimizer/analysis/catch_inputs.cpp +++ b/static_core/compiler/optimizer/analysis/catch_inputs.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/catch_inputs.h b/static_core/compiler/optimizer/analysis/catch_inputs.h index 1d19911268..e16b66af05 100644 --- a/static_core/compiler/optimizer/analysis/catch_inputs.h +++ b/static_core/compiler/optimizer/analysis/catch_inputs.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/countable_loop_parser.cpp b/static_core/compiler/optimizer/analysis/countable_loop_parser.cpp index dd48222bb1..5c3b23f36c 100644 --- a/static_core/compiler/optimizer/analysis/countable_loop_parser.cpp +++ b/static_core/compiler/optimizer/analysis/countable_loop_parser.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/countable_loop_parser.h b/static_core/compiler/optimizer/analysis/countable_loop_parser.h index 7d211198b0..64a48cff23 100644 --- a/static_core/compiler/optimizer/analysis/countable_loop_parser.h +++ b/static_core/compiler/optimizer/analysis/countable_loop_parser.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -56,6 +56,7 @@ private: void SetNormalizedConditionCode(); bool IsConditionCodeAcceptable(); BasicBlock *FindLoopExitBlock(); + bool CheckParsingLoopCorrectness(); private: const Loop &loop_; diff --git a/static_core/compiler/optimizer/analysis/dominators_tree.cpp b/static_core/compiler/optimizer/analysis/dominators_tree.cpp index 388af16ed7..3505dd6ae4 100644 --- a/static_core/compiler/optimizer/analysis/dominators_tree.cpp +++ b/static_core/compiler/optimizer/analysis/dominators_tree.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/dominators_tree.h b/static_core/compiler/optimizer/analysis/dominators_tree.h index a1d4f0135e..b8ff53ed96 100644 --- a/static_core/compiler/optimizer/analysis/dominators_tree.h +++ b/static_core/compiler/optimizer/analysis/dominators_tree.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/linear_order.cpp b/static_core/compiler/optimizer/analysis/linear_order.cpp index 28b4fc55ae..f7de9a2072 100644 --- a/static_core/compiler/optimizer/analysis/linear_order.cpp +++ b/static_core/compiler/optimizer/analysis/linear_order.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -168,7 +168,6 @@ BasicBlock *LinearOrder::LeastLikelySuccessorByBranchCounter(const BasicBlock *b auto counter0 = GetBranchCounter(block, true); auto counter1 = GetBranchCounter(block, false); - if (counter0 > 0 || counter1 > 0) { auto denom = std::max(counter0, counter1); ASSERT(denom != 0); diff --git a/static_core/compiler/optimizer/analysis/linear_order.h b/static_core/compiler/optimizer/analysis/linear_order.h index bb7285f162..a7c0513141 100644 --- a/static_core/compiler/optimizer/analysis/linear_order.h +++ b/static_core/compiler/optimizer/analysis/linear_order.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/live_registers.cpp b/static_core/compiler/optimizer/analysis/live_registers.cpp index 65a35fd572..78918fe178 100644 --- a/static_core/compiler/optimizer/analysis/live_registers.cpp +++ b/static_core/compiler/optimizer/analysis/live_registers.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/live_registers.h b/static_core/compiler/optimizer/analysis/live_registers.h index ba639860c4..2660fccac0 100644 --- a/static_core/compiler/optimizer/analysis/live_registers.h +++ b/static_core/compiler/optimizer/analysis/live_registers.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/liveness_analyzer.cpp b/static_core/compiler/optimizer/analysis/liveness_analyzer.cpp index 08bb62300f..a958d9b74b 100644 --- a/static_core/compiler/optimizer/analysis/liveness_analyzer.cpp +++ b/static_core/compiler/optimizer/analysis/liveness_analyzer.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -861,21 +861,15 @@ LifeNumber LifeIntervals::GetFirstIntersectionWith(const LifeIntervals *other, L } auto range_begin = std::max(search_from, range.GetBegin()); auto other_range_begin = std::max(search_from, other_range.GetBegin()); - - if (range_begin <= other_range_begin) { - if (other_range_begin < range.GetEnd()) { - // [range] - // [other] - return other_range_begin; - } - ASSERT(other_range_begin >= range.GetEnd()); - } else { + if (range_begin <= other_range_begin && other_range_begin < range.GetEnd()) { + // [range] + // [other] + return other_range_begin; + // NOLINTNEXTLINE(readability-else-after-return) + } else if (range_begin > other_range_begin && range_begin < other_range.GetEnd()) { // [range] // [other] - if (range_begin < other_range.GetEnd()) { - return range_begin; - } - ASSERT(range_begin >= other_range.GetEnd()); + return range_begin; } } } diff --git a/static_core/compiler/optimizer/analysis/liveness_analyzer.h b/static_core/compiler/optimizer/analysis/liveness_analyzer.h index 70330265c6..a51c680063 100644 --- a/static_core/compiler/optimizer/analysis/liveness_analyzer.h +++ b/static_core/compiler/optimizer/analysis/liveness_analyzer.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/liveness_use_table.cpp b/static_core/compiler/optimizer/analysis/liveness_use_table.cpp index 921f2f2c34..0faefc104a 100644 --- a/static_core/compiler/optimizer/analysis/liveness_use_table.cpp +++ b/static_core/compiler/optimizer/analysis/liveness_use_table.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/liveness_use_table.h b/static_core/compiler/optimizer/analysis/liveness_use_table.h index 3078aa4a09..60cd138f03 100644 --- a/static_core/compiler/optimizer/analysis/liveness_use_table.h +++ b/static_core/compiler/optimizer/analysis/liveness_use_table.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/loop_analyzer.cpp b/static_core/compiler/optimizer/analysis/loop_analyzer.cpp index d2d35b7e26..0b05f85622 100644 --- a/static_core/compiler/optimizer/analysis/loop_analyzer.cpp +++ b/static_core/compiler/optimizer/analysis/loop_analyzer.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/loop_analyzer.h b/static_core/compiler/optimizer/analysis/loop_analyzer.h index 202ec78013..8ec5b19564 100644 --- a/static_core/compiler/optimizer/analysis/loop_analyzer.h +++ b/static_core/compiler/optimizer/analysis/loop_analyzer.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/monitor_analysis.cpp b/static_core/compiler/optimizer/analysis/monitor_analysis.cpp index 722044eef0..bc57b6c77c 100644 --- a/static_core/compiler/optimizer/analysis/monitor_analysis.cpp +++ b/static_core/compiler/optimizer/analysis/monitor_analysis.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/monitor_analysis.h b/static_core/compiler/optimizer/analysis/monitor_analysis.h index 1a06b937a0..a3b22e1fb3 100644 --- a/static_core/compiler/optimizer/analysis/monitor_analysis.h +++ b/static_core/compiler/optimizer/analysis/monitor_analysis.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/object_type_propagation.cpp b/static_core/compiler/optimizer/analysis/object_type_propagation.cpp index a13e8c4b32..225918771d 100644 --- a/static_core/compiler/optimizer/analysis/object_type_propagation.cpp +++ b/static_core/compiler/optimizer/analysis/object_type_propagation.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/object_type_propagation.h b/static_core/compiler/optimizer/analysis/object_type_propagation.h index 1e85b86bc5..fa67309a9c 100644 --- a/static_core/compiler/optimizer/analysis/object_type_propagation.h +++ b/static_core/compiler/optimizer/analysis/object_type_propagation.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/reg_alloc_verifier.cpp b/static_core/compiler/optimizer/analysis/reg_alloc_verifier.cpp index 1a906cf956..2aabc564fe 100644 --- a/static_core/compiler/optimizer/analysis/reg_alloc_verifier.cpp +++ b/static_core/compiler/optimizer/analysis/reg_alloc_verifier.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/reg_alloc_verifier.h b/static_core/compiler/optimizer/analysis/reg_alloc_verifier.h index d47a0196e4..c94f960159 100644 --- a/static_core/compiler/optimizer/analysis/reg_alloc_verifier.h +++ b/static_core/compiler/optimizer/analysis/reg_alloc_verifier.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/rpo.cpp b/static_core/compiler/optimizer/analysis/rpo.cpp index a26d58484b..bd2c523725 100644 --- a/static_core/compiler/optimizer/analysis/rpo.cpp +++ b/static_core/compiler/optimizer/analysis/rpo.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/rpo.h b/static_core/compiler/optimizer/analysis/rpo.h index 66108e0148..16ef35062e 100644 --- a/static_core/compiler/optimizer/analysis/rpo.h +++ b/static_core/compiler/optimizer/analysis/rpo.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/types_analysis.cpp b/static_core/compiler/optimizer/analysis/types_analysis.cpp index d01320e0a7..ccb2bcc341 100644 --- a/static_core/compiler/optimizer/analysis/types_analysis.cpp +++ b/static_core/compiler/optimizer/analysis/types_analysis.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/analysis/types_analysis.h b/static_core/compiler/optimizer/analysis/types_analysis.h index a626f63ef4..5de1c14066 100644 --- a/static_core/compiler/optimizer/analysis/types_analysis.h +++ b/static_core/compiler/optimizer/analysis/types_analysis.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/callconv.h b/static_core/compiler/optimizer/code_generator/callconv.h index e7d16782fa..3392506a72 100644 --- a/static_core/compiler/optimizer/code_generator/callconv.h +++ b/static_core/compiler/optimizer/code_generator/callconv.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -100,19 +100,34 @@ public: ~CallConvMode() = default; +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define DECLARE_CALLCONV_MODE_MODIFIERS(name) \ + void Set##name(bool v) \ + { \ + Flag##name ::Set(v, &value_); \ + } \ + bool Is##name() const \ + { \ + return Flag##name ::Get(value_); \ + } + // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DECLARE_CALLCONV_MODE(name) \ static CallConvMode name(bool set = true) \ { \ return CallConvMode(Flag##name ::Encode(set)); \ } \ - void Set##name(bool v) \ - { \ - Flag##name ::Set(v, &value_); \ - } \ - bool Is##name() const \ - { \ - return Flag##name ::Get(value_); \ + DECLARE_CALLCONV_MODE_MODIFIERS(name) + +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define DECLARE_CALLCONV_MODE_MODIFIERS(name) \ + void Set##name(bool v) \ + { \ + Flag##name ::Set(v, &value_); \ + } \ + bool Is##name() const \ + { \ + return Flag##name ::Get(value_); \ } // Panda ABI convention (native - otherwise) @@ -125,6 +140,7 @@ public: DECLARE_CALLCONV_MODE(OptIrtoc); #undef DECLARE_CALLCONV_MODE +#undef DECLARE_CALLCONV_MODIFIERS private: using FlagPanda = BitField; diff --git a/static_core/compiler/optimizer/code_generator/codegen.cpp b/static_core/compiler/optimizer/code_generator/codegen.cpp index 2816515b3c..999aa97b2f 100644 --- a/static_core/compiler/optimizer/code_generator/codegen.cpp +++ b/static_core/compiler/optimizer/code_generator/codegen.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -520,7 +520,7 @@ void Codegen::IssueDisasm() pc = new_pc; } } else if (std::holds_alternative(item)) { - stream << std::get(item); + stream << (std::get(item)); } } } @@ -574,28 +574,7 @@ bool Codegen::RunImpl() } } - if (GetDisasm()->IsEnabled()) { - GetDisasm()->PrintMethodEntry(this); - } - - if (!BeginMethod()) { - return false; - } - - if (!VisitGraph()) { - return false; - } - EndMethod(); - - if (!CopyToCodeCache()) { - return false; - } - - if (GetDisasm()->IsEnabled()) { - IssueDisasm(); - } - - return true; + return Finalize(); } void Codegen::Initialize() @@ -666,6 +645,32 @@ void Codegen::Initialize() } } +bool Codegen::Finalize() +{ + if (GetDisasm()->IsEnabled()) { + GetDisasm()->PrintMethodEntry(this); + } + + if (!BeginMethod()) { + return false; + } + + if (!VisitGraph()) { + return false; + } + EndMethod(); + + if (!CopyToCodeCache()) { + return false; + } + + if (GetDisasm()->IsEnabled()) { + IssueDisasm(); + } + + return true; +} + Reg Codegen::ConvertRegister(Register r, DataType::Type type) { switch (type) { @@ -1109,7 +1114,6 @@ void Codegen::CreateNewObjCall(NewObjectInst *new_obj) auto runtime = GetRuntime(); auto max_tlab_size = runtime->GetTLABMaxSize(); - if (max_tlab_size == 0 || (init_class->GetOpcode() != Opcode::LoadAndInitClass && init_class->GetOpcode() != Opcode::LoadImmediate)) { CallRuntime(new_obj, EntrypointId::CREATE_OBJECT_BY_CLASS, dst, RegMask::GetZeroMask(), src); @@ -1819,7 +1823,6 @@ void Codegen::CreatePreWRB(Inst *inst, MemRef mem, RegMask preserved, bool store TryInsertImplicitNullCheck(inst, prev_offset); if constexpr (IS_CLASS) { enc->EncodeLdr(tmp_ref, false, MemRef(tmp_ref, runtime->GetManagedClassOffset(GetArch()))); - } else { CheckObject(tmp_ref, label); } @@ -2857,6 +2860,26 @@ void EncodeVisitor::VisitFillConstArray(GraphVisitor *visitor, Inst *inst) } } +static void GetEntryPointId(uint64_t element_size, RuntimeInterface::EntrypointId &eid) +{ + switch (element_size) { + case sizeof(uint8_t): + eid = RuntimeInterface::EntrypointId::ALLOCATE_ARRAY_TLAB8; + break; + case sizeof(uint16_t): + eid = RuntimeInterface::EntrypointId::ALLOCATE_ARRAY_TLAB16; + break; + case sizeof(uint32_t): + eid = RuntimeInterface::EntrypointId::ALLOCATE_ARRAY_TLAB32; + break; + case sizeof(uint64_t): + eid = RuntimeInterface::EntrypointId::ALLOCATE_ARRAY_TLAB64; + break; + default: + UNREACHABLE(); + } +} + void Codegen::VisitNewArray(Inst *inst) { auto method = inst->CastToNewArray()->GetMethod(); @@ -2868,7 +2891,6 @@ void Codegen::VisitNewArray(Inst *inst) auto encoder = GetEncoder(); auto max_tlab_size = runtime->GetTLABMaxSize(); - // TODO(msherstennikov): support NewArray fast path for arm32 if (max_tlab_size == 0 || GetArch() == Arch::AARCH32) { CallRuntime(inst, EntrypointId::CREATE_ARRAY, dst, RegMask::GetZeroMask(), src_class, src_size); @@ -2897,23 +2919,7 @@ void Codegen::VisitNewArray(Inst *inst) } EntrypointId eid; - switch (element_size) { - case sizeof(uint8_t): - eid = EntrypointId::ALLOCATE_ARRAY_TLAB8; - break; - case sizeof(uint16_t): - eid = EntrypointId::ALLOCATE_ARRAY_TLAB16; - break; - case sizeof(uint32_t): - eid = EntrypointId::ALLOCATE_ARRAY_TLAB32; - break; - case sizeof(uint64_t): - eid = EntrypointId::ALLOCATE_ARRAY_TLAB64; - break; - default: - UNREACHABLE(); - } - + GetEntryPointId(element_size, eid); CallFastPath(inst, eid, dst, RegMask::GetZeroMask(), src_class, src_size); if (inst->GetFlag(inst_flags::MEM_BARRIER)) { encoder->EncodeMemoryBarrier(memory_order::RELEASE); @@ -2936,7 +2942,6 @@ void EncodeVisitor::VisitParameter(GraphVisitor *visitor, Inst *inst) auto codegen = enc->GetCodegen(); auto param_inst = inst->CastToParameter(); auto sf = param_inst->GetLocationData(); - if (sf.GetSrc() == sf.GetDst()) { return; } @@ -4199,7 +4204,6 @@ void EncodeVisitor::VisitCheckCast(GraphVisitor *visitor, Inst *inst) auto encoder = enc->GetEncoder(); auto klass_type = inst->CastToCheckCast()->GetClassType(); - if (klass_type == ClassType::UNRESOLVED_CLASS) { FillUnresolvedClass(visitor, inst); return; @@ -5405,43 +5409,15 @@ void EncodeVisitor::VisitObjByIndexCheck(GraphVisitor *visitor, Inst *inst) UNREACHABLE(); } auto id = enc->GetCodegen()->CreateSlowPath(inst, DeoptimizeType::ANY_TYPE_CHECK)->GetLabel(); - if (TryObjByIndexCheckPluginGen(check_inst, enc, id)) { return; } UNREACHABLE(); } -/** - * Returns true if codegen emits call(s) to some library function(s) - * while processing the instruction. - */ -bool Codegen::InstEncodedWithLibCall(const Inst *inst, Arch arch) +static bool GetNeedBarrierProperty(const Inst *inst) { - ASSERT(inst != nullptr); Opcode op = inst->GetOpcode(); - if (op == Opcode::Mod) { - auto dst_type = inst->GetType(); - if (arch == Arch::AARCH64 || arch == Arch::X86_64) { - return dst_type == DataType::FLOAT32 || dst_type == DataType::FLOAT64; - } - return arch == Arch::AARCH32; - } - if (op == Opcode::Div && arch == Arch::AARCH32) { - auto dst_type = inst->GetType(); - return dst_type == DataType::INT64 || dst_type == DataType::UINT64; - } - if (op == Opcode::Cast && arch == Arch::AARCH32) { - auto dst_type = inst->GetType(); - auto src_type = inst->GetInputType(0); - if (dst_type == DataType::FLOAT32 || dst_type == DataType::FLOAT64) { - return src_type == DataType::INT64 || src_type == DataType::UINT64; - } - if (src_type == DataType::FLOAT32 || src_type == DataType::FLOAT64) { - return dst_type == DataType::INT64 || dst_type == DataType::UINT64; - } - return false; - } if (op == Opcode::LoadObject) { return inst->CastToLoadObject()->GetNeedBarrier(); } @@ -5481,6 +5457,40 @@ bool Codegen::InstEncodedWithLibCall(const Inst *inst, Arch arch) return false; } +/** + * Returns true if codegen emits call(s) to some library function(s) + * while processing the instruction. + */ +bool Codegen::InstEncodedWithLibCall(const Inst *inst, Arch arch) +{ + ASSERT(inst != nullptr); + Opcode op = inst->GetOpcode(); + if (op == Opcode::Mod) { + auto dst_type = inst->GetType(); + if (arch == Arch::AARCH64 || arch == Arch::X86_64) { + return dst_type == DataType::FLOAT32 || dst_type == DataType::FLOAT64; + } + return arch == Arch::AARCH32; + } + if (op == Opcode::Div && arch == Arch::AARCH32) { + auto dst_type = inst->GetType(); + return dst_type == DataType::INT64 || dst_type == DataType::UINT64; + } + if (op == Opcode::Cast && arch == Arch::AARCH32) { + auto dst_type = inst->GetType(); + auto src_type = inst->GetInputType(0); + if (dst_type == DataType::FLOAT32 || dst_type == DataType::FLOAT64) { + return src_type == DataType::INT64 || src_type == DataType::UINT64; + } + if (src_type == DataType::FLOAT32 || src_type == DataType::FLOAT64) { + return dst_type == DataType::INT64 || dst_type == DataType::UINT64; + } + return false; + } + + return GetNeedBarrierProperty(inst); +} + Reg Codegen::ConvertInstTmpReg(const Inst *inst, DataType::Type type) const { ASSERT(inst->GetTmpLocation().IsFixedRegister()); diff --git a/static_core/compiler/optimizer/code_generator/codegen.h b/static_core/compiler/optimizer/code_generator/codegen.h index 060d64e00d..52ebbbe416 100644 --- a/static_core/compiler/optimizer/code_generator/codegen.h +++ b/static_core/compiler/optimizer/code_generator/codegen.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -335,13 +335,16 @@ public: GetEncoder()->EncodeMov(dst_reg, ret_reg); } } + CallEntrypointFinalize(live_regs, params_mask, inst); + } + void CallEntrypointFinalize(RegMask &live_regs, RegMask ¶ms_mask, Inst *inst) + { LoadCallerRegisters(live_regs, VRegMask(), true); if (!inst->HasImplicitRuntimeCall()) { return; } - ASSERT(!GetRuntime()->IsEntrypointNoreturn(id)); for (auto i = 0U; i < params_mask.size(); i++) { if (params_mask.test(i)) { inst->GetSaveState()->GetRootsRegsMask().reset(i); @@ -502,6 +505,7 @@ public: // Initialization internal variables void Initialize(); + bool Finalize(); const Disassembly *GetDisasm() const { diff --git a/static_core/compiler/optimizer/code_generator/codegen_native.cpp b/static_core/compiler/optimizer/code_generator/codegen_native.cpp index e624b55a76..685788388b 100644 --- a/static_core/compiler/optimizer/code_generator/codegen_native.cpp +++ b/static_core/compiler/optimizer/code_generator/codegen_native.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/codegen_native.h b/static_core/compiler/optimizer/code_generator/codegen_native.h index 2e13ff9103..f385338d68 100644 --- a/static_core/compiler/optimizer/code_generator/codegen_native.h +++ b/static_core/compiler/optimizer/code_generator/codegen_native.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/disassembly.cpp b/static_core/compiler/optimizer/code_generator/disassembly.cpp index 8699e1d203..dcbcab7382 100644 --- a/static_core/compiler/optimizer/code_generator/disassembly.cpp +++ b/static_core/compiler/optimizer/code_generator/disassembly.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/disassembly.h b/static_core/compiler/optimizer/code_generator/disassembly.h index fec0eb1c6d..2189f3a4ac 100644 --- a/static_core/compiler/optimizer/code_generator/disassembly.h +++ b/static_core/compiler/optimizer/code_generator/disassembly.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/encode.h b/static_core/compiler/optimizer/code_generator/encode.h index 3d7aaa9440..1f51d027df 100644 --- a/static_core/compiler/optimizer/code_generator/encode.h +++ b/static_core/compiler/optimizer/code_generator/encode.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/frame_info.h b/static_core/compiler/optimizer/code_generator/frame_info.h index 422c0299ff..81fe3d3e7c 100644 --- a/static_core/compiler/optimizer/code_generator/frame_info.h +++ b/static_core/compiler/optimizer/code_generator/frame_info.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/lib_call_inst.h b/static_core/compiler/optimizer/code_generator/lib_call_inst.h index 1f9b661abc..f769c041a8 100644 --- a/static_core/compiler/optimizer/code_generator/lib_call_inst.h +++ b/static_core/compiler/optimizer/code_generator/lib_call_inst.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/method_properties.cpp b/static_core/compiler/optimizer/code_generator/method_properties.cpp index 837ce2018f..c482f58485 100644 --- a/static_core/compiler/optimizer/code_generator/method_properties.cpp +++ b/static_core/compiler/optimizer/code_generator/method_properties.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/method_properties.h b/static_core/compiler/optimizer/code_generator/method_properties.h index d906ae3cf4..eea546e2ac 100644 --- a/static_core/compiler/optimizer/code_generator/method_properties.h +++ b/static_core/compiler/optimizer/code_generator/method_properties.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/operands.h b/static_core/compiler/optimizer/code_generator/operands.h index 6e9e3523c9..51abc5d33e 100644 --- a/static_core/compiler/optimizer/code_generator/operands.h +++ b/static_core/compiler/optimizer/code_generator/operands.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -705,17 +705,17 @@ private: inline ArenaVector> ResoveParameterSequence( ArenaVector> *moved_registers, uint8_t tmp, ArenaAllocator *allocator) { - constexpr uint8_t INVALID_FIST = -1; + constexpr uint8_t INVALID_FIRST = -1; constexpr uint8_t INVALID_SECOND = -2; - moved_registers->emplace_back(std::pair(INVALID_FIST, INVALID_SECOND)); + moved_registers->emplace_back(std::pair(INVALID_FIRST, INVALID_SECOND)); /* Example: 1. mov x0 <- x3 2. mov x1 <- x0 3. mov x2 <- x3 4. mov x3 <- x2 - Agreement - in dst can't be multipy same registers (double move to one register) + Agreement - dst-s can't hold same registers multiple times (double move to one register) - src for movs can hold same register multiply times Algorithm: @@ -749,11 +749,10 @@ inline ArenaVector> ResoveParameterSequence( for (;;) { /* Need support single mov x1 <- x1: ASSERT(moved_registers->size() != 1); - */ + */ auto curr_pair = moved_registers->begin(); - - if (curr_pair->first == INVALID_FIST && curr_pair->second == INVALID_SECOND) { + if (curr_pair->first == INVALID_FIRST && curr_pair->second == INVALID_SECOND) { moved_registers->erase(curr_pair); break; // Finish algorithm - only marker in vector @@ -766,22 +765,18 @@ inline ArenaVector> ResoveParameterSequence( auto curr_reg = curr_pair->second; moved_registers->erase(curr_pair); - for (; curr_pair != moved_registers->end();) { + while (curr_pair != moved_registers->end()) { curr_pair = std::find_if(moved_registers->begin(), moved_registers->end(), [curr_reg](auto in_pair) { return in_pair.first == curr_reg; }); - if (curr_pair != moved_registers->end()) { - if (curr_pair->second == saved_reg) { - result.emplace_back(std::pair(curr_pair->first, tmp)); - moved_registers->erase(curr_pair); - break; - // exit from loop - }; - result.emplace_back(*curr_pair); - curr_reg = curr_pair->second; + ASSERT(curr_pair != moved_registers->end()); + if (curr_pair->second == saved_reg) { + result.emplace_back(std::pair(curr_pair->first, tmp)); moved_registers->erase(curr_pair); - } else { - ASSERT(curr_pair != moved_registers->end()); - } + break; + }; + result.emplace_back(*curr_pair); + curr_reg = curr_pair->second; + moved_registers->erase(curr_pair); } } return result; @@ -815,7 +810,7 @@ enum Condition { INVALID_COND }; -static inline bool IsTestCc(Condition cond) +inline bool IsTestCc(Condition cond) { return cond == TST_EQ || cond == TST_NE; } diff --git a/static_core/compiler/optimizer/code_generator/registers_description.h b/static_core/compiler/optimizer/code_generator/registers_description.h index eb3625d7f7..8464c7a193 100644 --- a/static_core/compiler/optimizer/code_generator/registers_description.h +++ b/static_core/compiler/optimizer/code_generator/registers_description.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/relocations.h b/static_core/compiler/optimizer/code_generator/relocations.h index 93fec3cb76..8c915e1117 100644 --- a/static_core/compiler/optimizer/code_generator/relocations.h +++ b/static_core/compiler/optimizer/code_generator/relocations.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/slow_path.cpp b/static_core/compiler/optimizer/code_generator/slow_path.cpp index 8df15aaecf..73d3b7db72 100644 --- a/static_core/compiler/optimizer/code_generator/slow_path.cpp +++ b/static_core/compiler/optimizer/code_generator/slow_path.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/slow_path.h b/static_core/compiler/optimizer/code_generator/slow_path.h index a2d5bdc5ca..b27d90f458 100644 --- a/static_core/compiler/optimizer/code_generator/slow_path.h +++ b/static_core/compiler/optimizer/code_generator/slow_path.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/spill_fill_encoder.cpp b/static_core/compiler/optimizer/code_generator/spill_fill_encoder.cpp index bd835d1b2e..237019c489 100644 --- a/static_core/compiler/optimizer/code_generator/spill_fill_encoder.cpp +++ b/static_core/compiler/optimizer/code_generator/spill_fill_encoder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -156,6 +156,29 @@ void SpillFillEncoder::EncodeSpillFill() } } +void SpillFillEncoder::EncodeImmWithCorrectType(DataType::Type sf_type, MemRef dst_mem, ConstantInst *const_inst) +{ + ASSERT(DataType::IsTypeNumeric(sf_type)); + switch (sf_type) { + case DataType::Type::FLOAT32: { + auto imm = const_inst->GetFloatValue(); + encoder_->EncodeSti(imm, dst_mem); + break; + } + case DataType::Type::FLOAT64: { + auto imm = const_inst->GetDoubleValue(); + encoder_->EncodeSti(imm, dst_mem); + break; + } + default: { + auto imm = const_inst->GetRawValue(); + auto store_size = Codegen::ConvertDataType(sf_type, codegen_->GetArch()).GetSize() / BYTE_SIZE; + encoder_->EncodeSti(imm, store_size, dst_mem); + break; + } + } +} + size_t SpillFillEncoder::EncodeImmToX(const SpillFillData &sf) { auto const_inst = graph_->GetSpilledConstant(sf.SrcValue()); @@ -192,25 +215,7 @@ size_t SpillFillEncoder::EncodeImmToX(const SpillFillData &sf) ASSERT(sf.GetDst().IsAnyStack()); // imm -> stack auto dst_mem = codegen_->GetMemRefForSlot(sf.GetDst()); auto sf_type = sf.GetCommonType(); - ASSERT(DataType::IsTypeNumeric(sf_type)); - switch (sf_type) { - case DataType::Type::FLOAT32: { - auto imm = const_inst->GetFloatValue(); - encoder_->EncodeSti(imm, dst_mem); - break; - } - case DataType::Type::FLOAT64: { - auto imm = const_inst->GetDoubleValue(); - encoder_->EncodeSti(imm, dst_mem); - break; - } - default: { - auto imm = const_inst->GetRawValue(); - auto store_size = Codegen::ConvertDataType(sf_type, codegen_->GetArch()).GetSize() / BYTE_SIZE; - encoder_->EncodeSti(imm, store_size, dst_mem); - break; - } - } + EncodeImmWithCorrectType(sf_type, dst_mem, const_inst); return 1U; } diff --git a/static_core/compiler/optimizer/code_generator/spill_fill_encoder.h b/static_core/compiler/optimizer/code_generator/spill_fill_encoder.h index 5425c508f0..64f641e0e5 100644 --- a/static_core/compiler/optimizer/code_generator/spill_fill_encoder.h +++ b/static_core/compiler/optimizer/code_generator/spill_fill_encoder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -60,6 +60,7 @@ private: size_t EncodeRegisterToX(const SpillFillData &sf, const SpillFillData *next, int consecutive_ops_hint = 0); size_t EncodeStackToX(const SpillFillData &sf, const SpillFillData *next, int consecutive_ops_hint = 0); static bool AreConsecutiveOps(const SpillFillData &pred, const SpillFillData &succ); + void EncodeImmWithCorrectType(DataType::Type sf_type, MemRef dst_mem, ConstantInst *const_inst); SpillFillInst *inst_; Graph *graph_; diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/callconv.cpp b/static_core/compiler/optimizer/code_generator/target/aarch32/callconv.cpp index f4e2b05dde..49e758533d 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/callconv.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/callconv.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp b/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp index c7c3c2fcdc..03271f758d 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/encode.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1891,7 +1891,6 @@ void Aarch32Encoder::EncodeVorr(Reg dst, Reg src0, Reg src1) vixl::aarch32::DRegister(src0.GetId() / 2U), vixl::aarch32::DRegister(tmp_reg.GetReg().GetId() / 2U)); GetMasm()->Vmov(VixlVReg(dst).S(), vixl::aarch32::SRegister(tmp_reg.GetReg().GetId() + (src0.GetId() & 1U))); - } else { GetMasm()->Vorr(VixlVReg(dst).D(), VixlVReg(src0).D(), VixlVReg(src1).D()); } @@ -2782,7 +2781,7 @@ bool Aarch32Encoder::CanEncodeImmLogical(uint64_t imm, uint32_t size) #ifndef NDEBUG if (size < DOUBLE_WORD_SIZE) { // Test if the highest part is consistent: - ASSERT((imm >> size == 0) || ((~imm) >> size == 0)); + ASSERT(((imm >> size) == 0) || (((~imm) >> size) == 0)); } #endif // NDEBUG return vixl::aarch32::ImmediateA32::IsImmediateA32(imm); diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/lib_helpers.inl b/static_core/compiler/optimizer/code_generator/target/aarch32/lib_helpers.inl index bfb8d5c799..06b165e1ac 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/lib_helpers.inl +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/lib_helpers.inl @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -49,6 +49,7 @@ struct DivLSResult { // NOLINTNEXTLINE(readability-identifier-naming,misc-definitions-in-headers) DivLUResult __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) { + ASSERT(denominator != 0); DivLUResult res {0, 0}; res.quotient = numerator / denominator; res.remainder = numerator % denominator; @@ -57,6 +58,7 @@ DivLUResult __aeabi_uldivmod(uint64_t numerator, uint64_t denominator) // NOLINTNEXTLINE(readability-identifier-naming,misc-definitions-in-headers) DivLSResult __aeabi_ldivmod(int64_t numerator, int64_t denominator) { + ASSERT(denominator != 0); DivLSResult res {0, 0}; res.quotient = numerator / denominator; res.remainder = numerator % denominator; @@ -76,6 +78,7 @@ struct DivSResult { // NOLINTNEXTLINE(readability-identifier-naming,misc-definitions-in-headers) DivUResult __aeabi_uidivmod(uint32_t numerator, uint32_t denominator) { + ASSERT(denominator != 0); DivUResult res {0, 0}; res.quotient = numerator / denominator; res.remainder = numerator % denominator; @@ -84,6 +87,7 @@ DivUResult __aeabi_uidivmod(uint32_t numerator, uint32_t denominator) // NOLINTNEXTLINE(readability-identifier-naming,misc-definitions-in-headers) DivSResult __aeabi_idivmod(int32_t numerator, int32_t denominator) { + ASSERT(denominator != 0); DivSResult res {0, 0}; res.quotient = numerator / denominator; res.remainder = numerator % denominator; diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.cpp b/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.cpp index f08bce1e4f..3c8c1e8167 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.h b/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.h index cb12a0760f..67dcb5a276 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/regfile.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch32/target.h b/static_core/compiler/optimizer/code_generator/target/aarch32/target.h index 37329b3c01..2e9c83fb8c 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch32/target.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch32/target.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/callconv.cpp b/static_core/compiler/optimizer/code_generator/target/aarch64/callconv.cpp index 24e13efdf2..db481c87a9 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/callconv.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/callconv.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp b/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp index cbcfa6e0bd..d10d4cb7b8 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/encode.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -2428,7 +2428,7 @@ bool Aarch64Encoder::CanEncodeImmLogical(uint64_t imm, uint32_t size) #ifndef NDEBUG if (size < DOUBLE_WORD_SIZE) { // Test if the highest part is consistent: - ASSERT((imm >> size == 0) || ((~imm) >> size == 0)); + ASSERT(((imm >> size) == 0) || (((~imm) >> size) == 0)); } #endif // NDEBUG return vixl::aarch64::Assembler::IsImmLogical(imm, size); @@ -2673,31 +2673,29 @@ void Aarch64Encoder::LoadStoreRegisters(RegMask registers, bool is_fp, int32_t s if (!has_mask) { index++; } - if (last_id != -1) { - auto reg = - CPURegister(id, vixl::aarch64::kXRegSize, is_fp ? CPURegister::kVRegister : CPURegister::kRegister); - auto last_reg = CPURegister(last_id, vixl::aarch64::kXRegSize, - is_fp ? CPURegister::kVRegister : CPURegister::kRegister); - if (!has_mask || last_id + 1 == id) { - static constexpr ssize_t OFFSET = 2; - if constexpr (IS_STORE) { // NOLINT - GetMasm()->Stp(last_reg, reg, - MemOperand(base_reg, (slot + index - OFFSET) * DOUBLE_WORD_SIZE_BYTES)); - } else { // NOLINT - GetMasm()->Ldp(last_reg, reg, - MemOperand(base_reg, (slot + index - OFFSET) * DOUBLE_WORD_SIZE_BYTES)); - } - last_id = -1; - } else { - if constexpr (IS_STORE) { // NOLINT - GetMasm()->Str(last_reg, MemOperand(base_reg, (slot + last_index - 1) * DOUBLE_WORD_SIZE_BYTES)); - } else { // NOLINT - GetMasm()->Ldr(last_reg, MemOperand(base_reg, (slot + last_index - 1) * DOUBLE_WORD_SIZE_BYTES)); - } - last_id = id; - last_index = index; + if (last_id == -1) { + last_id = id; + last_index = index; + continue; + } + + auto reg = CPURegister(id, vixl::aarch64::kXRegSize, is_fp ? CPURegister::kVRegister : CPURegister::kRegister); + auto last_reg = + CPURegister(last_id, vixl::aarch64::kXRegSize, is_fp ? CPURegister::kVRegister : CPURegister::kRegister); + if (!has_mask || last_id + 1 == id) { + static constexpr ssize_t OFFSET = 2; + if constexpr (IS_STORE) { // NOLINT + GetMasm()->Stp(last_reg, reg, MemOperand(base_reg, (slot + index - OFFSET) * DOUBLE_WORD_SIZE_BYTES)); + } else { // NOLINT + GetMasm()->Ldp(last_reg, reg, MemOperand(base_reg, (slot + index - OFFSET) * DOUBLE_WORD_SIZE_BYTES)); } + last_id = -1; } else { + if constexpr (IS_STORE) { // NOLINT + GetMasm()->Str(last_reg, MemOperand(base_reg, (slot + last_index - 1) * DOUBLE_WORD_SIZE_BYTES)); + } else { // NOLINT + GetMasm()->Ldr(last_reg, MemOperand(base_reg, (slot + last_index - 1) * DOUBLE_WORD_SIZE_BYTES)); + } last_id = id; last_index = index; } diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/lib_helpers.inl b/static_core/compiler/optimizer/code_generator/target/aarch64/lib_helpers.inl index ccff66040d..380eb92e58 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/lib_helpers.inl +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/lib_helpers.inl @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.cpp b/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.cpp index cd81ca32cd..910905bb6b 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.cpp +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.h b/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.h index 01e573fb20..cf771fcb6d 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/regfile.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/aarch64/target.h b/static_core/compiler/optimizer/code_generator/target/aarch64/target.h index 1694606d57..5c915c223f 100644 --- a/static_core/compiler/optimizer/code_generator/target/aarch64/target.h +++ b/static_core/compiler/optimizer/code_generator/target/aarch64/target.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/callconv.cpp b/static_core/compiler/optimizer/code_generator/target/amd64/callconv.cpp index ce0f71ee37..ae22825c93 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/callconv.cpp +++ b/static_core/compiler/optimizer/code_generator/target/amd64/callconv.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp b/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp index bd93f4e700..441b16dbda 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp +++ b/static_core/compiler/optimizer/code_generator/target/amd64/encode.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1556,7 +1556,6 @@ void Amd64Encoder::EncodeOr(Reg dst, Reg src, Imm imm) { ASSERT(dst.IsScalar()); auto imm_val = ImmToUnsignedInt(imm); - if (ImmFitsSize(imm_val, dst.GetSize())) { EncodeMov(dst, src); GetMasm()->or_(ArchReg(dst), imm_val); @@ -1576,7 +1575,6 @@ void Amd64Encoder::EncodeXor(Reg dst, Reg src, Imm imm) { ASSERT(dst.IsScalar()); auto imm_val = ImmToUnsignedInt(imm); - if (ImmFitsSize(imm_val, dst.GetSize())) { EncodeMov(dst, src); GetMasm()->xor_(ArchReg(dst), imm_val); @@ -2229,7 +2227,7 @@ bool Amd64Encoder::CanEncodeImmLogical(uint64_t imm, uint32_t size) #ifndef NDEBUG if (size < DOUBLE_WORD_SIZE) { // Test if the highest part is consistent: - ASSERT((imm >> size == 0) || ((~imm) >> size == 0)); + ASSERT(((imm >> size) == 0) || (((~imm) >> size) == 0)); } #endif // NDEBUG return ImmFitsSize(imm, size); diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/lib_helpers.inl b/static_core/compiler/optimizer/code_generator/target/amd64/lib_helpers.inl index 7cdc5dc610..d644ddcaf4 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/lib_helpers.inl +++ b/static_core/compiler/optimizer/code_generator/target/amd64/lib_helpers.inl @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/regfile.cpp b/static_core/compiler/optimizer/code_generator/target/amd64/regfile.cpp index 2723d44ec2..436da57a71 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/regfile.cpp +++ b/static_core/compiler/optimizer/code_generator/target/amd64/regfile.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/regfile.h b/static_core/compiler/optimizer/code_generator/target/amd64/regfile.h index fd99035854..9bdd553cd1 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/regfile.h +++ b/static_core/compiler/optimizer/code_generator/target/amd64/regfile.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/amd64/target.h b/static_core/compiler/optimizer/code_generator/target/amd64/target.h index b820686003..f229f56cfd 100644 --- a/static_core/compiler/optimizer/code_generator/target/amd64/target.h +++ b/static_core/compiler/optimizer/code_generator/target/amd64/target.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -293,7 +293,6 @@ public: mem_ = asmjit::x86::ptr(ArchReg(mem.GetBase()), ArchReg(mem.GetIndex(), base_size)); } else { auto scale = mem.GetScale(); - if (scale <= 3U) { mem_ = asmjit::x86::ptr(ArchReg(mem.GetBase()), ArchReg(mem.GetIndex(), base_size), scale); } else { diff --git a/static_core/compiler/optimizer/code_generator/target/asm_printer.cpp b/static_core/compiler/optimizer/code_generator/target/asm_printer.cpp index 38e2b31830..1b1b7c2a0c 100644 --- a/static_core/compiler/optimizer/code_generator/target/asm_printer.cpp +++ b/static_core/compiler/optimizer/code_generator/target/asm_printer.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/asm_printer.h b/static_core/compiler/optimizer/code_generator/target/asm_printer.h index 769f57e949..e5b436b805 100644 --- a/static_core/compiler/optimizer/code_generator/target/asm_printer.h +++ b/static_core/compiler/optimizer/code_generator/target/asm_printer.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target/target.cpp b/static_core/compiler/optimizer/code_generator/target/target.cpp index a1c8faeca0..7b2b67f8e9 100644 --- a/static_core/compiler/optimizer/code_generator/target/target.cpp +++ b/static_core/compiler/optimizer/code_generator/target/target.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/code_generator/target_info.h b/static_core/compiler/optimizer/code_generator/target_info.h index 183faf8f46..06e2d7412c 100644 --- a/static_core/compiler/optimizer/code_generator/target_info.h +++ b/static_core/compiler/optimizer/code_generator/target_info.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/analysis.cpp b/static_core/compiler/optimizer/ir/analysis.cpp index 9812293fa2..b1c0eb06cc 100644 --- a/static_core/compiler/optimizer/ir/analysis.cpp +++ b/static_core/compiler/optimizer/ir/analysis.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -246,6 +246,17 @@ static bool IsSaveStateForGc(Inst *inst) return false; } +bool FindAndRemindObjectInSaveState(Inst *object, Inst *inst, Inst **failed_ss) +{ + if (IsSaveStateForGc(inst) && !FindObjectInSaveState(object, inst)) { + if (failed_ss != nullptr) { + *failed_ss = inst; + } + return false; + } + return true; +} + // Checks if object is correctly used in SaveStates between it and user bool CheckObjectRec(Inst *object, const Inst *user, const BasicBlock *block, Inst *start_from, Marker visited, Inst **failed_ss) @@ -260,10 +271,7 @@ bool CheckObjectRec(Inst *object, const Inst *user, const BasicBlock *block, Ins if (inst->SetMarker(visited) || inst == object || inst == user) { return true; } - if (IsSaveStateForGc(inst) && !FindObjectInSaveState(object, inst)) { - if (failed_ss != nullptr) { - *failed_ss = inst; - } + if (!FindAndRemindObjectInSaveState(object, inst, failed_ss)) { return false; } } diff --git a/static_core/compiler/optimizer/ir/analysis.h b/static_core/compiler/optimizer/ir/analysis.h index 9a06ec728a..30adf1237e 100644 --- a/static_core/compiler/optimizer/ir/analysis.h +++ b/static_core/compiler/optimizer/ir/analysis.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -40,7 +40,7 @@ std::optional IsIfInverted(BasicBlock *phi_block, IfImmInst *if_imm); // If object input has known class, return pointer to the class, else returns nullptr RuntimeInterface::ClassPtr GetClassPtrForObject(Inst *inst, size_t input_num = 0); -static inline bool IsInstInDifferentBlocks(Inst *i1, Inst *i2) +inline bool IsInstInDifferentBlocks(Inst *i1, Inst *i2) { return i1->GetBasicBlock() != i2->GetBasicBlock(); } diff --git a/static_core/compiler/optimizer/ir/aot_data.cpp b/static_core/compiler/optimizer/ir/aot_data.cpp index 3031827534..c128122360 100644 --- a/static_core/compiler/optimizer/ir/aot_data.cpp +++ b/static_core/compiler/optimizer/ir/aot_data.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/aot_data.h b/static_core/compiler/optimizer/ir/aot_data.h index 22a88a0941..aa208689c6 100644 --- a/static_core/compiler/optimizer/ir/aot_data.h +++ b/static_core/compiler/optimizer/ir/aot_data.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/basicblock.cpp b/static_core/compiler/optimizer/ir/basicblock.cpp index 88cdcacac6..ad842cfacd 100644 --- a/static_core/compiler/optimizer/ir/basicblock.cpp +++ b/static_core/compiler/optimizer/ir/basicblock.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -295,10 +295,9 @@ void BasicBlock::JoinSuccessorBlock() if (loop->HasBackEdge(succ)) { loop->ReplaceBackEdge(succ, this); } - if (auto outer_loop = loop->GetOuterLoop()) { - if (outer_loop->HasBackEdge(succ)) { - outer_loop->ReplaceBackEdge(succ, this); - } + auto outer_loop = loop->GetOuterLoop(); + if (outer_loop != nullptr && outer_loop->HasBackEdge(succ)) { + outer_loop->ReplaceBackEdge(succ, this); } for (auto inner_loop : loop->GetInnerLoops()) { @@ -496,7 +495,6 @@ void BasicBlock::GenerateSelects(const SavedIfInfo *if_info) auto inst1 = phi->GetInput(index1).GetInst(); auto inst2 = phi->GetInput(index2).GetInst(); - if (inst1 == inst2) { // No select needed if (other->GetPredsBlocks().size() > TWO) { diff --git a/static_core/compiler/optimizer/ir/basicblock.h b/static_core/compiler/optimizer/ir/basicblock.h index d7c204eb08..3f16a1d0a6 100644 --- a/static_core/compiler/optimizer/ir/basicblock.h +++ b/static_core/compiler/optimizer/ir/basicblock.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/constants.h b/static_core/compiler/optimizer/ir/constants.h index 8485cbe263..cc5a022817 100644 --- a/static_core/compiler/optimizer/ir/constants.h +++ b/static_core/compiler/optimizer/ir/constants.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/datatype.h b/static_core/compiler/optimizer/ir/datatype.h index 21ce092c3e..74e293feca 100644 --- a/static_core/compiler/optimizer/ir/datatype.h +++ b/static_core/compiler/optimizer/ir/datatype.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/debug_info.h b/static_core/compiler/optimizer/ir/debug_info.h index 19ad84158b..b3b4652c6f 100644 --- a/static_core/compiler/optimizer/ir/debug_info.h +++ b/static_core/compiler/optimizer/ir/debug_info.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/dump.cpp b/static_core/compiler/optimizer/ir/dump.cpp index 6b9a001bd3..533eb8f194 100644 --- a/static_core/compiler/optimizer/ir/dump.cpp +++ b/static_core/compiler/optimizer/ir/dump.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -420,8 +420,8 @@ void AnyTypeCheckInst::DumpOpcode(std::ostream *out) const ArenaString opcode(GetOpcodeString(GetOpcode()), adapter); ArenaString any_base_type(AnyTypeTypeToString(GetAnyType()), adapter); (*out) << std::setw(INDENT_OPCODE) - << opcode + space + any_base_type + (IsIntegerWasSeen() ? " i" : "") + (IsSpecialWasSeen() ? " s" : "") + - (IsTypeWasProfiled() ? " p" : "") + space; + << (opcode + space + any_base_type + (IsIntegerWasSeen() ? " i" : "") + (IsSpecialWasSeen() ? " s" : "") + + (IsTypeWasProfiled() ? " p" : "") + space); } void HclassCheckInst::DumpOpcode(std::ostream *out) const @@ -563,8 +563,8 @@ void CastInst::DumpOpcode(std::ostream *out) const const auto &adapter = GetBasicBlock()->GetGraph()->GetLocalAllocator()->Adapter(); ArenaString space(" ", adapter); (*out) << std::setw(INDENT_OPCODE) - << ArenaString(GetOpcodeString(GetOpcode()), adapter) + space + - ArenaString(DataType::ToString(GetOperandsType()), adapter); + << (ArenaString(GetOpcodeString(GetOpcode()), adapter) + space + + ArenaString(DataType::ToString(GetOperandsType()), adapter)); } void NewObjectInst::DumpOpcode(std::ostream *out) const diff --git a/static_core/compiler/optimizer/ir/dump.h b/static_core/compiler/optimizer/ir/dump.h index 4ef9069e7c..18d3d3cfa7 100644 --- a/static_core/compiler/optimizer/ir/dump.h +++ b/static_core/compiler/optimizer/ir/dump.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/graph.cpp b/static_core/compiler/optimizer/ir/graph.cpp index f4f8ab0e93..10ec3f1685 100644 --- a/static_core/compiler/optimizer/ir/graph.cpp +++ b/static_core/compiler/optimizer/ir/graph.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -654,7 +654,6 @@ SpillFillData Graph::GetDataForNativeParam(DataType::Type type) } auto param = param_info_->GetNativeParam(Codegen::ConvertDataType(type, GetArch())); - if (std::holds_alternative(param)) { auto reg = std::get(param); // NOTE! Vector parameter can be put to scalar register in aarch32 @@ -798,7 +797,6 @@ int64_t Graph::GetBranchCounter(const BasicBlock *block, bool true_succ) int64_t Graph::GetThrowCounter(const BasicBlock *block) { auto last_inst = block->GetLastInst(); - if (last_inst == nullptr || last_inst->GetOpcode() != Opcode::Throw || last_inst->GetPc() == INVALID_PC) { return 0; } diff --git a/static_core/compiler/optimizer/ir/graph.h b/static_core/compiler/optimizer/ir/graph.h index 2ef14eaaef..091699adef 100644 --- a/static_core/compiler/optimizer/ir/graph.h +++ b/static_core/compiler/optimizer/ir/graph.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -55,6 +55,16 @@ enum AliasType : uint8_t; class GraphMode { public: explicit GraphMode(uint32_t value) : value_(value) {} +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define DECLARE_GRAPH_MODE_MODIFIERS(name) \ + void Set##name(bool v) \ + { \ + Flag##name ::Set(v, &value_); \ + } \ + bool Is##name() const \ + { \ + return Flag##name ::Get(value_); \ + } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define DECLARE_GRAPH_MODE(name) \ @@ -62,14 +72,7 @@ public: { \ return GraphMode(Flag##name ::Encode(set)); \ } \ - void Set##name(bool v) \ - { \ - Flag##name ::Set(v, &value_); \ - } \ - bool Is##name() const \ - { \ - return Flag##name ::Get(value_); \ - } + DECLARE_GRAPH_MODE_MODIFIERS(name) DECLARE_GRAPH_MODE(Osr); // The graph is used in BytecodeOptimizer mode @@ -90,6 +93,7 @@ public: DECLARE_GRAPH_MODE(InterpreterEntry); #undef DECLARE_GRAPH_MODE +#undef DECLARE_GRAPH_MODE_MODIFIERS bool SupportManagedCode() const { @@ -945,11 +949,11 @@ public: // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define INST_DEF(OPCODE, BASE, ...) \ case Opcode::OPCODE: { \ - auto inst = Inst::New(allocator_, Opcode::OPCODE); \ + auto inst = Inst::New(allocator_, Opcode::OPCODE); \ inst->SetId(instr_current_id_++); \ return inst; \ - } - OPCODE_LIST(INST_DEF) + } + OPCODE_LIST(INST_DEF) #undef INST_DEF default: diff --git a/static_core/compiler/optimizer/ir/graph_checker.cpp b/static_core/compiler/optimizer/ir/graph_checker.cpp index 95204fce7a..6484a576e1 100644 --- a/static_core/compiler/optimizer/ir/graph_checker.cpp +++ b/static_core/compiler/optimizer/ir/graph_checker.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,10 +31,10 @@ namespace panda::compiler { // ---- Below extended ASSERT and ASSERT_DO for GraphChecker ---- // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_DO_EXT(cond, func) ASSERT_DO(cond, func; PrintFailedMethodAndPass();) +#define ASSERT_DO_EXT(cond, func) ASSERT_DO((cond), func; PrintFailedMethodAndPass();) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_DO_EXT_VISITOR(cond, func) ASSERT_DO(cond, func; PrintFailedMethodAndPassVisitor(v);) +#define ASSERT_DO_EXT_VISITOR(cond, func) ASSERT_DO((cond), func; PrintFailedMethodAndPassVisitor(v);) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ASSERT_EXT(cond) ASSERT_DO_EXT(cond, ) @@ -43,11 +43,12 @@ namespace panda::compiler { #define ASSERT_EXT_VISITOR(cond) ASSERT_DO_EXT_VISITOR(cond, ) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_EXT_PRINT(cond, message) ASSERT_DO(cond, std::cerr << message << std::endl; PrintFailedMethodAndPass();) +#define ASSERT_EXT_PRINT(cond, message) \ + ASSERT_DO((cond), std::cerr << message << std::endl; PrintFailedMethodAndPass();) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ASSERT_EXT_PRINT_VISITOR(cond, message) \ - ASSERT_DO(cond, std::cerr << message << std::endl; PrintFailedMethodAndPassVisitor(v);) + ASSERT_DO((cond), std::cerr << message << std::endl; PrintFailedMethodAndPassVisitor(v);) // -------------------------------------------------------------- GraphChecker::GraphChecker(Graph *graph) diff --git a/static_core/compiler/optimizer/ir/graph_checker.h b/static_core/compiler/optimizer/ir/graph_checker.h index ff75858efb..df64e0607e 100644 --- a/static_core/compiler/optimizer/ir/graph_checker.h +++ b/static_core/compiler/optimizer/ir/graph_checker.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,23 +29,24 @@ // ---- Below extended ASSERT and ASSERT_DO for GraphChecker ---- // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_DO_EXT(cond, func) ASSERT_DO(cond, func; PrintFailedMethodAndPass();) +#define ASSERT_DO_EXT(cond, func) ASSERT_DO((cond), func; PrintFailedMethodAndPass();) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_DO_EXT_VISITOR(cond, func) ASSERT_DO(cond, func; PrintFailedMethodAndPassVisitor(v);) +#define ASSERT_DO_EXT_VISITOR(cond, func) ASSERT_DO((cond), func; PrintFailedMethodAndPassVisitor(v);) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_EXT(cond) ASSERT_DO_EXT(cond, ) +#define ASSERT_EXT(cond) ASSERT_DO_EXT((cond), ) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_EXT_VISITOR(cond) ASSERT_DO_EXT_VISITOR(cond, ) +#define ASSERT_EXT_VISITOR(cond) ASSERT_DO_EXT_VISITOR((cond), ) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ASSERT_EXT_PRINT(cond, message) ASSERT_DO(cond, std::cerr << message << std::endl; PrintFailedMethodAndPass();) +#define ASSERT_EXT_PRINT(cond, message) \ + ASSERT_DO((cond), std::cerr << message << std::endl; PrintFailedMethodAndPass();) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ASSERT_EXT_PRINT_VISITOR(cond, message) \ - ASSERT_DO(cond, std::cerr << message << std::endl; PrintFailedMethodAndPassVisitor(v);) + ASSERT_DO((cond), std::cerr << message << std::endl; PrintFailedMethodAndPassVisitor(v);) // -------------------------------------------------------------- namespace panda::compiler { diff --git a/static_core/compiler/optimizer/ir/graph_cloner.cpp b/static_core/compiler/optimizer/ir/graph_cloner.cpp index a2c6daa106..b816118b24 100644 --- a/static_core/compiler/optimizer/ir/graph_cloner.cpp +++ b/static_core/compiler/optimizer/ir/graph_cloner.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/graph_cloner.h b/static_core/compiler/optimizer/ir/graph_cloner.h index 22b31dcd99..ebf948142f 100644 --- a/static_core/compiler/optimizer/ir/graph_cloner.h +++ b/static_core/compiler/optimizer/ir/graph_cloner.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/graph_visitor.h b/static_core/compiler/optimizer/ir/graph_visitor.h index 18d79f4fc2..942d87892a 100644 --- a/static_core/compiler/optimizer/ir/graph_visitor.h +++ b/static_core/compiler/optimizer/ir/graph_visitor.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/inst.cpp b/static_core/compiler/optimizer/ir/inst.cpp index 180fd464ba..8b5b774657 100644 --- a/static_core/compiler/optimizer/ir/inst.cpp +++ b/static_core/compiler/optimizer/ir/inst.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/inst.h b/static_core/compiler/optimizer/ir/inst.h index d8df2419ba..59dcf4dab7 100644 --- a/static_core/compiler/optimizer/ir/inst.h +++ b/static_core/compiler/optimizer/ir/inst.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -303,7 +303,7 @@ enum Flags : uint32_t { inline constexpr uintptr_t GetFlagsMask(Opcode opcode) { -#define INST_DEF(OPCODE, BASE, FLAGS) FLAGS, // NOLINT(cppcoreguidelines-macro-usage) +#define INST_DEF(OPCODE, BASE, FLAGS) (FLAGS), // NOLINT(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(hicpp-signed-bitwise) constexpr std::array(Opcode::NUM_OPCODES)> INST_FLAGS_TABLE = {OPCODE_LIST(INST_DEF)}; #undef INST_DEF @@ -2239,7 +2239,7 @@ private: template class ConditionMixin : public T { public: - enum class Prediction { NONE, LIKELY, UNLIKELY, SIZE = UNLIKELY }; + enum class Prediction { NONE = 0, LIKELY, UNLIKELY, SIZE = UNLIKELY }; using T::T; explicit ConditionMixin(ConditionCode cc) diff --git a/static_core/compiler/optimizer/ir/instructions.yaml b/static_core/compiler/optimizer/ir/instructions.yaml index b676afcbb2..da7d8104b1 100644 --- a/static_core/compiler/optimizer/ir/instructions.yaml +++ b/static_core/compiler/optimizer/ir/instructions.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/ir_constructor.h b/static_core/compiler/optimizer/ir/ir_constructor.h index 1090a198d0..12425a1bda 100644 --- a/static_core/compiler/optimizer/ir/ir_constructor.h +++ b/static_core/compiler/optimizer/ir/ir_constructor.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/locations.cpp b/static_core/compiler/optimizer/ir/locations.cpp index 70aefe2c5c..c37b149f71 100644 --- a/static_core/compiler/optimizer/ir/locations.cpp +++ b/static_core/compiler/optimizer/ir/locations.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/locations.h b/static_core/compiler/optimizer/ir/locations.h index 34d53bbd20..7fe0f70d09 100644 --- a/static_core/compiler/optimizer/ir/locations.h +++ b/static_core/compiler/optimizer/ir/locations.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/loop_unswitcher.cpp b/static_core/compiler/optimizer/ir/loop_unswitcher.cpp index ffb11d0d5e..6a5a21d1b3 100644 --- a/static_core/compiler/optimizer/ir/loop_unswitcher.cpp +++ b/static_core/compiler/optimizer/ir/loop_unswitcher.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/loop_unswitcher.h b/static_core/compiler/optimizer/ir/loop_unswitcher.h index 1c8fa94a5f..e7d958e812 100644 --- a/static_core/compiler/optimizer/ir/loop_unswitcher.h +++ b/static_core/compiler/optimizer/ir/loop_unswitcher.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/marker.h b/static_core/compiler/optimizer/ir/marker.h index d34fc53310..8d950f47ac 100644 --- a/static_core/compiler/optimizer/ir/marker.h +++ b/static_core/compiler/optimizer/ir/marker.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/runtime_interface.h b/static_core/compiler/optimizer/ir/runtime_interface.h index f0f4a51cca..6075933b3d 100644 --- a/static_core/compiler/optimizer/ir/runtime_interface.h +++ b/static_core/compiler/optimizer/ir/runtime_interface.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -144,7 +144,6 @@ public: return 0; } - /**********************************************************************************/ /// Binary file information virtual BinaryFilePtr GetBinaryFileForMethod([[maybe_unused]] MethodPtr method) const { @@ -157,7 +156,6 @@ public: return cross_values::GetFileBaseOffset(arch); } - /**********************************************************************************/ /// Method information virtual MethodPtr GetMethodById([[maybe_unused]] MethodPtr parent_method, [[maybe_unused]] MethodId id) const { @@ -517,7 +515,6 @@ public: return 0; } - /**********************************************************************************/ /// Exec state information size_t GetTlsFrameKindOffset(Arch arch) const { @@ -582,7 +579,6 @@ public: return 0; } - /**********************************************************************************/ /// Array information uint32_t GetClassArraySize(Arch arch) const { @@ -619,7 +615,6 @@ public: return panda::cross_values::GetCoretypesArrayLengthOffset(arch); } - /**********************************************************************************/ /// String information virtual bool IsCompressedStringsEnabled() const { @@ -655,7 +650,6 @@ public: return cross_values::GetManagedThreadStringClassPtrOffset(arch); } - /**********************************************************************************/ /// managed Thread object information uint32_t GetThreadObjectOffset(Arch arch) const @@ -663,7 +657,6 @@ public: return panda::cross_values::GetManagedThreadObjectOffset(arch); } - /**********************************************************************************/ /// TLAB information virtual size_t GetTLABMaxSize() const @@ -699,7 +692,6 @@ public: return panda::cross_values::GetTlabMemoryEndAddrOffset(arch); } - /**********************************************************************************/ /// Object information virtual ClassPtr GetClass([[maybe_unused]] MethodPtr method, [[maybe_unused]] IdType id) const { @@ -789,7 +781,6 @@ public: return StringCtorType::UNKNOWN; } - /**********************************************************************************/ /// Class information // Returns Class Id for Field. @@ -878,7 +869,6 @@ public: return panda::cross_values::GetClassMethodsOffset(arch); } - /**********************************************************************************/ /// Field information /** @@ -1022,7 +1012,6 @@ public: return 0; } - /**********************************************************************************/ /// Type information virtual ClassPtr ResolveType([[maybe_unused]] MethodPtr method, [[maybe_unused]] size_t unused) const { @@ -1059,7 +1048,6 @@ public: return 0; } - /**********************************************************************************/ /// Entrypoints #include "compiler_interface_extensions.inl.h" #include @@ -1126,7 +1114,6 @@ public: UNREACHABLE(); } - /**********************************************************************************/ /// Dynamic object information virtual uint32_t GetFunctionTargetOffset([[maybe_unused]] Arch arch) const @@ -1185,7 +1172,6 @@ public: return 0; } - /**********************************************************************************/ /** * Check if GC can be triggered during call. * This is possible when method A calling method B and waiting while B is compiling. @@ -1195,7 +1181,6 @@ public: return false; } - /**********************************************************************************/ /// Bytecode profiling using BytecodeProfile = uintptr_t; using MethodProfile = profiling::ProfileType; diff --git a/static_core/compiler/optimizer/ir/spill_fill_data.h b/static_core/compiler/optimizer/ir/spill_fill_data.h index 64cccb95c6..9856c0502a 100644 --- a/static_core/compiler/optimizer/ir/spill_fill_data.h +++ b/static_core/compiler/optimizer/ir/spill_fill_data.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/visitor.inc b/static_core/compiler/optimizer/ir/visitor.inc index 83fcab846e..ee93d4c7e3 100644 --- a/static_core/compiler/optimizer/ir/visitor.inc +++ b/static_core/compiler/optimizer/ir/visitor.inc @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/visualizer_printer.cpp b/static_core/compiler/optimizer/ir/visualizer_printer.cpp index 97c0f572a3..51d75db8d2 100644 --- a/static_core/compiler/optimizer/ir/visualizer_printer.cpp +++ b/static_core/compiler/optimizer/ir/visualizer_printer.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir/visualizer_printer.h b/static_core/compiler/optimizer/ir/visualizer_printer.h index 6e2286b5cd..ce7af0227b 100644 --- a/static_core/compiler/optimizer/ir/visualizer_printer.h +++ b/static_core/compiler/optimizer/ir/visualizer_printer.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/inst_builder-inl.h b/static_core/compiler/optimizer/ir_builder/inst_builder-inl.h index 32d7fcfac2..9b1a92981a 100644 --- a/static_core/compiler/optimizer/ir_builder/inst_builder-inl.h +++ b/static_core/compiler/optimizer/ir_builder/inst_builder-inl.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1330,7 +1330,6 @@ void InstBuilder::BuildInitObject(const BytecodeInstruction *bc_inst, bool is_ra { auto method_id = GetRuntime()->ResolveMethodIndex(GetMethod(), bc_inst->GetId(0).AsIndex()); auto type_id = GetRuntime()->GetClassIdForMethod(GetMethod(), method_id); - if (GetRuntime()->IsArrayClass(GetMethod(), type_id)) { if (GetGraph()->IsBytecodeOptimizer()) { BuildInitObjectMultiDimensionalArray(bc_inst, is_range); @@ -1514,7 +1513,6 @@ void InstBuilder::BuildCastToAnyNumber(const BytecodeInstruction *bc_inst) { auto input = GetDefinitionAcc(); auto type = input->GetType(); - if (input->IsConst() && !DataType::IsFloatType(type)) { auto const_insn = input->CastToConstant(); if (const_insn->GetType() == DataType::INT64) { diff --git a/static_core/compiler/optimizer/ir_builder/inst_builder.cpp b/static_core/compiler/optimizer/ir_builder/inst_builder.cpp index 60dd9124c2..f2c2b0e515 100644 --- a/static_core/compiler/optimizer/ir_builder/inst_builder.cpp +++ b/static_core/compiler/optimizer/ir_builder/inst_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/inst_builder.h b/static_core/compiler/optimizer/ir_builder/inst_builder.h index 017692059a..2ea21b4b7a 100644 --- a/static_core/compiler/optimizer/ir_builder/inst_builder.h +++ b/static_core/compiler/optimizer/ir_builder/inst_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/inst_templates.yaml b/static_core/compiler/optimizer/ir_builder/inst_templates.yaml index f99c24505b..33dc8b88fb 100644 --- a/static_core/compiler/optimizer/ir_builder/inst_templates.yaml +++ b/static_core/compiler/optimizer/ir_builder/inst_templates.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/ir_builder.cpp b/static_core/compiler/optimizer/ir_builder/ir_builder.cpp index 6d16b65a60..d876737db7 100644 --- a/static_core/compiler/optimizer/ir_builder/ir_builder.cpp +++ b/static_core/compiler/optimizer/ir_builder/ir_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/ir_builder.h b/static_core/compiler/optimizer/ir_builder/ir_builder.h index c752c34fc8..44256d7401 100644 --- a/static_core/compiler/optimizer/ir_builder/ir_builder.h +++ b/static_core/compiler/optimizer/ir_builder/ir_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/pbc_iterator.h b/static_core/compiler/optimizer/ir_builder/pbc_iterator.h index e8ff0d6671..242fac340d 100644 --- a/static_core/compiler/optimizer/ir_builder/pbc_iterator.h +++ b/static_core/compiler/optimizer/ir_builder/pbc_iterator.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/ir_builder/phi_resolver.h b/static_core/compiler/optimizer/ir_builder/phi_resolver.h index 2870f3cebf..288ce31e9e 100644 --- a/static_core/compiler/optimizer/ir_builder/phi_resolver.h +++ b/static_core/compiler/optimizer/ir_builder/phi_resolver.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -47,18 +47,10 @@ public: if (!inst->IsPhi() && !inst->IsCatchPhi()) { continue; } - for (auto &user : inst->GetUsers()) { - auto user_inst = user.GetInst(); - auto can_remove_user = user_inst->IsPhi() || user_inst->IsCatchPhi() || - (user_inst->IsSaveState() && !user.GetVirtualRegister().IsEnv()); - if (!can_remove_user) { - // inst certainly cannot be removed from user's inputs - MarkHasRealUserRec(inst); - break; - } - } + MarkPhiWithRealUsers(inst); } } + for (auto bb : graph_->GetBlocksRPO()) { for (auto inst : bb->AllInstsSafe()) { if (!inst->IsPhi() && !inst->IsCatchPhi()) { @@ -84,32 +76,8 @@ public: } } } - // If any input of phi instruction is not defined then we assume that phi is dead. - // We move users to the input and remove the PHI - for (auto bb : graph_->GetBlocksRPO()) { - for (auto inst : bb->PhiInstsSafe()) { - // Skip catch phi - if (!inst->IsPhi()) { - continue; - } - if (inst->GetInputsCount() != bb->GetPredsBlocks().size()) { - // if the number of PHI inputs less then the number of block predecessor and all inputs are equal - // Repleace users to the input - if (inst->GetInputsCount() != 0) { - auto input_inst = inst->GetInput(0).GetInst(); -#ifndef NDEBUG - if (!inst->GetUsers().Empty()) { - for ([[maybe_unused]] auto &input : inst->GetInputs()) { - ASSERT(input.GetInst() == input_inst); - } - } -#endif - inst->ReplaceUsers(input_inst); - } - bb->RemoveInst(inst); - } - } - } + + RemoveDeadPhi(); } private: @@ -338,6 +306,55 @@ private: graph_->EraseMarker(marker_); } + void MarkPhiWithRealUsers(Inst *inst) + { + for (auto &user : inst->GetUsers()) { + auto user_inst = user.GetInst(); + auto can_remove_user = user_inst->IsPhi() || user_inst->IsCatchPhi() || + (user_inst->IsSaveState() && !user.GetVirtualRegister().IsEnv()); + if (!can_remove_user) { + // inst certainly cannot be removed from user's inputs + MarkHasRealUserRec(inst); + break; + } + } + } + + void ReplaceDeadPhiUsers(Inst *inst, BasicBlock *bb) + { + if (inst->GetInputsCount() != 0) { + auto input_inst = inst->GetInput(0).GetInst(); +#ifndef NDEBUG + if (!inst->GetUsers().Empty()) { + for ([[maybe_unused]] auto &input : inst->GetInputs()) { + ASSERT(input.GetInst() == input_inst); + } + } +#endif + inst->ReplaceUsers(input_inst); + } + bb->RemoveInst(inst); + } + + void RemoveDeadPhi() + { + // If any input of phi instruction is not defined then we assume that phi is dead. + // We move users to the input and remove the PHI + for (auto bb : graph_->GetBlocksRPO()) { + for (auto inst : bb->PhiInstsSafe()) { + // Skip catch phi + if (!inst->IsPhi()) { + continue; + } + if (inst->GetInputsCount() != bb->GetPredsBlocks().size()) { + // if the number of PHI inputs less than the number of block predecessor and all inputs are equal + // Replace users to the input + ReplaceDeadPhiUsers(inst, bb); + } + } + } + } + private: Graph *graph_ {nullptr}; InstVector real_inputs_; diff --git a/static_core/compiler/optimizer/optimizations/adjust_arefs.cpp b/static_core/compiler/optimizer/optimizations/adjust_arefs.cpp index 4644c175ea..ebed2292fe 100644 --- a/static_core/compiler/optimizer/optimizations/adjust_arefs.cpp +++ b/static_core/compiler/optimizer/optimizations/adjust_arefs.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -230,7 +230,6 @@ void AdjustRefs::InsertMem(Inst *org, Inst *base, Inst *index, uint8_t scale) // to // 5.ptr AddI v1, 0x10 + (0xN << 3) -> v6 // 6.i64 Load v5, v2 -> .... -// void AdjustRefs::ProcessIndex(Inst *mem) { Inst *index = mem->GetInput(1).GetInst(); diff --git a/static_core/compiler/optimizer/optimizations/adjust_arefs.h b/static_core/compiler/optimizer/optimizations/adjust_arefs.h index 647dcd7361..4df9794fc7 100644 --- a/static_core/compiler/optimizer/optimizations/adjust_arefs.h +++ b/static_core/compiler/optimizer/optimizations/adjust_arefs.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/balance_expressions.cpp b/static_core/compiler/optimizer/optimizations/balance_expressions.cpp index 79cba500c6..3ceaad20c4 100644 --- a/static_core/compiler/optimizer/optimizations/balance_expressions.cpp +++ b/static_core/compiler/optimizer/optimizations/balance_expressions.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/balance_expressions.h b/static_core/compiler/optimizer/optimizations/balance_expressions.h index 5d22df6bca..9dcdec1334 100644 --- a/static_core/compiler/optimizer/optimizations/balance_expressions.h +++ b/static_core/compiler/optimizer/optimizations/balance_expressions.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/branch_elimination.cpp b/static_core/compiler/optimizer/optimizations/branch_elimination.cpp index 419ec01767..d281013b06 100644 --- a/static_core/compiler/optimizer/optimizations/branch_elimination.cpp +++ b/static_core/compiler/optimizer/optimizations/branch_elimination.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -215,7 +215,6 @@ void BranchElimination::EliminateBranch(BasicBlock *if_block, BasicBlock *elimin return pred != if_block && !eliminated_block->IsDominate(pred); }); bool dominates_all_preds = (it == preds.cend()); - if (preds.size() > 1 && !dominates_all_preds) { RemovePredecessorUpdateDF(eliminated_block, if_block); if_block->RemoveSucc(eliminated_block); @@ -351,7 +350,6 @@ std::optional BranchElimination::GetCompareAnyTypeResult(IfImmInst *if_imm auto compare_any = if_imm->GetInput(0).GetInst()->CastToCompareAnyType(); Inst *input = compare_any->GetInput(0).GetInst(); const auto it = same_input_compare_any_type_.find(input); - if (it == same_input_compare_any_type_.end()) { return std::nullopt; } diff --git a/static_core/compiler/optimizer/optimizations/branch_elimination.h b/static_core/compiler/optimizer/optimizations/branch_elimination.h index 462b3964f2..78cf71660b 100644 --- a/static_core/compiler/optimizer/optimizations/branch_elimination.h +++ b/static_core/compiler/optimizer/optimizations/branch_elimination.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/checks_elimination.cpp b/static_core/compiler/optimizer/optimizations/checks_elimination.cpp index 30171376e0..e96964b32a 100644 --- a/static_core/compiler/optimizer/optimizations/checks_elimination.cpp +++ b/static_core/compiler/optimizer/optimizations/checks_elimination.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -777,13 +777,14 @@ Inst *ChecksElimination::FindOptimalSaveStateForHoist(Inst *inst, Inst **optimal bool inputs_are_dominate = true; for (size_t i = 0; i < inst->GetInputsCount() - 1; ++i) { auto input = inst->GetInput(i).GetInst(); - if (!input->IsDominate(insert_after)) { - if (insert_after->GetBasicBlock() == input->GetBasicBlock()) { - insert_after = input; - } else { - inputs_are_dominate = false; - break; - } + if (input->IsDominate(insert_after)) { + continue; + } + if (insert_after->GetBasicBlock() == input->GetBasicBlock()) { + insert_after = input; + } else { + inputs_are_dominate = false; + break; } } @@ -1053,7 +1054,7 @@ bool ChecksElimination::TryInsertDeoptimization(LoopInfo loop_info, Inst *len_ar InsertBoundsCheckDeoptimization(cc, result_len_array, max_add, upper, ss, insert_deopt_after, opcode); } else if (lower_range.IsConst() && lower_range.GetLeft() == 0 && countable_loop_info.normalized_cc == CC_LT && result_len_array == upper && max_add == static_cast(const_step) - 1) { - // for (int i = 0; i < len; i += x) process(a[i], ..., a[i + x - 1]) + // For (int i = 0; i < len; i += x) process(a[i], ..., a[i + x - 1]) // deoptimize if len % x != 0 auto zero_const = GetGraph()->FindOrCreateConstant(0); InsertBoundsCheckDeoptimization(ConditionCode::CC_NE, result_len_array, const_step, zero_const, ss, diff --git a/static_core/compiler/optimizer/optimizations/checks_elimination.h b/static_core/compiler/optimizer/optimizations/checks_elimination.h index 863c28bc3b..c3782a906d 100644 --- a/static_core/compiler/optimizer/optimizations/checks_elimination.h +++ b/static_core/compiler/optimizer/optimizations/checks_elimination.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/cleanup.cpp b/static_core/compiler/optimizer/optimizations/cleanup.cpp index 05fdf00755..936a9e8baf 100644 --- a/static_core/compiler/optimizer/optimizations/cleanup.cpp +++ b/static_core/compiler/optimizer/optimizations/cleanup.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -104,7 +104,6 @@ bool Cleanup::RunOnce(ArenaSet *empty_blocks, ArenaSetGetLoop(); bool loop_is_header = !loop->IsRoot() && loop->GetHeader() == block; - if (loop_is_header) { for (auto inst : block->InstsReverse()) { if (IsEnqueuedForRemoval(inst)) { diff --git a/static_core/compiler/optimizer/optimizations/escape.h b/static_core/compiler/optimizer/optimizations/escape.h index 1a7b8d3e6d..e45d085301 100644 --- a/static_core/compiler/optimizer/optimizations/escape.h +++ b/static_core/compiler/optimizer/optimizations/escape.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/if_conversion.cpp b/static_core/compiler/optimizer/optimizations/if_conversion.cpp index 4734e627f3..113551e78c 100644 --- a/static_core/compiler/optimizer/optimizations/if_conversion.cpp +++ b/static_core/compiler/optimizer/optimizations/if_conversion.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/if_conversion.h b/static_core/compiler/optimizer/optimizations/if_conversion.h index dc2abd7b8e..f71f952e84 100644 --- a/static_core/compiler/optimizer/optimizations/if_conversion.h +++ b/static_core/compiler/optimizer/optimizations/if_conversion.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/if_merging.cpp b/static_core/compiler/optimizer/optimizations/if_merging.cpp index a94971c675..8f104ff2d6 100644 --- a/static_core/compiler/optimizer/optimizations/if_merging.cpp +++ b/static_core/compiler/optimizer/optimizations/if_merging.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/if_merging.h b/static_core/compiler/optimizer/optimizations/if_merging.h index 5a5f794ec5..c59398c3b5 100644 --- a/static_core/compiler/optimizer/optimizations/if_merging.h +++ b/static_core/compiler/optimizer/optimizations/if_merging.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/inline_intrinsics.cpp b/static_core/compiler/optimizer/optimizations/inline_intrinsics.cpp index 91a0a5d95d..09443cd58e 100644 --- a/static_core/compiler/optimizer/optimizations/inline_intrinsics.cpp +++ b/static_core/compiler/optimizer/optimizations/inline_intrinsics.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/inline_intrinsics.h b/static_core/compiler/optimizer/optimizations/inline_intrinsics.h index 4cb041afd3..95abd5576c 100644 --- a/static_core/compiler/optimizer/optimizations/inline_intrinsics.h +++ b/static_core/compiler/optimizer/optimizations/inline_intrinsics.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/inlining.cpp b/static_core/compiler/optimizer/optimizations/inlining.cpp index 72b4a94e80..b059237e56 100644 --- a/static_core/compiler/optimizer/optimizations/inlining.cpp +++ b/static_core/compiler/optimizer/optimizations/inlining.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/inlining.h b/static_core/compiler/optimizer/optimizations/inlining.h index cf2138450d..df1fd452cd 100644 --- a/static_core/compiler/optimizer/optimizations/inlining.h +++ b/static_core/compiler/optimizer/optimizations/inlining.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/licm.cpp b/static_core/compiler/optimizer/optimizations/licm.cpp index eacc23b5b6..196fbdc0ba 100644 --- a/static_core/compiler/optimizer/optimizations/licm.cpp +++ b/static_core/compiler/optimizer/optimizations/licm.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/licm.h b/static_core/compiler/optimizer/optimizations/licm.h index fbc888d86d..67f152630e 100644 --- a/static_core/compiler/optimizer/optimizations/licm.h +++ b/static_core/compiler/optimizer/optimizations/licm.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/licm_conditions.cpp b/static_core/compiler/optimizer/optimizations/licm_conditions.cpp index 4162c8dd67..d38b626d26 100644 --- a/static_core/compiler/optimizer/optimizations/licm_conditions.cpp +++ b/static_core/compiler/optimizer/optimizations/licm_conditions.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/licm_conditions.h b/static_core/compiler/optimizer/optimizations/licm_conditions.h index 4aa890285c..c4689feaa9 100644 --- a/static_core/compiler/optimizer/optimizations/licm_conditions.h +++ b/static_core/compiler/optimizer/optimizations/licm_conditions.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/locations_builder.cpp b/static_core/compiler/optimizer/optimizations/locations_builder.cpp index 8c8eeb5599..c0fb58dee9 100644 --- a/static_core/compiler/optimizer/optimizations/locations_builder.cpp +++ b/static_core/compiler/optimizer/optimizations/locations_builder.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/locations_builder.h b/static_core/compiler/optimizer/optimizations/locations_builder.h index caba787e56..4fd32dd392 100644 --- a/static_core/compiler/optimizer/optimizations/locations_builder.h +++ b/static_core/compiler/optimizer/optimizations/locations_builder.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_idioms.cpp b/static_core/compiler/optimizer/optimizations/loop_idioms.cpp index cc7934b637..373110c94c 100644 --- a/static_core/compiler/optimizer/optimizations/loop_idioms.cpp +++ b/static_core/compiler/optimizer/optimizations/loop_idioms.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_idioms.h b/static_core/compiler/optimizer/optimizations/loop_idioms.h index 24c28a1f2c..9e0138d65e 100644 --- a/static_core/compiler/optimizer/optimizations/loop_idioms.h +++ b/static_core/compiler/optimizer/optimizations/loop_idioms.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_peeling.cpp b/static_core/compiler/optimizer/optimizations/loop_peeling.cpp index da575d20f2..eff4f345c0 100644 --- a/static_core/compiler/optimizer/optimizations/loop_peeling.cpp +++ b/static_core/compiler/optimizer/optimizations/loop_peeling.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_peeling.h b/static_core/compiler/optimizer/optimizations/loop_peeling.h index 6495581afd..612785cd65 100644 --- a/static_core/compiler/optimizer/optimizations/loop_peeling.h +++ b/static_core/compiler/optimizer/optimizations/loop_peeling.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_transform.cpp b/static_core/compiler/optimizer/optimizations/loop_transform.cpp index febd9dd33e..7218a62cdb 100644 --- a/static_core/compiler/optimizer/optimizations/loop_transform.cpp +++ b/static_core/compiler/optimizer/optimizations/loop_transform.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_transform.h b/static_core/compiler/optimizer/optimizations/loop_transform.h index 12e44d8492..df7b2bc6a2 100644 --- a/static_core/compiler/optimizer/optimizations/loop_transform.h +++ b/static_core/compiler/optimizer/optimizations/loop_transform.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_unroll.cpp b/static_core/compiler/optimizer/optimizations/loop_unroll.cpp index a0f339db84..cfbc1e885d 100644 --- a/static_core/compiler/optimizer/optimizations/loop_unroll.cpp +++ b/static_core/compiler/optimizer/optimizations/loop_unroll.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_unroll.h b/static_core/compiler/optimizer/optimizations/loop_unroll.h index 8ad517c617..bd057aa63b 100644 --- a/static_core/compiler/optimizer/optimizations/loop_unroll.h +++ b/static_core/compiler/optimizer/optimizations/loop_unroll.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_unswitch.cpp b/static_core/compiler/optimizer/optimizations/loop_unswitch.cpp index 0902ff7777..511487b7b9 100644 --- a/static_core/compiler/optimizer/optimizations/loop_unswitch.cpp +++ b/static_core/compiler/optimizer/optimizations/loop_unswitch.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/loop_unswitch.h b/static_core/compiler/optimizer/optimizations/loop_unswitch.h index 4a99681560..ae820b7d3a 100644 --- a/static_core/compiler/optimizer/optimizations/loop_unswitch.h +++ b/static_core/compiler/optimizer/optimizations/loop_unswitch.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/lowering.cpp b/static_core/compiler/optimizer/optimizations/lowering.cpp index 9c6c302cb6..cc9723ed7a 100644 --- a/static_core/compiler/optimizer/optimizations/lowering.cpp +++ b/static_core/compiler/optimizer/optimizations/lowering.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -641,7 +641,6 @@ void Lowering::LowerMulDivMod(Inst *inst) { ASSERT(inst->GetOpcode() == OPCODE); auto graph = inst->GetBasicBlock()->GetGraph(); - if (graph->IsInstThrowable(inst)) { return; } @@ -841,7 +840,6 @@ Inst *Lowering::LowerBinaryOperationWithShiftedOperand(Inst *inst) InstructionsCapture<2U> insts {}; InstructionsCapture<3U> inv_insts {}; constexpr auto FLAGS = IS_COMMUTATIVE ? Flags::COMMUTATIVE : Flags::NONE; - // constexpr auto OPCODE = OPCODE; // NOLINT(readability-magic-numbers) // We're expecting that at this point all "shift by immediate" patterns were replaced with ShlI/ShrI/AShrI // clang-format off @@ -888,7 +886,6 @@ void Lowering::LowerUnaryOperationWithShiftedOperand(Inst *inst) { OperandsCapture<1> operands {}; InstructionsCapture<2U> insts {}; - // constexpr auto OPCODE = OPCODE; // NOLINT(readability-magic-numbers) // We're expecting that at this point all "shift by immediate" patterns were replaced with ShlI/ShrI/AShrI // clang-format off using Matcher = AnyOf>, diff --git a/static_core/compiler/optimizer/optimizations/lowering.h b/static_core/compiler/optimizer/optimizations/lowering.h index 532a053543..60fe24efdc 100644 --- a/static_core/compiler/optimizer/optimizations/lowering.h +++ b/static_core/compiler/optimizer/optimizations/lowering.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/lse.cpp b/static_core/compiler/optimizer/optimizations/lse.cpp index a3beea4364..858cd42c78 100644 --- a/static_core/compiler/optimizer/optimizations/lse.cpp +++ b/static_core/compiler/optimizer/optimizations/lse.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/lse.h b/static_core/compiler/optimizer/optimizations/lse.h index c9ff89525a..c4bbd96ea7 100644 --- a/static_core/compiler/optimizer/optimizations/lse.h +++ b/static_core/compiler/optimizer/optimizations/lse.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/memory_barriers.cpp b/static_core/compiler/optimizer/optimizations/memory_barriers.cpp index 6cc01b7906..6b33d87288 100644 --- a/static_core/compiler/optimizer/optimizations/memory_barriers.cpp +++ b/static_core/compiler/optimizer/optimizations/memory_barriers.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/memory_barriers.h b/static_core/compiler/optimizer/optimizations/memory_barriers.h index 3a7842aa5e..ee54062204 100644 --- a/static_core/compiler/optimizer/optimizations/memory_barriers.h +++ b/static_core/compiler/optimizer/optimizations/memory_barriers.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/memory_coalescing.cpp b/static_core/compiler/optimizer/optimizations/memory_coalescing.cpp index 2c3a9a34ca..f131276d8f 100644 --- a/static_core/compiler/optimizer/optimizations/memory_coalescing.cpp +++ b/static_core/compiler/optimizer/optimizations/memory_coalescing.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/memory_coalescing.h b/static_core/compiler/optimizer/optimizations/memory_coalescing.h index f1acd14708..34dc0257c5 100644 --- a/static_core/compiler/optimizer/optimizations/memory_coalescing.h +++ b/static_core/compiler/optimizer/optimizations/memory_coalescing.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/move_constants.cpp b/static_core/compiler/optimizer/optimizations/move_constants.cpp index 96123e5b43..44d304f094 100644 --- a/static_core/compiler/optimizer/optimizations/move_constants.cpp +++ b/static_core/compiler/optimizer/optimizations/move_constants.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -63,7 +63,6 @@ void MoveConstants::MoveFromStartBlock(Inst *inst) auto user_inst = SingleBlockNoPhiDominatingUser(inst); if (user_inst != nullptr) { target_bb = user_inst->GetBasicBlock(); - if (IsBlockSuitable(target_bb)) { graph->GetStartBlock()->EraseInst(inst); target_bb->InsertBefore(inst, user_inst); diff --git a/static_core/compiler/optimizer/optimizations/move_constants.h b/static_core/compiler/optimizer/optimizations/move_constants.h index 8fef2b0384..620634274f 100644 --- a/static_core/compiler/optimizer/optimizations/move_constants.h +++ b/static_core/compiler/optimizer/optimizations/move_constants.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/object_type_check_elimination.cpp b/static_core/compiler/optimizer/optimizations/object_type_check_elimination.cpp index 9c0743f6ee..26efbfcbc6 100644 --- a/static_core/compiler/optimizer/optimizations/object_type_check_elimination.cpp +++ b/static_core/compiler/optimizer/optimizations/object_type_check_elimination.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/object_type_check_elimination.h b/static_core/compiler/optimizer/optimizations/object_type_check_elimination.h index c9b891c813..ec5edad37e 100644 --- a/static_core/compiler/optimizer/optimizations/object_type_check_elimination.h +++ b/static_core/compiler/optimizer/optimizations/object_type_check_elimination.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/peepholes.cpp b/static_core/compiler/optimizer/optimizations/peepholes.cpp index 2ad0bbdcba..26c8241016 100644 --- a/static_core/compiler/optimizer/optimizations/peepholes.cpp +++ b/static_core/compiler/optimizer/optimizations/peepholes.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -115,6 +115,34 @@ void Peepholes::VisitNot([[maybe_unused]] GraphVisitor *v, Inst *inst) } } +void Peepholes::VisitAddFinalize([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1) +{ + auto visitor = static_cast(v); + // Some of the previous transformations might change the opcode of inst. + if (inst->GetOpcode() == Opcode::Add) { + if (visitor->TryReassociateShlShlAddSub(inst)) { + PEEPHOLE_IS_APPLIED(visitor, inst); + return; + } + + if (input0->GetOpcode() == Opcode::Add && input1->GetOpcode() == Opcode::Sub) { + std::swap(input0, input1); + } + + if (input0->GetOpcode() == Opcode::Sub && input1->GetOpcode() == Opcode::Add) { + if (visitor->TrySimplifyAddSubAdd(inst, input0, input1)) { + return; + } + } + + if (input0->GetOpcode() == Opcode::Sub && input1->GetOpcode() == Opcode::Sub) { + if (visitor->TrySimplifyAddSubSub(inst, input0, input1)) { + return; + } + } + } +} + /** * Case 1: Swap inputs if the first is a constant * 2. add const, v1 -> {...} @@ -243,33 +271,26 @@ void Peepholes::VisitAdd([[maybe_unused]] GraphVisitor *v, Inst *inst) visitor->TrySimplifyAddSub(inst, input0, input1); visitor->TrySimplifyAddSub(inst, input1, input0); + VisitAddFinalize(v, inst, input0, input1); +} + +void Peepholes::VisitSubFinalize([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1) +{ + auto visitor = static_cast(v); // Some of the previous transformations might change the opcode of inst. - if (inst->GetOpcode() == Opcode::Add) { + if (inst->GetOpcode() == Opcode::Sub) { if (visitor->TryReassociateShlShlAddSub(inst)) { PEEPHOLE_IS_APPLIED(visitor, inst); return; } - if (input0->GetOpcode() == Opcode::Add && input1->GetOpcode() == Opcode::Sub) { - std::swap(input0, input1); - } - - if (input0->GetOpcode() == Opcode::Sub) { - if (input1->GetOpcode() == Opcode::Add) { - if (visitor->TrySimplifyAddSubAdd(inst, input0, input1)) { - return; - } - } - - if (input1->GetOpcode() == Opcode::Sub) { - if (visitor->TrySimplifyAddSubSub(inst, input0, input1)) { - return; - } + if (input0->GetOpcode() == Opcode::Add && input1->GetOpcode() == Opcode::Add) { + if (visitor->TrySimplifySubAddAdd(inst, input0, input1)) { + return; } } } } - /** * Case 1 * Subtraction of zero @@ -369,20 +390,7 @@ void Peepholes::VisitSub([[maybe_unused]] GraphVisitor *v, Inst *inst) return; } } - - // Some of the previous transformations might change the opcode of inst. - if (inst->GetOpcode() == Opcode::Sub) { - if (visitor->TryReassociateShlShlAddSub(inst)) { - PEEPHOLE_IS_APPLIED(visitor, inst); - return; - } - - if (input0->GetOpcode() == Opcode::Add && input1->GetOpcode() == Opcode::Add) { - if (visitor->TrySimplifySubAddAdd(inst, input0, input1)) { - return; - } - } - } + VisitSubFinalize(v, inst, input0, input1); } void Peepholes::VisitMulOneConst([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1) @@ -963,6 +971,67 @@ void Peepholes::VisitCompare(GraphVisitor *v, Inst *inst) } } +bool Peepholes::TrySimplifyCompareAnyTypeCase1(Inst *inst, Inst *input0, Inst *input1) +{ + auto cmp_inst = inst->CastToCompare(); + + // 2.any CastValueToAnyType BOOLEAN_TYPE v0 -> (v4) + // 3.any CastValueToAnyType BOOLEAN_TYPE v1 -> (v4) + // 4. Compare EQ/NE any v2, v3 + // =======> + // 4. Compare EQ/NE bool v0, v1 + if (input0->CastToCastValueToAnyType()->GetAnyType() != input1->CastToCastValueToAnyType()->GetAnyType()) { + return false; + } + if (SkipThisPeepholeInOSR(cmp_inst, input0->GetInput(0).GetInst()) || + SkipThisPeepholeInOSR(cmp_inst, input1->GetInput(0).GetInst())) { + return false; + } + cmp_inst->SetOperandsType(DataType::BOOL); + cmp_inst->SetInput(0, input0->GetInput(0).GetInst()); + cmp_inst->SetInput(1, input1->GetInput(0).GetInst()); + return true; +} + +bool Peepholes::TrySimplifyCompareAnyTypeCase2(Inst *inst, Inst *input0, Inst *input1) +{ + auto graph = inst->GetBasicBlock()->GetGraph(); + auto cmp_inst = inst->CastToCompare(); + auto cc = cmp_inst->GetCc(); + auto if_imm = input1->CastToConstant()->GetRawValue(); + auto runtime = graph->GetRuntime(); + uint64_t new_const; + + // 3.any CastValueToAnyType BOOLEAN_TYPE v2 -> (v4) + // 4. Compare EQ/NE any v3, DYNAMIC_TRUE/FALSE + // =======> + // 4. Compare EQ/NE bool v2, 0x1/0x0 + if (SkipThisPeepholeInOSR(cmp_inst, input0->GetInput(0).GetInst())) { + return false; + } + if (if_imm == runtime->GetDynamicPrimitiveFalse()) { + new_const = 0; + } else if (if_imm == runtime->GetDynamicPrimitiveTrue()) { + new_const = 1; + } else { + // In this case, we are comparing the dynamic boolean type with not boolean constant. + // So the Compare EQ/NE alwayes false/true. + // In this case, we can change the Compare to Constant instruction. + // NOTE! It is assumed that there is only one Boolean type for each dynamic language. + // Support for multiple Boolean types must be maintained separately. + if (cc != CC_EQ && cc != CC_NE) { + return false; + } + // We create constant, so we don't need to check SaveStateOSR between insts + cmp_inst->ReplaceUsers(graph->FindOrCreateConstant(cc == CC_NE ? 1 : 0)); + return true; + } + cmp_inst->SetOperandsType(DataType::BOOL); + cmp_inst->SetInput(0, input0->GetInput(0).GetInst()); + cmp_inst->SetInput(1, graph->FindOrCreateConstant(new_const)); + return true; +} + bool Peepholes::TrySimplifyCompareAnyType(Inst *inst) { auto graph = inst->GetBasicBlock()->GetGraph(); @@ -991,59 +1060,13 @@ bool Peepholes::TrySimplifyCompareAnyType(Inst *inst) } if (input1->GetOpcode() == Opcode::CastValueToAnyType) { - // 2.any CastValueToAnyType BOOLEAN_TYPE v0 -> (v4) - // 3.any CastValueToAnyType BOOLEAN_TYPE v1 -> (v4) - // 4. Compare EQ/NE any v2, v3 - // =======> - // 4. Compare EQ/NE bool v0, v1 - - if (input0->CastToCastValueToAnyType()->GetAnyType() != input1->CastToCastValueToAnyType()->GetAnyType()) { - return false; - } - if (SkipThisPeepholeInOSR(cmp_inst, input0->GetInput(0).GetInst()) || - SkipThisPeepholeInOSR(cmp_inst, input1->GetInput(0).GetInst())) { - return false; - } - cmp_inst->SetOperandsType(DataType::BOOL); - cmp_inst->SetInput(0, input0->GetInput(0).GetInst()); - cmp_inst->SetInput(1, input1->GetInput(0).GetInst()); - return true; + return TrySimplifyCompareAnyTypeCase1(inst, input0, input1); } if (!input1->IsConst()) { return false; } - // 3.any CastValueToAnyType BOOLEAN_TYPE v2 -> (v4) - // 4. Compare EQ/NE any v3, DYNAMIC_TRUE/FALSE - // =======> - // 4. Compare EQ/NE bool v2, 0x1/0x0 - auto if_imm = input1->CastToConstant()->GetRawValue(); - auto runtime = graph->GetRuntime(); - uint64_t new_const; - if (SkipThisPeepholeInOSR(cmp_inst, input0->GetInput(0).GetInst())) { - return false; - } - if (if_imm == runtime->GetDynamicPrimitiveFalse()) { - new_const = 0; - } else if (if_imm == runtime->GetDynamicPrimitiveTrue()) { - new_const = 1; - } else { - // In this case, we are comparing the dynamic boolean type with not boolean constant. - // So the Compare EQ/NE alwayes false/true. - // In this case, we can change the Compare to Constant instruction. - // NOTE! It is assumed that there is only one Boolean type for each dynamic language. - // Support for multiple Boolean types must be maintained separately. - if (cc != CC_EQ && cc != CC_NE) { - return false; - } - // We create constant, so we don't need to check SaveStateOSR between insts - cmp_inst->ReplaceUsers(graph->FindOrCreateConstant(cc == CC_NE ? 1 : 0)); - return true; - } - cmp_inst->SetOperandsType(DataType::BOOL); - cmp_inst->SetInput(0, input0->GetInput(0).GetInst()); - cmp_inst->SetInput(1, graph->FindOrCreateConstant(new_const)); - return true; + return TrySimplifyCompareAnyTypeCase2(inst, input0, input1); } // This VisitIf is using only for compile IRTOC @@ -1189,6 +1212,89 @@ static inline bool IsCastAllowedInBytecode(const Inst *inst) } } +void Peepholes::VisitCastCase1([[maybe_unused]] GraphVisitor *v, Inst *inst) +{ + // case 1: + // remove redundant cast, when source type is equal with target type + auto input = inst->GetInput(0).GetInst(); + if (SkipThisPeepholeInOSR(inst, input)) { + return; + } + inst->ReplaceUsers(input); + PEEPHOLE_IS_APPLIED(static_cast(v), inst); +} + +void Peepholes::VisitCastCase2([[maybe_unused]] GraphVisitor *v, Inst *inst) +{ + // case 2: + // remove redundant cast, when cast from source to target and back + // for bytecode optimizer, this operation may cause mistake for float32-converter pass + auto input = inst->GetInput(0).GetInst(); + auto prev_type = input->GetType(); + auto curr_type = inst->GetType(); + auto graph = inst->GetBasicBlock()->GetGraph(); + auto arch = graph->GetArch(); + auto orig_inst = input->GetInput(0).GetInst(); + auto orig_type = orig_inst->GetType(); + if (curr_type == orig_type && DataType::GetTypeSize(prev_type, arch) > DataType::GetTypeSize(curr_type, arch)) { + if (SkipThisPeepholeInOSR(inst, orig_inst)) { + return; + } + inst->ReplaceUsers(orig_inst); + PEEPHOLE_IS_APPLIED(static_cast(v), inst); + return; + } + // case 2.1: + // join two sequent narrowing integer casts, e.g: + // replace + // cast i64toi32 + // cast i32toi16 + // with + // cast i64toi16 + if (ApplyForCastJoin(inst, input, orig_inst, arch)) { + auto cast = inst->CastToCast(); + if (SkipThisPeepholeInOSR(cast, orig_inst)) { + return; + } + cast->SetOperandsType(orig_inst->GetType()); + cast->SetInput(0, orig_inst); + PEEPHOLE_IS_APPLIED(static_cast(v), inst); + return; + } +} + +void Peepholes::VisitCastCase3([[maybe_unused]] GraphVisitor *v, Inst *inst) +{ + auto input = inst->GetInput(0).GetInst(); + auto curr_type = inst->GetType(); + auto graph = inst->GetBasicBlock()->GetGraph(); + auto arch = graph->GetArch(); + + // case 3: + // i8.Cast(v1 & 0xff) = i8.Cast(u8.Cast(v1)) = i8.Cast(v1) + // i16.Cast(v1 & 0xffff) = i16.Cast(u16.Cast(v1)) = i16.Cast(v1) + // i32.Cast(v1 & 0xffffffff) = i32.Cast(u32.Cast(v1)) = i32.Cast(v1) + auto op0 = input->GetInput(0).GetInst(); + if (graph->IsBytecodeOptimizer() && !IsCastAllowedInBytecode(op0)) { + return; + } + auto op1 = input->GetInput(1).GetInst(); + auto type_size = DataType::GetTypeSize(curr_type, arch); + if (op1->IsConst() && type_size < DOUBLE_WORD_SIZE) { + auto val = op1->CastToConstant()->GetIntValue(); + auto mask = (1ULL << type_size) - 1; + if ((val & mask) == mask) { + if (SkipThisPeepholeInOSR(inst, op0)) { + return; + } + inst->SetInput(0, op0); + inst->CastToCast()->SetOperandsType(op0->GetType()); + PEEPHOLE_IS_APPLIED(static_cast(v), inst); + return; + } + } +} + void Peepholes::VisitCast([[maybe_unused]] GraphVisitor *v, Inst *inst) { if (ConstFoldingCast(inst)) { @@ -1199,76 +1305,20 @@ void Peepholes::VisitCast([[maybe_unused]] GraphVisitor *v, Inst *inst) auto prev_type = input->GetType(); auto curr_type = inst->GetType(); auto graph = inst->GetBasicBlock()->GetGraph(); - auto arch = graph->GetArch(); - // case 1: - // remove redundant cast, when source type is equal with target type + if (prev_type == curr_type) { - if (SkipThisPeepholeInOSR(inst, input)) { - return; - } - inst->ReplaceUsers(input); - PEEPHOLE_IS_APPLIED(static_cast(v), inst); + VisitCastCase1(v, inst); return; } - if (!graph->IsBytecodeOptimizer()) { - if (input->GetOpcode() == Opcode::Cast) { - auto orig_inst = input->GetInput(0).GetInst(); - auto orig_type = orig_inst->GetType(); - // case 2: - // remove redundant cast, when cast from source to target and back - // for bytecode optimizer, this operation may cause mistake for float32-converter pass - if (curr_type == orig_type && - DataType::GetTypeSize(prev_type, arch) > DataType::GetTypeSize(curr_type, arch)) { - if (SkipThisPeepholeInOSR(inst, orig_inst)) { - return; - } - inst->ReplaceUsers(orig_inst); - PEEPHOLE_IS_APPLIED(static_cast(v), inst); - return; - } - // case 4: - // join two sequent narrowing integer casts, e.g: - // replace - // cast i64toi32 - // cast i32toi16 - // with - // cast i64toi16 - if (ApplyForCastJoin(inst, input, orig_inst, arch)) { - auto cast = inst->CastToCast(); - if (SkipThisPeepholeInOSR(cast, orig_inst)) { - return; - } - cast->SetOperandsType(orig_inst->GetType()); - cast->SetInput(0, orig_inst); - PEEPHOLE_IS_APPLIED(static_cast(v), inst); - return; - } - } + + if (!graph->IsBytecodeOptimizer() && input->GetOpcode() == Opcode::Cast) { + VisitCastCase2(v, inst); + return; } - // case 3: - // i8.Cast(v1 & 0xff) = i8.Cast(u8.Cast(v1)) = i8.Cast(v1) - // i16.Cast(v1 & 0xffff) = i16.Cast(u16.Cast(v1)) = i16.Cast(v1) - // i32.Cast(v1 & 0xffffffff) = i32.Cast(u32.Cast(v1)) = i32.Cast(v1) + if (input->GetOpcode() == Opcode::And && DataType::GetCommonType(curr_type) == DataType::INT64) { - auto op0 = input->GetInput(0).GetInst(); - if (graph->IsBytecodeOptimizer() && !IsCastAllowedInBytecode(op0)) { - return; - } - auto op1 = input->GetInput(1).GetInst(); - auto type_size = DataType::GetTypeSize(curr_type, arch); - if (op1->IsConst() && type_size < DOUBLE_WORD_SIZE) { - auto val = op1->CastToConstant()->GetIntValue(); - auto mask = (1ULL << type_size) - 1; - if ((val & mask) == mask) { - if (SkipThisPeepholeInOSR(inst, op0)) { - return; - } - inst->SetInput(0, op0); - inst->CastToCast()->SetOperandsType(op0->GetType()); - PEEPHOLE_IS_APPLIED(static_cast(v), inst); - return; - } - } + VisitCastCase3(v, inst); + return; } } @@ -2040,10 +2090,8 @@ bool Peepholes::TryReassociateShlShlAddSub(Inst *inst) return false; } auto input0 = inst->GetInput(0).GetInst(); - if (!input0->IsConst() && !input0->IsParameter()) { - if (!input0->IsDominate(input1)) { - return false; - } + if (!input0->IsConst() && !input0->IsParameter() && !input0->IsDominate(input1)) { + return false; } Opcode op_input1 = input1->GetOpcode(); diff --git a/static_core/compiler/optimizer/optimizations/peepholes.h b/static_core/compiler/optimizer/optimizations/peepholes.h index ba07c21696..372d1d8996 100644 --- a/static_core/compiler/optimizer/optimizations/peepholes.h +++ b/static_core/compiler/optimizer/optimizations/peepholes.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,7 +26,7 @@ namespace panda::compiler { // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define PEEPHOLE_IS_APPLIED(visitor, inst) visitor->SetIsApplied(inst, true, __FILE__, __LINE__) +#define PEEPHOLE_IS_APPLIED(visitor, inst) (visitor)->SetIsApplied((inst), true, __FILE__, __LINE__) // NOLINTNEXTLINE(fuchsia-multiple-inheritance) class Peepholes : public Optimization, public GraphVisitor { @@ -64,7 +64,9 @@ public: static void VisitAbs([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitNot([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitAdd([[maybe_unused]] GraphVisitor *v, Inst *inst); + static void VisitAddFinalize([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1); static void VisitSub([[maybe_unused]] GraphVisitor *v, Inst *inst); + static void VisitSubFinalize([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1); static void VisitMulOneConst([[maybe_unused]] GraphVisitor *v, Inst *inst, Inst *input0, Inst *input1); static void VisitMul([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitDiv([[maybe_unused]] GraphVisitor *v, Inst *inst); @@ -81,6 +83,9 @@ public: static void VisitCompare([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitIf(GraphVisitor *v, Inst *inst); static void VisitCast([[maybe_unused]] GraphVisitor *v, Inst *inst); + static void VisitCastCase1([[maybe_unused]] GraphVisitor *v, Inst *inst); + static void VisitCastCase2([[maybe_unused]] GraphVisitor *v, Inst *inst); + static void VisitCastCase3([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitLenArray(GraphVisitor *v, Inst *inst); static void VisitPhi([[maybe_unused]] GraphVisitor *v, Inst *inst); static void VisitSqrt([[maybe_unused]] GraphVisitor *v, Inst *inst); @@ -158,6 +163,8 @@ private: void TryRemoveOverflowCheck(Inst *inst); static bool TrySimplifyCompareAndZero(Inst *inst, bool *is_osr_blocked); static bool TrySimplifyCompareAnyType(Inst *inst); + static bool TrySimplifyCompareAnyTypeCase1(Inst *inst, Inst *input0, Inst *input1); + static bool TrySimplifyCompareAnyTypeCase2(Inst *inst, Inst *input0, Inst *input1); static bool TrySimplifyCompareLenArrayWithZero(Inst *inst); // Try to combine constants when arithmetic operations with constants are repeated template diff --git a/static_core/compiler/optimizer/optimizations/phi_type_resolving.cpp b/static_core/compiler/optimizer/optimizations/phi_type_resolving.cpp index b3638e3bb2..e1c7f1b3e2 100644 --- a/static_core/compiler/optimizer/optimizations/phi_type_resolving.cpp +++ b/static_core/compiler/optimizer/optimizations/phi_type_resolving.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/phi_type_resolving.h b/static_core/compiler/optimizer/optimizations/phi_type_resolving.h index 4cabc22c24..72bbd22779 100644 --- a/static_core/compiler/optimizer/optimizations/phi_type_resolving.h +++ b/static_core/compiler/optimizer/optimizations/phi_type_resolving.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.cpp b/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.cpp index 54dc81b3c0..c410e9a504 100644 --- a/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.cpp +++ b/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.h b/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.h index 81fdc8aaf9..9fe3431b01 100644 --- a/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.h +++ b/static_core/compiler/optimizer/optimizations/redundant_loop_elimination.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.cpp b/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.cpp index 178a57c6c8..25f6470ef1 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.h b/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.h index 1d76bcb9d4..fa5618172d 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/cleanup_empty_blocks.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.cpp b/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.cpp index 1e84292839..e206a66884 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -124,7 +124,6 @@ ArenaVector InterferenceGraph::LexBFS() const auto it = std::stable_partition(out.begin() + pos, out.begin() + prev_end, [id, &out, this](unsigned val) { return HasEdge(id, out[val]); }); auto pivot = static_cast(std::distance(out.begin(), it)); - // Split group if needed if (pivot > pos && pivot != prev_end) { boundary_stack.push_back(pivot); diff --git a/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.h b/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.h index e48072c65c..0e7038ba45 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/interference_graph.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/location_mask.h b/static_core/compiler/optimizer/optimizations/regalloc/location_mask.h index efa9e7a8f1..0cfa328089 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/location_mask.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/location_mask.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.cpp index c55bdd8ca8..c64d65d0d0 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.h index 5da0dc1ff1..09a4d629d7 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.cpp index 6026c5e7e8..03e3cc5401 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.h index 4b735872cd..7bfdd25c88 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_base.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.cpp index 32b20acfa4..c92d8717a9 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,6 +29,17 @@ namespace panda::compiler { RegAllocGraphColoring::RegAllocGraphColoring(Graph *graph) : RegAllocBase(graph) {} RegAllocGraphColoring::RegAllocGraphColoring(Graph *graph, size_t regs_count) : RegAllocBase(graph, regs_count) {} +void RegAllocGraphColoring::FillPhysicalNodes(InterferenceGraph *ig, WorkingRanges *ranges, + ArenaVector &physical_nodes) +{ + for (auto physical_interval : ranges->physical) { + ColorNode *node = ig->AllocNode(); + node->Assign(physical_interval); + node->SetPhysical(); + physical_nodes.push_back(node); + } +} + void RegAllocGraphColoring::BuildIG(InterferenceGraph *ig, WorkingRanges *ranges, bool remat_constants) { ig->Reserve(ranges->regular.size() + ranges->physical.size()); @@ -36,12 +47,7 @@ void RegAllocGraphColoring::BuildIG(InterferenceGraph *ig, WorkingRanges *ranges ArenaVector physical_nodes(GetGraph()->GetLocalAllocator()->Adapter()); const auto &la = GetGraph()->GetAnalysis(); - for (auto physical_interval : ranges->physical) { - ColorNode *node = ig->AllocNode(); - node->Assign(physical_interval); - node->SetPhysical(); - physical_nodes.push_back(node); - } + FillPhysicalNodes(ig, ranges, physical_nodes); for (auto current_interval : ranges->regular) { auto range_start = current_interval->GetBegin(); diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.h index 37b568ed78..b21b5c3382 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_graph_coloring.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -50,6 +50,7 @@ protected: private: void InitWorkingRanges(WorkingRanges *general_ranges, WorkingRanges *fp_ranges); + void FillPhysicalNodes(InterferenceGraph *ig, WorkingRanges *ranges, ArenaVector &physical_nodes); void BuildIG(InterferenceGraph *ig, WorkingRanges *ranges, bool remat_constants = false); IndexVector PrecolorIG(InterferenceGraph *ig); IndexVector PrecolorIG(InterferenceGraph *ig, const RegisterMap &map); diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.cpp index f2bf6764b4..fe52280ed2 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.h index f1643078db..476b86c9e8 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_linear_scan.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.cpp index 093c900625..c16b3f8fe1 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.h index 23e34f53f7..e7cc18dbe0 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_resolver.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.cpp index a202d07ab0..cbed6ae5e5 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.h index 94cee822de..288a7b9a44 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_alloc_stat.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_map.cpp b/static_core/compiler/optimizer/optimizations/regalloc/reg_map.cpp index 7af54321f4..f7a63ac93d 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_map.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_map.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_map.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_map.h index 8be095dac8..f08feef618 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_map.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_map.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/reg_type.h b/static_core/compiler/optimizer/optimizations/regalloc/reg_type.h index b38f166b07..3674c78179 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/reg_type.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/reg_type.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.cpp b/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.cpp index d015feffd4..3cf0aa454c 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.h b/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.h index b623b07997..9603a41b95 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/spill_fills_resolver.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.cpp b/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.cpp index 9ce826d6ea..9ea1227e7b 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.cpp +++ b/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.h b/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.h index 8466e9e794..853060a33c 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/split_resolver.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/regalloc/working_ranges.h b/static_core/compiler/optimizer/optimizations/regalloc/working_ranges.h index e8ed68dc1b..ee89f75a1e 100644 --- a/static_core/compiler/optimizer/optimizations/regalloc/working_ranges.h +++ b/static_core/compiler/optimizer/optimizations/regalloc/working_ranges.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/scheduler.cpp b/static_core/compiler/optimizer/optimizations/scheduler.cpp index 6036a082d8..ee459b2f7e 100644 --- a/static_core/compiler/optimizer/optimizations/scheduler.cpp +++ b/static_core/compiler/optimizer/optimizations/scheduler.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/scheduler.h b/static_core/compiler/optimizer/optimizations/scheduler.h index 3b6c6c301e..6c40deb728 100644 --- a/static_core/compiler/optimizer/optimizations/scheduler.h +++ b/static_core/compiler/optimizer/optimizations/scheduler.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/try_catch_resolving.cpp b/static_core/compiler/optimizer/optimizations/try_catch_resolving.cpp index bdf9f4006c..b1bbb6f8f4 100644 --- a/static_core/compiler/optimizer/optimizations/try_catch_resolving.cpp +++ b/static_core/compiler/optimizer/optimizations/try_catch_resolving.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -89,6 +89,33 @@ void TryCatchResolving::CollectCandidates() } } +void TryCatchResolving::ConnectThrowCatchImpl(BasicBlock *catch_block, BasicBlock *throw_block, uint32_t catch_pc, + Inst *new_obj, Inst *thr0w) +{ + auto throw_block_succ = throw_block->GetSuccessor(0); + throw_block->RemoveSucc(throw_block_succ); + throw_block_succ->RemovePred(throw_block); + throw_block->AddSucc(catch_block); + PhiInst *phi_inst = nullptr; + auto pit = phi_insts_.find(catch_pc); + if (pit == phi_insts_.end()) { + phi_inst = GetGraph()->CreateInstPhi(new_obj->GetType(), catch_pc); + catch_block->AppendPhi(phi_inst); + phi_insts_.emplace(catch_pc, phi_inst); + } else { + phi_inst = pit->second; + } + phi_inst->AppendInput(new_obj); + auto cpit = catch2cphis_.find(catch_block); + ASSERT(cpit != catch2cphis_.end()); + auto cphis_block = cpit->second; + RemoveCatchPhis(cphis_block, catch_block, thr0w, phi_inst); + COMPILER_LOG(DEBUG, TRY_CATCH_RESOLVING) + << "throw I " << thr0w->GetId() << " BB " << throw_block->GetId() << " is connected with catch BB " + << catch_block->GetId() << " and removed"; + throw_block->RemoveInst(thr0w); +} + void TryCatchResolving::ConnectThrowCatch() { auto *graph = GetGraph(); @@ -124,29 +151,7 @@ void TryCatchResolving::ConnectThrowCatch() if (cit == catch_blocks_.end()) { continue; } - auto catch_block = cit->second; - auto throw_block_succ = throw_block->GetSuccessor(0); - throw_block->RemoveSucc(throw_block_succ); - throw_block_succ->RemovePred(throw_block); - throw_block->AddSucc(catch_block); - PhiInst *phi_inst = nullptr; - auto pit = phi_insts_.find(catch_pc); - if (pit == phi_insts_.end()) { - phi_inst = GetGraph()->CreateInstPhi(new_obj->GetType(), catch_pc); - catch_block->AppendPhi(phi_inst); - phi_insts_.emplace(catch_pc, phi_inst); - } else { - phi_inst = pit->second; - } - phi_inst->AppendInput(new_obj); - auto cpit = catch2cphis_.find(catch_block); - ASSERT(cpit != catch2cphis_.end()); - auto cphis_block = cpit->second; - RemoveCatchPhis(cphis_block, catch_block, thr0w, phi_inst); - COMPILER_LOG(DEBUG, TRY_CATCH_RESOLVING) - << "throw I " << thr0w->GetId() << " BB " << throw_block->GetId() << " is connected with catch BB " - << catch_block->GetId() << " and removed"; - throw_block->RemoveInst(thr0w); + ConnectThrowCatchImpl(cit->second, throw_block, catch_pc, new_obj, thr0w); } } @@ -192,6 +197,38 @@ void TryCatchResolving::DeleteTryCatchEdges(BasicBlock *try_begin, BasicBlock *t } } +void TryCatchResolving::RemoveCatchPhisImpl(CatchPhiInst *catch_phi, BasicBlock *catch_block, Inst *throw_inst) +{ + auto throw_insts = catch_phi->GetThrowableInsts(); + auto it = std::find(throw_insts->begin(), throw_insts->end(), throw_inst); + if (it != throw_insts->end()) { + auto input_index = std::distance(throw_insts->begin(), it); + auto input_inst = catch_phi->GetInput(input_index).GetInst(); + PhiInst *phi = nullptr; + auto cit = cphi2phi_.find(catch_phi); + if (cit == cphi2phi_.end()) { + phi = GetGraph()->CreateInstPhi(catch_phi->GetType(), catch_block->GetGuestPc())->CastToPhi(); + catch_block->AppendPhi(phi); + catch_phi->ReplaceUsers(phi); + cphi2phi_.emplace(catch_phi, phi); + } else { + phi = cit->second; + } + phi->AppendInput(input_inst); + } else { + while (!catch_phi->GetUsers().Empty()) { + auto &user = catch_phi->GetUsers().Front(); + auto user_inst = user.GetInst(); + if (user_inst->IsSaveState() || user_inst->IsCatchPhi()) { + user_inst->RemoveInput(user.GetIndex()); + } else { + auto input_inst = catch_phi->GetInput(0).GetInst(); + user_inst->ReplaceInput(catch_phi, input_inst); + } + } + } +} + /** * Replace all catch-phi instructions with their inputs * Replace accumulator's catch-phi with exception's object @@ -208,34 +245,7 @@ void TryCatchResolving::RemoveCatchPhis(BasicBlock *cphis_block, BasicBlock *cat if (catch_phi->IsAcc()) { catch_phi->ReplaceUsers(phi_inst); } else { - auto throw_insts = catch_phi->GetThrowableInsts(); - auto it = std::find(throw_insts->begin(), throw_insts->end(), throw_inst); - if (it != throw_insts->end()) { - auto input_index = std::distance(throw_insts->begin(), it); - auto input_inst = catch_phi->GetInput(input_index).GetInst(); - PhiInst *phi = nullptr; - auto cit = cphi2phi_.find(catch_phi); - if (cit == cphi2phi_.end()) { - phi = GetGraph()->CreateInstPhi(catch_phi->GetType(), catch_block->GetGuestPc())->CastToPhi(); - catch_block->AppendPhi(phi); - catch_phi->ReplaceUsers(phi); - cphi2phi_.emplace(catch_phi, phi); - } else { - phi = cit->second; - } - phi->AppendInput(input_inst); - } else { - while (!catch_phi->GetUsers().Empty()) { - auto &user = catch_phi->GetUsers().Front(); - auto user_inst = user.GetInst(); - if (user_inst->IsSaveState() || user_inst->IsCatchPhi()) { - user_inst->RemoveInput(user.GetIndex()); - } else { - auto input_inst = catch_phi->GetInput(0).GetInst(); - user_inst->ReplaceInput(catch_phi, input_inst); - } - } - } + RemoveCatchPhisImpl(catch_phi, catch_block, throw_inst); } } } diff --git a/static_core/compiler/optimizer/optimizations/try_catch_resolving.h b/static_core/compiler/optimizer/optimizations/try_catch_resolving.h index 08815e5a3c..9e2582de69 100644 --- a/static_core/compiler/optimizer/optimizations/try_catch_resolving.h +++ b/static_core/compiler/optimizer/optimizations/try_catch_resolving.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -48,8 +48,11 @@ private: void CollectCandidates(); void VisitTryInst(TryInst *try_inst); void ConnectThrowCatch(); + void ConnectThrowCatchImpl(BasicBlock *catch_block, BasicBlock *throw_block, uint32_t catch_pc, Inst *new_obj, + Inst *thr0w); void DeleteTryCatchEdges(BasicBlock *try_begin, BasicBlock *try_end); void RemoveCatchPhis(BasicBlock *cphis_block, BasicBlock *catch_block, Inst *throw_inst, Inst *phi_inst); + void RemoveCatchPhisImpl(CatchPhiInst *catch_phi, BasicBlock *catch_block, Inst *throw_inst); private: Marker marker_ {UNDEF_MARKER}; diff --git a/static_core/compiler/optimizer/optimizations/vn.cpp b/static_core/compiler/optimizer/optimizations/vn.cpp index d1f4b228a4..c57a475048 100644 --- a/static_core/compiler/optimizer/optimizations/vn.cpp +++ b/static_core/compiler/optimizer/optimizations/vn.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/optimizations/vn.h b/static_core/compiler/optimizer/optimizations/vn.h index 753edf9779..aa26cac1be 100644 --- a/static_core/compiler/optimizer/optimizations/vn.h +++ b/static_core/compiler/optimizer/optimizations/vn.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pass.cpp b/static_core/compiler/optimizer/pass.cpp index 549091dada..8253ae9bc8 100644 --- a/static_core/compiler/optimizer/pass.cpp +++ b/static_core/compiler/optimizer/pass.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pass.h b/static_core/compiler/optimizer/pass.h index 7f76c9587b..58d4f84fe5 100644 --- a/static_core/compiler/optimizer/pass.h +++ b/static_core/compiler/optimizer/pass.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pass_manager.cpp b/static_core/compiler/optimizer/pass_manager.cpp index 86bdb5fa5d..6cc91ed697 100644 --- a/static_core/compiler/optimizer/pass_manager.cpp +++ b/static_core/compiler/optimizer/pass_manager.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pass_manager.h b/static_core/compiler/optimizer/pass_manager.h index fbb648e90f..ef11dc575e 100644 --- a/static_core/compiler/optimizer/pass_manager.h +++ b/static_core/compiler/optimizer/pass_manager.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -65,7 +65,7 @@ public: } template - static constexpr size_t GetIndex(std::index_sequence) + static constexpr size_t GetIndex(std::index_sequence /* unused */) { static_assert(HasType()); return (0 + ... + diff --git a/static_core/compiler/optimizer/pass_manager_statistics.cpp b/static_core/compiler/optimizer/pass_manager_statistics.cpp index a4ded73895..9334ca81a6 100644 --- a/static_core/compiler/optimizer/pass_manager_statistics.cpp +++ b/static_core/compiler/optimizer/pass_manager_statistics.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -54,8 +54,9 @@ void PassManagerStatistics::PrintStatistics() const for (const auto& stat : pass_stat_list_) { auto indent = stat.run_depth * OFFSET_STAT; space_buf[indent] = 0; - out << std::setw(OFFSET_ID) << std::right << index << space_buf << " " << std::left << std::setw(OFFSET_PASS_NAME - indent) - << stat.pass_name << ": " << std::right << std::setw(OFFSET_DEFAULT) << stat.mem_used_ir << std::setw(OFFSET_DEFAULT) + out << std::setw(OFFSET_ID) << std::right << index << space_buf << " " + << std::left << std::setw(OFFSET_PASS_NAME - indent) << stat.pass_name << ": " + << std::right << std::setw(OFFSET_DEFAULT) << stat.mem_used_ir << std::setw(OFFSET_DEFAULT) << stat.mem_used_local << std::setw(OFFSET_DEFAULT) << stat.time_us << std::endl; space_buf[indent] = ' '; index++; diff --git a/static_core/compiler/optimizer/pass_manager_statistics.h b/static_core/compiler/optimizer/pass_manager_statistics.h index 49f78e751a..505ccbaadf 100644 --- a/static_core/compiler/optimizer/pass_manager_statistics.h +++ b/static_core/compiler/optimizer/pass_manager_statistics.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pipeline.cpp b/static_core/compiler/optimizer/pipeline.cpp index 6e8e2372d1..9675459fdd 100644 --- a/static_core/compiler/optimizer/pipeline.cpp +++ b/static_core/compiler/optimizer/pipeline.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer/pipeline.h b/static_core/compiler/optimizer/pipeline.h index b93c0fe284..219e5a34c6 100644 --- a/static_core/compiler/optimizer/pipeline.h +++ b/static_core/compiler/optimizer/pipeline.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/optimizer_run.h b/static_core/compiler/optimizer_run.h index 59de55b7ab..8501965421 100644 --- a/static_core/compiler/optimizer_run.h +++ b/static_core/compiler/optimizer_run.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/aarch32/callconv32_test.cpp b/static_core/compiler/tests/aarch32/callconv32_test.cpp index d820b4228f..a04478058c 100644 --- a/static_core/compiler/tests/aarch32/callconv32_test.cpp +++ b/static_core/compiler/tests/aarch32/callconv32_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/aarch32/encoder32_test.cpp b/static_core/compiler/tests/aarch32/encoder32_test.cpp index f4cc58eb81..bf8da0a939 100644 --- a/static_core/compiler/tests/aarch32/encoder32_test.cpp +++ b/static_core/compiler/tests/aarch32/encoder32_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -99,6 +99,8 @@ static T RandomGen() return panda::bit_cast(gen & MASK_DENORMAL_DOUBLE); } } + default: + break; } // Uniform distribution floating value @@ -456,7 +458,6 @@ bool TestNeg(Encoder32Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, -tmp)) { @@ -466,7 +467,6 @@ bool TestNeg(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -509,9 +509,7 @@ bool TestNot(Encoder32Test *test) for (uint64_t i = 0; i < ITERATION; ++i) { // Second type-dependency T tmp = RandomGen(); - // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, ~tmp)) { // NOLINT(hicpp-signed-bitwise) @@ -559,7 +557,6 @@ bool TestMov(Encoder32Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, tmp)) { @@ -569,7 +566,6 @@ bool TestMov(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -606,7 +602,6 @@ bool TestMov2(Encoder32Test *test) Src src = RandomGen(); Dst dst = bit_cast(src); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(src, dst)) { @@ -617,7 +612,6 @@ bool TestMov2(Encoder32Test *test) if constexpr (std::is_floating_point_v) { Src nan = std::numeric_limits::quiet_NaN(); Dst dst_nan = bit_cast(nan); - if (!test->CallCode(nan, dst_nan)) { return false; } @@ -1151,7 +1145,6 @@ bool TestAbs(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -1207,7 +1200,6 @@ bool TestSqrt(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -1252,7 +1244,6 @@ bool TestAdd(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 + tmp2)) { @@ -1262,7 +1253,6 @@ bool TestAdd(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1319,7 +1309,6 @@ bool TestAddImm(Encoder32Test *test) // Second type-dependency T tmp1 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp1 + param2)) { @@ -1367,7 +1356,6 @@ bool TestSub(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 - tmp2)) { @@ -1377,7 +1365,6 @@ bool TestSub(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1439,7 +1426,6 @@ bool TestSubImm(Encoder32Test *test) // Second type-dependency T tmp1 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp1 - param2)) { @@ -1490,7 +1476,6 @@ bool TestMul(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 * tmp2)) { @@ -1500,7 +1485,6 @@ bool TestMul(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1579,7 +1563,6 @@ bool TestMin(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1662,7 +1645,6 @@ bool TestMax(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1914,7 +1896,6 @@ bool TestAnd(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 & tmp2)) { @@ -1962,7 +1943,6 @@ bool TestOr(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 | tmp2)) { @@ -2010,7 +1990,6 @@ bool TestXor(Encoder32Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 ^ tmp2)) { @@ -2252,7 +2231,6 @@ bool TestFcmp(Encoder32Test *test, bool is_fcmpg) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, 5.0, is_fcmpg ? 1 : -1)) { return false; } @@ -2489,11 +2467,7 @@ bool TestCast(Encoder32Test *test) auto float_max_int = static_cast(max_int); if (src > float_min_int) { - if (src < float_max_int) { - dst = static_cast(src); - } else { - dst = max_int; - } + dst = src < float_max_int ? static_cast(src) : max_int; } else if (std::isnan(src)) { dst = 0; } else { @@ -2690,7 +2664,6 @@ bool TestDiv(Encoder32Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -2725,6 +2698,55 @@ TEST_F(Encoder32Test, DivTest) EXPECT_TRUE(TestDiv(this)); } +template +bool TestModMainLoop(Encoder32Test *test) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + T tmp1 = RandomGen(); + T tmp2 = RandomGen(); + if (tmp2 == 0) { + tmp2 += 1; + } + // Main check - compare parameter and + // return value + if constexpr (std::is_same::value) { + if (!test->CallCode(tmp1, tmp2, fmodf(tmp1, tmp2))) { + return false; + } + } else if constexpr (std::is_same::value) { + if (!test->CallCode(tmp1, tmp2, fmod(tmp1, tmp2))) { + return false; + } + } else { + if (!test->CallCode(tmp1, tmp2, static_cast(tmp1 % tmp2))) { + return false; + } + } + } + + if constexpr (std::is_floating_point_v) { + T nan = std::numeric_limits::quiet_NaN(); + if (!test->CallCode(nan, RandomGen(), nan)) { + return false; + } + if (!test->CallCode(RandomGen(), nan, nan)) { + return false; + } + if (!test->CallCode(0.0, 0.0, nan)) { + return false; + } + if (!test->CallCode(std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { + return false; + } + if (!test->CallCode(-std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { + return false; + } + } + return true; +} + template bool TestMod(Encoder32Test *test) { @@ -2760,52 +2782,7 @@ bool TestMod(Encoder32Test *test) // Change this for enable print disasm test->Dump(false); - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - T tmp1 = RandomGen(); - T tmp2 = RandomGen(); - if (tmp2 == 0) { - tmp2 += 1; - } - // Main check - compare parameter and - // return value - if constexpr (std::is_same::value) { - if (!test->CallCode(tmp1, tmp2, fmodf(tmp1, tmp2))) { - return false; - } - } else if constexpr (std::is_same::value) { - if (!test->CallCode(tmp1, tmp2, fmod(tmp1, tmp2))) { - return false; - } - } else { - if (!test->CallCode(tmp1, tmp2, static_cast(tmp1 % tmp2))) { - return false; - } - } - } - - if constexpr (std::is_floating_point_v) { - T nan = std::numeric_limits::quiet_NaN(); - - if (!test->CallCode(nan, RandomGen(), nan)) { - return false; - } - if (!test->CallCode(RandomGen(), nan, nan)) { - return false; - } - if (!test->CallCode(0.0, 0.0, nan)) { - return false; - } - if (!test->CallCode(std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { - return false; - } - if (!test->CallCode(-std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { - return false; - } - } - - return true; + return TestModMainLoop(test); } TEST_F(Encoder32Test, ModTest) @@ -2830,13 +2807,54 @@ TEST_F(Encoder32Test, ModTest) // TEST_F(Encoder32Test, MemCopyzTest) { // EncodeMemCopyz(MemRef mem_from, MemRef mem_to, size_t size) +// int32_t uint64_t int32_t int64_t int32_t int32_t +// r0 r2+r3 stack0 stack2(align) stack4 +using FunctionPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); + +template +bool TestParamMainLoop(FunctionPtr func) +{ + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + auto param_0 = RandomGen(); + auto param_1 = RandomGen(); + auto param_2 = RandomGen(); + auto param_3 = RandomGen(); + auto param_4 = RandomGen(); + auto param_5 = RandomGen(); + + // Main check - compare parameter and + // return value + const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); + T result; + if constexpr (ID == 0) { + result = param_0; + } + if constexpr (ID == 1) { + result = param_1; + } + if constexpr (ID == 2) { + result = param_2; + } + if constexpr (ID == 3) { + result = param_3; + } + if constexpr (ID == 4) { + result = param_4; + } + if constexpr (ID == 5) { + result = param_5; + } + if (curr_result != result) { + return false; + }; + } + return true; +} + template bool TestParam(Encoder32Test *test) { - // int32_t uint64_t int32_t int64_t int32_t int32_t - // r0 r2+r3 stack0 stack2(align) stack4 - using FunctPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); - bool is_signed = std::is_signed::value; // NOLINTNEXTLINE(modernize-avoid-c-arrays) @@ -2883,45 +2901,9 @@ bool TestParam(Encoder32Test *test) auto size = test->GetCallconv()->GetCodeSize(); void *offset = (static_cast(test->GetCallconv()->GetCodeEntry())); void *ptr = test->GetCodeAllocator()->AllocateCode(size, offset); - auto func = reinterpret_cast(ptr); + auto func = reinterpret_cast(ptr); - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - auto param_0 = RandomGen(); - auto param_1 = RandomGen(); - auto param_2 = RandomGen(); - auto param_3 = RandomGen(); - auto param_4 = RandomGen(); - auto param_5 = RandomGen(); - - // Main check - compare parameter and - // return value - const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); - T result; - if constexpr (ID == 0) { - result = param_0; - } - if constexpr (ID == 1) { - result = param_1; - } - if constexpr (ID == 2) { - result = param_2; - } - if constexpr (ID == 3) { - result = param_3; - } - if constexpr (ID == 4) { - result = param_4; - } - if constexpr (ID == 5) { - result = param_5; - } - if (curr_result != result) { - return false; - }; - } - return true; + return TestParamMainLoop(func); } TEST_F(Encoder32Test, ReadParams) diff --git a/static_core/compiler/tests/aarch32/register32_test.cpp b/static_core/compiler/tests/aarch32/register32_test.cpp index 8fc2334d22..830c93e898 100644 --- a/static_core/compiler/tests/aarch32/register32_test.cpp +++ b/static_core/compiler/tests/aarch32/register32_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/aarch64/callconv64_test.cpp b/static_core/compiler/tests/aarch64/callconv64_test.cpp index 3a73ffa8b7..902257f11c 100644 --- a/static_core/compiler/tests/aarch64/callconv64_test.cpp +++ b/static_core/compiler/tests/aarch64/callconv64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/aarch64/codegen_test.cpp b/static_core/compiler/tests/aarch64/codegen_test.cpp index 6069595f9e..50685fc036 100644 --- a/static_core/compiler/tests/aarch64/codegen_test.cpp +++ b/static_core/compiler/tests/aarch64/codegen_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -454,7 +454,8 @@ public: ASSERT_TRUE(setup_frame ? GetGraph()->RunPass() : GetGraph()->RunPass()); ASSERT_TRUE(GetGraph()->GetCode().Size() == expected_asm.size() * vixl::aarch64::kInstructionSize); auto code_entry = reinterpret_cast(GetGraph()->GetCode().Data()); - auto code_exit = code_entry + GetGraph()->GetCode().Size(); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + auto code_exit = code_entry + GetGraph()->GetCode().Size(); size_t code_items = (code_exit - code_entry) / vixl::aarch64::kInstructionSize; ASSERT_TRUE(code_items == expected_asm.size()); @@ -545,7 +546,8 @@ public: ASSERT_TRUE(setup_frame ? GetGraph()->RunPass() : GetGraph()->RunPass()); ASSERT_TRUE(GetGraph()->GetCode().Size() == expected_asm.size() * vixl::aarch64::kInstructionSize); auto code_entry = reinterpret_cast(GetGraph()->GetCode().Data()); - auto code_exit = code_entry + GetGraph()->GetCode().Size(); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) + auto code_exit = code_entry + GetGraph()->GetCode().Size(); size_t code_items = (code_exit - code_entry) / vixl::aarch64::kInstructionSize; ASSERT_TRUE(code_items == expected_asm.size()); diff --git a/static_core/compiler/tests/aarch64/encoder64_test.cpp b/static_core/compiler/tests/aarch64/encoder64_test.cpp index d30befed49..db3268b07b 100644 --- a/static_core/compiler/tests/aarch64/encoder64_test.cpp +++ b/static_core/compiler/tests/aarch64/encoder64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -98,6 +98,8 @@ static T RandomGen() return panda::bit_cast(gen & MASK_DENORMAL_DOUBLE); } } + default: + break; } // Uniform distribution floating value @@ -313,7 +315,6 @@ public: if constexpr (std::is_same::value) { std::cerr << " reslt=" << bit_cast(result); std::cerr << " current_reslt=" << bit_cast(curr_result); - } else if constexpr (std::is_same::value) { std::cerr << " result=" << bit_cast(result); std::cerr << " current_result=" << bit_cast(curr_result); @@ -463,7 +464,6 @@ bool TestNeg(Encoder64Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, -tmp)) { @@ -473,7 +473,6 @@ bool TestNeg(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -513,9 +512,7 @@ bool TestNot(Encoder64Test *test) for (uint64_t i = 0; i < ITERATION; ++i) { // Second type-dependency T tmp = RandomGen(); - // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, ~tmp)) { // NOLINT(hicpp-signed-bitwise) @@ -558,7 +555,6 @@ bool TestMov(Encoder64Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, tmp)) { @@ -568,7 +564,6 @@ bool TestMov(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -605,7 +600,6 @@ bool TestMov2(Encoder64Test *test) Src src = RandomGen(); Dst dst = bit_cast(src); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(src, dst)) { @@ -616,7 +610,6 @@ bool TestMov2(Encoder64Test *test) if constexpr (std::is_floating_point_v) { Src nan = std::numeric_limits::quiet_NaN(); Dst dst_nan = bit_cast(nan); - if (!test->CallCode(nan, dst_nan)) { return false; } @@ -1123,10 +1116,62 @@ TEST_F(Encoder64Test, StrTest) // + mem(base + index< +bool TestStrzMainLoop(Encoder64Test *test) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Test : param - Pointer to value + // return - value (loaded by ptr) + // Value is resulting type, but call is ptr_type + if constexpr (std::is_floating_point_v) { + // Second type-dependency + T tmp = RandomGen(); + T ret_data[ARRAY_SIZE]; // NOLINT(modernize-avoid-c-arrays) + T *ptr = ret_data; + for (auto &el : ret_data) { + el = RandomGen(); + } + + auto result = test->CallCodeStore(reinterpret_cast(ptr), tmp); + // Store must change ret_data value + bool ret = (ret_data[0] == tmp && std::signbit(ret_data[0]) == std::signbit(tmp)) || + (std::isnan(ret_data[0]) && std::isnan(tmp)) || (std::isinf(ret_data[0]) && std::isinf(tmp)); + if (ret) { + continue; + } + + if constexpr (std::is_same::value) { + std::cerr << std::hex << "Strz test fail " << bit_cast(tmp) + << " ret_data = " << bit_cast(ret_data[0]) << "\n"; + } + if constexpr (std::is_same::value) { + std::cerr << std::hex << "Strz test fail " << bit_cast(tmp) + << " ret_data = " << bit_cast(ret_data[0]) << "\n"; + } + std::cerr << std::hex << "Strz test fail " << tmp << " ret_data = " << ret_data[0] << "\n"; + return false; + } else { + // Second type-dependency + T tmp = RandomGen(); + uint64_t ret_data = 0xffffffffffffffff; + T *ptr = reinterpret_cast(&ret_data); + + auto result = test->CallCodeStore(reinterpret_cast(ptr), tmp); + // Store must change ret_data value + if (ret_data != tmp) { + std::cerr << std::hex << "Strz test fail " << (uint64_t)tmp << " ret_data = " << (uint64_t)ret_data + << "\n"; + return false; + } + } + } + return true; +} + // Store immediate test // TEST_F(Encoder64Test, StiTest) { // EncodeSti(Imm src, MemRef mem) - template bool TestStrz(Encoder64Test *test) { @@ -1152,54 +1197,7 @@ bool TestStrz(Encoder64Test *test) } // Change this for enable print disasm test->Dump(false); - - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Test : param - Pointer to value - // return - value (loaded by ptr) - // Value is resulting type, but call is ptr_type - if constexpr (std::is_floating_point_v) { - // Second type-dependency - T tmp = RandomGen(); - T ret_data[ARRAY_SIZE]; // NOLINT(modernize-avoid-c-arrays) - T *ptr = ret_data; - for (auto &el : ret_data) { - el = RandomGen(); - } - - auto result = test->CallCodeStore(reinterpret_cast(ptr), tmp); - // Store must change ret_data value - bool ret = (ret_data[0] == tmp && std::signbit(ret_data[0]) == std::signbit(tmp)) || - (std::isnan(ret_data[0]) && std::isnan(tmp)) || (std::isinf(ret_data[0]) && std::isinf(tmp)); - - if (!ret) { - if constexpr (std::is_same::value) { - std::cerr << std::hex << "Strz test fail " << bit_cast(tmp) - << " ret_data = " << bit_cast(ret_data[0]) << "\n"; - } - if constexpr (std::is_same::value) { - std::cerr << std::hex << "Strz test fail " << bit_cast(tmp) - << " ret_data = " << bit_cast(ret_data[0]) << "\n"; - } - std::cerr << std::hex << "Strz test fail " << tmp << " ret_data = " << ret_data[0] << "\n"; - return false; - } - } else { - // Second type-dependency - T tmp = RandomGen(); - uint64_t ret_data = 0xffffffffffffffff; - T *ptr = reinterpret_cast(&ret_data); - - auto result = test->CallCodeStore(reinterpret_cast(ptr), tmp); - // Store must change ret_data value - if (ret_data != tmp) { - std::cerr << std::hex << "Strz test fail " << (uint64_t)tmp << " ret_data = " << (uint64_t)ret_data - << "\n"; - return false; - } - } - } - return true; + return TestStrzMainLoop(test); } // Store zero upper test @@ -1320,7 +1318,6 @@ bool TestAbs(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -1373,7 +1370,6 @@ bool TestSqrt(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -1418,7 +1414,6 @@ bool TestAdd(Encoder64Test *test) auto tmp1 = RandomGen(); auto tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 + tmp2)) { @@ -1428,7 +1423,6 @@ bool TestAdd(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1482,7 +1476,6 @@ bool TestAddImm(Encoder64Test *test) // Second type-dependency T tmp1 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp1 + param2)) { @@ -1530,7 +1523,6 @@ bool TestSub(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 - tmp2)) { @@ -1540,7 +1532,6 @@ bool TestSub(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1595,7 +1586,6 @@ bool TestSubImm(Encoder64Test *test) // Second type-dependency T tmp1 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp1 - param2)) { @@ -1642,7 +1632,6 @@ bool TestMul(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 * tmp2)) { @@ -1652,7 +1641,6 @@ bool TestMul(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1729,7 +1717,6 @@ bool TestMin(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1808,7 +1795,6 @@ bool TestMax(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -2047,7 +2033,6 @@ bool TestAnd(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 & tmp2)) { @@ -2093,7 +2078,6 @@ bool TestOr(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 | tmp2)) { @@ -2139,7 +2123,6 @@ bool TestXor(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 ^ tmp2)) { @@ -2373,7 +2356,6 @@ bool TestFcmp(Encoder64Test *test, bool is_fcmpg) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, 5.0, is_fcmpg ? 1 : -1)) { return false; } @@ -2597,11 +2579,7 @@ bool TestCast(Encoder64Test *test) auto float_max_int = static_cast(max_int); if (src > float_min_int) { - if (src < float_max_int) { - dst = static_cast(src); - } else { - dst = max_int; - } + dst = src < float_max_int ? static_cast(src) : max_int; } else if (std::isnan(src)) { dst = 0; } else { @@ -2833,7 +2811,6 @@ bool TestDiv(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -2864,6 +2841,55 @@ TEST_F(Encoder64Test, DivTest) EXPECT_TRUE(TestDiv(this)); } +template +bool TestModMainLoop(Encoder64Test *test) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + T tmp1 = RandomGen(); + T tmp2 = RandomGen(); + if (tmp2 == 0) { + tmp2 += 1; + } + // Main check - compare parameter and + // return value + if constexpr (std::is_same::value) { + if (!test->CallCode(tmp1, tmp2, fmodf(tmp1, tmp2))) { + return false; + } + } else if constexpr (std::is_same::value) { + if (!test->CallCode(tmp1, tmp2, fmod(tmp1, tmp2))) { + return false; + } + } else { + if (!test->CallCode(tmp1, tmp2, static_cast(tmp1 % tmp2))) { + return false; + } + } + } + + if constexpr (std::is_floating_point_v) { + T nan = std::numeric_limits::quiet_NaN(); + if (!test->CallCode(nan, RandomGen(), nan)) { + return false; + } + if (!test->CallCode(RandomGen(), nan, nan)) { + return false; + } + if (!test->CallCode(0.0, 0.0, nan)) { + return false; + } + if (!test->CallCode(std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { + return false; + } + if (!test->CallCode(-std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { + return false; + } + } + return true; +} + template bool TestMod(Encoder64Test *test) { @@ -2896,53 +2922,7 @@ bool TestMod(Encoder64Test *test) } // Change this for enable print disasm test->Dump(false); - - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - T tmp1 = RandomGen(); - T tmp2 = RandomGen(); - if (tmp2 == 0) { - tmp2 += 1; - } - // Main check - compare parameter and - // return value - if constexpr (std::is_same::value) { - if (!test->CallCode(tmp1, tmp2, fmodf(tmp1, tmp2))) { - return false; - } - } else if constexpr (std::is_same::value) { - if (!test->CallCode(tmp1, tmp2, fmod(tmp1, tmp2))) { - return false; - } - } else { - if (!test->CallCode(tmp1, tmp2, static_cast(tmp1 % tmp2))) { - return false; - } - } - } - - if constexpr (std::is_floating_point_v) { - T nan = std::numeric_limits::quiet_NaN(); - - if (!test->CallCode(nan, RandomGen(), nan)) { - return false; - } - if (!test->CallCode(RandomGen(), nan, nan)) { - return false; - } - if (!test->CallCode(0.0, 0.0, nan)) { - return false; - } - if (!test->CallCode(std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { - return false; - } - if (!test->CallCode(-std::numeric_limits::infinity(), std::numeric_limits::infinity(), nan)) { - return false; - } - } - - return true; + return TestModMainLoop(test); } TEST_F(Encoder64Test, ModTest) @@ -2963,13 +2943,55 @@ TEST_F(Encoder64Test, ModTest) // TEST_F(Encoder64Test, MemCopyzTest) { // EncodeMemCopyz(MemRef mem_from, MemRef mem_to, size_t size) +// int32_t uint64_t int32_t int64_t int32_t int32_t +// r0 r2+r3 stack0 stack2(align) stack4 +using FunctionPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); + +template +bool TestParamMainLoop(FunctionPtr func) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + auto param_0 = RandomGen(); + auto param_1 = RandomGen(); + auto param_2 = RandomGen(); + auto param_3 = RandomGen(); + auto param_4 = RandomGen(); + auto param_5 = RandomGen(); + + // Main check - compare parameter and + // return value + const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); + T result; + if constexpr (ID == 0) { + result = param_0; + } + if constexpr (ID == 1) { + result = param_1; + } + if constexpr (ID == 2) { + result = param_2; + } + if constexpr (ID == 3) { + result = param_3; + } + if constexpr (ID == 4) { + result = param_4; + } + if constexpr (ID == 5) { + result = param_5; + } + if (curr_result != result) { + return false; + }; + } + return true; +} + template bool TestParam(Encoder64Test *test) { - // int32_t uint64_t int32_t int64_t int32_t int32_t - // r0 r2+r3 stack0 stack2(align) stack4 - using FunctPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); - bool is_signed = std::is_signed::value; // NOLINTNEXTLINE(modernize-avoid-c-arrays) @@ -3013,45 +3035,9 @@ bool TestParam(Encoder64Test *test) auto size = test->GetCallconv()->GetCodeSize() - test->GetCursor(); void *offset = (static_cast(test->GetCallconv()->GetCodeEntry())); void *ptr = test->GetCodeAllocator()->AllocateCode(size, offset); - auto func = reinterpret_cast(ptr); + auto func = reinterpret_cast(ptr); - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - auto param_0 = RandomGen(); - auto param_1 = RandomGen(); - auto param_2 = RandomGen(); - auto param_3 = RandomGen(); - auto param_4 = RandomGen(); - auto param_5 = RandomGen(); - - // Main check - compare parameter and - // return value - const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); - T result; - if constexpr (ID == 0) { - result = param_0; - } - if constexpr (ID == 1) { - result = param_1; - } - if constexpr (ID == 2) { - result = param_2; - } - if constexpr (ID == 3) { - result = param_3; - } - if constexpr (ID == 4) { - result = param_4; - } - if constexpr (ID == 5) { - result = param_5; - } - if (curr_result != result) { - return false; - }; - } - return true; + return TestParamMainLoop(func); } TEST_F(Encoder64Test, ReadParams) diff --git a/static_core/compiler/tests/aarch64/register64_test.cpp b/static_core/compiler/tests/aarch64/register64_test.cpp index b1d85dce96..a95a08ccf7 100644 --- a/static_core/compiler/tests/aarch64/register64_test.cpp +++ b/static_core/compiler/tests/aarch64/register64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/adjust_arefs_test.cpp b/static_core/compiler/tests/adjust_arefs_test.cpp index 1626ca5bf6..0cfd6bbe94 100644 --- a/static_core/compiler/tests/adjust_arefs_test.cpp +++ b/static_core/compiler/tests/adjust_arefs_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/alias_analysis_test.cpp b/static_core/compiler/tests/alias_analysis_test.cpp index c64e3abaf1..94a41c8d24 100644 --- a/static_core/compiler/tests/alias_analysis_test.cpp +++ b/static_core/compiler/tests/alias_analysis_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/amd64/asmjit_test.cpp b/static_core/compiler/tests/amd64/asmjit_test.cpp index 85adf9bb33..32c731fe72 100644 --- a/static_core/compiler/tests/amd64/asmjit_test.cpp +++ b/static_core/compiler/tests/amd64/asmjit_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/amd64/callconv64_test.cpp b/static_core/compiler/tests/amd64/callconv64_test.cpp index a1c92c26f8..c929a71974 100644 --- a/static_core/compiler/tests/amd64/callconv64_test.cpp +++ b/static_core/compiler/tests/amd64/callconv64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/amd64/encoder64_test.cpp b/static_core/compiler/tests/amd64/encoder64_test.cpp index e94677916a..d7f216e102 100644 --- a/static_core/compiler/tests/amd64/encoder64_test.cpp +++ b/static_core/compiler/tests/amd64/encoder64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -97,6 +97,8 @@ static T RandomGen() return panda::bit_cast(gen & MASK_DENORMAL_DOUBLE); } } + default: + break; } // Uniform distribution floating value @@ -310,7 +312,6 @@ public: if constexpr (std::is_same::value) { std::cerr << " reslt=" << bit_cast(result); std::cerr << " current_reslt=" << bit_cast(curr_result); - } else if constexpr (std::is_same::value) { std::cerr << " result=" << bit_cast(result); std::cerr << " current_result=" << bit_cast(curr_result); @@ -460,7 +461,6 @@ bool TestNeg(Encoder64Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, -tmp)) { @@ -470,7 +470,6 @@ bool TestNeg(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -511,9 +510,7 @@ bool TestNot(Encoder64Test *test) for (uint64_t i = 0; i < ITERATION; ++i) { // Second type-dependency T tmp = RandomGen(); - // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, ~tmp)) { // NOLINT(hicpp-signed-bitwise) @@ -556,7 +553,6 @@ bool TestMov(Encoder64Test *test) // Second type-dependency T tmp = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp, tmp)) { @@ -566,7 +562,6 @@ bool TestMov(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -603,7 +598,6 @@ bool TestMov2(Encoder64Test *test) Src src = RandomGen(); Dst dst = bit_cast(src); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(src, dst)) { @@ -614,7 +608,6 @@ bool TestMov2(Encoder64Test *test) if constexpr (std::is_floating_point_v) { Src nan = std::numeric_limits::quiet_NaN(); Dst dst_nan = bit_cast(nan); - if (!test->CallCode(nan, dst_nan)) { return false; } @@ -641,8 +634,7 @@ TEST_F(Encoder64Test, MovTest) // Jump w/o cc TEST_F(Encoder64Test, JumpTest) { - // Test for - // EncodeJump(LabelHolder::LabelId label) + // Test for EncodeJump(LabelHolder::LabelId label) PreWork(); auto param = Target::Current().GetParamReg(0); @@ -686,7 +678,7 @@ TEST_F(Encoder64Test, JumpTest) // Fail value GetEncoder()->EncodeMov(param, Imm(0x0)); GetEncoder()->EncodeReturn(); - // Sucess exit + // Success exit GetEncoder()->BindLabel(t5); PostWork(); @@ -890,6 +882,36 @@ bool TestSubOverflow(Encoder64Test *test) return true; } +template +bool TestJumpCCMainLoop(Encoder64Test *test) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + T tmp = RandomGen(); + if (tmp == 0) { // Only non-zero values + tmp += 1; + } + // Deduced conflicting types for parameter + + if constexpr (CC == Condition::EQ) { + if (!test->CallCode(tmp, 1)) { + std::cerr << "non-zero EQ test fail " << tmp << " \n"; + return false; + } + } + if constexpr (CC == Condition::NE) { + if (!test->CallCode(tmp, 0)) { + std::cerr << "non-zero EQ test fail " << tmp << " \n"; + return false; + } + } + // Main check - compare parameter and + // return value + } + return true; +} + template bool TestJumpCC(Encoder64Test *test) { @@ -938,32 +960,7 @@ bool TestJumpCC(Encoder64Test *test) return false; } } - - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - T tmp = RandomGen(); - if (tmp == 0) { // Only non-zero values - tmp += 1; - } - // Deduced conflicting types for parameter - - if constexpr (CC == Condition::EQ) { - if (!test->CallCode(tmp, 1)) { - std::cerr << "non-zero EQ test fail " << tmp << " \n"; - return false; - } - } - if constexpr (CC == Condition::NE) { - if (!test->CallCode(tmp, 0)) { - std::cerr << "non-zero EQ test fail " << tmp << " \n"; - return false; - } - } - // Main check - compare parameter and - // return value - } - return true; + return TestJumpCCMainLoop(test); } // Jump with cc @@ -1008,8 +1005,6 @@ TEST_F(Encoder64Test, SubOverflow) EXPECT_TRUE((TestSubOverflow(this))); } -// EncodeJump(LabelHolder::LabelId id, Reg src1, Reg src2, Condition cc); - template bool TestLdr(Encoder64Test *test) { @@ -1233,7 +1228,6 @@ bool TestAbs(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, nan)) { return false; } @@ -1297,7 +1291,6 @@ bool TestAdd(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1424,7 +1417,6 @@ bool TestSub(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1551,7 +1543,6 @@ bool TestMul(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1624,7 +1615,6 @@ bool TestMin(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1699,7 +1689,6 @@ bool TestMax(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -1942,7 +1931,6 @@ bool TestAnd(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 & tmp2)) { // NOLINT(hicpp-signed-bitwise) @@ -1988,7 +1976,6 @@ bool TestOr(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 | tmp2)) { // NOLINT(hicpp-signed-bitwise) @@ -2034,7 +2021,6 @@ bool TestXor(Encoder64Test *test) T tmp1 = RandomGen(); T tmp2 = RandomGen(); // Deduced conflicting types for parameter - // Main check - compare parameter and // return value if (!test->CallCode(tmp1, tmp2, tmp1 ^ tmp2)) { // NOLINT(hicpp-signed-bitwise) @@ -2269,7 +2255,6 @@ bool TestFcmp(Encoder64Test *test, bool is_fcmpg) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, 5.0, is_fcmpg ? 1 : -1)) { return false; } @@ -2495,11 +2480,7 @@ bool TestCast(Encoder64Test *test) auto float_max_int = static_cast(max_int); if (src > float_min_int) { - if (src < float_max_int) { - dst = static_cast(src); - } else { - dst = max_int; - } + dst = src < float_max_int ? static_cast(src) : max_int; } else if (std::isnan(src)) { dst = 0; } else { @@ -2692,7 +2673,6 @@ bool TestDiv(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -2775,7 +2755,6 @@ bool TestMod(Encoder64Test *test) if constexpr (std::is_floating_point_v) { T nan = std::numeric_limits::quiet_NaN(); - if (!test->CallCode(nan, RandomGen(), nan)) { return false; } @@ -2814,13 +2793,56 @@ TEST_F(Encoder64Test, ModTest) // TEST_F(Encoder64Test, MemCopyzTest) { // EncodeMemCopyz(MemRef mem_from, MemRef mem_to, size_t size) +// int32_t uint64_t int32_t int64_t int32_t int32_t +// r0 r2+r3 stack0 stack2(align) stack4 +using FunctionPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); + +template +bool TestParamMainLoop(FunctionPtr func) +{ + // Main test loop: + for (uint64_t i = 0; i < ITERATION; ++i) { + // Second type-dependency + auto param_0 = RandomGen(); + auto param_1 = RandomGen(); + auto param_2 = RandomGen(); + auto param_3 = RandomGen(); + auto param_4 = RandomGen(); + auto param_5 = RandomGen(); + + // Main check - compare parameter and + // return value + const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); + T result; + if constexpr (ID == 0) { + result = param_0; + } + if constexpr (ID == 1) { + result = param_1; + } + if constexpr (ID == 2) { + result = param_2; + } + if constexpr (ID == 3) { + result = param_3; + } + if constexpr (ID == 4) { + result = param_4; + } + if constexpr (ID == 5) { + result = param_5; + } + + if (curr_result != result) { + return false; + }; + } + return true; +} + template bool TestParam(Encoder64Test *test) { - // int32_t uint64_t int32_t int64_t int32_t int32_t - // r0 r2+r3 stack0 stack2(align) stack4 - using FunctPtr = uint64_t (*)(uint32_t, uint64_t, int32_t, int64_t, int32_t, int32_t); - bool is_signed = std::is_signed::value; constexpr std::array PARAMS {INT32_TYPE, INT64_TYPE, INT32_TYPE, INT64_TYPE, INT32_TYPE, INT32_TYPE}; @@ -2860,46 +2882,9 @@ bool TestParam(Encoder64Test *test) auto size = test->GetCallconv()->GetCodeSize() - test->GetCursor(); void *offset = (static_cast(test->GetCallconv()->GetCodeEntry())); void *ptr = test->GetCodeAllocator()->AllocateCode(size, offset); - auto func = reinterpret_cast(ptr); + auto func = reinterpret_cast(ptr); - // Main test loop: - for (uint64_t i = 0; i < ITERATION; ++i) { - // Second type-dependency - auto param_0 = RandomGen(); - auto param_1 = RandomGen(); - auto param_2 = RandomGen(); - auto param_3 = RandomGen(); - auto param_4 = RandomGen(); - auto param_5 = RandomGen(); - - // Main check - compare parameter and - // return value - const T curr_result = func(param_0, param_1, param_2, param_3, param_4, param_5); - T result; - if constexpr (ID == 0) { - result = param_0; - } - if constexpr (ID == 1) { - result = param_1; - } - if constexpr (ID == 2) { - result = param_2; - } - if constexpr (ID == 3) { - result = param_3; - } - if constexpr (ID == 4) { - result = param_4; - } - if constexpr (ID == 5) { - result = param_5; - } - - if (curr_result != result) { - return false; - }; - } - return true; + return TestParamMainLoop(func); } TEST_F(Encoder64Test, ReadParams) diff --git a/static_core/compiler/tests/amd64/register64_test.cpp b/static_core/compiler/tests/amd64/register64_test.cpp index 4b008c4be1..dd5d27d913 100644 --- a/static_core/compiler/tests/amd64/register64_test.cpp +++ b/static_core/compiler/tests/amd64/register64_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/analysis_test.cpp b/static_core/compiler/tests/analysis_test.cpp index f190a3672f..4e5ac203df 100644 --- a/static_core/compiler/tests/analysis_test.cpp +++ b/static_core/compiler/tests/analysis_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/aot_test.cpp b/static_core/compiler/tests/aot_test.cpp index 92772bc66b..ab33d4d02b 100644 --- a/static_core/compiler/tests/aot_test.cpp +++ b/static_core/compiler/tests/aot_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -144,7 +144,7 @@ TEST_F(AotTest, PaocLocation) static const std::string PANDA_FILE_PATH = LOCATION + "/" + panda_fname.GetFileName(); auto source = R"( - .function u32 add(u64 a0, u64 a1){ + .function u32 add(u64 a0, u64 a1) { add a0, a1 return } diff --git a/static_core/compiler/tests/asm_caller.cpp b/static_core/compiler/tests/asm_caller.cpp index 25f554eec1..818b7f8536 100644 --- a/static_core/compiler/tests/asm_caller.cpp +++ b/static_core/compiler/tests/asm_caller.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -25,7 +25,9 @@ class AsmCaller : public ::testing::Test {}; // Debug print to stdout -// #define STDOUT_PRINT +#ifdef ENABLE_DEBUG_STDOUT_PRINT +#define STDOUT_PRINT +#endif // ENABLE_DEBUG_STDOUT_PRINT // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define EMITED_ONE_PARAM_INST_LIST(DEF) \ diff --git a/static_core/compiler/tests/asm_printer_test.cpp b/static_core/compiler/tests/asm_printer_test.cpp index f3c3b91772..9b5edaabb9 100644 --- a/static_core/compiler/tests/asm_printer_test.cpp +++ b/static_core/compiler/tests/asm_printer_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -30,7 +30,9 @@ static std::string OUTPUT_DIR = "asm_output"; // Debug print to stdout -// #define STDOUT_PRINT +#if ENABLE_DEBUG_STDOUT_PRINT +#define STDOUT_PRINT +#endif // ENABLE_DEBUG_STDOUT_PRINT namespace panda::compiler { diff --git a/static_core/compiler/tests/balance_expressions_test.cpp b/static_core/compiler/tests/balance_expressions_test.cpp index 08420f396e..2ce601da83 100644 --- a/static_core/compiler/tests/balance_expressions_test.cpp +++ b/static_core/compiler/tests/balance_expressions_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/basicblock_test.cpp b/static_core/compiler/tests/basicblock_test.cpp index a7ae242402..8bd300bc5c 100644 --- a/static_core/compiler/tests/basicblock_test.cpp +++ b/static_core/compiler/tests/basicblock_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/bounds_analysis_test.cpp b/static_core/compiler/tests/bounds_analysis_test.cpp index 017a065aa6..3ac72c1ce4 100644 --- a/static_core/compiler/tests/bounds_analysis_test.cpp +++ b/static_core/compiler/tests/bounds_analysis_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -411,7 +411,7 @@ TEST_F(BoundsAnalysisTest, NullCompare) TEST_F(BoundsAnalysisTest, InitMoreThenTest) { - // for (int i = 10, i < 0, i++) {} + // For (int i = 10, i < 0, i++) {} // this loop is counable, but init > test value. GRAPH(GetGraph()) { @@ -476,7 +476,7 @@ TEST_F(BoundsAnalysisTest, ModTest) TEST_F(BoundsAnalysisTest, LoopWithBigStep) { - // for (int i = 0, i < 5, i += 10) {} + // For (int i = 0, i < 5, i += 10) {} // this loop is countable, and init + step > test value. GRAPH(GetGraph()) { @@ -509,7 +509,7 @@ TEST_F(BoundsAnalysisTest, LoopWithBigStep) TEST_F(BoundsAnalysisTest, LoopWithBigStep2) { - // for (int i = 1, i < 6, i += 2) {} + // For (int i = 1, i < 6, i += 2) {} GRAPH(GetGraph()) { CONSTANT(0U, 0U); diff --git a/static_core/compiler/tests/branch_elimination_test.cpp b/static_core/compiler/tests/branch_elimination_test.cpp index 36c8e672ed..e8d79d98cf 100644 --- a/static_core/compiler/tests/branch_elimination_test.cpp +++ b/static_core/compiler/tests/branch_elimination_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/call_input_types_test.cpp b/static_core/compiler/tests/call_input_types_test.cpp index 19582edf6f..63b5ccc94e 100644 --- a/static_core/compiler/tests/call_input_types_test.cpp +++ b/static_core/compiler/tests/call_input_types_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/catch_inputs_test.cpp b/static_core/compiler/tests/catch_inputs_test.cpp index 49a4897128..b2f96092df 100644 --- a/static_core/compiler/tests/catch_inputs_test.cpp +++ b/static_core/compiler/tests/catch_inputs_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/checks_elimination_test.cpp b/static_core/compiler/tests/checks_elimination_test.cpp index 9dc6f3a649..42d22aecbf 100644 --- a/static_core/compiler/tests/checks_elimination_test.cpp +++ b/static_core/compiler/tests/checks_elimination_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1710,7 +1710,7 @@ TEST_F(ChecksEliminationTest, PhiTest) TEST_F(ChecksEliminationTest, SimpleLoopTestInc) { // new_array(len_array) - // for(int i = 0, i < len_array, i++) begin + // For(int i = 0, i < len_array, i++) begin // boundscheck(len_array, i) - can remove // a[i] = 0 // end @@ -1781,7 +1781,7 @@ TEST_F(ChecksEliminationTest, SimpleLoopTestInc) TEST_F(ChecksEliminationTest, SimpleLoopTestIncAfterPeeling) { // new_array(len_array) - // for(int i = 0, i < len_array, i++) begin + // For(int i = 0, i < len_array, i++) begin // boundscheck(len_array, i) - can remove // a[i] = 0 // end @@ -1850,7 +1850,7 @@ TEST_F(ChecksEliminationTest, SimpleLoopTestIncAfterPeeling) TEST_F(ChecksEliminationTest, SimpleLoopTestIncAfterPeeling1) { // new_array(len_array) - // for(int i = 0, i < len_array, i++) begin + // For(int i = 0, i < len_array, i++) begin // boundscheck(len_array, i) - can remove // a[i] = 0 // end @@ -1915,7 +1915,7 @@ TEST_F(ChecksEliminationTest, SimpleLoopTestIncAfterPeeling1) TEST_F(ChecksEliminationTest, SimpleLoopTestDec) { // new_array(len_array) - // for(int i = len_array-1, i >= 0, i--) begin + // For(int i = len_array-1, i >= 0, i--) begin // boundscheck(len_array, i) - can remove // a[i] = 0 // end diff --git a/static_core/compiler/tests/class_hash_table_test.cpp b/static_core/compiler/tests/class_hash_table_test.cpp index afc4be3ef6..013ff76d29 100644 --- a/static_core/compiler/tests/class_hash_table_test.cpp +++ b/static_core/compiler/tests/class_hash_table_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -139,7 +139,7 @@ TEST_F(ClassHashTableTest, GetClassHashTable) ldai 1 return } - )"; + )"; pandasm::Parser parser; auto res = parser.Parse(source); @@ -158,7 +158,7 @@ TEST_F(ClassHashTableTest, GetClassHashTable) call.short Animal.fun return } - )"; + )"; pandasm::Parser parser; auto res = parser.Parse(source); diff --git a/static_core/compiler/tests/cleanup_empty_blocks_test.cpp b/static_core/compiler/tests/cleanup_empty_blocks_test.cpp index bc4c90b02b..c65a7adc22 100644 --- a/static_core/compiler/tests/cleanup_empty_blocks_test.cpp +++ b/static_core/compiler/tests/cleanup_empty_blocks_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/cleanup_test.cpp b/static_core/compiler/tests/cleanup_test.cpp index 066b1af7f5..c3e45a63b0 100644 --- a/static_core/compiler/tests/cleanup_test.cpp +++ b/static_core/compiler/tests/cleanup_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/code_info_test.cpp b/static_core/compiler/tests/code_info_test.cpp index 0c1702ea73..f890bbd7c3 100644 --- a/static_core/compiler/tests/code_info_test.cpp +++ b/static_core/compiler/tests/code_info_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/code_sink_test.cpp b/static_core/compiler/tests/code_sink_test.cpp index 1ff29660de..df4544cfe7 100644 --- a/static_core/compiler/tests/code_sink_test.cpp +++ b/static_core/compiler/tests/code_sink_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/codegen_runner_test.cpp b/static_core/compiler/tests/codegen_runner_test.cpp index d86f37651f..460dcb5550 100644 --- a/static_core/compiler/tests/codegen_runner_test.cpp +++ b/static_core/compiler/tests/codegen_runner_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -110,8 +110,6 @@ static constexpr auto CODEGEN_OBJECT_PARAMS_SOURCE = R"( # Result 0xAAA000000000000 # Result 0xAAA00000AAA0AAA - - .function i64 foo(Value a0, Value a1, Value a2, Value a3, Value a4, Value a5) { ldai.64 0 sta.64 v17 @@ -319,8 +317,6 @@ success_label: return.64 } - - )"; constexpr uint64_t CORRUPT_SIZE = 0xFFF; diff --git a/static_core/compiler/tests/codegen_test.cpp b/static_core/compiler/tests/codegen_test.cpp index 4ebd30dea2..e611a1d3fa 100644 --- a/static_core/compiler/tests/codegen_test.cpp +++ b/static_core/compiler/tests/codegen_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -2014,7 +2014,7 @@ TEST_F(CodegenTest, ResolveParamSequence) auto dst = result[j].first; for (uint8_t k = j + 1U; k < reg_size; ++k) { if (result[k].second == dst && result[k].second != tmp_reg) { - std::cerr << " first = " << result[k].first << " tmp = " << reg_size + 5U << "\n"; + std::cerr << " first = " << result[k].first << " tmp = " << (reg_size + 5U) << "\n"; std::cerr << " Before:\n"; for (auto &it : orig_vector) { std::cerr << " " << (size_t)it.first << "<-" << (size_t)it.second << "\n"; diff --git a/static_core/compiler/tests/const_folding_test.cpp b/static_core/compiler/tests/const_folding_test.cpp index 50391671eb..6dd47e8efe 100644 --- a/static_core/compiler/tests/const_folding_test.cpp +++ b/static_core/compiler/tests/const_folding_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -84,7 +84,6 @@ public: inst = graph->FindConstant(DataType::INT64, dst); } else if (dst_type == DataType::FLOAT32) { inst = graph->FindConstant(DataType::FLOAT32, bit_cast(dst)); - } else if (dst_type == DataType::FLOAT64) { inst = graph->FindConstant(DataType::FLOAT64, bit_cast(dst)); } @@ -202,7 +201,7 @@ TEST_F(ConstFoldingTest, NegFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)12U); + CONSTANT(0, static_cast(12U)); BASIC_BLOCK(2U, 1U) { INST(1U, Opcode::Neg).f32().Inputs(0U); @@ -279,7 +278,7 @@ TEST_F(ConstFoldingTest, AbsFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)-12.0); + CONSTANT(0U, static_cast(-12.0)); BASIC_BLOCK(2U, 1U) { INST(1U, Opcode::Abs).f32().Inputs(0U); @@ -397,8 +396,8 @@ TEST_F(ConstFoldingTest, AddInt8Test) { GRAPH(GetGraph()) { - CONSTANT(0U, (uint8_t)0xffffffffU); - CONSTANT(1U, (uint8_t)1U); + CONSTANT(0U, static_cast(0xffffffffU)); + CONSTANT(1U, static_cast(1U)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Add).u8().Inputs(0U, 1U); @@ -438,8 +437,8 @@ TEST_F(ConstFoldingTest, AddFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)-2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(-2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Add).f32().Inputs(0U, 1U); @@ -560,8 +559,8 @@ TEST_F(ConstFoldingTest, SubFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Sub).f32().Inputs(0U, 1U); @@ -695,8 +694,8 @@ TEST_F(ConstFoldingTest, MulFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Mul).f32().Inputs(0U, 1U); @@ -899,8 +898,8 @@ TEST_F(ConstFoldingTest, DivFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Div).f32().Inputs(0U, 1U); @@ -959,8 +958,8 @@ TEST_F(ConstFoldingTest, MinFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Min).f32().Inputs(0U, 1U); @@ -1113,8 +1112,8 @@ TEST_F(ConstFoldingTest, MaxFloatTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)2.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(2.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Max).f32().Inputs(0U, 1U); @@ -2648,8 +2647,8 @@ TEST_F(ConstFoldingTest, MulFloatZeroTest) { GRAPH(GetGraph()) { - CONSTANT(0U, (float)3.0); - CONSTANT(1U, (float)0.0); + CONSTANT(0U, static_cast(3.0)); + CONSTANT(1U, static_cast(0.0)); BASIC_BLOCK(2U, 1U) { INST(2U, Opcode::Mul).f32().Inputs(0U, 1U); diff --git a/static_core/compiler/tests/constructor_test.cpp b/static_core/compiler/tests/constructor_test.cpp index e52fd8bd84..62f4b52317 100644 --- a/static_core/compiler/tests/constructor_test.cpp +++ b/static_core/compiler/tests/constructor_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/cse_test.cpp b/static_core/compiler/tests/cse_test.cpp index 78ced88190..a58c1c57c4 100644 --- a/static_core/compiler/tests/cse_test.cpp +++ b/static_core/compiler/tests/cse_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/deoptimize_elimination_test.cpp b/static_core/compiler/tests/deoptimize_elimination_test.cpp index 489e6069b9..d0e7df4763 100644 --- a/static_core/compiler/tests/deoptimize_elimination_test.cpp +++ b/static_core/compiler/tests/deoptimize_elimination_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/dom_tree_test.cpp b/static_core/compiler/tests/dom_tree_test.cpp index 334d384a73..8a092c7c41 100644 --- a/static_core/compiler/tests/dom_tree_test.cpp +++ b/static_core/compiler/tests/dom_tree_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -84,7 +84,6 @@ TEST_F(DomTreeTest, OneBlock) * \----->[exit]<-------------/ * * Dominators tree: - * * [entry] * | * v diff --git a/static_core/compiler/tests/encoder_operands.cpp b/static_core/compiler/tests/encoder_operands.cpp index 7be8844943..2e04c678b9 100644 --- a/static_core/compiler/tests/encoder_operands.cpp +++ b/static_core/compiler/tests/encoder_operands.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/encoders_test.cpp b/static_core/compiler/tests/encoders_test.cpp index 0515117004..86e1a28c9e 100644 --- a/static_core/compiler/tests/encoders_test.cpp +++ b/static_core/compiler/tests/encoders_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/escape_analysis_test.cpp b/static_core/compiler/tests/escape_analysis_test.cpp index 54e3587ed6..de8ca457c2 100644 --- a/static_core/compiler/tests/escape_analysis_test.cpp +++ b/static_core/compiler/tests/escape_analysis_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/graph_cloner_test.cpp b/static_core/compiler/tests/graph_cloner_test.cpp index 2524c2638d..cabd832c8b 100644 --- a/static_core/compiler/tests/graph_cloner_test.cpp +++ b/static_core/compiler/tests/graph_cloner_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/graph_comparator.h b/static_core/compiler/tests/graph_comparator.h index 8439c4c2a3..120bc5022d 100644 --- a/static_core/compiler/tests/graph_comparator.h +++ b/static_core/compiler/tests/graph_comparator.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -70,17 +70,8 @@ public: block2->AllInsts().end(), inst_cmp); } - // NOLINTNEXTLINE(readability-function-size) - bool Compare(Inst *inst1, Inst *inst2) + bool InstInitialCompare(Inst *inst1, Inst *inst2) { - if (auto it = inst_compare_map_.insert({inst1, inst2}); !it.second) { - if (inst2 == it.first->second) { - return true; - } - inst_compare_map_.erase(inst1); - return false; - } - if (inst1->GetOpcode() != inst2->GetOpcode() || inst1->GetType() != inst2->GetType() || inst1->GetInputsCount() != inst2->GetInputsCount()) { inst_compare_map_.erase(inst1); @@ -119,6 +110,8 @@ public: } } } + return true; + } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage #define CAST(Opc) CastTo##Opc() @@ -128,6 +121,9 @@ public: inst_compare_map_.erase(inst1); \ return false; \ } + + bool InstPropertiesCompare(Inst *inst1, Inst *inst2) + { CHECK(Cast, GetOperandsType) CHECK(Cmp, GetOperandsType) @@ -164,6 +160,11 @@ public: CHECK(OrI, GetImm) CHECK(XorI, GetImm) + return true; + } + + bool InstAdditionalPropertiesCompare(Inst *inst1, Inst *inst2) + { CHECK(LoadArray, GetNeedBarrier) CHECK(LoadArrayPair, GetNeedBarrier) CHECK(StoreArray, GetNeedBarrier) @@ -224,8 +225,70 @@ public: // CHECK(IsInstance, GetTypeId) // CHECK(LoadString, GetTypeId) // CHECK(LoadType, GetTypeId) + + return true; + } #undef CHECK #undef CAST + + bool InstSaveStateCompare(Inst *inst1, Inst *inst2) + { + auto *sv_st1 = static_cast(inst1); + auto *sv_st2 = static_cast(inst2); + if (sv_st1->GetImmediatesCount() != sv_st2->GetImmediatesCount()) { + inst_compare_map_.erase(inst1); + return false; + } + + std::vector regs1; + std::vector regs2; + regs1.reserve(sv_st1->GetInputsCount()); + regs2.reserve(sv_st2->GetInputsCount()); + for (size_t i {0}; i < sv_st1->GetInputsCount(); ++i) { + regs1.emplace_back(sv_st1->GetVirtualRegister(i).Value()); + regs2.emplace_back(sv_st2->GetVirtualRegister(i).Value()); + } + std::sort(regs1.begin(), regs1.end()); + std::sort(regs2.begin(), regs2.end()); + if (regs1 != regs2) { + inst_compare_map_.erase(inst1); + return false; + } + if (sv_st1->GetImmediatesCount() != 0) { + auto eq_lambda = [](SaveStateImm i1, SaveStateImm i2) { + return i1.value == i2.value && i1.vreg == i2.vreg && i1.vreg_type == i2.vreg_type && i1.type == i2.type; + }; + if (!std::equal(sv_st1->GetImmediates()->begin(), sv_st1->GetImmediates()->end(), + sv_st2->GetImmediates()->begin(), eq_lambda)) { + inst_compare_map_.erase(inst1); + return false; + } + } + return true; + } + + bool Compare(Inst *inst1, Inst *inst2) + { + if (auto it = inst_compare_map_.insert({inst1, inst2}); !it.second) { + if (inst2 == it.first->second) { + return true; + } + inst_compare_map_.erase(inst1); + return false; + } + + if (!InstInitialCompare(inst1, inst2)) { + return false; + } + + if (!InstPropertiesCompare(inst1, inst2)) { + return false; + } + + if (!InstAdditionalPropertiesCompare(inst1, inst2)) { + return false; + } + if (inst1->GetOpcode() == Opcode::Constant) { auto c1 = inst1->CastToConstant(); auto c2 = inst2->CastToConstant(); @@ -259,38 +322,7 @@ public: } } if (inst1->IsSaveState()) { - auto *sv_st1 = static_cast(inst1); - auto *sv_st2 = static_cast(inst2); - if (sv_st1->GetImmediatesCount() != sv_st2->GetImmediatesCount()) { - inst_compare_map_.erase(inst1); - return false; - } - - std::vector regs1; - std::vector regs2; - regs1.reserve(sv_st1->GetInputsCount()); - regs2.reserve(sv_st2->GetInputsCount()); - for (size_t i {0}; i < sv_st1->GetInputsCount(); ++i) { - regs1.emplace_back(sv_st1->GetVirtualRegister(i).Value()); - regs2.emplace_back(sv_st2->GetVirtualRegister(i).Value()); - } - std::sort(regs1.begin(), regs1.end()); - std::sort(regs2.begin(), regs2.end()); - if (regs1 != regs2) { - inst_compare_map_.erase(inst1); - return false; - } - if (sv_st1->GetImmediatesCount() != 0) { - auto eq_lambda = [](SaveStateImm i1, SaveStateImm i2) { - return i1.value == i2.value && i1.vreg == i2.vreg && i1.vreg_type == i2.vreg_type && - i1.type == i2.type; - }; - if (!std::equal(sv_st1->GetImmediates()->begin(), sv_st1->GetImmediates()->end(), - sv_st2->GetImmediates()->begin(), eq_lambda)) { - inst_compare_map_.erase(inst1); - return false; - } - } + return InstSaveStateCompare(inst1, inst2); } return true; } diff --git a/static_core/compiler/tests/graph_comparator_test.cpp b/static_core/compiler/tests/graph_comparator_test.cpp index 5ea62944fe..c4a0a08cae 100644 --- a/static_core/compiler/tests/graph_comparator_test.cpp +++ b/static_core/compiler/tests/graph_comparator_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/graph_creation_test.cpp b/static_core/compiler/tests/graph_creation_test.cpp index f962fca11e..c8c37ab82f 100644 --- a/static_core/compiler/tests/graph_creation_test.cpp +++ b/static_core/compiler/tests/graph_creation_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/if_conversion_test.cpp b/static_core/compiler/tests/if_conversion_test.cpp index e0c1d03f03..ca5c77fd3b 100644 --- a/static_core/compiler/tests/if_conversion_test.cpp +++ b/static_core/compiler/tests/if_conversion_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/if_merging_test.cpp b/static_core/compiler/tests/if_merging_test.cpp index f112ab3d69..abea34768b 100644 --- a/static_core/compiler/tests/if_merging_test.cpp +++ b/static_core/compiler/tests/if_merging_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -1159,7 +1159,6 @@ TEST_F(IfMergingTest, ConstantPhiLoopBackEdge) * \----[3] [exit] * * Transform to: - * * [0] -> [3] -> [exit] * */ @@ -1214,7 +1213,6 @@ TEST_F(IfMergingTest, ConstantPhiUnrollLoop) * \----[3] [exit] * * Transform to: - * * [0] * | * v @@ -1276,7 +1274,6 @@ TEST_F(IfMergingTest, ConstantPhiRemoveLoopExit) * \----[3] [exit] * * Transform to: - * * [0] -> [2] -> [exit] * */ @@ -1329,7 +1326,6 @@ TEST_F(IfMergingTest, ConstantPhiRemoveLoop) * \-----/ [exit] * * Transform to: - * * [0] -> [2] -> [exit] * */ @@ -1380,7 +1376,6 @@ TEST_F(IfMergingTest, ConstantPhiRemoveEmptyLoop) * \-----/ [exit] * * Could be transformed to: - * * [0] -> [2] -> [2] -> [exit] * * but basic block 2 would be duplicated. Not applied diff --git a/static_core/compiler/tests/inlining_test.cpp b/static_core/compiler/tests/inlining_test.cpp index 14fe08141b..7aee2e01ae 100644 --- a/static_core/compiler/tests/inlining_test.cpp +++ b/static_core/compiler/tests/inlining_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -71,7 +71,7 @@ auto PopulateInstructionMap(Graph *graph) TEST_F(InliningTest, Simple) { auto source = R"( -.function u1 main(u32 a0, u32 a1){ +.function u1 main(u32 a0, u32 a1) { movi v0, 1 movi v1, 2 or a0, v1 @@ -82,7 +82,7 @@ TEST_F(InliningTest, Simple) return } -.function u32 inline(u32 a0, u32 a1){ +.function u32 inline(u32 a0, u32 a1) { movi v2, 2023 movi v3, 2 add a0, v2 @@ -100,7 +100,7 @@ TEST_F(InliningTest, Simple) TEST_F(InliningTest, TwoMethods) { auto source = R"( -.function u1 main(u32 a0, u32 a1){ +.function u1 main(u32 a0, u32 a1) { movi v0, 1 movi v1, 2 or a0, v1 @@ -113,7 +113,7 @@ TEST_F(InliningTest, TwoMethods) return } -.function u32 inline1(u32 a0, u32 a1){ +.function u32 inline1(u32 a0, u32 a1) { movi v2, 2023 movi v3, 2 add a0, v2 @@ -123,7 +123,7 @@ TEST_F(InliningTest, TwoMethods) return } -.function u32 inline2(u32 a0, u32 a1){ +.function u32 inline2(u32 a0, u32 a1) { movi v2, 2023 movi v3, 2 add a0, v2 @@ -141,12 +141,12 @@ TEST_F(InliningTest, TwoMethods) TEST_F(InliningTest, MultipleReturns) { auto source = R"( -.function f64 main(f64 a0, f64 a1){ +.function f64 main(f64 a0, f64 a1) { call.short inline, a0, a1 return.64 } -.function f64 inline(f64 a0){ +.function f64 inline(f64 a0) { fldai.64 0.0 fcmpl.64 a0 jlez label @@ -165,14 +165,14 @@ label: TEST_F(InliningTest, WithCalls) { auto source = R"( -.function u32 main(u32 a0, u32 a1){ +.function u32 main(u32 a0, u32 a1) { sub a0, a1 sta a0 call.short inline, a0, a0 addi 1 return } -.function u32 inline(u32 a0){ +.function u32 inline(u32 a0) { lda a0 not jlez label @@ -183,7 +183,7 @@ label: lda a0 return } -.function u32 fn(u32 a0){ +.function u32 fn(u32 a0) { ldai 14 sub2 a0 return @@ -204,14 +204,14 @@ label: TEST_F(InliningTest, WithLoop) { auto source = R"( -.function u32 main(u32 a0, u32 a1){ +.function u32 main(u32 a0, u32 a1) { sub a0, a1 sta a0 call.short inline, a0, a0 addi 1 return } -.function u32 inline(u32 a0){ +.function u32 inline(u32 a0) { lda a0 not loop: @@ -240,14 +240,14 @@ exit: TEST_F(InliningTest, WithChecks) { auto source = R"( -.function u32 main(u32 a0, u32 a1){ +.function u32 main(u32 a0, u32 a1) { sub a0, a1 sta a0 call.short inline, a0, a0 addi 1 return } -.function u32 inline(u32 a0){ +.function u32 inline(u32 a0) { ldai 123 div2 a0 return @@ -469,7 +469,7 @@ TEST_F(InliningTest, InliningToInfLoop) return; #endif auto source = R"( - .function u32 foo_inf(i32 a0){ + .function u32 foo_inf(i32 a0) { loop: inci a0, 1 call foo_throw diff --git a/static_core/compiler/tests/inst_generator.cpp b/static_core/compiler/tests/inst_generator.cpp index 7bee81cd83..1ae58631ae 100644 --- a/static_core/compiler/tests/inst_generator.cpp +++ b/static_core/compiler/tests/inst_generator.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/inst_generator.h b/static_core/compiler/tests/inst_generator.h index 509a9eef1f..b75aae81dd 100644 --- a/static_core/compiler/tests/inst_generator.h +++ b/static_core/compiler/tests/inst_generator.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/inst_generator_test.cpp b/static_core/compiler/tests/inst_generator_test.cpp index 55ccd223fa..a8ad3784d4 100644 --- a/static_core/compiler/tests/inst_generator_test.cpp +++ b/static_core/compiler/tests/inst_generator_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -279,7 +279,7 @@ public: return; } default: - ASSERT_DO(0U, std::cerr << (int)opc << "\n"); + ASSERT_DO(0U, std::cerr << static_cast(opc) << "\n"); } } @@ -384,8 +384,8 @@ public: auto calc_data = DoLogic(opc, param_1, param_2, param_3, shift_type, DataType::GetTypeSize(type, graph->GetArch())); if (calc_data != ret_data) { - std::cout << " data " << ret_data << " sizeof type " << (uint64_t)(sizeof(ParamType) * 8U) - << " \n"; + std::cout << " data " << ret_data << " sizeof type " + << static_cast(sizeof(ParamType) * 8U) << " \n"; std::cout << std::hex << "parameter_1 = " << param_1 << " parameter_2 = " << param_2 << "parameter_3 = " << param_3 << "\n"; inst->Dump(&std::cerr); @@ -462,15 +462,15 @@ public: if (calc_data != ret_data) { if constexpr (std::is_same_v || std::is_same_v) { std::cout << std::hex << " in parameter = " << param_1 << "\n"; - std::cout << std::hex << "parameter_1 = " << (double)param_1 << "\n"; + std::cout << std::hex << "parameter_1 = " << static_cast(param_1) << "\n"; } #ifndef NDEBUG std::cout << " cast from " << DataType::ToString(VixlExecModule::GetType()) << " to " << DataType::ToString(VixlExecModule::GetType()) << "\n"; #endif - std::cout << " data " << ret_data << " sizeof type " << (uint64_t)(sizeof(ParamType) * 8U) - << " \n"; + std::cout << " data " << ret_data << " sizeof type " + << static_cast(sizeof(ParamType) * 8U) << " \n"; inst->Dump(&std::cerr); exec_module_.SetDump(true); exec_module_.SetParameter(0U, param_1); @@ -487,19 +487,20 @@ public: { switch (shift_type) { case ShiftType::LSL: - return (uint64_t)value << scale; + return static_cast(value) << scale; case ShiftType::ROR: - return ((uint64_t)value >> scale) | (value << (type_size - scale)); // NOLINT(hicpp-signed-bitwise) + return (static_cast(value) >> scale) | + (value << (type_size - scale)); // NOLINT(hicpp-signed-bitwise) case ShiftType::LSR: if constexpr (std::is_same_v || std::is_same_v) { - return ((uint32_t)value) >> (uint32_t)scale; + return static_cast(value) >> static_cast(scale); } if constexpr (std::is_same_v || std::is_same_v) { - return ((uint64_t)value) >> scale; + return static_cast(value) >> scale; } /* fall-through */ case ShiftType::ASR: - return (int64_t)value >> scale; // NOLINT(hicpp-signed-bitwise) + return static_cast(value) >> scale; // NOLINT(hicpp-signed-bitwise) default: UNREACHABLE(); } @@ -652,7 +653,7 @@ public: } /* fall-through */ default: - ASSERT_DO(false, std::cerr << "Unsupported!" << (int)opc << "\n"); + ASSERT_DO(false, std::cerr << "Unsupported!" << static_cast(opc) << "\n"); return -1L; } } diff --git a/static_core/compiler/tests/inst_test.cpp b/static_core/compiler/tests/inst_test.cpp index e7f4aebc77..e444963871 100644 --- a/static_core/compiler/tests/inst_test.cpp +++ b/static_core/compiler/tests/inst_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/intrinsic_codegen_test.cpp b/static_core/compiler/tests/intrinsic_codegen_test.cpp index 865c03a7be..78ac6abf53 100644 --- a/static_core/compiler/tests/intrinsic_codegen_test.cpp +++ b/static_core/compiler/tests/intrinsic_codegen_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/ir_builder_test.cpp b/static_core/compiler/tests/ir_builder_test.cpp index bc6da9e6aa..39ae2d1606 100644 --- a/static_core/compiler/tests/ir_builder_test.cpp +++ b/static_core/compiler/tests/ir_builder_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -56,7 +56,7 @@ public: } std::string source = ".function " + curr_type + " main("; - source += curr_type + " a0){\n"; + source += curr_type + " a0) {\n"; if (inst_name == "mov") { source += "mov" + inst_type + " v0, a0\n"; source += "lda" + inst_type + " v0\n"; @@ -94,7 +94,7 @@ public: ASSERT(inst_name == "mov" || inst_name == "fmov" || inst_name == "lda" || inst_name == "flda"); std::string curr_type = ToString(data_type); - std::string source = ".function " + curr_type + " main(){\n"; + std::string source = ".function " + curr_type + " main() {\n"; if (inst_name == "mov") { source += "movi" + inst_type + " v0, 0\n"; source += "lda" + inst_type + " v0\n"; @@ -141,7 +141,7 @@ public: } std::string source = ".function i32 main("; source += curr_type + " a0, "; - source += curr_type + " a1){\n"; + source += curr_type + " a1) {\n"; source += "lda" + inst_type + " a0\n"; source += inst_name + inst_type + " a1\n"; source += "return\n"; @@ -173,7 +173,7 @@ public: std::string source = ".function i32 main("; source += curr_type + " a0, "; - source += curr_type + " a1){\n"; + source += curr_type + " a1) {\n"; source += "lda" + inst_type + " a0\n"; source += inst_name + inst_type + " a1\n"; source += "return\n"; @@ -340,7 +340,7 @@ private: TEST_F(IrBuilderTest, LoadArrayType64) { auto source = R"( - .function void main(i64[] a0, i32[] a1){ + .function void main(i64[] a0, i32[] a1) { ldai 0 ldarr.64 a0 movi v0, 0 @@ -379,7 +379,7 @@ TEST_F(IrBuilderTest, IntrinsicPrintU64) auto source = R"( .record IO .function void IO.printU64(u64 a0) - .function void main(u64 a0){ + .function void main(u64 a0) { ldai.64 23 sub2.64 a0 sta.64 a0 @@ -412,7 +412,7 @@ TEST_F(IrBuilderTest, BuiltinIsInf) auto source = R"( .record Double .function u1 Double.isInfinite(f64 a0) - .function u1 main(f64 a0){ + .function u1 main(f64 a0) { call.short Double.isInfinite, a0 return } @@ -440,7 +440,7 @@ TEST_F(IrBuilderTest, IntrinsicAbs) auto source = R"( .record Math .function f64 Math.absF64(f64 a0) - .function f64 main(f64 a0){ + .function f64 main(f64 a0) { fldai.64 1.23 fsub2.64 a0 sta.64 v5 @@ -470,7 +470,7 @@ TEST_F(IrBuilderTest, IntrinsicMathSqrt) auto source = R"( .record Math .function f64 Math.sqrt(f64 a0) - .function f64 main(f64 a0){ + .function f64 main(f64 a0) { fldai.64 3.14 fsub2.64 a0 sta.64 v1 @@ -500,7 +500,7 @@ TEST_F(IrBuilderTest, IntrinsicMathFsqrt) auto source = R"( .record Math .function f32 Math.fsqrt(f32 a0) - .function f32 main(f32 a0){ + .function f32 main(f32 a0) { fldai 3.14 fsub2 a0 sta v1 @@ -736,7 +736,7 @@ TEST_F(IrBuilderTest, IntrinsicMathMaxF32) TEST_F(IrBuilderTest, NoCheckForFloatDiv) { auto source = R"( - .function f64 main(f64 a0){ + .function f64 main(f64 a0) { fldai.64 23.0 fdiv2.64 a0 return @@ -762,7 +762,7 @@ TEST_F(IrBuilderTest, MultipleThrow) { auto source = R"( .record array - .function void main(array a0){ + .function void main(array a0) { throw a0 throw a0 throw a0 @@ -884,7 +884,7 @@ TEST_F(IrBuilderTest, MovNull) { auto source = R"( .record panda.String - .function panda.String main(){ + .function panda.String main() { mov.null v0 lda v0 return @@ -981,7 +981,7 @@ TEST_F(IrBuilderTest, LdaNull) { auto source = R"( .record panda.String - .function panda.String main(){ + .function panda.String main() { lda.null return.obj } @@ -1037,7 +1037,7 @@ TEST_F(IrBuilderTest, LdaStr) { auto source = R"( .record panda.String - .function panda.String main(){ + .function panda.String main() { lda.str "lda_test" return.obj } @@ -1062,7 +1062,7 @@ TEST_F(IrBuilderTest, LdaType) { auto source = R"( .record R {} - .function R main(){ + .function R main() { lda.type R return.obj } @@ -1126,7 +1126,7 @@ TEST_F(IrBuilderTest, StaObj) TEST_F(IrBuilderTest, Jmp) { auto source = R"( - .function void main(){ + .function void main() { jmp label label: return.void @@ -1302,7 +1302,7 @@ TEST_F(IrBuilderTest, Jge) TEST_F(IrBuilderTest, Fadd2) { auto source = R"( - .function f32 main(f32 a0, f32 a1){ + .function f32 main(f32 a0, f32 a1) { lda a0 fadd2 a1 return @@ -1328,7 +1328,7 @@ TEST_F(IrBuilderTest, Fadd2) TEST_F(IrBuilderTest, Fadd2f64) { auto source = R"( - .function f64 main(f64 a0, f64 a1){ + .function f64 main(f64 a0, f64 a1) { lda.64 a0 fadd2.64 a1 return.64 @@ -1354,7 +1354,7 @@ TEST_F(IrBuilderTest, Fadd2f64) TEST_F(IrBuilderTest, Fsub2) { auto source = R"( - .function f32 main(f32 a0, f32 a1){ + .function f32 main(f32 a0, f32 a1) { lda a0 fsub2 a1 return @@ -1380,7 +1380,7 @@ TEST_F(IrBuilderTest, Fsub2) TEST_F(IrBuilderTest, Fsub2f64) { auto source = R"( - .function f64 main(f64 a0, f64 a1){ + .function f64 main(f64 a0, f64 a1) { lda.64 a0 fsub2.64 a1 return.64 @@ -1406,7 +1406,7 @@ TEST_F(IrBuilderTest, Fsub2f64) TEST_F(IrBuilderTest, Fmul2) { auto source = R"( - .function f32 main(f32 a0, f32 a1){ + .function f32 main(f32 a0, f32 a1) { lda a0 fmul2 a1 return @@ -1432,7 +1432,7 @@ TEST_F(IrBuilderTest, Fmul2) TEST_F(IrBuilderTest, Fmul2f64) { auto source = R"( - .function f64 main(f64 a0, f64 a1){ + .function f64 main(f64 a0, f64 a1) { lda.64 a0 fmul2.64 a1 return.64 @@ -1458,7 +1458,7 @@ TEST_F(IrBuilderTest, Fmul2f64) TEST_F(IrBuilderTest, Fdiv2) { auto source = R"( - .function f32 main(f32 a0, f32 a1){ + .function f32 main(f32 a0, f32 a1) { lda a0 fdiv2 a1 return @@ -1484,7 +1484,7 @@ TEST_F(IrBuilderTest, Fdiv2) TEST_F(IrBuilderTest, Fdiv2f64) { auto source = R"( - .function f64 main(f64 a0, f64 a1){ + .function f64 main(f64 a0, f64 a1) { lda.64 a0 fdiv2.64 a1 return.64 @@ -1510,7 +1510,7 @@ TEST_F(IrBuilderTest, Fdiv2f64) TEST_F(IrBuilderTest, Fmod2) { auto source = R"( - .function f32 main(f32 a0, f32 a1){ + .function f32 main(f32 a0, f32 a1) { lda a0 fmod2 a1 return @@ -1536,7 +1536,7 @@ TEST_F(IrBuilderTest, Fmod2) TEST_F(IrBuilderTest, Fmod2f64) { auto source = R"( - .function f64 main(f64 a0, f64 a1){ + .function f64 main(f64 a0, f64 a1) { lda.64 a0 fmod2.64 a1 return.64 @@ -1562,7 +1562,7 @@ TEST_F(IrBuilderTest, Fmod2f64) TEST_F(IrBuilderTest, Add2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 add2 a1 return @@ -1588,7 +1588,7 @@ TEST_F(IrBuilderTest, Add2) TEST_F(IrBuilderTest, Add2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 add2.64 a1 return.64 @@ -1614,7 +1614,7 @@ TEST_F(IrBuilderTest, Add2i64) TEST_F(IrBuilderTest, Sub2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 sub2 a1 return @@ -1640,7 +1640,7 @@ TEST_F(IrBuilderTest, Sub2) TEST_F(IrBuilderTest, Sub2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 sub2.64 a1 return.64 @@ -1666,7 +1666,7 @@ TEST_F(IrBuilderTest, Sub2i64) TEST_F(IrBuilderTest, Mul2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 mul2 a1 return @@ -1692,7 +1692,7 @@ TEST_F(IrBuilderTest, Mul2) TEST_F(IrBuilderTest, Mul2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 mul2.64 a1 return.64 @@ -1718,7 +1718,7 @@ TEST_F(IrBuilderTest, Mul2i64) TEST_F(IrBuilderTest, And2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 and2 a1 return @@ -1744,7 +1744,7 @@ TEST_F(IrBuilderTest, And2) TEST_F(IrBuilderTest, And2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 and2.64 a1 return.64 @@ -1770,7 +1770,7 @@ TEST_F(IrBuilderTest, And2i64) TEST_F(IrBuilderTest, Or2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 or2 a1 return @@ -1796,7 +1796,7 @@ TEST_F(IrBuilderTest, Or2) TEST_F(IrBuilderTest, Or2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 or2.64 a1 return.64 @@ -1822,7 +1822,7 @@ TEST_F(IrBuilderTest, Or2i64) TEST_F(IrBuilderTest, Xor2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 xor2 a1 return @@ -1848,7 +1848,7 @@ TEST_F(IrBuilderTest, Xor2) TEST_F(IrBuilderTest, Xor2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 xor2.64 a1 return.64 @@ -1874,7 +1874,7 @@ TEST_F(IrBuilderTest, Xor2i64) TEST_F(IrBuilderTest, Shl2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 shl2 a1 return @@ -1900,7 +1900,7 @@ TEST_F(IrBuilderTest, Shl2) TEST_F(IrBuilderTest, Shl2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 shl2.64 a1 return.64 @@ -1926,7 +1926,7 @@ TEST_F(IrBuilderTest, Shl2i64) TEST_F(IrBuilderTest, Shr2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 shr2 a1 return @@ -1952,7 +1952,7 @@ TEST_F(IrBuilderTest, Shr2) TEST_F(IrBuilderTest, Shr2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 shr2.64 a1 return.64 @@ -1978,7 +1978,7 @@ TEST_F(IrBuilderTest, Shr2i64) TEST_F(IrBuilderTest, Ashr2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 ashr2 a1 return @@ -2004,7 +2004,7 @@ TEST_F(IrBuilderTest, Ashr2) TEST_F(IrBuilderTest, Ashr2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 ashr2.64 a1 return.64 @@ -2030,7 +2030,7 @@ TEST_F(IrBuilderTest, Ashr2i64) TEST_F(IrBuilderTest, Div2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 div2 a1 return @@ -2058,7 +2058,7 @@ TEST_F(IrBuilderTest, Div2) TEST_F(IrBuilderTest, Div2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 div2.64 a1 return.64 @@ -2086,7 +2086,7 @@ TEST_F(IrBuilderTest, Div2i64) TEST_F(IrBuilderTest, Mod2) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { lda a0 mod2 a1 return @@ -2114,7 +2114,7 @@ TEST_F(IrBuilderTest, Mod2) TEST_F(IrBuilderTest, Mod2i64) { auto source = R"( - .function i64 main(i64 a0, i64 a1){ + .function i64 main(i64 a0, i64 a1) { lda.64 a0 mod2.64 a1 return.64 @@ -2142,7 +2142,7 @@ TEST_F(IrBuilderTest, Mod2i64) TEST_F(IrBuilderTest, Divu2) { auto source = R"( - .function u32 main(u32 a0, u32 a1){ + .function u32 main(u32 a0, u32 a1) { lda a0 divu2 a1 return @@ -2170,7 +2170,7 @@ TEST_F(IrBuilderTest, Divu2) TEST_F(IrBuilderTest, Divu2u64) { auto source = R"( - .function u64 main(u64 a0, u64 a1){ + .function u64 main(u64 a0, u64 a1) { lda.64 a0 divu2.64 a1 return.64 @@ -2198,7 +2198,7 @@ TEST_F(IrBuilderTest, Divu2u64) TEST_F(IrBuilderTest, Modu2) { auto source = R"( - .function u32 main(u32 a0, u32 a1){ + .function u32 main(u32 a0, u32 a1) { lda a0 modu2 a1 return @@ -2226,7 +2226,7 @@ TEST_F(IrBuilderTest, Modu2) TEST_F(IrBuilderTest, Modu2u64) { auto source = R"( - .function u64 main(u64 a0, u64 a1){ + .function u64 main(u64 a0, u64 a1) { lda.64 a0 modu2.64 a1 return.64 @@ -2254,7 +2254,7 @@ TEST_F(IrBuilderTest, Modu2u64) TEST_F(IrBuilderTest, Add) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { add a0, a1 return } @@ -2279,7 +2279,7 @@ TEST_F(IrBuilderTest, Add) TEST_F(IrBuilderTest, Sub) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { sub a0, a1 return } @@ -2304,7 +2304,7 @@ TEST_F(IrBuilderTest, Sub) TEST_F(IrBuilderTest, Mul) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { mul a0, a1 return } @@ -2329,7 +2329,7 @@ TEST_F(IrBuilderTest, Mul) TEST_F(IrBuilderTest, And) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { and a0, a1 return } @@ -2354,7 +2354,7 @@ TEST_F(IrBuilderTest, And) TEST_F(IrBuilderTest, Or) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { or a0, a1 return } @@ -2379,7 +2379,7 @@ TEST_F(IrBuilderTest, Or) TEST_F(IrBuilderTest, Xor) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { xor a0, a1 return } @@ -2404,7 +2404,7 @@ TEST_F(IrBuilderTest, Xor) TEST_F(IrBuilderTest, Shl) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { shl a0, a1 return } @@ -2429,7 +2429,7 @@ TEST_F(IrBuilderTest, Shl) TEST_F(IrBuilderTest, Shr) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { shr a0, a1 return } @@ -2454,7 +2454,7 @@ TEST_F(IrBuilderTest, Shr) TEST_F(IrBuilderTest, Ashr) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { ashr a0, a1 return } @@ -2479,7 +2479,7 @@ TEST_F(IrBuilderTest, Ashr) TEST_F(IrBuilderTest, Div) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { div a0, a1 return } @@ -2506,7 +2506,7 @@ TEST_F(IrBuilderTest, Div) TEST_F(IrBuilderTest, Mod) { auto source = R"( - .function i32 main(i32 a0, i32 a1){ + .function i32 main(i32 a0, i32 a1) { mod a0, a1 return } @@ -2533,7 +2533,7 @@ TEST_F(IrBuilderTest, Mod) TEST_F(IrBuilderTest, Addi) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 addi 1 return @@ -2559,7 +2559,7 @@ TEST_F(IrBuilderTest, Addi) TEST_F(IrBuilderTest, Subi) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 subi 1 return @@ -2585,7 +2585,7 @@ TEST_F(IrBuilderTest, Subi) TEST_F(IrBuilderTest, Muli) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 muli 1 return @@ -2611,7 +2611,7 @@ TEST_F(IrBuilderTest, Muli) TEST_F(IrBuilderTest, Andi) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 andi 1 return @@ -2637,7 +2637,7 @@ TEST_F(IrBuilderTest, Andi) TEST_F(IrBuilderTest, Ori) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 ori 1 return @@ -2663,7 +2663,7 @@ TEST_F(IrBuilderTest, Ori) TEST_F(IrBuilderTest, Xori) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 xori 1 return @@ -2689,7 +2689,7 @@ TEST_F(IrBuilderTest, Xori) TEST_F(IrBuilderTest, Shli) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 shli 1 return @@ -2715,7 +2715,7 @@ TEST_F(IrBuilderTest, Shli) TEST_F(IrBuilderTest, Shri) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 shri 1 return @@ -2741,7 +2741,7 @@ TEST_F(IrBuilderTest, Shri) TEST_F(IrBuilderTest, Ashri) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 ashri 1 return @@ -2767,7 +2767,7 @@ TEST_F(IrBuilderTest, Ashri) TEST_F(IrBuilderTest, Divi) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 divi 1 return @@ -2795,7 +2795,7 @@ TEST_F(IrBuilderTest, Divi) TEST_F(IrBuilderTest, Modi) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 modi 1 return @@ -2823,7 +2823,7 @@ TEST_F(IrBuilderTest, Modi) TEST_F(IrBuilderTest, Fneg) { auto source = R"( - .function f32 main(f32 a0){ + .function f32 main(f32 a0) { lda a0 fneg return @@ -2848,7 +2848,7 @@ TEST_F(IrBuilderTest, Fneg) TEST_F(IrBuilderTest, Fneg64) { auto source = R"( - .function f64 main(f64 a0){ + .function f64 main(f64 a0) { lda a0 fneg.64 return.64 @@ -2873,7 +2873,7 @@ TEST_F(IrBuilderTest, Fneg64) TEST_F(IrBuilderTest, Neg) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 neg return @@ -2898,7 +2898,7 @@ TEST_F(IrBuilderTest, Neg) TEST_F(IrBuilderTest, Neg64) { auto source = R"( - .function i64 main(i64 a0){ + .function i64 main(i64 a0) { lda a0 neg.64 return.64 @@ -2923,7 +2923,7 @@ TEST_F(IrBuilderTest, Neg64) TEST_F(IrBuilderTest, Not) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 not return @@ -2948,7 +2948,7 @@ TEST_F(IrBuilderTest, Not) TEST_F(IrBuilderTest, Not64) { auto source = R"( - .function i64 main(i64 a0){ + .function i64 main(i64 a0) { lda a0 not.64 return.64 @@ -2973,7 +2973,7 @@ TEST_F(IrBuilderTest, Not64) TEST_F(IrBuilderTest, Inci) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { inci a0, 1 lda a0 return @@ -3000,7 +3000,7 @@ TEST_F(IrBuilderTest, Inci) TEST_F(IrBuilderTest, I32tof32) { auto source = R"( - .function f32 main(i32 a0){ + .function f32 main(i32 a0) { lda a0 i32tof32 return @@ -3026,7 +3026,7 @@ TEST_F(IrBuilderTest, I32tof32) TEST_F(IrBuilderTest, I32tof64) { auto source = R"( - .function f64 main(i32 a0){ + .function f64 main(i32 a0) { lda a0 i32tof64 return.64 @@ -3052,7 +3052,7 @@ TEST_F(IrBuilderTest, I32tof64) TEST_F(IrBuilderTest, U32tof32) { auto source = R"( - .function f32 main(u32 a0){ + .function f32 main(u32 a0) { lda a0 u32tof32 return @@ -3078,7 +3078,7 @@ TEST_F(IrBuilderTest, U32tof32) TEST_F(IrBuilderTest, U32tof64) { auto source = R"( - .function f64 main(u32 a0){ + .function f64 main(u32 a0) { lda a0 u32tof64 return.64 @@ -3104,7 +3104,7 @@ TEST_F(IrBuilderTest, U32tof64) TEST_F(IrBuilderTest, I64tof32) { auto source = R"( - .function f32 main(i64 a0){ + .function f32 main(i64 a0) { lda.64 a0 i64tof32 return @@ -3130,7 +3130,7 @@ TEST_F(IrBuilderTest, I64tof32) TEST_F(IrBuilderTest, I64tof64) { auto source = R"( - .function f64 main(i64 a0){ + .function f64 main(i64 a0) { lda.64 a0 i64tof64 return.64 @@ -3156,7 +3156,7 @@ TEST_F(IrBuilderTest, I64tof64) TEST_F(IrBuilderTest, U64tof32) { auto source = R"( - .function f32 main(u64 a0){ + .function f32 main(u64 a0) { lda.64 a0 u64tof32 return @@ -3182,7 +3182,7 @@ TEST_F(IrBuilderTest, U64tof32) TEST_F(IrBuilderTest, U64tof64) { auto source = R"( - .function f64 main(u64 a0){ + .function f64 main(u64 a0) { lda.64 a0 u64tof64 return.64 @@ -3208,7 +3208,7 @@ TEST_F(IrBuilderTest, U64tof64) TEST_F(IrBuilderTest, F32toi32) { auto source = R"( - .function i32 main(f32 a0){ + .function i32 main(f32 a0) { lda a0 f32toi32 return @@ -3234,7 +3234,7 @@ TEST_F(IrBuilderTest, F32toi32) TEST_F(IrBuilderTest, F32toi64) { auto source = R"( - .function i64 main(f32 a0){ + .function i64 main(f32 a0) { lda a0 f32toi64 return.64 @@ -3260,7 +3260,7 @@ TEST_F(IrBuilderTest, F32toi64) TEST_F(IrBuilderTest, F32tou32) { auto source = R"( - .function u32 main(f32 a0){ + .function u32 main(f32 a0) { lda a0 f32tou32 return @@ -3286,7 +3286,7 @@ TEST_F(IrBuilderTest, F32tou32) TEST_F(IrBuilderTest, F32tou64) { auto source = R"( - .function u64 main(f32 a0){ + .function u64 main(f32 a0) { lda a0 f32tou64 return.64 @@ -3312,7 +3312,7 @@ TEST_F(IrBuilderTest, F32tou64) TEST_F(IrBuilderTest, F32tof64) { auto source = R"( - .function f64 main(f32 a0){ + .function f64 main(f32 a0) { lda a0 f32tof64 return.64 @@ -3338,7 +3338,7 @@ TEST_F(IrBuilderTest, F32tof64) TEST_F(IrBuilderTest, F64toi32) { auto source = R"( - .function i32 main(f64 a0){ + .function i32 main(f64 a0) { lda.64 a0 f64toi32 return @@ -3364,7 +3364,7 @@ TEST_F(IrBuilderTest, F64toi32) TEST_F(IrBuilderTest, F64toi64) { auto source = R"( - .function i64 main(f64 a0){ + .function i64 main(f64 a0) { lda.64 a0 f64toi64 return.64 @@ -3390,7 +3390,7 @@ TEST_F(IrBuilderTest, F64toi64) TEST_F(IrBuilderTest, F64tou32) { auto source = R"( - .function u32 main(f64 a0){ + .function u32 main(f64 a0) { lda.64 a0 f64tou32 return @@ -3416,7 +3416,7 @@ TEST_F(IrBuilderTest, F64tou32) TEST_F(IrBuilderTest, F64tou64) { auto source = R"( - .function u64 main(f64 a0){ + .function u64 main(f64 a0) { lda.64 a0 f64tou64 return.64 @@ -3442,7 +3442,7 @@ TEST_F(IrBuilderTest, F64tou64) TEST_F(IrBuilderTest, F64tof32) { auto source = R"( - .function f32 main(f64 a0){ + .function f32 main(f64 a0) { lda.64 a0 f64tof32 return @@ -3468,7 +3468,7 @@ TEST_F(IrBuilderTest, F64tof32) TEST_F(IrBuilderTest, I32toi64) { auto source = R"( - .function i64 main(i32 a0){ + .function i64 main(i32 a0) { lda a0 i32toi64 return @@ -3493,7 +3493,7 @@ TEST_F(IrBuilderTest, I32toi64) TEST_F(IrBuilderTest, I64toi32) { auto source = R"( - .function i32 main(i64 a0){ + .function i32 main(i64 a0) { lda.64 a0 i64toi32 return @@ -3518,7 +3518,7 @@ TEST_F(IrBuilderTest, I64toi32) TEST_F(IrBuilderTest, U32toi64) { auto source = R"( - .function i64 main(u32 a0){ + .function i64 main(u32 a0) { lda a0 u32toi64 return @@ -3543,7 +3543,7 @@ TEST_F(IrBuilderTest, U32toi64) TEST_F(IrBuilderTest, Ldarr8) { auto source = R"( - .function i8 main(i32 a0, i8[] a1){ + .function i8 main(i32 a0, i8[] a1) { lda a0 ldarr.8 a1 return @@ -3573,7 +3573,7 @@ TEST_F(IrBuilderTest, Ldarr8) TEST_F(IrBuilderTest, Ldarru8) { auto source = R"( - .function u8 main(i32 a0, u8[] a1){ + .function u8 main(i32 a0, u8[] a1) { lda a0 ldarru.8 a1 return @@ -3603,7 +3603,7 @@ TEST_F(IrBuilderTest, Ldarru8) TEST_F(IrBuilderTest, Ldarr16) { auto source = R"( - .function i16 main(i32 a0, i16[] a1){ + .function i16 main(i32 a0, i16[] a1) { lda a0 ldarr.16 a1 return @@ -3633,7 +3633,7 @@ TEST_F(IrBuilderTest, Ldarr16) TEST_F(IrBuilderTest, Ldarru16) { auto source = R"( - .function u16 main(i32 a0, u16[] a1){ + .function u16 main(i32 a0, u16[] a1) { lda a0 ldarru.16 a1 return @@ -3663,7 +3663,7 @@ TEST_F(IrBuilderTest, Ldarru16) TEST_F(IrBuilderTest, Ldarr) { auto source = R"( - .function i32 main(i32 a0, i32[] a1){ + .function i32 main(i32 a0, i32[] a1) { lda a0 ldarr a1 return @@ -3693,7 +3693,7 @@ TEST_F(IrBuilderTest, Ldarr) TEST_F(IrBuilderTest, Fldarr32) { auto source = R"( - .function f32 main(i32 a0, f32[] a1){ + .function f32 main(i32 a0, f32[] a1) { lda a0 fldarr.32 a1 return @@ -3723,7 +3723,7 @@ TEST_F(IrBuilderTest, Fldarr32) TEST_F(IrBuilderTest, Ldarr64) { auto source = R"( - .function u64 main(i32 a0, u64[] a1){ + .function u64 main(i32 a0, u64[] a1) { lda a0 ldarr.64 a1 return @@ -3753,7 +3753,7 @@ TEST_F(IrBuilderTest, Ldarr64) TEST_F(IrBuilderTest, Fldarr64) { auto source = R"( - .function f64 main(i32 a0, f64[] a1){ + .function f64 main(i32 a0, f64[] a1) { lda a0 fldarr.64 a1 return @@ -3784,7 +3784,7 @@ TEST_F(IrBuilderTest, LdarrObj) { auto source = R"( .record panda.String - .function panda.String main(i32 a0, panda.String[] a1){ + .function panda.String main(i32 a0, panda.String[] a1) { lda a0 ldarr.obj a1 return @@ -3814,7 +3814,7 @@ TEST_F(IrBuilderTest, LdarrObj) TEST_F(IrBuilderTest, Starr8) { auto source = R"( - .function void main(i32 a0, u8[] a1, u8 a2){ + .function void main(i32 a0, u8[] a1, u8 a2) { lda a2 starr.8 a1, a0 return.void @@ -3845,7 +3845,7 @@ TEST_F(IrBuilderTest, Starr8) TEST_F(IrBuilderTest, Starr16) { auto source = R"( - .function void main(i32 a0, u16[] a1, u16 a2){ + .function void main(i32 a0, u16[] a1, u16 a2) { lda a2 starr.16 a1, a0 return.void @@ -3876,7 +3876,7 @@ TEST_F(IrBuilderTest, Starr16) TEST_F(IrBuilderTest, Starr) { auto source = R"( - .function void main(i32 a0, i32[] a1, i32 a2){ + .function void main(i32 a0, i32[] a1, i32 a2) { lda a2 starr a1, a0 return.void @@ -3907,7 +3907,7 @@ TEST_F(IrBuilderTest, Starr) TEST_F(IrBuilderTest, Fstarr32) { auto source = R"( - .function void main(i32 a0, f32[] a1, f32 a2){ + .function void main(i32 a0, f32[] a1, f32 a2) { lda a2 fstarr.32 a1, a0 return.void @@ -3938,7 +3938,7 @@ TEST_F(IrBuilderTest, Fstarr32) TEST_F(IrBuilderTest, Starr64) { auto source = R"( - .function void main(i32 a0, i64[] a1, i64 a2){ + .function void main(i32 a0, i64[] a1, i64 a2) { lda.64 a2 starr.64 a1, a0 return.void @@ -3969,7 +3969,7 @@ TEST_F(IrBuilderTest, Starr64) TEST_F(IrBuilderTest, Fstarr64) { auto source = R"( - .function void main(i32 a0, f64[] a1, f64 a2){ + .function void main(i32 a0, f64[] a1, f64 a2) { lda.64 a2 fstarr.64 a1, a0 return.void @@ -4001,7 +4001,7 @@ TEST_F(IrBuilderTest, StarrObj) { auto source = R"( .record panda.String - .function void main(i32 a0, panda.String[] a1, panda.String a2){ + .function void main(i32 a0, panda.String[] a1, panda.String a2) { lda.obj a2 starr.obj a1, a0 return.void @@ -4033,7 +4033,7 @@ TEST_F(IrBuilderTest, StarrObj) TEST_F(IrBuilderTest, Lenarr) { auto source = R"( - .function i32 main(i32[] a0){ + .function i32 main(i32[] a0) { lenarr a0 return } @@ -4059,7 +4059,7 @@ TEST_F(IrBuilderTest, Lenarr) TEST_F(IrBuilderTest, Newarr) { auto source = R"( - .function i32[] main(i32 a0){ + .function i32[] main(i32 a0) { newarr a0, a0, i32[] lda.obj a0 return @@ -4264,7 +4264,7 @@ TEST_F(IrBuilderTest, Newobj) { auto source = R"( .record panda.String - .function panda.String main(){ + .function panda.String main() { newobj v0, panda.String lda.obj v0 return @@ -4291,7 +4291,7 @@ TEST_F(IrBuilderTest, Initobj) .record R{ i32 f } - .function R main(){ + .function R main() { initobj R.ctor return } @@ -4324,7 +4324,7 @@ TEST_F(IrBuilderTest, DISABLED_MultiArray) .record __I .function ___I _init__i32_i32_(i32 a0, i32 a1) .record panda.Array - .function panda.Array main(i32 a0){ + .function panda.Array main(i32 a0) { movi v0, 0x1 initobj _init__i32_i32_ v0, a0 return @@ -4359,7 +4359,7 @@ TEST_F(IrBuilderTest, Ldobj) i32 v_i32 panda.String v_string } - .function i32 main(R a0){ + .function i32 main(R a0) { ldobj a0, R.v_i32 return } @@ -4390,7 +4390,7 @@ TEST_F(IrBuilderTest, Ldobj64) i64 v_i64 panda.String v_string } - .function i64 main(R a0){ + .function i64 main(R a0) { ldobj.64 a0, R.v_i64 return } @@ -4422,7 +4422,7 @@ TEST_F(IrBuilderTest, LdobjObj) i32 v_i32 panda.String v_string } - .function panda.String main(R a0){ + .function panda.String main(R a0) { ldobj.obj a0, R.v_string return.obj } @@ -4453,7 +4453,7 @@ TEST_F(IrBuilderTest, Stobj) i32 v_i32 panda.String v_string } - .function void main(R a0, i32 a1){ + .function void main(R a0, i32 a1) { lda a1 stobj a0, R.v_i32 return.void @@ -4486,7 +4486,7 @@ TEST_F(IrBuilderTest, Stobj64) i64 v_i64 panda.String v_string } - .function void main(R a0, i64 a1){ + .function void main(R a0, i64 a1) { lda.64 a1 stobj.64 a0, R.v_i64 return.void @@ -4519,7 +4519,7 @@ TEST_F(IrBuilderTest, StobjObj) i32 v_i32 panda.String v_string } - .function void main(R a0, panda.String a1){ + .function void main(R a0, panda.String a1) { lda.obj a1 stobj.obj a0, R.v_string return.void @@ -4552,7 +4552,7 @@ TEST_F(IrBuilderTest, Ldstatic) i32 v_i32 panda.String v_string } - .function i32 main(){ + .function i32 main() { ldstatic R.v_i32 return } @@ -4581,7 +4581,7 @@ TEST_F(IrBuilderTest, Ldstatic64) i64 v_i64 panda.String v_string } - .function i64 main(){ + .function i64 main() { ldstatic.64 R.v_i64 return } @@ -4610,7 +4610,7 @@ TEST_F(IrBuilderTest, LdstaticObj) i32 v_i32 panda.String v_string } - .function panda.String main(){ + .function panda.String main() { ldstatic.obj R.v_string return } @@ -4639,7 +4639,7 @@ TEST_F(IrBuilderTest, Ststatic) i32 v_i32 panda.String v_string } - .function void main(i32 a0){ + .function void main(i32 a0) { lda a0 ststatic R.v_i32 return.void @@ -4671,7 +4671,7 @@ TEST_F(IrBuilderTest, Ststatic64) i64 v_i64 panda.String v_string } - .function void main(i64 a0){ + .function void main(i64 a0) { lda.64 a0 ststatic.64 R.v_i64 return.void @@ -4703,7 +4703,7 @@ TEST_F(IrBuilderTest, StstaticObj) i32 v_i32 panda.String v_string } - .function void main(panda.String a0){ + .function void main(panda.String a0) { lda.obj a0 ststatic.obj R.v_string return.void @@ -4730,7 +4730,7 @@ TEST_F(IrBuilderTest, StstaticObj) TEST_F(IrBuilderTest, Return) { auto source = R"( - .function i32 main(i32 a0){ + .function i32 main(i32 a0) { lda a0 return } @@ -4753,7 +4753,7 @@ TEST_F(IrBuilderTest, Return) TEST_F(IrBuilderTest, Return64) { auto source = R"( - .function i64 main(i64 a0){ + .function i64 main(i64 a0) { lda.64 a0 return.64 } @@ -4777,7 +4777,7 @@ TEST_F(IrBuilderTest, ReturnObj) { auto source = R"( .record panda.String - .function panda.String main(panda.String a0){ + .function panda.String main(panda.String a0) { lda.obj a0 return.obj } @@ -4800,7 +4800,7 @@ TEST_F(IrBuilderTest, ReturnObj) TEST_F(IrBuilderTest, ReturnVoid) { auto source = R"( - .function void main(){ + .function void main() { return.void } )"; @@ -4821,7 +4821,7 @@ TEST_F(IrBuilderTest, Throw) { auto source = R"( .record panda.String - .function void main(panda.String a0){ + .function void main(panda.String a0) { throw a0 } )"; @@ -4844,7 +4844,7 @@ TEST_F(IrBuilderTest, Throw) TEST_F(IrBuilderTest, CallShort) { auto source = R"( - .function i32 main(){ + .function i32 main() { movi.64 v0, 1 call.short foo1, v0, v0 call.short foo2, v0, v0 @@ -4882,7 +4882,7 @@ TEST_F(IrBuilderTest, CallShort) TEST_F(IrBuilderTest, Call) { auto source = R"( - .function i64 main(){ + .function i64 main() { movi.64 v0, 1 call foo1, v0, v0, v0, v0 call foo2, v0, v0, v0, v0 @@ -4920,7 +4920,7 @@ TEST_F(IrBuilderTest, Call) TEST_F(IrBuilderTest, CallRange) { auto source = R"( - .function i64 main(){ + .function i64 main() { movi.64 v0, 1 movi.64 v1, 2 call.range foo, v0 @@ -4955,7 +4955,7 @@ TEST_F(IrBuilderTest, Checkcast) i32 asm1 i64 asm2 } - .function void main(){ + .function void main() { newobj v0, Asm lda.obj v0 checkcast Asm @@ -4987,7 +4987,7 @@ TEST_F(IrBuilderTest, Isinstance) i32 asm1 i64 asm2 } - .function u1 main(){ + .function u1 main() { newobj v0, Asm lda.obj v0 isinstance Asm @@ -5746,7 +5746,7 @@ exit: TEST_F(IrBuilderTest, OsrMode) { auto source = R"( - .function u32 foo(u32 a0){ + .function u32 foo(u32 a0) { lda a0 loop: jlez exit @@ -5791,7 +5791,7 @@ TEST_F(IrBuilderTest, OsrMode) TEST_F(IrBuilderTest, TestSaveStateDeoptimize) { auto source = R"( - .function u32 foo(u32 a0){ + .function u32 foo(u32 a0) { lda a0 loop: jlez exit @@ -5837,7 +5837,7 @@ TEST_F(IrBuilderTest, TestSaveStateDeoptimize) TEST_F(IrBuilderTest, InfiniteLoop) { auto source = R"( - .function u32 foo_inf(i32 a0){ + .function u32 foo_inf(i32 a0) { loop: inci a0, 1 jmp loop @@ -5867,7 +5867,7 @@ TEST_F(IrBuilderTest, InfiniteLoop) TEST_F(IrBuilderTest, TestSaveStateDeoptimizeAuxiliaryBlock) { auto source = R"( - .function u32 foo(i32 a0){ + .function u32 foo(i32 a0) { ldai 0 jne a0, test jmp end_test diff --git a/static_core/compiler/tests/iterators_test.cpp b/static_core/compiler/tests/iterators_test.cpp index 23aeebc5a9..803569af0a 100644 --- a/static_core/compiler/tests/iterators_test.cpp +++ b/static_core/compiler/tests/iterators_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/licm_conditions_test.cpp b/static_core/compiler/tests/licm_conditions_test.cpp index f7f3ea4461..0fc9e8cb86 100644 --- a/static_core/compiler/tests/licm_conditions_test.cpp +++ b/static_core/compiler/tests/licm_conditions_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/licm_test.cpp b/static_core/compiler/tests/licm_test.cpp index 7fe09b7137..0ee9b9a8fa 100644 --- a/static_core/compiler/tests/licm_test.cpp +++ b/static_core/compiler/tests/licm_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -150,7 +150,6 @@ TEST_F(LicmTest, OneLoop) * TODO (a.popov) Improve Licm to support this test with updated DF: `INST(19, Opcode::Phi).u64().Inputs(1, 18)` * * Test Graph: - * * [0] * | * v diff --git a/static_core/compiler/tests/life_intervals_test.cpp b/static_core/compiler/tests/life_intervals_test.cpp index 02ca1f4731..5cc525c066 100644 --- a/static_core/compiler/tests/life_intervals_test.cpp +++ b/static_core/compiler/tests/life_intervals_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/linear_order_test.cpp b/static_core/compiler/tests/linear_order_test.cpp index b4955ac8fc..25b7c10288 100644 --- a/static_core/compiler/tests/linear_order_test.cpp +++ b/static_core/compiler/tests/linear_order_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/live_registers_test.cpp b/static_core/compiler/tests/live_registers_test.cpp index 316185c1b6..10fcd39505 100644 --- a/static_core/compiler/tests/live_registers_test.cpp +++ b/static_core/compiler/tests/live_registers_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/liveness_analyzer_test.cpp b/static_core/compiler/tests/liveness_analyzer_test.cpp index 889e608487..c1b8924eb2 100644 --- a/static_core/compiler/tests/liveness_analyzer_test.cpp +++ b/static_core/compiler/tests/liveness_analyzer_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/loop_analyzer_test.cpp b/static_core/compiler/tests/loop_analyzer_test.cpp index 48429bbea7..5a5458dfb0 100644 --- a/static_core/compiler/tests/loop_analyzer_test.cpp +++ b/static_core/compiler/tests/loop_analyzer_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -239,7 +239,6 @@ TEST_F(LoopAnalyzerTest, LoopAnalyzer) * [exit] * * After loop pre-header insertion: - * * [entry] * | * v @@ -344,7 +343,28 @@ TEST_F(LoopAnalyzerTest, PreheaderInsert) * [6]----->[1] * * After loop pre-headers insertion: - * + * [0] + * | + * v + * [pre-header] + * | + * v + * [2]<------\ + * | | + * v | + * [3]-------/ + * | + * v + * [pre-header] + * | + * v + * [4]<------\ + * | | + * v | + * [5]-------/ + * | + * V + * [6]----->[1] */ TEST_F(LoopAnalyzerTest, PreheaderInsert2) { @@ -612,8 +632,7 @@ TEST_F(LoopAnalyzerTest, InfiniteLoop) /** * Test checks the ASSERTION fail issue fix in a Loop::AppendBlock. * - * Original progam: - * + * Original program: * .function u1 main(){ * ldai 0 * jltz loop1 @@ -626,7 +645,6 @@ TEST_F(LoopAnalyzerTest, InfiniteLoop) * } * * Graph dump: - * * BB 5 * prop: start * succs: [bb 0] @@ -650,7 +668,6 @@ TEST_F(LoopAnalyzerTest, InfiniteLoop) * prop: end * * Test Graph: - * * [5-start] * | * [0] --> [2] diff --git a/static_core/compiler/tests/loop_idioms_test.cpp b/static_core/compiler/tests/loop_idioms_test.cpp index 3569d7ffe6..998ed45bff 100644 --- a/static_core/compiler/tests/loop_idioms_test.cpp +++ b/static_core/compiler/tests/loop_idioms_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/loop_peeling_test.cpp b/static_core/compiler/tests/loop_peeling_test.cpp index b8b6c67180..89b6d32f0c 100644 --- a/static_core/compiler/tests/loop_peeling_test.cpp +++ b/static_core/compiler/tests/loop_peeling_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -232,9 +232,8 @@ TEST_F(LoopPeelingTest, CloneBlock) * \-----[3] [4] * | * [exit] - * + * Transform to: - * * [0] * | * v @@ -333,7 +332,6 @@ TEST_F(LoopPeelingTest, SingleLoop) * \------------------/ * * Transform to: - * * [0] * | * v @@ -451,7 +449,6 @@ TEST_F(LoopPeelingTest, InnerLoop) * \-------[6] [exit] * * Transform to: - * * [0] * | * v diff --git a/static_core/compiler/tests/loop_unroll_test.cpp b/static_core/compiler/tests/loop_unroll_test.cpp index d518273223..51cd6d2abf 100644 --- a/static_core/compiler/tests/loop_unroll_test.cpp +++ b/static_core/compiler/tests/loop_unroll_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/loop_unswitch_test.cpp b/static_core/compiler/tests/loop_unswitch_test.cpp index 06d4e3f2c5..30449c35ca 100644 --- a/static_core/compiler/tests/loop_unswitch_test.cpp +++ b/static_core/compiler/tests/loop_unswitch_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/lowering_test.cpp b/static_core/compiler/tests/lowering_test.cpp index 63eac6dfe5..5bb7864fc2 100644 --- a/static_core/compiler/tests/lowering_test.cpp +++ b/static_core/compiler/tests/lowering_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -2406,7 +2406,6 @@ TEST_F(LoweringTest, LowerUnsignedCast) INST(18U, Opcode::Return).u64().Inputs(17U); } } - } else { graph_expected = GraphCloner(graph, graph->GetAllocator(), graph->GetLocalAllocator()).CloneGraph(); } diff --git a/static_core/compiler/tests/lse_test.cpp b/static_core/compiler/tests/lse_test.cpp index 1b87975b6f..d1a21a4f14 100644 --- a/static_core/compiler/tests/lse_test.cpp +++ b/static_core/compiler/tests/lse_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -521,7 +521,7 @@ TEST_F(LSETest, LoopElimination) INST(31U, Opcode::Compare).b().CC(CC_GE).Inputs(30U, 7U); INST(32U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(31U); } - // for (v10 = 0, v10 < lenarr(v3), ++v10) + // For (v10 = 0, v10 < lenarr(v3), ++v10) // v11 += v3[v10] BASIC_BLOCK(4U, 3U, 4U) { @@ -557,7 +557,7 @@ TEST_F(LSETest, LoopElimination) INST(31U, Opcode::Compare).b().CC(CC_GE).Inputs(30U, 7U); INST(32U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(31U); } - // for (v10 = 0, v10 < lenarr(v3), ++v10) + // For (v10 = 0, v10 < lenarr(v3), ++v10) // v11 += v3[v10] BASIC_BLOCK(4U, 3U, 4U) { @@ -598,7 +598,7 @@ TEST_F(LSETest, LoopBranches) INST(48U, Opcode::Compare).b().CC(CC_GE).Inputs(7U, 6U); INST(49U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(48U); } - // for (v11 = 0, v11 < lenarr(v3), ++v11) + // For (v11 = 0, v11 < lenarr(v3), ++v11) BASIC_BLOCK(4U, 5U, 6U) { INST(11U, Opcode::Phi).s32().Inputs({{2U, 7U}, {7U, 46U}}); @@ -607,7 +607,7 @@ TEST_F(LSETest, LoopBranches) INST(23U, Opcode::Compare).b().CC(CC_EQ).Inputs(22U, 7U); INST(24U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(23U); } - // if (v11 % 2 == 1) + // If (v11 % 2 == 1) // v44 = v3[v11] BASIC_BLOCK(6U, 7U) { @@ -651,7 +651,7 @@ TEST_F(LSETest, LoopBranches) INST(48U, Opcode::Compare).b().CC(CC_GE).Inputs(7U, 6U); INST(49U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(48U); } - // for (v11 = 0, v11 < lenarr(v3), ++v11) + // For (v11 = 0, v11 < lenarr(v3), ++v11) BASIC_BLOCK(4U, 5U, 6U) { INST(11U, Opcode::Phi).s32().Inputs({{2U, 7U}, {7U, 46U}}); @@ -660,7 +660,7 @@ TEST_F(LSETest, LoopBranches) INST(23U, Opcode::Compare).b().CC(CC_EQ).Inputs(22U, 7U); INST(24U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(23U); } - // if (v11 % 2 == 1) + // If (v11 % 2 == 1) // v44 = v3[v11] BASIC_BLOCK(6U, 7U) { @@ -708,7 +708,7 @@ TEST_F(LSETest, NestedLoopElimination) INST(7U, Opcode::LoadObject).ref().Inputs(0U).TypeId(195U); INST(10U, Opcode::LenArray).s32().Inputs(7U); } - // for (v14 = 0, v14 < lenarr(v7), v14++) + // For (v14 = 0, v14 < lenarr(v7), v14++) BASIC_BLOCK(8U, 3U, 4U) { INST(14U, Opcode::Phi).s32().Inputs({{2U, 11U}, {5U, 63U}}); @@ -725,7 +725,7 @@ TEST_F(LSETest, NestedLoopElimination) INST(66U, Opcode::Compare).b().CC(CC_GE).Inputs(65U, 11U); INST(67U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(66U); } - // for (v35 = 0, v35 < lenarr(v25), v35++) + // For (v35 = 0, v35 < lenarr(v25), v35++) // v32 += (v7[v14] * v25[v35]) BASIC_BLOCK(6U, 5U, 6U) { @@ -765,7 +765,7 @@ TEST_F(LSETest, NestedLoopElimination) INST(7U, Opcode::LoadObject).ref().Inputs(0U).TypeId(195U); INST(10U, Opcode::LenArray).s32().Inputs(7U); } - // for (v14 = 0, v14 < lenarr(v7), v14++) + // For (v14 = 0, v14 < lenarr(v7), v14++) BASIC_BLOCK(8U, 3U, 4U) { INST(14U, Opcode::Phi).s32().Inputs({{2U, 11U}, {5U, 63U}}); @@ -782,7 +782,7 @@ TEST_F(LSETest, NestedLoopElimination) INST(66U, Opcode::Compare).b().CC(CC_GE).Inputs(65U, 11U); INST(67U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(66U); } - // for (v35 = 0, v35 < lenarr(v25), v35++) + // For (v35 = 0, v35 < lenarr(v25), v35++) // v32 += (v7[v14] * v25[v35]) BASIC_BLOCK(6U, 5U, 6U) { @@ -827,7 +827,7 @@ TEST_F(LSETest, LoopWithMayAliases) INST(45U, Opcode::Compare).b().CC(CC_GE).Inputs(1U, 9U); INST(46U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(45U); } - // for (v12 = 0, v12 < lenarr(v0[0]), v12++) + // For (v12 = 0, v12 < lenarr(v0[0]), v12++) // v13 += v0[0][0] + v0[1][0] BASIC_BLOCK(4U, 3U, 4U) { @@ -862,7 +862,7 @@ TEST_F(LSETest, LoopWithMayAliases) INST(45U, Opcode::Compare).b().CC(CC_GE).Inputs(1U, 9U); INST(46U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(45U); } - // for (v12 = 0, v12 < lenarr(v0[0]), v12++) + // For (v12 = 0, v12 < lenarr(v0[0]), v12++) // v13 += v0[0][0] + v0[1][0] BASIC_BLOCK(4U, 3U, 4U) { @@ -903,7 +903,7 @@ TEST_F(LSETest, CombinedWithLoop) INST(45U, Opcode::Compare).b().CC(CC_GE).Inputs(1U, 9U); INST(46U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(45U); } - // for (v12 = 0, v12 < lenarr(v0[0]), v12++) + // For (v12 = 0, v12 < lenarr(v0[0]), v12++) // v13 += v0[0][0] + v0[0][0] BASIC_BLOCK(4U, 3U, 4U) { @@ -938,7 +938,7 @@ TEST_F(LSETest, CombinedWithLoop) INST(45U, Opcode::Compare).b().CC(CC_GE).Inputs(1U, 9U); INST(46U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(45U); } - // for (v12 = 0, v12 < lenarr(v0[0]), v12++) + // For (v12 = 0, v12 < lenarr(v0[0]), v12++) // v13 += v0[0][0] + v0[0][0] BASIC_BLOCK(4U, 3U, 4U) { @@ -1237,7 +1237,7 @@ TEST_F(LSETest, LoopWithOverwrite) INST(31U, Opcode::Compare).b().CC(CC_GE).Inputs(30U, 7U); INST(32U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(31U); } - // for (v10 = 0, v10 < lenarr(v3), v10++) + // For (v10 = 0, v10 < lenarr(v3), v10++) // v3 = v3[v10] BASIC_BLOCK(4U, 3U, 4U) { @@ -1273,7 +1273,7 @@ TEST_F(LSETest, LoopWithOverwrite) INST(31U, Opcode::Compare).b().CC(CC_GE).Inputs(30U, 7U); INST(32U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(31U); } - // for (v10 = 0, v10 < lenarr(v3), v10++) + // For (v10 = 0, v10 < lenarr(v3), v10++) // v3 = v3[v10] BASIC_BLOCK(4U, 3U, 4U) { @@ -2300,7 +2300,7 @@ TEST_F(LSETest, InnerOverwrite) INST(4U, Opcode::LoadObject).ref().Inputs(0U).TypeId(194U); INST(7U, Opcode::LenArray).s32().Inputs(4U); } - // for (v11 = 0, v11 < lenarr(v4), v11++) + // For (v11 = 0, v11 < lenarr(v4), v11++) BASIC_BLOCK(8U, 3U, 4U) { INST(11U, Opcode::Phi).s32().Inputs({{2U, 8U}, {5U, 63U}}); @@ -2316,7 +2316,7 @@ TEST_F(LSETest, InnerOverwrite) INST(66U, Opcode::Compare).b().CC(CC_GE).Inputs(65U, 8U); INST(67U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(66U); } - // for (v28 = 0, v28 < lenarr(v1), v28++) + // For (v28 = 0, v28 < lenarr(v1), v28++) // v4 = v28[v4[v11]] BASIC_BLOCK(6U, 5U, 6U) { @@ -2363,7 +2363,7 @@ TEST_F(LSETest, OuterOverwrite) INST(4U, Opcode::LoadObject).ref().Inputs(0U).TypeId(194U); INST(7U, Opcode::LenArray).s32().Inputs(4U); } - // for (v11 = 0, v11 < lenarr(v4), v11++) + // For (v11 = 0, v11 < lenarr(v4), v11++) BASIC_BLOCK(8U, 3U, 4U) { INST(11U, Opcode::Phi).s32().Inputs({{2U, 8U}, {5U, 55U}}); @@ -2378,7 +2378,7 @@ TEST_F(LSETest, OuterOverwrite) INST(58U, Opcode::Compare).b().CC(CC_GE).Inputs(57U, 8U); INST(59U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(58U); } - // for (v28 = 0, v28 < lenarr(v4), v28++) + // For (v28 = 0, v28 < lenarr(v4), v28++) // v12 += v4[v28] BASIC_BLOCK(6U, 5U, 6U) { @@ -2417,7 +2417,7 @@ TEST_F(LSETest, OuterOverwrite) INST(4U, Opcode::LoadObject).ref().Inputs(0U).TypeId(194U); INST(7U, Opcode::LenArray).s32().Inputs(4U); } - // for (v11 = 0, v11 < lenarr(v4), v11++) + // For (v11 = 0, v11 < lenarr(v4), v11++) BASIC_BLOCK(8U, 3U, 4U) { INST(11U, Opcode::Phi).s32().Inputs({{2U, 8U}, {5U, 55U}}); @@ -2433,7 +2433,7 @@ TEST_F(LSETest, OuterOverwrite) INST(58U, Opcode::Compare).b().CC(CC_GE).Inputs(57U, 8U); INST(59U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(58U); } - // for (v28 = 0, v28 < lenarr(v4), v28++) + // For (v28 = 0, v28 < lenarr(v4), v28++) // v12 += v4[v28] BASIC_BLOCK(6U, 5U, 6U) { @@ -2481,7 +2481,7 @@ TEST_F(LSETest, PhiCandOverCall) INST(31U, Opcode::Compare).b().CC(CC_GE).Inputs(30U, 7U); INST(32U, Opcode::IfImm).SrcType(DataType::BOOL).CC(CC_NE).Imm(0x0U).Inputs(31U); } - // for (v10 = 0, v10 < lenarr(v3), ++v10) + // For (v10 = 0, v10 < lenarr(v3), ++v10) // v11 += v3[v10] BASIC_BLOCK(4U, 3U, 4U) { diff --git a/static_core/compiler/tests/memory_barriers_test.cpp b/static_core/compiler/tests/memory_barriers_test.cpp index 95ac93910c..6f6bbfe3f6 100644 --- a/static_core/compiler/tests/memory_barriers_test.cpp +++ b/static_core/compiler/tests/memory_barriers_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/memory_coalescing_test.cpp b/static_core/compiler/tests/memory_coalescing_test.cpp index 14377b80c3..0278f44a49 100644 --- a/static_core/compiler/tests/memory_coalescing_test.cpp +++ b/static_core/compiler/tests/memory_coalescing_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/method_properties_test.cpp b/static_core/compiler/tests/method_properties_test.cpp index 1f1862d564..96014c5394 100644 --- a/static_core/compiler/tests/method_properties_test.cpp +++ b/static_core/compiler/tests/method_properties_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/monitor_analysis_test.cpp b/static_core/compiler/tests/monitor_analysis_test.cpp index 03624dd506..f169f15a13 100644 --- a/static_core/compiler/tests/monitor_analysis_test.cpp +++ b/static_core/compiler/tests/monitor_analysis_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/move_constants_test.cpp b/static_core/compiler/tests/move_constants_test.cpp index e90bc0c4b2..b4f72141eb 100644 --- a/static_core/compiler/tests/move_constants_test.cpp +++ b/static_core/compiler/tests/move_constants_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/osr_test.cpp b/static_core/compiler/tests/osr_test.cpp index 332637d8fc..23148782b1 100644 --- a/static_core/compiler/tests/osr_test.cpp +++ b/static_core/compiler/tests/osr_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -208,7 +208,7 @@ TEST_F(OsrTest, OsrAfterIFrameRestoreAccAfterVoid) runner.GetCompilerOptions().SetCompilerNonOptimizing(true); ScopeEvents scope_events; - runner.Run(OSR_AFTER_IFRAME_RESTORE_ACC_AFTER_VOID, (ssize_t)0U); + runner.Run(OSR_AFTER_IFRAME_RESTORE_ACC_AFTER_VOID, static_cast(0U)); auto events = Events::CastTo(); auto osr_events = events->Select(); ASSERT_EQ(osr_events.size(), 1U); diff --git a/static_core/compiler/tests/panda_runner.cpp b/static_core/compiler/tests/panda_runner.cpp index 29542712d8..327ac00d8f 100644 --- a/static_core/compiler/tests/panda_runner.cpp +++ b/static_core/compiler/tests/panda_runner.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/panda_runner.h b/static_core/compiler/tests/panda_runner.h index 563c125ce6..774107fd7e 100644 --- a/static_core/compiler/tests/panda_runner.h +++ b/static_core/compiler/tests/panda_runner.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/peepholes_test.cpp b/static_core/compiler/tests/peepholes_test.cpp index 5ad119d3db..2a40e4eda9 100644 --- a/static_core/compiler/tests/peepholes_test.cpp +++ b/static_core/compiler/tests/peepholes_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/profiling_runner_test.cpp b/static_core/compiler/tests/profiling_runner_test.cpp index 56335c91b6..3bc85e3e72 100644 --- a/static_core/compiler/tests/profiling_runner_test.cpp +++ b/static_core/compiler/tests/profiling_runner_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,38 +22,38 @@ class ProfilingRunnerTest : public testing::Test {}; static constexpr auto SOURCE = R"( .function void main() { - movi v0, 0x2 - movi v1, 0x0 - jump_label_1: lda v1 - jge v0, jump_label_0 - call.short foo - inci v1, 0x1 - jmp jump_label_1 - jump_label_0: return.void + movi v0, 0x2 + movi v1, 0x0 + jump_label_1: lda v1 + jge v0, jump_label_0 + call.short foo + inci v1, 0x1 + jmp jump_label_1 + jump_label_0: return.void } .function i32 foo() { - movi v0, 0x64 - movi v1, 0x0 - mov v2, v1 - jump_label_3: lda v2 - jge v0, jump_label_0 - lda v2 - modi 0x3 - jnez jump_label_1 - lda v1 - addi 0x2 - sta v3 - mov v1, v3 - jmp jump_label_2 - jump_label_1: lda v1 - addi 0x3 - sta v3 - mov v1, v3 - jump_label_2: inci v2, 0x1 - jmp jump_label_3 - jump_label_0: lda v1 - return + movi v0, 0x64 + movi v1, 0x0 + mov v2, v1 + jump_label_3: lda v2 + jge v0, jump_label_0 + lda v2 + modi 0x3 + jnez jump_label_1 + lda v1 + addi 0x2 + sta v3 + mov v1, v3 + jmp jump_label_2 + jump_label_1: lda v1 + addi 0x3 + sta v3 + mov v1, v3 + jump_label_2: inci v2, 0x1 + jmp jump_label_3 + jump_label_0: lda v1 + return } )"; diff --git a/static_core/compiler/tests/redundant_loop_elimination_test.cpp b/static_core/compiler/tests/redundant_loop_elimination_test.cpp index cb139396d9..d409ac9aca 100644 --- a/static_core/compiler/tests/redundant_loop_elimination_test.cpp +++ b/static_core/compiler/tests/redundant_loop_elimination_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -647,7 +647,7 @@ TEST_F(RedundantLoopEliminationTest, PotentiallyInfinitLoop) { // This is potentially infinite loop. We can't remove it. // public static void loop1(boolean incoming) { - // while (incoming) {} + // While (incoming) {} // } GRAPH(GetGraph()) { diff --git a/static_core/compiler/tests/reg_alloc_common_test.cpp b/static_core/compiler/tests/reg_alloc_common_test.cpp index 642b248060..fa3c47edc5 100644 --- a/static_core/compiler/tests/reg_alloc_common_test.cpp +++ b/static_core/compiler/tests/reg_alloc_common_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/reg_alloc_graph_coloring_test.cpp b/static_core/compiler/tests/reg_alloc_graph_coloring_test.cpp index 918a2aeb87..e3a62175e6 100644 --- a/static_core/compiler/tests/reg_alloc_graph_coloring_test.cpp +++ b/static_core/compiler/tests/reg_alloc_graph_coloring_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/reg_alloc_interference_graph_test.cpp b/static_core/compiler/tests/reg_alloc_interference_graph_test.cpp index 74feb91196..9e0da250e3 100644 --- a/static_core/compiler/tests/reg_alloc_interference_graph_test.cpp +++ b/static_core/compiler/tests/reg_alloc_interference_graph_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/reg_alloc_linear_scan_test.cpp b/static_core/compiler/tests/reg_alloc_linear_scan_test.cpp index 99ff47d7dc..19e62d82f0 100644 --- a/static_core/compiler/tests/reg_alloc_linear_scan_test.cpp +++ b/static_core/compiler/tests/reg_alloc_linear_scan_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/reg_alloc_resolver_test.cpp b/static_core/compiler/tests/reg_alloc_resolver_test.cpp index 6f42791d43..d8e546a9aa 100644 --- a/static_core/compiler/tests/reg_alloc_resolver_test.cpp +++ b/static_core/compiler/tests/reg_alloc_resolver_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/reg_alloc_verifier_test.cpp b/static_core/compiler/tests/reg_alloc_verifier_test.cpp index 3dc2457878..71dd1bd97c 100644 --- a/static_core/compiler/tests/reg_alloc_verifier_test.cpp +++ b/static_core/compiler/tests/reg_alloc_verifier_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/rpo_test.cpp b/static_core/compiler/tests/rpo_test.cpp index c1225638e4..f4ece9440e 100644 --- a/static_core/compiler/tests/rpo_test.cpp +++ b/static_core/compiler/tests/rpo_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/scheduler_test.cpp b/static_core/compiler/tests/scheduler_test.cpp index 5edd2687f0..61625bc9e7 100644 --- a/static_core/compiler/tests/scheduler_test.cpp +++ b/static_core/compiler/tests/scheduler_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/spill_fill_encoder_test.cpp b/static_core/compiler/tests/spill_fill_encoder_test.cpp index ff047253c9..632daf61c7 100644 --- a/static_core/compiler/tests/spill_fill_encoder_test.cpp +++ b/static_core/compiler/tests/spill_fill_encoder_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/split_resolver_test.cpp b/static_core/compiler/tests/split_resolver_test.cpp index 1692ab39d4..6bfaac1044 100644 --- a/static_core/compiler/tests/split_resolver_test.cpp +++ b/static_core/compiler/tests/split_resolver_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,15 +20,15 @@ #include "compiler/optimizer/analysis/liveness_analyzer.h" // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define INITIALIZE_GRAPHS(G_BEFORE, G_AFTER) \ - for (auto __after_resolve : {true, false}) \ - if (auto ___g = (__after_resolve ? G_AFTER : G_BEFORE)) \ +#define INITIALIZE_GRAPHS(G_BEFORE, G_AFTER) \ + for (auto __after_resolve : {true, false}) \ + if (auto ___g = (__after_resolve ? (G_AFTER) : (G_BEFORE))) \ GRAPH(___g) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define AFTER_SPLIT_RESOLUTION(OP) \ if (__after_resolve) \ - OP + (OP) namespace panda::compiler { class SplitResolverTest : public GraphTest { diff --git a/static_core/compiler/tests/try_catch_resolving_test.cpp b/static_core/compiler/tests/try_catch_resolving_test.cpp index e64fc31dd7..fac45f30a4 100644 --- a/static_core/compiler/tests/try_catch_resolving_test.cpp +++ b/static_core/compiler/tests/try_catch_resolving_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -50,10 +50,9 @@ TEST_F(TryCatchResolvingTest, ThrowNewObject) try_begin: throw v0 ldai 2 -try_end: +try_end: return - catch_block1_begin: ldai 0 return @@ -106,7 +105,6 @@ TEST_F(TryCatchResolvingTest, RemoveAllCatchHandlers) try_end: return - catch_block1: ldai 0 return @@ -122,7 +120,6 @@ TEST_F(TryCatchResolvingTest, RemoveAllCatchHandlers) .catch E1, try_begin, try_end, catch_block1 .catch E2, try_begin, try_end, catch_block2 .catch E3, try_begin, try_end, catch_block3 - } )"; diff --git a/static_core/compiler/tests/unit_test.cpp b/static_core/compiler/tests/unit_test.cpp index 08e68b4963..2ada7a5b60 100644 --- a/static_core/compiler/tests/unit_test.cpp +++ b/static_core/compiler/tests/unit_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/unit_test.h b/static_core/compiler/tests/unit_test.h index 6d84fdfbbc..460fef0afa 100644 --- a/static_core/compiler/tests/unit_test.h +++ b/static_core/compiler/tests/unit_test.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/vixl_exec_module.h b/static_core/compiler/tests/vixl_exec_module.h index 2263a6ac9c..83a142354c 100644 --- a/static_core/compiler/tests/vixl_exec_module.h +++ b/static_core/compiler/tests/vixl_exec_module.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -43,27 +43,27 @@ T CutValue(uint64_t data, DataType::Type type) ASSERT(false); return -1; case (DataType::BOOL): - return (T)((bool)(data)); + return static_cast((static_cast(data))); case (DataType::UINT8): - return (T)((uint8_t)(data)); + return static_cast((static_cast(data))); case (DataType::INT8): - return (T)((int8_t)(data)); + return static_cast((static_cast(data))); case (DataType::UINT16): - return (T)((uint16_t)(data)); + return static_cast((static_cast(data))); case (DataType::INT16): - return (T)((int16_t)(data)); + return static_cast((static_cast(data))); case (DataType::UINT32): - return (T)((uint32_t)(data)); + return static_cast((static_cast(data))); case (DataType::INT32): - return (T)((int32_t)(data)); + return static_cast((static_cast(data))); case (DataType::UINT64): - return (T)((uint64_t)(data)); + return static_cast((static_cast(data))); case (DataType::INT64): - return (T)((int64_t)(data)); + return static_cast((static_cast(data))); case (DataType::FLOAT32): - return (T)((float)(data)); + return static_cast((static_cast(data))); case (DataType::FLOAT64): - return (T)((double)(data)); + return static_cast((static_cast(data))); } return 0; } diff --git a/static_core/compiler/tests/vn_test.cpp b/static_core/compiler/tests/vn_test.cpp index 2e59e12c36..cdfb61e993 100644 --- a/static_core/compiler/tests/vn_test.cpp +++ b/static_core/compiler/tests/vn_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/x86/asmjit_test.cpp b/static_core/compiler/tests/x86/asmjit_test.cpp index b2272d05e4..bed118d881 100644 --- a/static_core/compiler/tests/x86/asmjit_test.cpp +++ b/static_core/compiler/tests/x86/asmjit_test.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tests/x86/asmjit_test.h b/static_core/compiler/tests/x86/asmjit_test.h index febd9dd33e..7218a62cdb 100644 --- a/static_core/compiler/tests/x86/asmjit_test.h +++ b/static_core/compiler/tests/x86/asmjit_test.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/aotdump/BUILD.gn b/static_core/compiler/tools/aotdump/BUILD.gn index 2a9853e84c..e30143f704 100644 --- a/static_core/compiler/tools/aotdump/BUILD.gn +++ b/static_core/compiler/tools/aotdump/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/aotdump/CMakeLists.txt b/static_core/compiler/tools/aotdump/CMakeLists.txt index 481e4de494..fb0f7917d0 100644 --- a/static_core/compiler/tools/aotdump/CMakeLists.txt +++ b/static_core/compiler/tools/aotdump/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/aotdump/aotdump.cpp b/static_core/compiler/tools/aotdump/aotdump.cpp index 90afc6ee7e..11fb003348 100644 --- a/static_core/compiler/tools/aotdump/aotdump.cpp +++ b/static_core/compiler/tools/aotdump/aotdump.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/aotdump/aotdump.yaml b/static_core/compiler/tools/aotdump/aotdump.yaml index 591cf7a15b..88f6e77c26 100644 --- a/static_core/compiler/tools/aotdump/aotdump.yaml +++ b/static_core/compiler/tools/aotdump/aotdump.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/debug/jit_writer.cpp b/static_core/compiler/tools/debug/jit_writer.cpp index 653f687d25..cc69c73ce9 100644 --- a/static_core/compiler/tools/debug/jit_writer.cpp +++ b/static_core/compiler/tools/debug/jit_writer.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/debug/jit_writer.h b/static_core/compiler/tools/debug/jit_writer.h index 892142372a..bf1671f6f2 100644 --- a/static_core/compiler/tools/debug/jit_writer.h +++ b/static_core/compiler/tools/debug/jit_writer.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/BUILD.gn b/static_core/compiler/tools/paoc/BUILD.gn index cb256517c9..209ebd670c 100644 --- a/static_core/compiler/tools/paoc/BUILD.gn +++ b/static_core/compiler/tools/paoc/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/CMakeLists.txt b/static_core/compiler/tools/paoc/CMakeLists.txt index fb99397efb..bd07c21fe2 100644 --- a/static_core/compiler/tools/paoc/CMakeLists.txt +++ b/static_core/compiler/tools/paoc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc.cpp b/static_core/compiler/tools/paoc/paoc.cpp index d198d85bc8..677d361cb0 100644 --- a/static_core/compiler/tools/paoc/paoc.cpp +++ b/static_core/compiler/tools/paoc/paoc.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc.h b/static_core/compiler/tools/paoc/paoc.h index dcae1e2000..30e6783ff4 100644 --- a/static_core/compiler/tools/paoc/paoc.h +++ b/static_core/compiler/tools/paoc/paoc.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc.yaml b/static_core/compiler/tools/paoc/paoc.yaml index f63a15ed7f..8b1b26a759 100644 --- a/static_core/compiler/tools/paoc/paoc.yaml +++ b/static_core/compiler/tools/paoc/paoc.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc_clusters.h b/static_core/compiler/tools/paoc/paoc_clusters.h index d057e70761..622d9b5972 100644 --- a/static_core/compiler/tools/paoc/paoc_clusters.h +++ b/static_core/compiler/tools/paoc/paoc_clusters.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc_llvm.cpp b/static_core/compiler/tools/paoc/paoc_llvm.cpp index c906ccb2a6..9ef5aab03a 100644 --- a/static_core/compiler/tools/paoc/paoc_llvm.cpp +++ b/static_core/compiler/tools/paoc/paoc_llvm.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/compiler/tools/paoc/paoc_llvm.h b/static_core/compiler/tools/paoc/paoc_llvm.h index c374a88fe3..dcd9425e04 100644 --- a/static_core/compiler/tools/paoc/paoc_llvm.h +++ b/static_core/compiler/tools/paoc/paoc_llvm.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/accumulators.h b/static_core/disassembler/accumulators.h index 96b7af1c27..b976f83e76 100644 --- a/static_core/disassembler/accumulators.h +++ b/static_core/disassembler/accumulators.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/disasm.cpp b/static_core/disassembler/disasm.cpp index 3a96e5bd46..0cafb02a12 100644 --- a/static_core/disassembler/disasm.cpp +++ b/static_core/disassembler/disasm.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/disasm_backed_debug_info_extractor.cpp b/static_core/disassembler/disasm_backed_debug_info_extractor.cpp index 8cc18f6b5e..2139499e6e 100644 --- a/static_core/disassembler/disasm_backed_debug_info_extractor.cpp +++ b/static_core/disassembler/disasm_backed_debug_info_extractor.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/disasm_backed_debug_info_extractor.h b/static_core/disassembler/disasm_backed_debug_info_extractor.h index 1ed0730f02..43bed410da 100644 --- a/static_core/disassembler/disasm_backed_debug_info_extractor.h +++ b/static_core/disassembler/disasm_backed_debug_info_extractor.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/disassembler.cpp b/static_core/disassembler/disassembler.cpp index 17b5d0ec01..caff814de1 100644 --- a/static_core/disassembler/disassembler.cpp +++ b/static_core/disassembler/disassembler.cpp @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/disassembler/disassembler.h b/static_core/disassembler/disassembler.h index d751e0c687..4e79045e23 100644 --- a/static_core/disassembler/disassembler.h +++ b/static_core/disassembler/disassembler.h @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/static_core/plugins/ets/compiler/optimizer/ets_intrinsics_peephole.cpp b/static_core/plugins/ets/compiler/optimizer/ets_intrinsics_peephole.cpp index ff48dfb4ba..bc9ae7da0d 100644 --- a/static_core/plugins/ets/compiler/optimizer/ets_intrinsics_peephole.cpp +++ b/static_core/plugins/ets/compiler/optimizer/ets_intrinsics_peephole.cpp @@ -27,7 +27,6 @@ bool Peepholes::PeepholeStringEquals([[maybe_unused]] GraphVisitor *v, Intrinsic auto input0 = intrinsic->GetInput(0).GetInst(); auto input1 = intrinsic->GetInput(1).GetInst(); - if (input0->IsNullPtr() || input1->IsNullPtr()) { auto bb = intrinsic->GetBasicBlock(); auto graph = bb->GetGraph();