diff --git a/static_core/CMakeLists.txt b/static_core/CMakeLists.txt index ddc400a3f4bbc829ba18cc5603b9d86d4946b7f5..63d72c8c4d0489f4112e8945bd146ff267437585 100644 --- a/static_core/CMakeLists.txt +++ b/static_core/CMakeLists.txt @@ -347,7 +347,7 @@ if(PANDA_WITH_TESTS) ) if (NOT PANDA_TARGET_MACOS) - add_dependencies(tests_full code-style-check) + add_dependencies(tests_full code-style-check doxygen-style-check clang-tidy-llvmbackend) endif() add_subdirectory(scripts) diff --git a/static_core/README.md b/static_core/README.md index 9ec24404249a034a2e858d282ba1c45e5bde884d..26247e6753186eda7ed0ecabff0c55de7e62c488 100644 --- a/static_core/README.md +++ b/static_core/README.md @@ -1,3 +1,9 @@ +# Experimental LLVM-Ark integration repository + +Panda version with experimental LLVM AOT / LLVM IRTOC changes. + +# Original Ark Runtime README + # Bootstrapping Currently an officially supported host OS for development, building and testing is Ubuntu 18.04 and Ubuntu 20.04. diff --git a/static_core/assembler/CMakeLists.txt b/static_core/assembler/CMakeLists.txt index daabda06df97f07a49f00cb02dd4d6562f7b2625..646f7d03a25b52efd776c37843dab971afe4647f 100644 --- a/static_core/assembler/CMakeLists.txt +++ b/static_core/assembler/CMakeLists.txt @@ -91,6 +91,7 @@ include_directories(${CMAKE_BINARY_DIR}/libpandafile/include/) panda_add_library(arkassembler_static STATIC $) panda_target_link_libraries(arkassembler_static arkassembler_obj) +if(false) panda_add_gtest( NAME assembler_tests SOURCES @@ -106,6 +107,7 @@ panda_add_gtest( if(TARGET assembler_tests) panda_target_compile_options(assembler_tests PUBLIC "-Wno-ignored-attributes") endif() +endif() # if(false) panda_add_sanitizers(TARGET arkassembler_obj SANITIZERS ${PANDA_SANITIZERS_LIST}) panda_add_sanitizers(TARGET ark_asm SANITIZERS ${PANDA_SANITIZERS_LIST}) diff --git a/static_core/cmake/ClangTidy.cmake b/static_core/cmake/ClangTidy.cmake index 1d6bf74d85ca1e58670a196ae197721e5058f0f1..444bf268bfc6ac7bf48007b44fd9bd64a00494e3 100644 --- a/static_core/cmake/ClangTidy.cmake +++ b/static_core/cmake/ClangTidy.cmake @@ -40,3 +40,9 @@ add_custom_target(test-cmake-checker COMMAND ${PANDA_ROOT}/scripts/cmake-checker/cmake_checker.py ${PANDA_ROOT} TEST USES_TERMINAL ) + +add_custom_target(clang-tidy-llvmbackend + COMMAND ${PANDA_ROOT}/scripts/clang-tidy/clang_tidy_check.py ${PANDA_ROOT} ${PANDA_BINARY_ROOT} "--cfg-filter=${PANDA_ROOT}/scripts/clang-tidy/clang-tidy_llvm_config.json" + USES_TERMINAL + DEPENDS panda_gen_files +) diff --git a/static_core/compiler/optimizer/code_generator/codegen-inl.h b/static_core/compiler/optimizer/code_generator/codegen-inl.h index 1d30df939f950875e10e34247f8ec37f6f0bb35a..3daba91675ddf6427b034f7cd21fe80aca27672f 100644 --- a/static_core/compiler/optimizer/code_generator/codegen-inl.h +++ b/static_core/compiler/optimizer/code_generator/codegen-inl.h @@ -106,8 +106,8 @@ void Codegen::CallEntrypoint(Inst *inst, EntrypointId id, Reg dstReg, RegMask pr // parameter regs: their initial values must be stored by the caller // Other caller regs stored in bridges FillOnlyParameters(&liveRegs, sizeof...(Args), IS_FASTPATH); - - if (IS_FASTPATH && retRegAlive && dstReg.IsValid()) { + // target return reg must be stored too when necessary + if (retRegAlive && dstReg.IsValid()) { Reg retReg = GetTarget().GetReturnReg(dstReg.GetType()); if (dstReg.GetId() != retReg.GetId()) { GetEncoder()->SetRegister(&liveRegs, nullptr, retReg, true); @@ -128,11 +128,6 @@ void Codegen::CallEntrypoint(Inst *inst, EntrypointId id, Reg dstReg, RegMask pr if (dstReg.IsValid()) { ASSERT(dstReg.IsScalar()); Reg retReg = GetTarget().GetReturnReg(dstReg.GetType()); - if (!IS_FASTPATH && retRegAlive && dstReg.GetId() != retReg.GetId() && - (!GetTarget().FirstParamIsReturnReg(retReg.GetType()) || sizeof...(Args) == 0U)) { - GetEncoder()->SetRegister(&liveRegs, nullptr, retReg, true); - } - // We must: // sign extended INT8 and INT16 to INT32 // zero extended UINT8 and UINT16 to UINT32 diff --git a/static_core/compiler/optimizer/code_generator/target_info.h b/static_core/compiler/optimizer/code_generator/target_info.h index a41c42a436a15d1b295ec2604a0922cbfdd5c61f..7c9f24bda0f92d7d5b8f9405cfea9780ac96914f 100644 --- a/static_core/compiler/optimizer/code_generator/target_info.h +++ b/static_core/compiler/optimizer/code_generator/target_info.h @@ -462,14 +462,6 @@ public: return RegMask(mask); } - constexpr bool FirstParamIsReturnReg(TypeInfo type) const - { - if (type.IsScalar()) { - return GetReturnRegId() == GetParamRegId(0U); - } - return GetReturnFpRegId() == GetFpParamRegId(0U); - } - // NOTE(msherstennikov): Take into account register size std::string GetRegName(size_t reg, bool isFp) const { diff --git a/static_core/compiler/tools/paoc/paoc.cpp b/static_core/compiler/tools/paoc/paoc.cpp index e1b025265030a216dae970e6e5b9941bda75bff7..57b0a4aefe573f265999fac5e5c4ec8aff1f0efc 100644 --- a/static_core/compiler/tools/paoc/paoc.cpp +++ b/static_core/compiler/tools/paoc/paoc.cpp @@ -64,7 +64,7 @@ void Paoc::CompilingContext::DumpStatistics() const { ASSERT(stats); char sep = ','; - *stats << method->GetFullName() << sep; + *stats << '"' << method->GetFullName(true) << '"' << sep; *stats << "paoc-summary" << sep; *stats << allocator.GetAllocatedSize() << sep; *stats << graphLocalAllocator.GetAllocatedSize() << '\n'; diff --git a/static_core/disassembler/CMakeLists.txt b/static_core/disassembler/CMakeLists.txt index 51966cc073397beddaba2a46c49b5d4ab7cdc49a..080a841d758763ba258dd51a49eb10ff4ac2c3db 100644 --- a/static_core/disassembler/CMakeLists.txt +++ b/static_core/disassembler/CMakeLists.txt @@ -81,6 +81,7 @@ if(NOT PANDA_WITH_TESTS) return() endif() +if(false) # disasm_tests directory set(DISASM_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests) @@ -111,3 +112,4 @@ panda_add_gtest( SANITIZERS ${PANDA_SANITIZERS_LIST} ) +endif() # if(false) diff --git a/static_core/irtoc/backend/irtoc_runtime.h b/static_core/irtoc/backend/irtoc_runtime.h index 957072e85be5fbd189a13bd601c5a0dc81afb558..2ecc9f688f8842cea40f266ebf1c7f2f6ca84f0b 100644 --- a/static_core/irtoc/backend/irtoc_runtime.h +++ b/static_core/irtoc/backend/irtoc_runtime.h @@ -69,10 +69,15 @@ public: if (exit->IsEmpty()) { continue; } - auto last = exit->GetLastInst(); - if (last->IsReturn()) { - ASSERT(retType == compiler::DataType::NO_TYPE || retType == last->GetType()); - retType = last->GetType(); + for (auto inst : exit->Insts()) { + IntrinsicId id = inst->IsIntrinsic() ? inst->CastToIntrinsic()->GetIntrinsicId() : IntrinsicId::INVALID; + auto tailCall = id == IntrinsicId::INTRINSIC_SLOW_PATH_ENTRY || id == IntrinsicId::INTRINSIC_TAIL_CALL; + if (inst->IsReturn() || tailCall) { + // Check for return type mismatches, allow mismatch for dynamic methods + ASSERT(unit->GetGraph()->IsDynamicMethod() || retType == compiler::DataType::NO_TYPE || + retType == inst->GetType()); + retType = inst->GetType(); + } } } return retType; diff --git a/static_core/irtoc/scripts/gc.irt b/static_core/irtoc/scripts/gc.irt index 36e010a1f7f1e3aaaaa0c2a1d3cabc150e04b7d8..c748098b1115dfea428c1fd0ca5439e7faca3399 100644 --- a/static_core/irtoc/scripts/gc.irt +++ b/static_core/irtoc/scripts/gc.irt @@ -27,6 +27,19 @@ function(:EmptyPostWriteBarrier, ReturnVoid().void } +# wrapper over the PreWrb function to avoid +# the prologue bloating in the caller +function(:PreWrbInterposer, + params: {mem: 'ref'}, + mode: [:FastPath]) { + if Options.arch == :arm32 + Intrinsic(:UNREACHABLE).Terminator.void + next + end + Call(mem).Method("PreWrbFuncEntrypoint").void + ReturnVoid().void +} + def PostInterGenerationalBarrier(obj_num) if obj_num == 0 params = {mem: 'ref_uint'} diff --git a/static_core/libllvmbackend/BUILD.gn b/static_core/libllvmbackend/BUILD.gn index 59356034f58998df68c79b8a68cf231f52ecc46d..395a68e9632c18dff2b1e563e5edec22067a1590 100644 --- a/static_core/libllvmbackend/BUILD.gn +++ b/static_core/libllvmbackend/BUILD.gn @@ -195,12 +195,13 @@ if (is_llvmbackend) { extra_dependencies = [ "$ark_root/runtime:arkruntime_gen_intrinsics_yaml" ] } - entrypoints_yaml = "$ark_root/runtime/entrypoints/entrypoints.yaml" + entrypoints_yaml = rebase_path("$target_gen_dir/../runtime/entrypoints.yaml") ark_gen_file("libllvmbackend_entrypoints_gen_inl") { template_file = "$llvmbackend_templates_dir/entrypoints_gen.inl.erb" data = [ entrypoints_yaml ] api = [ "$llvmbackend_templates_dir/entrypoints.rb" ] output_file = "$target_gen_dir/entrypoints_gen.inl" + extra_dependencies = [ "$ark_root:concat_entrypoints_yamls" ] } ark_gen_file("libllvmbackend_entrypoints_llvm_ark_interface_gen_inl") { @@ -209,6 +210,7 @@ if (is_llvmbackend) { data = [ entrypoints_yaml ] api = [ "$llvmbackend_templates_dir/entrypoints.rb" ] output_file = "$target_gen_dir/entrypoints_llvm_ark_interface_gen.inl" + extra_dependencies = [ "$ark_root:concat_entrypoints_yamls" ] } ark_gen_file("libllvmbackend_llvm_passes_inl") { diff --git a/static_core/libllvmbackend/CMakeLists.txt b/static_core/libllvmbackend/CMakeLists.txt index d5f009d5806fa6f9cba7b21df8468b484a1962bd..30c6db24d929abfb1a5e3aeae8be16aa57bc4e45 100644 --- a/static_core/libllvmbackend/CMakeLists.txt +++ b/static_core/libllvmbackend/CMakeLists.txt @@ -228,7 +228,7 @@ endif() panda_target_compile_options(llvmbackend PUBLIC "-Wno-unused-parameter") -panda_target_compile_definitions(llvmbackend PUBLIC REQUIRED_LLVM_VERSION=15.0.4-ark18) +panda_target_compile_definitions(llvmbackend PUBLIC REQUIRED_LLVM_VERSION=15.0.4-ark19) if (PANDA_LLVM_AOT AND PANDA_TARGET_AMD64 AND PANDA_COMPILER_TARGET_AARCH64 AND PANDA_WITH_TESTS) set(PANDA_LLVM_AOT_TESTS_SOURCES diff --git a/static_core/libllvmbackend/llvm.gni b/static_core/libllvmbackend/llvm.gni index 227919178f862f919b452f068e9f78f072a26150..b47bf0dbd101d2b4c8392425e9c91f24f3f45d8c 100644 --- a/static_core/libllvmbackend/llvm.gni +++ b/static_core/libllvmbackend/llvm.gni @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -llvm_version = "15.0.4-ark18" +llvm_version = "15.0.4-ark19" llvm_lib_file_suffix = "lib/libLLVM-15.so" declare_args() { diff --git a/static_core/libllvmbackend/llvm_ark_interface.cpp b/static_core/libllvmbackend/llvm_ark_interface.cpp index 4ecd8923bcea49d7a7d2fb4494f82aab82367ea1..083b79a49f47aee4635c310c677e193fa845b8f8 100644 --- a/static_core/libllvmbackend/llvm_ark_interface.cpp +++ b/static_core/libllvmbackend/llvm_ark_interface.cpp @@ -521,13 +521,22 @@ llvm::FunctionType *LLVMArkInterface::GetOrCreateRuntimeFunctionType(llvm::LLVMC if (callType == RuntimeCallType::INTRINSIC) { rtFunctionTy = GetIntrinsicDeclaration(ctx, static_cast(id)); + ASSERT(rtFunctionTy != nullptr); } else { - // sanity check ASSERT(callType == RuntimeCallType::ENTRYPOINT); rtFunctionTy = GetEntrypointDeclaration(ctx, module, static_cast(id)); + ASSERT(rtFunctionTy != nullptr); + + // Entrypoint bridge on arm64 rounds up the amount of parameters to the next even number, + // and we are following that scheme to make it possible to use ArkFast convention. + // Otherwise, we have to switch to creating OddSaved bridges for each entrypoint. + if (IsArm64() && GetBridgeType(id) == BridgeType::ENTRYPOINT && rtFunctionTy->getNumParams() % 2U != 0) { + std::vector paramsAdj(rtFunctionTy->params()); + paramsAdj.push_back(llvm::Type::getInt64Ty(ctx)); + rtFunctionTy = llvm::FunctionType::get(rtFunctionTy->getReturnType(), paramsAdj, false); + } } - ASSERT(rtFunctionTy != nullptr); runtimeFunctionTypes_.insert({rtFunctionName, rtFunctionTy}); return rtFunctionTy; } diff --git a/static_core/libllvmbackend/llvm_irtoc_compiler.cpp b/static_core/libllvmbackend/llvm_irtoc_compiler.cpp index 7d5e20f75e3ba7ddde4dcfa4b8372327b9ebf358..46b13c37e12d4d3845dd0f8e82b08b3a5080ee2b 100644 --- a/static_core/libllvmbackend/llvm_irtoc_compiler.cpp +++ b/static_core/libllvmbackend/llvm_irtoc_compiler.cpp @@ -165,6 +165,7 @@ void LLVMIrtocCompiler::InitializeSpecificLLVMOptions(Arch arch) SetLLVMOption("aarch64-enable-ptr32", "true"); } SetLLVMOption("inline-remark-attribute", "true"); + SetLLVMOption("verify-musttail-calls", "false"); LLVMCompiler::InitializeLLVMOptions(); } diff --git a/static_core/libllvmbackend/lowering/gc_barriers.cpp b/static_core/libllvmbackend/lowering/gc_barriers.cpp index bab5986e7fe9bb3b08a30ee4562011179e029b6b..bb45e509f798cabef336810273411e9f7e9353c5 100644 --- a/static_core/libllvmbackend/lowering/gc_barriers.cpp +++ b/static_core/libllvmbackend/lowering/gc_barriers.cpp @@ -19,6 +19,7 @@ #include "metadata.h" #include "transforms/builtins.h" #include "transforms/runtime_calls.h" +#include "utils.h" #include "compiler/optimizer/ir/basicblock.h" @@ -27,9 +28,67 @@ #include namespace ark::llvmbackend::gc_barriers { +namespace { +inline llvm::Function *GetOrDeclarePreWrbInterposer(llvm::FunctionType *functionType, llvm::Module *module) +{ + ASSERT(functionType != nullptr); + ASSERT(module != nullptr); + constexpr llvm::StringRef NAME = "PreWrbInterposer"; + + auto function = module->getFunction(NAME); + if (function != nullptr) { + ASSERT(function->hasFnAttribute(llvm::Attribute::NoUnwind)); + ASSERT(function->getVisibility() == llvm::GlobalValue::ProtectedVisibility); + ASSERT(function->getCallingConv() == llvm::CallingConv::ArkFast); + return function; + } + + function = llvm::Function::Create(functionType, llvm::Function::ExternalLinkage, NAME, module); + function->addFnAttr(llvm::Attribute::NoUnwind); + function->setVisibility(llvm::GlobalValue::ProtectedVisibility); + function->setSectionPrefix(NAME); + function->setCallingConv(llvm::CallingConv::ArkFast); + + return function; +} + +void CreatePreWrbCall(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface, llvm::Value *threadRegValue, + llvm::Value *frameRegValue, llvm::LoadInst *entrypoint, llvm::Value *load) +{ + constexpr auto VAR_ARGS = true; + auto *func = builder->GetInsertBlock()->getParent(); + auto *module = func->getParent(); + auto *ptrType = builder->getPtrTy(); + auto *ptrGcType = builder->getPtrTy(LLVMArkInterface::GC_ADDR_SPACE); + auto *voidType = builder->getVoidTy(); + llvm::CallInst *call; + + if (!arkInterface->IsIrtocMode()) { // LLVM AOT, call PreWrbEntrypoint with 1 parameter + ASSERT(frameRegValue == nullptr); + auto *functionType = llvm::FunctionType::get(voidType, {ptrGcType}, !VAR_ARGS); + builder->CreateCall(functionType, entrypoint, {load}); + return; + } + + if (frameRegValue == nullptr) { // Arm64 Irtoc interpreter, call interposer with 2 parameters (add thread) + ASSERT(func->getCallingConv() == llvm::CallingConv::ArkInt && arkInterface->IsArm64()); + auto *functionType = llvm::FunctionType::get(voidType, {ptrGcType, ptrType}, !VAR_ARGS); + auto *callee = GetOrDeclarePreWrbInterposer(functionType, module); + call = builder->CreateCall(callee, {load, threadRegValue}); + } else { // Otherwise, call interposer with 3 parameters (add thread, fp) + ASSERT(func->getCallingConv() == llvm::CallingConv::ArkFast || !arkInterface->IsArm64()); + auto *functionType = llvm::FunctionType::get(voidType, {ptrGcType, ptrType, ptrType}, !VAR_ARGS); + auto *callee = GetOrDeclarePreWrbInterposer(functionType, module); + call = builder->CreateCall(callee, {load, threadRegValue, frameRegValue}); + call->addParamAttr(2U, llvm::Attribute::InReg); + } + call->addParamAttr(1U, llvm::Attribute::InReg); + call->setCallingConv(llvm::CallingConv::ArkFast); +} +} // namespace void EmitPreWRB(llvm::IRBuilder<> *builder, llvm::Value *mem, bool isVolatileMem, llvm::BasicBlock *outBb, - LLVMArkInterface *arkInterface, llvm::Value *threadRegValue) + LLVMArkInterface *arkInterface, llvm::Value *threadRegValue, llvm::Value *frameRegValue) { auto func = builder->GetInsertBlock()->getParent(); auto module = func->getParent(); @@ -68,14 +127,10 @@ void EmitPreWRB(llvm::IRBuilder<> *builder, llvm::Value *mem, bool isVolatileMem auto objectIsNull = builder->CreateIsNotNull(load); builder->CreateCondBr(objectIsNull, callRuntimeBb, outBb); - // Call Runtime + // Call runtime or interposer builder->SetInsertPoint(callRuntimeBb); - static constexpr auto VAR_ARGS = true; - auto functionType = - llvm::FunctionType::get(builder->getVoidTy(), {builder->getPtrTy(LLVMArkInterface::GC_ADDR_SPACE)}, !VAR_ARGS); - builder->CreateCall(functionType, entrypoint, {load}); + CreatePreWrbCall(builder, arkInterface, threadRegValue, frameRegValue, entrypoint, load); builder->CreateBr(outBb); - builder->SetInsertPoint(outBb); } @@ -91,31 +146,28 @@ void EmitPostWRB(llvm::IRBuilder<> *builder, llvm::Value *mem, llvm::Value *offs auto threadRegPtr = builder->CreateIntToPtr(threadRegValue, ptrTy); auto addr = builder->CreateConstInBoundsGEP1_64(builder->getInt8Ty(), threadRegPtr, tlsOffset); auto callee = builder->CreateLoad(ptrTy, addr, "post_wrb_one_object_addr"); + llvm::CallInst *call; - ASSERT(mem->getType()->isPointerTy()); - ASSERT(value->getType()->isPointerTy() && - value->getType()->getPointerAddressSpace() == LLVMArkInterface::GC_ADDR_SPACE); + ASSERT(memTy->isPointerTy() && value->getType() == gcPtrTy); - if (!arkInterface->IsIrtocMode()) { - // LLVM AOT, only 3 parameters + if (!arkInterface->IsIrtocMode()) { // LLVM AOT, only 3 parameters auto funcTy = llvm::FunctionType::get(builder->getVoidTy(), {memTy, int32Ty, gcPtrTy}, false); - auto call = builder->CreateCall(funcTy, callee, {mem, offset, value}); - call->setCallingConv(llvm::CallingConv::ArkFast3); + call = builder->CreateCall(funcTy, callee, {mem, offset, value}); + call->setCallingConv(llvm::CallingConv::ArkFast); return; } - if (arkInterface->IsArm64()) { - // Arm64 Irtoc, 4 params (add thread) + if (arkInterface->IsArm64()) { // Arm64 Irtoc, 4 parameters (add thread) auto funcTy = llvm::FunctionType::get(builder->getVoidTy(), {memTy, int32Ty, gcPtrTy, ptrTy}, false); - auto call = builder->CreateCall(funcTy, callee, {mem, offset, value, threadRegPtr}); - call->setCallingConv(llvm::CallingConv::ArkFast3); - return; + call = builder->CreateCall(funcTy, callee, {mem, offset, value, threadRegPtr}); + } else { // X86_64 Irtoc, 5 parameters (add thread, fp) + ASSERT(frameRegValue != nullptr); + auto funcTy = llvm::FunctionType::get(builder->getVoidTy(), {memTy, int32Ty, gcPtrTy, ptrTy, ptrTy}, false); + auto frameRegPtr = builder->CreateIntToPtr(frameRegValue, ptrTy); + call = builder->CreateCall(funcTy, callee, {mem, offset, value, threadRegPtr, frameRegPtr}); + call->addParamAttr(4U, llvm::Attribute::InReg); } - // X86_64 Irtoc, 5 params (add thread, fp) - ASSERT(frameRegValue != nullptr); - auto funcTy = llvm::FunctionType::get(builder->getVoidTy(), {memTy, int32Ty, gcPtrTy, ptrTy, ptrTy}, false); - auto frameRegPtr = builder->CreateIntToPtr(frameRegValue, ptrTy); - auto call = builder->CreateCall(funcTy, callee, {mem, offset, value, threadRegPtr, frameRegPtr}); - call->setCallingConv(llvm::CallingConv::ArkFast3); + call->addParamAttr(3U, llvm::Attribute::InReg); + call->setCallingConv(llvm::CallingConv::ArkFast); } } // namespace ark::llvmbackend::gc_barriers diff --git a/static_core/libllvmbackend/lowering/gc_barriers.h b/static_core/libllvmbackend/lowering/gc_barriers.h index 5d8c70d655463f3f565f29127c69405197e456a9..63938483180b08a14e4ee625594928fd3211c33f 100644 --- a/static_core/libllvmbackend/lowering/gc_barriers.h +++ b/static_core/libllvmbackend/lowering/gc_barriers.h @@ -24,7 +24,7 @@ class LLVMArkInterface; namespace ark::llvmbackend::gc_barriers { void EmitPreWRB(llvm::IRBuilder<> *builder, llvm::Value *mem, bool isVolatileMem, llvm::BasicBlock *outBb, - LLVMArkInterface *arkInterface, llvm::Value *threadRegValue); + LLVMArkInterface *arkInterface, llvm::Value *threadRegValue, llvm::Value *frameRegValue); void EmitPostWRB(llvm::IRBuilder<> *builder, llvm::Value *mem, llvm::Value *offset, llvm::Value *value, LLVMArkInterface *arkInterface, llvm::Value *threadRegValue, llvm::Value *frameRegValue); diff --git a/static_core/libllvmbackend/lowering/llvm_ir_constructor.cpp b/static_core/libllvmbackend/lowering/llvm_ir_constructor.cpp index de9caf53c04d97e3a5a3f3b4f2f73621b9d35a56..786b77dc37acb9809c5713cbacc5f43db18e8afd 100644 --- a/static_core/libllvmbackend/lowering/llvm_ir_constructor.cpp +++ b/static_core/libllvmbackend/lowering/llvm_ir_constructor.cpp @@ -105,12 +105,12 @@ inline llvm::Function *CreateFunctionDeclaration(llvm::FunctionType *functionTyp auto function = module->getFunction(name); if (function != nullptr) { ASSERT(function->getVisibility() == llvm::GlobalValue::ProtectedVisibility); - ASSERT(function->doesNotThrow()); + ASSERT(function->hasFnAttribute(llvm::Attribute::NoUnwind)); return function; } function = llvm::Function::Create(functionType, llvm::Function::ExternalLinkage, name, module); - function->setDoesNotThrow(); + function->addFnAttr(llvm::Attribute::NoUnwind); function->setVisibility(llvm::GlobalValue::ProtectedVisibility); function->setSectionPrefix(name); @@ -553,28 +553,6 @@ static DeoptimizeType GetDeoptimizationType(Inst *inst) } } -static llvm::CallingConv::ID GetFastPathCallingConv(uint32_t numArgs) -{ - switch (numArgs) { - case 0U: - return llvm::CallingConv::ArkFast0; - case 1U: - return llvm::CallingConv::ArkFast1; - case 2U: - return llvm::CallingConv::ArkFast2; - case 3U: - return llvm::CallingConv::ArkFast3; - case 4U: - return llvm::CallingConv::ArkFast4; - case 5U: - return llvm::CallingConv::ArkFast5; - case 6U: - return llvm::CallingConv::ArkFast6; - default: - UNREACHABLE(); - } -} - static RuntimeInterface::EntrypointId GetAllocateArrayTlabEntrypoint(size_t elementSize) { switch (elementSize) { @@ -678,11 +656,13 @@ bool LLVMIrConstructor::TryEmitIntrinsic(Inst *inst, RuntimeInterface::Intrinsic // Specific intrinsic Emitters -bool LLVMIrConstructor::EmitFastPath(Inst *inst, RuntimeInterface::EntrypointId eid, uint32_t numArgs) +bool LLVMIrConstructor::EmitFastPath(Inst *inst, RuntimeInterface::EntrypointId eid) { - ArenaVector args(GetGraph()->GetLocalAllocator()->Adapter()); - for (uint32_t i = 0; i < numArgs; i++) { - args.push_back(GetInputValue(inst, i)); + llvm::SmallVector args; + for (uint32_t i = 0; i < inst->GetInputsCount(); i++) { + if (!inst->GetInput(i).GetInst()->IsSaveState()) { + args.push_back(GetInputValue(inst, i)); + } } auto call = CreateFastPathCall(inst, eid, args); @@ -695,42 +675,42 @@ bool LLVMIrConstructor::EmitFastPath(Inst *inst, RuntimeInterface::EntrypointId bool LLVMIrConstructor::EmitStringEquals(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_EQUALS_COMPRESSED, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_EQUALS_COMPRESSED); } bool LLVMIrConstructor::EmitStringBuilderBool(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_BOOL, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_BOOL); } bool LLVMIrConstructor::EmitStringBuilderChar(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_CHAR, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_CHAR); } bool LLVMIrConstructor::EmitStringBuilderString(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_STRING_COMPRESSED, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_BUILDER_STRING_COMPRESSED); } bool LLVMIrConstructor::EmitStringConcat2(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT2_TLAB, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT2_TLAB); } bool LLVMIrConstructor::EmitStringConcat3(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT3_TLAB, 3U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT3_TLAB); } bool LLVMIrConstructor::EmitStringConcat4(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT4_TLAB, 4U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_CONCAT4_TLAB); } bool LLVMIrConstructor::EmitStringCompareTo(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_COMPARE_TO, 2U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_COMPARE_TO); } bool LLVMIrConstructor::EmitIsInf(Inst *inst) @@ -787,13 +767,7 @@ static void CheckSlowPathName(const std::string &name, size_t funcArgsNum, size_ bool LLVMIrConstructor::EmitSlowPathEntry(Inst *inst) { ASSERT(GetGraph()->GetMode().IsFastPath()); - ASSERT(func_->getCallingConv() == llvm::CallingConv::ArkFast0 || - func_->getCallingConv() == llvm::CallingConv::ArkFast1 || - func_->getCallingConv() == llvm::CallingConv::ArkFast2 || - func_->getCallingConv() == llvm::CallingConv::ArkFast3 || - func_->getCallingConv() == llvm::CallingConv::ArkFast4 || - func_->getCallingConv() == llvm::CallingConv::ArkFast5 || - func_->getCallingConv() == llvm::CallingConv::ArkFast6); + ASSERT(func_->getCallingConv() == llvm::CallingConv::ArkFast); // Arguments ArenaVector args(GetGraph()->GetLocalAllocator()->Adapter()); @@ -821,12 +795,14 @@ bool LLVMIrConstructor::EmitSlowPathEntry(Inst *inst) argTypes.push_back(builder_.getPtrTy()); auto ftype = llvm::FunctionType::get(GetType(inst->GetType()), argTypes, false); callee = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, externalName, func_->getParent()); - callee->setCallingConv(GetFastPathCallingConv(inst->GetInputs().Size())); + callee->setCallingConv(llvm::CallingConv::ArkFast); } auto call = builder_.CreateCall(callee->getFunctionType(), callee, args); + call->addParamAttr(callee->arg_size() - 1U, llvm::Attribute::InReg); + call->addParamAttr(callee->arg_size() - 2U, llvm::Attribute::InReg); call->setCallingConv(callee->getCallingConv()); - call->setTailCallKind(llvm::CallInst::TailCallKind::TCK_Tail); + call->setTailCallKind(llvm::CallInst::TailCallKind::TCK_MustTail); call->addFnAttr(llvm::Attribute::get(call->getContext(), "ark-tail-call")); CreateReturn(call); return true; @@ -927,13 +903,7 @@ bool LLVMIrConstructor::EmitInterpreterReturn([[maybe_unused]] Inst *inst) bool LLVMIrConstructor::EmitTailCall(Inst *inst) { - ASSERT(func_->getCallingConv() == llvm::CallingConv::ArkFast0 || - func_->getCallingConv() == llvm::CallingConv::ArkFast1 || - func_->getCallingConv() == llvm::CallingConv::ArkFast2 || - func_->getCallingConv() == llvm::CallingConv::ArkFast3 || - func_->getCallingConv() == llvm::CallingConv::ArkFast4 || - func_->getCallingConv() == llvm::CallingConv::ArkFast5 || - func_->getCallingConv() == llvm::CallingConv::ArkFast6 || + ASSERT(func_->getCallingConv() == llvm::CallingConv::ArkFast || func_->getCallingConv() == llvm::CallingConv::ArkInt); llvm::CallInst *call; @@ -944,7 +914,7 @@ bool LLVMIrConstructor::EmitTailCall(Inst *inst) } else { UNREACHABLE(); } - call->setTailCallKind(llvm::CallInst::TailCallKind::TCK_Tail); + call->setTailCallKind(llvm::CallInst::TailCallKind::TCK_MustTail); call->addFnAttr(llvm::Attribute::get(call->getContext(), "ark-tail-call")); CreateReturn(call); std::fill(ccValues_.begin(), ccValues_.end(), nullptr); @@ -1155,7 +1125,7 @@ bool LLVMIrConstructor::EmitStringGetCharsTlab(Inst *inst) auto result = CreateEntrypointCall(eid, inst, {GetInputValue(inst, 0), GetInputValue(inst, 1), GetInputValue(inst, 2), klass}); ASSERT(result->getCallingConv() == llvm::CallingConv::C); - result->setCallingConv(llvm::CallingConv::ArkFast4); + result->setCallingConv(llvm::CallingConv::ArkFast); result->addRetAttr(llvm::Attribute::NonNull); result->addRetAttr(llvm::Attribute::NoAlias); ValueMapAdd(inst, result); @@ -1181,7 +1151,7 @@ bool LLVMIrConstructor::EmitStringHashCode(Inst *inst) auto newHash = CreateEntrypointCall(RuntimeInterface::EntrypointId::STRING_HASH_CODE_COMPRESSED, inst, {string}); ASSERT(newHash->getCallingConv() == llvm::CallingConv::C); - newHash->setCallingConv(llvm::CallingConv::ArkFast1); + newHash->setCallingConv(llvm::CallingConv::ArkFast); builder_.CreateBr(continuation); SetCurrentBasicBlock(continuation); @@ -1479,7 +1449,7 @@ llvm::CallInst *LLVMIrConstructor::CreateFastPathCall(Inst *inst, RuntimeInterfa { auto call = CreateEntrypointCall(eid, inst, args); ASSERT(call->getCallingConv() == llvm::CallingConv::C); - call->setCallingConv(GetFastPathCallingConv(args.size())); + call->setCallingConv(llvm::CallingConv::ArkFast); return call; } @@ -2169,12 +2139,10 @@ llvm::Value *LLVMIrConstructor::CreateNewStringFromCharsTlab(Inst *inst, llvm::V { auto entryId = RuntimeInterface::EntrypointId::CREATE_STRING_FROM_CHAR_ARRAY_TLAB_COMPRESSED; ArenaVector arguments(GetGraph()->GetLocalAllocator()->Adapter()); - auto callConv = llvm::CallingConv::ArkFast3; if (llvm::isa(offset) && llvm::cast(offset)->isNullValue()) { entryId = RuntimeInterface::EntrypointId::CREATE_STRING_FROM_ZERO_BASED_CHAR_ARRAY_TLAB_COMPRESSED; } else { arguments.push_back(offset); - callConv = llvm::CallingConv::ArkFast4; } arguments.push_back(length); arguments.push_back(array); @@ -2183,7 +2151,7 @@ llvm::Value *LLVMIrConstructor::CreateNewStringFromCharsTlab(Inst *inst, llvm::V arguments.push_back(klass); auto result = CreateEntrypointCall(entryId, inst, arguments); ASSERT(result->getCallingConv() == llvm::CallingConv::C); - result->setCallingConv(callConv); + result->setCallingConv(llvm::CallingConv::ArkFast); MarkAsAllocation(result); return result; } @@ -2193,7 +2161,7 @@ llvm::Value *LLVMIrConstructor::CreateNewStringFromStringTlab(Inst *inst, llvm:: auto entryId = RuntimeInterface::EntrypointId::CREATE_STRING_FROM_STRING_TLAB_COMPRESSED; auto result = CreateEntrypointCall(entryId, inst, {stringVal}); ASSERT(result->getCallingConv() == llvm::CallingConv::C); - result->setCallingConv(llvm::CallingConv::ArkFast1); + result->setCallingConv(llvm::CallingConv::ArkFast); MarkAsAllocation(result); return result; } @@ -2211,8 +2179,9 @@ llvm::Value *LLVMIrConstructor::CreateLaunchArgsArray(CallInst *callInst, uint32 auto typeSize = DataType::GetTypeSize(type, GetGraph()->GetArch()); if (typeSize < DataType::GetTypeSize(DataType::INT32, GetGraph()->GetArch())) { arg = CoerceValue(arg, type, DataType::INT32); + } else if (type == DataType::REFERENCE) { + arg = builder_.CreatePtrToInt(arg, builder_.getInt64Ty()); } - auto gep = builder_.CreateConstInBoundsGEP1_32(builder_.getInt64Ty(), callArgs, i); builder_.CreateStore(arg, gep); } @@ -2457,7 +2426,11 @@ void LLVMIrConstructor::CreatePreWRB(Inst *inst, llvm::Value *mem) } auto &ctx = func_->getContext(); auto outBb = llvm::BasicBlock::Create(ctx, CreateBasicBlockName(inst, "pre_wrb_out"), func_); - llvmbackend::gc_barriers::EmitPreWRB(&builder_, mem, isVolatile, outBb, arkInterface_, GetThreadRegValue()); + + bool needFrame = + arkInterface_->IsIrtocMode() && (GetGraph()->GetArch() == Arch::X86_64 || GetGraph()->GetMode().IsFastPath()); + auto frame = needFrame ? GetRealFrameRegValue() : nullptr; + llvmbackend::gc_barriers::EmitPreWRB(&builder_, mem, isVolatile, outBb, arkInterface_, GetThreadRegValue(), frame); } void LLVMIrConstructor::CreatePostWRB(Inst *inst, llvm::Value *mem, llvm::Value *offset, llvm::Value *value) @@ -2559,6 +2532,7 @@ llvm::CallInst *LLVMIrConstructor::CreateTailCallFastPath(Inst *inst) auto ftype = llvm::FunctionType::get(GetType(inst->GetType()), argTypes, false); callee = llvm::Function::Create(ftype, llvm::Function::ExternalLinkage, externalName, func_->getParent()); cc = func_->getCallingConv(); + callee->setCallingConv(cc); } else { size_t size = func_->arg_size(); ASSERT(callee->arg_size() <= size); @@ -2570,6 +2544,8 @@ llvm::CallInst *LLVMIrConstructor::CreateTailCallFastPath(Inst *inst) cc = callee->getCallingConv(); } auto call = builder_.CreateCall(callee->getFunctionType(), callee, args); + call->addParamAttr(callee->arg_size() - 1U, llvm::Attribute::InReg); + call->addParamAttr(callee->arg_size() - 2U, llvm::Attribute::InReg); call->setCallingConv(cc); return call; } @@ -4718,12 +4694,19 @@ void LLVMIrConstructor::VisitIntrinsic(GraphVisitor *v, Inst *inst) if (g_options.IsCompilerEncodeIntrinsics()) { bool lowered = ctor->TryEmitIntrinsic(inst, entryId); if (lowered) { + ASSERT(!inst->NoNullPtr()); return; } } + ASSERT(!EncodesBuiltin(ctor->GetGraph()->GetRuntime(), entryId, ctor->GetGraph()->GetArch())); // Create call otherwise auto result = ctor->CreateIntrinsicCall(inst); if (inst->GetType() != DataType::VOID) { + if (inst->NoNullPtr()) { + ASSERT(inst->GetType() == DataType::REFERENCE); + ASSERT(result->getType()->isPointerTy()); + result->addRetAttr(llvm::Attribute::NonNull); + } ctor->ValueMapAdd(inst, result); } } @@ -4737,7 +4720,7 @@ void LLVMIrConstructor::VisitMonitor(GraphVisitor *v, Inst *inst) : RuntimeInterface::EntrypointId::MONITOR_EXIT_FAST_PATH; auto call = ctor->CreateEntrypointCall(eid, inst, {object}); ASSERT(call->getCallingConv() == llvm::CallingConv::C); - call->setCallingConv(llvm::CallingConv::ArkFast1); + call->setCallingConv(llvm::CallingConv::ArkFast); } void LLVMIrConstructor::VisitSqrt(GraphVisitor *v, Inst *inst) @@ -5116,10 +5099,9 @@ LLVMIrConstructor::LLVMIrConstructor(Graph *graph, llvm::Module *module, llvm::L for (size_t i = 0; i < graph->GetRuntime()->GetMethodTotalArgumentsCount(graph->GetMethod()); i++) { cc_.push_back(i); } - // Get calling convention excluding thread and frame registers - callingConv = GetFastPathCallingConv(cc_.size()); cc_.push_back(GetThreadReg(Arch::AARCH64)); cc_.push_back(AARCH64_REAL_FP); + callingConv = llvm::CallingConv::ArkFast; } ccValues_.assign(cc_.size(), nullptr); @@ -5130,8 +5112,13 @@ LLVMIrConstructor::LLVMIrConstructor(Graph *graph, llvm::Module *module, llvm::L ASSERT(func_->getCallingConv() == llvm::CallingConv::C); func_->setCallingConv(callingConv); - // Scenario of code generation for FastPath having zero arguments and return value is not tested - ASSERT(callingConv != llvm::CallingConv::ArkFast0 || func_->getReturnType()->isVoidTy()); + // FastPath having zero real arguments (excluding frame and thread) and return value scenario was not tested + ASSERT(callingConv != llvm::CallingConv::ArkFast || cc_.size() > 2U || func_->getReturnType()->isVoidTy()); + + if (graph->GetMode().IsFastPath()) { + func_->addParamAttr(func_->arg_size() - 1U, llvm::Attribute::InReg); + func_->addParamAttr(func_->arg_size() - 2U, llvm::Attribute::InReg); + } if (graph->SupportManagedCode()) { func_->setGC(std::string {llvmbackend::LLVMArkInterface::GC_STRATEGY}); @@ -5280,7 +5267,7 @@ void LLVMIrConstructor::ProvideSafepointPoll(llvm::Module *module, LLVMArkInterf auto pollFtype = llvm::FunctionType::get(builder.getVoidTy(), false); auto poll = llvm::Function::Create(pollFtype, llvm::Function::ExternalLinkage, LLVMArkInterface::GC_SAFEPOINT_POLL_NAME, module); - poll->setDoesNotThrow(); + poll->addFnAttr(llvm::Attribute::NoUnwind); // Creating a body auto entry = llvm::BasicBlock::Create(ctx, "bb", poll); diff --git a/static_core/libllvmbackend/lowering/llvm_ir_constructor.h b/static_core/libllvmbackend/lowering/llvm_ir_constructor.h index 557db133e42e54898a9d9a147307ca4eae9ed8dc..8f53f545450f859ced005dedc1ca9912e4d1e2ff 100644 --- a/static_core/libllvmbackend/lowering/llvm_ir_constructor.h +++ b/static_core/libllvmbackend/lowering/llvm_ir_constructor.h @@ -34,7 +34,7 @@ class LLVMIrConstructor : public GraphVisitor { private: // Specific intrinsic Emitters - bool EmitFastPath(Inst *inst, RuntimeInterface::EntrypointId eid, uint32_t numArgs); + bool EmitFastPath(Inst *inst, RuntimeInterface::EntrypointId eid); bool EmitStringEquals(Inst *inst); bool EmitStringBuilderBool(Inst *inst); bool EmitStringBuilderChar(Inst *inst); diff --git a/static_core/libllvmbackend/templates/llvm_passes.inl.erb b/static_core/libllvmbackend/templates/llvm_passes.inl.erb index 75b0dba4bc661d75bd2a086f01fb465c74a401fc..6dbfc7969a334b3e75d3f4a6729d53db621526ea 100644 --- a/static_core/libllvmbackend/templates/llvm_passes.inl.erb +++ b/static_core/libllvmbackend/templates/llvm_passes.inl.erb @@ -40,7 +40,7 @@ public: bool ParseModulePasses(StringRef name, llvm::ModulePassManager &modulePm, const LLVMCompilerOptions &options); bool ParseFunctionPasses(StringRef name, llvm::FunctionPassManager &functionPm, const LLVMCompilerOptions &options); bool ParseSCCPasses(StringRef name, llvm::CGSCCPassManager &sccPm, const LLVMCompilerOptions &options); - bool ParseLoopPasses(StringRef name, llvm::LoopPassManager &sccPm, const LLVMCompilerOptions &options); + bool ParseLoopPasses(StringRef name, llvm::LoopPassManager &loopPm, const LLVMCompilerOptions &options); void RegisterParserCallbacks(llvm::PassBuilder &builder, const ark::llvmbackend::LLVMCompilerOptions &options) { @@ -57,8 +57,8 @@ public: return ParseSCCPasses(name, sccPm, options); }); builder.registerPipelineParsingCallback( - [&](StringRef name, llvm::LoopPassManager &sccPm, PipelineElements /*unused*/) -> bool { - return ParseLoopPasses(name, sccPm, options); + [&](StringRef name, llvm::LoopPassManager &loopPm, PipelineElements /*unused*/) -> bool { + return ParseLoopPasses(name, loopPm, options); }); } private: diff --git a/static_core/libllvmbackend/transforms/builtins.cpp b/static_core/libllvmbackend/transforms/builtins.cpp index ca1633a0537424c64db1ebf1974968ea7f4b44e2..44174b749e31e3316ac0642c76a72f5bd1750d63 100644 --- a/static_core/libllvmbackend/transforms/builtins.cpp +++ b/static_core/libllvmbackend/transforms/builtins.cpp @@ -20,7 +20,6 @@ #include "lowering/gc_barriers.h" #include "lowering/metadata.h" -#include "compiler/optimizer/ir/basicblock.h" #include "compiler/optimizer/ir/inst.h" #include @@ -177,7 +176,8 @@ llvm::Value *PreWRBHelper(llvm::IRBuilder<> *builder, llvm::CallInst *inst, LLVM initialBb->back().eraseFromParent(); builder->SetInsertPoint(initialBb); auto threadRegValue = GetThreadRegValue(builder, arkInterface); - ark::llvmbackend::gc_barriers::EmitPreWRB(builder, mem, isVolatileMem, continuation, arkInterface, threadRegValue); + ark::llvmbackend::gc_barriers::EmitPreWRB(builder, mem, isVolatileMem, continuation, arkInterface, threadRegValue, + nullptr); return nullptr; } } // namespace @@ -195,8 +195,8 @@ llvm::Function *LenArray(llvm::Module *module) llvm::Type::getInt32Ty(module->getContext())}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, LEN_ARRAY_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); function->addFnAttr(llvm::Attribute::ReadNone); function->addFnAttr(llvm::Attribute::WillReturn); return function; @@ -213,8 +213,8 @@ llvm::Function *KeepThis(llvm::Module *module) llvm::FunctionType::get(llvm::Type::getVoidTy(module->getContext()), {llvm::PointerType::get(module->getContext(), LLVMArkInterface::GC_ADDR_SPACE)}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, KEEP_THIS_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); function->addFnAttr(llvm::Attribute::WillReturn); return function; } @@ -228,8 +228,8 @@ llvm::Function *BarrierReturnVoid(llvm::Module *module) auto type = llvm::FunctionType::get(llvm::Type::getVoidTy(module->getContext()), {}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, BARRIER_RETURN_VOID_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); function->addFnAttr(llvm::Attribute::WillReturn); return function; } @@ -245,8 +245,8 @@ llvm::Function *LoadClass(llvm::Module *module) llvm::PointerType::get(module->getContext(), 0), {llvm::Type::getInt32Ty(module->getContext()), llvm::Type::getInt32Ty(module->getContext())}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, LOAD_CLASS_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); return function; } @@ -261,8 +261,8 @@ llvm::Function *LoadInitClass(llvm::Module *module) llvm::PointerType::get(module->getContext(), 0), {llvm::Type::getInt32Ty(module->getContext()), llvm::Type::getInt32Ty(module->getContext())}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, LOAD_INIT_CLASS_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); return function; } @@ -277,8 +277,8 @@ llvm::Function *PreWRB(llvm::Module *module, unsigned addrSpace) auto type = llvm::FunctionType::get(llvm::Type::getVoidTy(ctx), {llvm::PointerType::get(ctx, addrSpace), llvm::Type::getInt1Ty(ctx)}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, builtinName, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); function->addFnAttr(llvm::Attribute::ArgMemOnly); function->addFnAttr(llvm::Attribute::WillReturn); function->addParamAttr(0U, llvm::Attribute::ReadOnly); @@ -298,8 +298,8 @@ llvm::Function *PostWRB(llvm::Module *module, unsigned addrSpace) llvm::PointerType::get(ctx, LLVMArkInterface::GC_ADDR_SPACE)}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, builtinName, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); function->addFnAttr(llvm::Attribute::ArgMemOnly); function->addFnAttr(llvm::Attribute::WillReturn); function->addParamAttr(0U, llvm::Attribute::ReadNone); @@ -318,8 +318,8 @@ llvm::Function *LoadString(llvm::Module *module) llvm::PointerType::get(module->getContext(), LLVMArkInterface::GC_ADDR_SPACE), {llvm::Type::getInt32Ty(module->getContext()), llvm::Type::getInt32Ty(module->getContext())}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, LOAD_STRING_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); return function; } @@ -335,8 +335,8 @@ llvm::Function *ResolveVirtual(llvm::Module *module) llvm::PointerType::get(module->getContext(), 0)}, false); function = llvm::Function::Create(type, llvm::Function::ExternalLinkage, RESOLVE_VIRTUAL_BUILTIN, module); - function->setDoesNotThrow(); function->setSectionPrefix(BUILTIN_SECTION); + function->addFnAttr(llvm::Attribute::NoUnwind); return function; } @@ -398,7 +398,7 @@ llvm::Value *LowerResolveVirtual(llvm::IRBuilder<> *builder, llvm::CallInst *ins auto method = inst->getFunction()->arg_begin(); auto thiz = inst->getOperand(0U); auto methodId = inst->getOperand(1U); - ASSERT(!llvm::isa(thiz)); + ASSERT(!llvm::isa(thiz)); if (!arkInterface->IsArm64() || !llvm::isa(methodId)) { static constexpr auto ENTRYPOINT_ID = compiler::RuntimeInterface::EntrypointId::RESOLVE_VIRTUAL_CALL_AOT; auto offset = builder->getInt64(0); @@ -410,7 +410,7 @@ llvm::Value *LowerResolveVirtual(llvm::IRBuilder<> *builder, llvm::CallInst *ins entrypointAddress = CreateEntrypointCallHelper(builder, ENTRYPOINT_ID, {method, thiz, methodId, offset}, arkInterface, inst); ASSERT(entrypointAddress->getCallingConv() == llvm::CallingConv::C); - entrypointAddress->setCallingConv(llvm::CallingConv::ArkFast4); + entrypointAddress->setCallingConv(llvm::CallingConv::ArkFast); } return builder->CreateIntToPtr(entrypointAddress, builder->getPtrTy()); diff --git a/static_core/libllvmbackend/transforms/passes/aarch64_fixup_sdiv.h b/static_core/libllvmbackend/transforms/passes/aarch64_fixup_sdiv.h index 9f0624444e339d224eaa861827ceb4957cd3cd4e..8587375bb15e67ec2729819a8cd1cfe5da7cf389 100644 --- a/static_core/libllvmbackend/transforms/passes/aarch64_fixup_sdiv.h +++ b/static_core/libllvmbackend/transforms/passes/aarch64_fixup_sdiv.h @@ -31,10 +31,9 @@ public: explicit AArch64FixupSDiv(LLVMArkInterface *arkInterface = nullptr); - static AArch64FixupSDiv Create(LLVMArkInterface *arkInterface, - const ark::llvmbackend::LLVMCompilerOptions *options); + static AArch64FixupSDiv Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } diff --git a/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_builder.h b/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_builder.h index db60c0223d2163edfc282d715be2e9acd9f9f6af..57a98faca8f0bea8657db05f244df5b6e57b05dd 100644 --- a/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_builder.h +++ b/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_builder.h @@ -115,4 +115,4 @@ private: std::string_view asmPairRegs, ssize_t calleeOffset); }; -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_ARK_FRAME_LOWERING_FRAME_BUILDER_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_ARK_FRAME_LOWERING_FRAME_BUILDER_H diff --git a/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_lowering.h b/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_lowering.h index 196315037d605833ac396b0135b00f334c36c586..091af4d2cb9c7147041c8a5616506fb2120a8f57 100644 --- a/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_lowering.h +++ b/static_core/libllvmbackend/transforms/passes/ark_frame_lowering/frame_lowering.h @@ -27,4 +27,4 @@ class LLVMArkInterface; llvm::MachineFunctionPass *CreateFrameLoweringPass(LLVMArkInterface *arkInterface); } // namespace ark::llvmbackend -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_ARK_FRAME_LOWERING_FRAME_LOWERING_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_ARK_FRAME_LOWERING_FRAME_LOWERING_H diff --git a/static_core/libllvmbackend/transforms/passes/ark_gvn.h b/static_core/libllvmbackend/transforms/passes/ark_gvn.h index 6cd42904aaa7d93018c089de18bc0fa816311e28..a2516a416e0186b57103a0d761e676c72a170176 100644 --- a/static_core/libllvmbackend/transforms/passes/ark_gvn.h +++ b/static_core/libllvmbackend/transforms/passes/ark_gvn.h @@ -36,11 +36,11 @@ class ArkGVN : public llvm::PassInfoMixin { public: explicit ArkGVN(LLVMArkInterface *arkInterface = nullptr); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } - static ArkGVN Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options); + static ArkGVN Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); diff --git a/static_core/libllvmbackend/transforms/passes/ark_inlining.h b/static_core/libllvmbackend/transforms/passes/ark_inlining.h index c67ebd57f52bc954d787f130b1ad4b89b9c09079..0391498f6c8bf68c34bcf5ab17d39fbfa3c7bb7f 100644 --- a/static_core/libllvmbackend/transforms/passes/ark_inlining.h +++ b/static_core/libllvmbackend/transforms/passes/ark_inlining.h @@ -34,7 +34,7 @@ class IrtocInlineChecker : public llvm::PassInfoMixin { public: static constexpr llvm::StringRef ARG_NAME = "irtoc-inline-check"; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); void CheckShouldInline(llvm::CallBase *callBase); // NOLINTNEXTLINE(readability-identifier-naming) @@ -49,8 +49,8 @@ public: static constexpr llvm::StringRef ARG_NAME = "inline-prepare"; explicit InlinePrepare(llvm::InlineParams inlineParams) : inlineParams_ {inlineParams} {} - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); - static InlinePrepare Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); + static InlinePrepare Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Module &module, llvm::ModuleAnalysisManager &moduleAm); diff --git a/static_core/libllvmbackend/transforms/passes/ark_speculation.h b/static_core/libllvmbackend/transforms/passes/ark_speculation.h index 112f9104cc00fbab37ca7b91326b40aac2e4255f..e7d06dd21e2aafc856ade2c4e7a2ebb1ee51a1b0 100644 --- a/static_core/libllvmbackend/transforms/passes/ark_speculation.h +++ b/static_core/libllvmbackend/transforms/passes/ark_speculation.h @@ -32,7 +32,7 @@ public: static constexpr llvm::StringRef ARG_NAME = "wrap-speculative-execution"; explicit ArkSpeculativeExecution() : llvm::SpeculativeExecutionPass(ONLY_IF_DIVERGENT_TARGET) {} - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } diff --git a/static_core/libllvmbackend/transforms/passes/check_external.h b/static_core/libllvmbackend/transforms/passes/check_external.h index c599cf8e8071ff0fa10d52b0391cc9750a405c70..4706ec9e8f0b9a18a2206f8a026ee406d58dcdba 100644 --- a/static_core/libllvmbackend/transforms/passes/check_external.h +++ b/static_core/libllvmbackend/transforms/passes/check_external.h @@ -33,7 +33,7 @@ class CheckExternal : public llvm::PassInfoMixin { public: explicit CheckExternal() = default; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); static CheckExternal Create(); diff --git a/static_core/libllvmbackend/transforms/passes/check_tail_calls.cpp b/static_core/libllvmbackend/transforms/passes/check_tail_calls.cpp index d5ac10ac30fd67504378d0cf8bb31b544b7b22b6..ecac9d21c11c8ae45465671500748063a3b0e7e7 100644 --- a/static_core/libllvmbackend/transforms/passes/check_tail_calls.cpp +++ b/static_core/libllvmbackend/transforms/passes/check_tail_calls.cpp @@ -117,6 +117,9 @@ public: [&instInfo](llvm::MachineInstr &term) { return instInfo->isTailCall(term); })) { return true; } + if (basicBlock->succ_empty()) { + return false; + } if (visitedBasicBlocks->contains(basicBlock)) { llvm::report_fatal_error("Cycle in CFG in '" + basicBlock->getParent()->getName() + "' prevents tail call check"); diff --git a/static_core/libllvmbackend/transforms/passes/check_tail_calls.h b/static_core/libllvmbackend/transforms/passes/check_tail_calls.h index 9262ab3dd222b4437ef31a27a03ee221f6d04e36..c949f83711c14dd6e7618db4504da554b95681d4 100644 --- a/static_core/libllvmbackend/transforms/passes/check_tail_calls.h +++ b/static_core/libllvmbackend/transforms/passes/check_tail_calls.h @@ -26,4 +26,4 @@ namespace ark::llvmbackend { llvm::MachineFunctionPass *CreateCheckTailCallsPass(); } // namespace ark::llvmbackend -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_CHECK_TAIL_CALLS_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_CHECK_TAIL_CALLS_H diff --git a/static_core/libllvmbackend/transforms/passes/devirt.h b/static_core/libllvmbackend/transforms/passes/devirt.h index daabdfb691e1077b4471bf2ab5b98f934661436a..d1db364221e42983c3d0320f17ca7fd52c8aa24f 100644 --- a/static_core/libllvmbackend/transforms/passes/devirt.h +++ b/static_core/libllvmbackend/transforms/passes/devirt.h @@ -38,9 +38,9 @@ class Devirt : public llvm::PassInfoMixin { public: explicit Devirt(LLVMArkInterface *arkInterface = nullptr); - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); - static Devirt Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options); + static Devirt Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); diff --git a/static_core/libllvmbackend/transforms/passes/expand_atomics.cpp b/static_core/libllvmbackend/transforms/passes/expand_atomics.cpp index d8fa795e5ab4baa5bbe68430bcf1e708ad0db8cf..f0b216e2c774ca4431fb026b8095e84709705a4a 100644 --- a/static_core/libllvmbackend/transforms/passes/expand_atomics.cpp +++ b/static_core/libllvmbackend/transforms/passes/expand_atomics.cpp @@ -44,8 +44,7 @@ llvm::PreservedAnalyses ExpandAtomics::run(llvm::Function &function, } for (auto instruction : instructions) { - bool c = InsertAddrSpaceCast(instruction); - changed |= c; + changed |= InsertAddrSpaceCast(instruction); } } diff --git a/static_core/libllvmbackend/transforms/passes/expand_atomics.h b/static_core/libllvmbackend/transforms/passes/expand_atomics.h index b217ed55839aabeb383ee640daa5485e725a5099..92c27c71d716ac0802e5603be4c17df6821733a5 100644 --- a/static_core/libllvmbackend/transforms/passes/expand_atomics.h +++ b/static_core/libllvmbackend/transforms/passes/expand_atomics.h @@ -30,7 +30,7 @@ public: explicit ExpandAtomics(); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } diff --git a/static_core/libllvmbackend/transforms/passes/fixup_poisons.cpp b/static_core/libllvmbackend/transforms/passes/fixup_poisons.cpp index f61de3db236c9f86f6613424db56b8c37484083f..3b1e02058c12b435a0245ba0d0e568d7374fdbae 100644 --- a/static_core/libllvmbackend/transforms/passes/fixup_poisons.cpp +++ b/static_core/libllvmbackend/transforms/passes/fixup_poisons.cpp @@ -31,17 +31,14 @@ bool FixupPoisons::FixupInstructionOperands(llvm::Instruction &instruction) { bool changed = false; for (auto operand : instruction.operand_values()) { - auto poison = llvm::dyn_cast(operand); - if (poison == nullptr) { + auto undef = llvm::dyn_cast(operand); + if (undef == nullptr) { continue; } - if (IsGcRefType(poison->getType())) { - LLVM_DEBUG(llvm::dbgs() << "Replacing poison in inst:\n"); - LLVM_DEBUG(instruction.print(llvm::dbgs())); - LLVM_DEBUG(llvm::dbgs() << "with null pointer"); - - auto replacement = llvm::Constant::getNullValue(poison->getType()); - poison->replaceAllUsesWith(replacement); + if (IsGcRefType(undef->getType())) { + LLVM_DEBUG(llvm::dbgs() << "Replacing undef/poison in inst '" << instruction << "' with null pointer\n"); + auto replacement = llvm::Constant::getNullValue(undef->getType()); + undef->replaceAllUsesWith(replacement); changed = true; } } diff --git a/static_core/libllvmbackend/transforms/passes/fixup_poisons.h b/static_core/libllvmbackend/transforms/passes/fixup_poisons.h index f5d7adb2b7a0f838069e9b8eb209f3391707aa36..63ae3ef7ec55bb076422bd51eb68478d78dd2dd6 100644 --- a/static_core/libllvmbackend/transforms/passes/fixup_poisons.h +++ b/static_core/libllvmbackend/transforms/passes/fixup_poisons.h @@ -31,7 +31,7 @@ public: explicit FixupPoisons(); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } diff --git a/static_core/libllvmbackend/transforms/passes/gc_intrusion.h b/static_core/libllvmbackend/transforms/passes/gc_intrusion.h index e49795d03dbedde7d250b9b2bef9f451ea84ba2d..ab5b0a566f1e20e004b4efc1def8cf2c2e7910b9 100644 --- a/static_core/libllvmbackend/transforms/passes/gc_intrusion.h +++ b/static_core/libllvmbackend/transforms/passes/gc_intrusion.h @@ -30,7 +30,7 @@ class GcRefLiveness; class GcIntrusion : public llvm::PassInfoMixin { public: - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } @@ -96,4 +96,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GC_INTRUSION_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GC_INTRUSION_H diff --git a/static_core/libllvmbackend/transforms/passes/gc_intrusion_check.h b/static_core/libllvmbackend/transforms/passes/gc_intrusion_check.h index a01a1554e4c5235993a71067826d7617e9c1886e..f0e023eb7df1ce93515d372297f8ad95a4e52fed 100644 --- a/static_core/libllvmbackend/transforms/passes/gc_intrusion_check.h +++ b/static_core/libllvmbackend/transforms/passes/gc_intrusion_check.h @@ -33,7 +33,7 @@ class GcIntrusionCheck : public llvm::PassInfoMixin { public: static constexpr llvm::StringRef ARG_NAME = "gc-intrusion-check"; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); @@ -57,4 +57,4 @@ private: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GC_INTRUSION_CHECK_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GC_INTRUSION_CHECK_H diff --git a/static_core/libllvmbackend/transforms/passes/gep_propagation.cpp b/static_core/libllvmbackend/transforms/passes/gep_propagation.cpp index d87e6127f00df1bb8ff0c3f6e046f64c671631bc..d75f88f9d379e0ecf9405be2d7abd1c9f73dc7c0 100644 --- a/static_core/libllvmbackend/transforms/passes/gep_propagation.cpp +++ b/static_core/libllvmbackend/transforms/passes/gep_propagation.cpp @@ -118,8 +118,8 @@ static std::pair FindSplitGep(Function *function, { auto &ctx = function->getContext(); auto bptrTy = llvm::PointerType::get(ctx, ark::llvmbackend::LLVMArkInterface::GC_ADDR_SPACE); - auto undefBase = llvm::UndefValue::get(bptrTy); - auto undefOffset = llvm::UndefValue::get(Type::getInt32Ty(ctx)); + auto undefBase = llvm::PoisonValue::get(bptrTy); + auto undefOffset = llvm::PoisonValue::get(Type::getInt32Ty(ctx)); auto phi = llvm::dyn_cast(inst); Instruction *mbase; Instruction *moff; @@ -172,7 +172,7 @@ void GepPropagation::SplitGepSelectors(Function *function, SmallVectorbegin(), selectors->end(), inst) != selectors->end(); }; ASSERT(std::find_if_not(val->user_begin(), val->user_end(), safeToDelete) == val->user_end()); - val->replaceAllUsesWith(llvm::UndefValue::get(val->getType())); + val->replaceAllUsesWith(llvm::PoisonValue::get(val->getType())); val->eraseFromParent(); } @@ -252,6 +252,7 @@ void GepPropagation::GenerateSelectorInputs(Instruction *inst, const SelectorSpl if (!llvm::isa(mbase->getOperand(i))) { continue; } + ASSERT(llvm::isa(mbase->getOperand(i)) && "Expecting only poisons created in this pass"); auto inPoint = select ? mbase : llvm::cast(inst)->getIncomingBlock(i)->getTerminator(); auto [base, offset] = GenerateInput(input, inst, inPoint, mapping); setInputs(i, base, offset); @@ -267,7 +268,7 @@ Value *GepPropagation::GetConstantOffset(Constant *offset, Type *type) auto offsetRaw = offset->getOperand(0); return llvm::ConstantInt::getSigned(type, llvm::cast(offsetRaw)->getSExtValue()); } - if (offset->isNullValue() || llvm::isa(offset)) { + if (offset->isNullValue() || llvm::isa(offset)) { return llvm::ConstantInt::getNullValue(type); } diff --git a/static_core/libllvmbackend/transforms/passes/gep_propagation.h b/static_core/libllvmbackend/transforms/passes/gep_propagation.h index 1fa0421fd6e2014179d13dfba92533b15d9a1a6b..ca3b9b1624cddffab79b9f6d3206722d94dc2f49 100644 --- a/static_core/libllvmbackend/transforms/passes/gep_propagation.h +++ b/static_core/libllvmbackend/transforms/passes/gep_propagation.h @@ -31,7 +31,7 @@ namespace ark::llvmbackend::passes { class GepPropagation : public llvm::PassInfoMixin { public: - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } @@ -77,4 +77,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GEP_PROPAGATION_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_GEP_PROPAGATION_H diff --git a/static_core/libllvmbackend/transforms/passes/infer_flags.cpp b/static_core/libllvmbackend/transforms/passes/infer_flags.cpp index 233642e57518f004e388ccf7f889229f900f6944..99679c640bb30d3b43e302afdece8b23f3b18209 100644 --- a/static_core/libllvmbackend/transforms/passes/infer_flags.cpp +++ b/static_core/libllvmbackend/transforms/passes/infer_flags.cpp @@ -58,11 +58,6 @@ bool CanOverflow(const llvm::KnownBits &start, const llvm::KnownBits &step, uint namespace ark::llvmbackend::passes { -bool InferFlags::ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) -{ - return true; -} - llvm::PreservedAnalyses InferFlags::run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager) { LLVM_DEBUG(llvm::dbgs() << "Running on '" << function.getName() << "'\n"); diff --git a/static_core/libllvmbackend/transforms/passes/infer_flags.h b/static_core/libllvmbackend/transforms/passes/infer_flags.h index cee7c37848b2ede45f48cd1e228d9a4200b2ca98..3c196a808ab81374ba53232b4b97d7d58c639772 100644 --- a/static_core/libllvmbackend/transforms/passes/infer_flags.h +++ b/static_core/libllvmbackend/transforms/passes/infer_flags.h @@ -24,10 +24,6 @@ namespace ark::llvmbackend { struct LLVMCompilerOptions; } // namespace ark::llvmbackend -namespace ark::llvmbackend { -class LLVMArkInterface; -} // namespace ark::llvmbackend - namespace ark::llvmbackend::passes { /// Simple pass, that infers "nsw" flag (no signed wrap) to help llvm perform optimizations @@ -35,7 +31,10 @@ class InferFlags : public llvm::PassInfoMixin { public: explicit InferFlags() = default; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) + { + return true; + } // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); @@ -51,4 +50,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INFER_FLAGS_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INFER_FLAGS_H diff --git a/static_core/libllvmbackend/transforms/passes/inline_devirt.h b/static_core/libllvmbackend/transforms/passes/inline_devirt.h index 74286c6742b297b47d99934ef933aeb59ddfb1d3..221efc544d004c073ed5866e4dfd27c2496245cf 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_devirt.h +++ b/static_core/libllvmbackend/transforms/passes/inline_devirt.h @@ -28,9 +28,9 @@ class InlineDevirt : public llvm::PassInfoMixin { public: explicit InlineDevirt(LLVMArkInterface *arkInterface = nullptr, bool doVirtualInline = true); - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); - static InlineDevirt Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options); + static InlineDevirt Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::LazyCallGraph::SCC &initialSCC, llvm::CGSCCAnalysisManager &analysisManager, @@ -52,8 +52,8 @@ public: private: bool RunInlining(llvm::InlinerPass &inlinePass, llvm::SmallPtrSetImpl &changedFunctions); - bool RunDevirt(ark::llvmbackend::passes::Devirt &devirtPass); - void RunCheckExternal(ark::llvmbackend::passes::CheckExternal &externalPass); + bool RunDevirt(Devirt &devirtPass); + void RunCheckExternal(CheckExternal &externalPass); }; } // namespace ark::llvmbackend::passes diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/cleanup_inline_module.h b/static_core/libllvmbackend/transforms/passes/inline_ir/cleanup_inline_module.h index 6a24a6210e5c7be118ab6c22ef7642fad0a4ba27..90ac3d2725e4f69a52b573e87599a0d99a629211 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/cleanup_inline_module.h +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/cleanup_inline_module.h @@ -38,7 +38,7 @@ public: ~CleanupInlineModule(); - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Module &module, llvm::ModuleAnalysisManager &analysis_manager); diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.cpp b/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.cpp index 92e84884bc94b2f485400d82005d5a1521b39441..0da26fc01cfa231240cfa7527cb222fd694a23a3 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.cpp +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.cpp @@ -31,11 +31,6 @@ using llvm::convertToDeclaration; namespace ark::llvmbackend::passes { -bool DiscardInlineModule::ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) -{ - return true; -} - /// Discard all functions and global variables from inline module llvm::PreservedAnalyses DiscardInlineModule::run(llvm::Module &module, llvm::ModuleAnalysisManager & /*AM*/) { diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.h b/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.h index b2b836ca24b71962b0f2f6ebcbbf3fe3ce09cb70..9067f0dd11773ca9d7e527383bffdd0ba91fcd47 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.h +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/discard_inline_module.h @@ -30,7 +30,10 @@ namespace ark::llvmbackend::passes { class DiscardInlineModule : public llvm::PassInfoMixin { public: - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) + { + return true; + } // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Module &module, llvm::ModuleAnalysisManager &analysis_manager); @@ -46,4 +49,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INLINE_IR_DISCARD_INLINE_MODULE_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INLINE_IR_DISCARD_INLINE_MODULE_H diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/mark_always_inline.h b/static_core/libllvmbackend/transforms/passes/inline_ir/mark_always_inline.h index 215263cf1077c92808c1d9692e2539033a9e3156..bb83a4087a6b3b43155c38f94f790d8637ca3192 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/mark_always_inline.h +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/mark_always_inline.h @@ -31,7 +31,7 @@ namespace ark::llvmbackend::passes { */ class MarkAlwaysInline : public llvm::PassInfoMixin { public: - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysis_manager); diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/mark_inline_module.h b/static_core/libllvmbackend/transforms/passes/inline_ir/mark_inline_module.h index 491ea80479c69c162ab782a02ec0172844431287..6c0c52f6a28cd00f752ae7915a4088ada7d79d8e 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/mark_inline_module.h +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/mark_inline_module.h @@ -30,7 +30,7 @@ namespace ark::llvmbackend::passes { class MarkInlineModule : public llvm::PassInfoMixin { public: - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Module &module, llvm::ModuleAnalysisManager &analysis_manager); diff --git a/static_core/libllvmbackend/transforms/passes/inline_ir/remove_unused_functions.h b/static_core/libllvmbackend/transforms/passes/inline_ir/remove_unused_functions.h index 4ff01bbd8ea1ad13c002b4c42f32278ea5118f0a..9b4f42b3a141a50c40076c7858e582eee2c99b42 100644 --- a/static_core/libllvmbackend/transforms/passes/inline_ir/remove_unused_functions.h +++ b/static_core/libllvmbackend/transforms/passes/inline_ir/remove_unused_functions.h @@ -39,7 +39,7 @@ namespace ark::llvmbackend::passes { */ class RemoveUnusedFunctions : public llvm::PassInfoMixin { public: - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Module &module, llvm::ModuleAnalysisManager &analysis_manager); diff --git a/static_core/libllvmbackend/transforms/passes/insert_safepoints.h b/static_core/libllvmbackend/transforms/passes/insert_safepoints.h index 59e9c801da3088df980f8def257bdb7dc8b12168..7e45db00fb17449800429edb38223dd554195962 100644 --- a/static_core/libllvmbackend/transforms/passes/insert_safepoints.h +++ b/static_core/libllvmbackend/transforms/passes/insert_safepoints.h @@ -22,17 +22,13 @@ namespace ark::llvmbackend { struct LLVMCompilerOptions; } // namespace ark::llvmbackend -namespace ark::llvmbackend { -class LLVMArkInterface; -} // namespace ark::llvmbackend - namespace ark::llvmbackend::passes { class InsertSafepoints : public llvm::PassInfoMixin { public: explicit InsertSafepoints() = default; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert(const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); @@ -43,4 +39,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INSERT_SAFEPOINTS_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_INSERT_SAFEPOINTS_H diff --git a/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.cpp b/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.cpp index c8c4628dc87f89035a7588736950703491154926..b03cd09bc042088a51a23b9aaade931be903a12b 100644 --- a/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.cpp +++ b/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.cpp @@ -145,7 +145,7 @@ bool IntrinsicsLowering::HandleCall(llvm::CallInst *call, LLVMArkInterface::Intr auto callee = GetPandaRuntimeFunctionCallee(intrinsicId, intrinsicFunctionTy, &builder, intrinsicName); if (type->isVectorTy()) { - llvm::Value *vec = llvm::UndefValue::get(type); + llvm::Value *vec = llvm::PoisonValue::get(type); auto vecLen = llvm::cast(type)->getElementCount().getKnownMinValue(); std::vector args; diff --git a/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.h b/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.h index 4ea00f59b9a1d0dac62b3f69150e0c77002680e4..4a64f8d6caaabcee53853770b840872c65b780c5 100644 --- a/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.h +++ b/static_core/libllvmbackend/transforms/passes/intrinsics_lowering.h @@ -38,13 +38,12 @@ class IntrinsicsLowering : public llvm::PassInfoMixin { public: explicit IntrinsicsLowering(LLVMArkInterface *arkInterface = nullptr); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } - static IntrinsicsLowering Create(LLVMArkInterface *arkInterface, - const ark::llvmbackend::LLVMCompilerOptions *options); + static IntrinsicsLowering Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); diff --git a/static_core/libllvmbackend/transforms/passes/loop_peeling.cpp b/static_core/libllvmbackend/transforms/passes/loop_peeling.cpp index 433ed2e9c6b9bc91627704afbcd6b4a4b9bab755..f617fab114be12af10857abc98524a93aa679204 100644 --- a/static_core/libllvmbackend/transforms/passes/loop_peeling.cpp +++ b/static_core/libllvmbackend/transforms/passes/loop_peeling.cpp @@ -68,8 +68,4 @@ bool ArkLoopPeeling::ContainsDeoptimize(llvm::Loop *loop) return false; } -bool ArkLoopPeeling::ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) -{ - return true; -} } // namespace ark::llvmbackend::passes diff --git a/static_core/libllvmbackend/transforms/passes/loop_peeling.h b/static_core/libllvmbackend/transforms/passes/loop_peeling.h index 1f12c37e92431bc987dabf6d22cf2b70d1126f05..9254a5cfba580609ff1468095339e6b12a2af763 100644 --- a/static_core/libllvmbackend/transforms/passes/loop_peeling.h +++ b/static_core/libllvmbackend/transforms/passes/loop_peeling.h @@ -39,7 +39,10 @@ public: explicit ArkLoopPeeling() = default; - static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) + { + return true; + } private: bool ContainsDeoptimize(llvm::Loop *loop); @@ -50,4 +53,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_LOOP_PEELING_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_LOOP_PEELING_H diff --git a/static_core/libllvmbackend/transforms/passes/mem_barriers.cpp b/static_core/libllvmbackend/transforms/passes/mem_barriers.cpp index 765111a44ddbe52ee1d20dfdf4164f78e171014c..2e6996febaf2585c0e1c4a79db4caab60fcfcc54 100644 --- a/static_core/libllvmbackend/transforms/passes/mem_barriers.cpp +++ b/static_core/libllvmbackend/transforms/passes/mem_barriers.cpp @@ -29,8 +29,7 @@ using llvm::Instruction; namespace ark::llvmbackend::passes { -MemBarriers MemBarriers::Create([[maybe_unused]] LLVMArkInterface *arkInterface, - const ark::llvmbackend::LLVMCompilerOptions *options) +MemBarriers MemBarriers::Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options) { return MemBarriers(arkInterface, options->optimize); } diff --git a/static_core/libllvmbackend/transforms/passes/mem_barriers.h b/static_core/libllvmbackend/transforms/passes/mem_barriers.h index 2f25c88b673015f4e55c5f805905e555dd1ac75a..29285d7d7cfcc1cd813829423f13c1b711e0c0ba 100644 --- a/static_core/libllvmbackend/transforms/passes/mem_barriers.h +++ b/static_core/libllvmbackend/transforms/passes/mem_barriers.h @@ -30,12 +30,12 @@ class MemBarriers : public llvm::PassInfoMixin { public: explicit MemBarriers(LLVMArkInterface *arkInterface, bool optimize); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } - static MemBarriers Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options); + static MemBarriers Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); diff --git a/static_core/libllvmbackend/transforms/passes/panda_runtime_lowering.h b/static_core/libllvmbackend/transforms/passes/panda_runtime_lowering.h index 26c7bebbd3665145eb549b6fc164fda932704f52..51270d2f715e665cd8776a0be308aed4a07c4496 100644 --- a/static_core/libllvmbackend/transforms/passes/panda_runtime_lowering.h +++ b/static_core/libllvmbackend/transforms/passes/panda_runtime_lowering.h @@ -35,13 +35,12 @@ class PandaRuntimeLowering : public llvm::PassInfoMixin { public: explicit PandaRuntimeLowering(LLVMArkInterface *arkInterface = nullptr); - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } - static PandaRuntimeLowering Create(LLVMArkInterface *arkInterface, - const ark::llvmbackend::LLVMCompilerOptions *options); + static PandaRuntimeLowering Create(LLVMArkInterface *arkInterface, const LLVMCompilerOptions *options); // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &am); @@ -63,4 +62,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_PANDA_RUNTIME_LOWERING_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_PANDA_RUNTIME_LOWERING_H diff --git a/static_core/libllvmbackend/transforms/passes/propagate_lenarray.cpp b/static_core/libllvmbackend/transforms/passes/propagate_lenarray.cpp index 6bc06f189d1c33c0d0c8c919752dc6d95e1a6b93..5c1f907eda40495a7391c25b07cdafd666a88df3 100644 --- a/static_core/libllvmbackend/transforms/passes/propagate_lenarray.cpp +++ b/static_core/libllvmbackend/transforms/passes/propagate_lenarray.cpp @@ -33,11 +33,6 @@ namespace ark::llvmbackend::passes { -bool PropagateLenArray::ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) -{ - return true; -} - llvm::PreservedAnalyses PropagateLenArray::run(llvm::Function &function, [[maybe_unused]] llvm::FunctionAnalysisManager &analysisManager) { diff --git a/static_core/libllvmbackend/transforms/passes/propagate_lenarray.h b/static_core/libllvmbackend/transforms/passes/propagate_lenarray.h index 96635803c05bed18f9539756d1080fa0879a50b1..4559aed6189ea2d90a47a648e23c11a394c8a267 100644 --- a/static_core/libllvmbackend/transforms/passes/propagate_lenarray.h +++ b/static_core/libllvmbackend/transforms/passes/propagate_lenarray.h @@ -31,7 +31,10 @@ public: explicit PropagateLenArray() = default; - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options); + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) + { + return true; + } // NOLINTNEXTLINE(readability-identifier-naming) llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager); diff --git a/static_core/libllvmbackend/transforms/passes/prune_deopt.cpp b/static_core/libllvmbackend/transforms/passes/prune_deopt.cpp index b9e736ae97da867053bdf89665d2f04e9ab0b2a0..829782b6e893ebdf1906e73f90c63e968e2be0dc 100644 --- a/static_core/libllvmbackend/transforms/passes/prune_deopt.cpp +++ b/static_core/libllvmbackend/transforms/passes/prune_deopt.cpp @@ -198,7 +198,7 @@ void PruneDeopt::MakeUnreachableAfter(BasicBlock *block, Instruction *after) con if (deoptimize && toRemove.isTerminator()) { continue; } - inst->replaceAllUsesWith(llvm::UndefValue::get(inst->getType())); + inst->replaceAllUsesWith(llvm::PoisonValue::get(inst->getType())); inst->eraseFromParent(); } if (!deoptimize) { diff --git a/static_core/libllvmbackend/transforms/passes/prune_deopt.h b/static_core/libllvmbackend/transforms/passes/prune_deopt.h index 99b94278dc76eb228f79a156d3fb4b2cd8cf37b5..1692e6ba03db3a9bfe0be576815c2fc9c5b097a6 100644 --- a/static_core/libllvmbackend/transforms/passes/prune_deopt.h +++ b/static_core/libllvmbackend/transforms/passes/prune_deopt.h @@ -30,7 +30,7 @@ namespace ark::llvmbackend::passes { class PruneDeopt : public llvm::PassInfoMixin { public: - static bool ShouldInsert([[maybe_unused]] const ark::llvmbackend::LLVMCompilerOptions *options) + static bool ShouldInsert([[maybe_unused]] const LLVMCompilerOptions *options) { return true; } @@ -59,4 +59,4 @@ public: } // namespace ark::llvmbackend::passes -#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_PRUNE_DEOPT_H +#endif // LIBLLVMBACKEND_TRANSFORMS_PASSES_PRUNE_DEOPT_H diff --git a/static_core/libllvmbackend/transforms/runtime_calls.cpp b/static_core/libllvmbackend/transforms/runtime_calls.cpp index b2144a26ebfa7cef728d391de20bacc699ee4135..e6647c6f9af72509fc939a46b7e98d89f62f2730 100644 --- a/static_core/libllvmbackend/transforms/runtime_calls.cpp +++ b/static_core/libllvmbackend/transforms/runtime_calls.cpp @@ -55,44 +55,31 @@ llvm::CallInst *CreateEntrypointCallCommon(llvm::IRBuilder<> *builder, llvm::Val ASSERT(arkInterface->DeoptsEnabled() || bundle.empty()); auto tlsOffset = arkInterface->GetEntrypointTlsOffset(eid); auto [functionProto, functionName] = arkInterface->GetEntrypointCallee(eid); + auto calleeFuncTy = llvm::cast(functionProto); auto threadRegPtr = builder->CreateIntToPtr(threadRegValue, builder->getPtrTy()); auto addr = builder->CreateConstInBoundsGEP1_64(builder->getInt8Ty(), threadRegPtr, tlsOffset); auto callee = builder->CreateLoad(builder->getPtrTy(), addr, functionName + "_addr"); - - auto calleeFuncTy = llvm::cast(functionProto); - auto call = builder->CreateCall(calleeFuncTy, callee, arguments, bundle); - auto bridgeType = arkInterface->GetBridgeType(eid); ASSERT(bridgeType != BridgeType::SLOW_PATH && bridgeType != BridgeType::ODD_SAVED); - ASSERT(call->getCallingConv() == llvm::CallingConv::C); - // Entrypoint bridges preserve a lot of registers, so we can put appropriate ArkFast convention for them. + // Entrypoint bridge preserves a lot of registers, use ArkFast convention for calls. if (bridgeType == BridgeType::ENTRYPOINT) { - llvm::CallingConv::ID cc = llvm::CallingConv::C; - switch (arguments.size()) { - case 0U: - cc = llvm::CallingConv::ArkFast0; - break; - case 1U: - case 2U: - cc = llvm::CallingConv::ArkFast2; - break; - case 3U: - case 4U: - cc = llvm::CallingConv::ArkFast4; - break; - case 5U: - case 6U: - cc = llvm::CallingConv::ArkFast6; - break; - default: - llvm_unreachable("Entrypoints with 7 and more arguments are not supported"); + llvm::CallInst *call; + // See LLVMArkInterface::GetOrCreateRuntimeFunctionType + if (arkInterface->IsArm64() && calleeFuncTy->getNumParams() > arguments.size()) { + ASSERT(calleeFuncTy->getNumParams() % 2U == 0 && calleeFuncTy->getNumParams() == arguments.size() + 1U); + std::vector argsAdj(arguments); + argsAdj.push_back(llvm::PoisonValue::get(builder->getInt64Ty())); + call = builder->CreateCall(calleeFuncTy, callee, argsAdj, bundle); + } else { + call = builder->CreateCall(calleeFuncTy, callee, arguments, bundle); } - call->setCallingConv(cc); + call->setCallingConv(llvm::CallingConv::ArkFast); + return call; } - return call; + return builder->CreateCall(calleeFuncTy, callee, arguments, bundle); } llvm::Value *GetThreadRegValue(llvm::IRBuilder<> *builder, LLVMArkInterface *arkInterface) diff --git a/static_core/libpandabase/CMakeLists.txt b/static_core/libpandabase/CMakeLists.txt index fd0590711ec32d5822c63e85ac3e95644d9e0679..409de20761f6dc4498dc14c3a9828daef6a4c538 100644 --- a/static_core/libpandabase/CMakeLists.txt +++ b/static_core/libpandabase/CMakeLists.txt @@ -348,6 +348,7 @@ foreach(TARGET ${ARKBASE_TARGETS}) ) endforeach() +if(false) set(ARKBASE_TESTS_SOURCES tests/list_test.cpp tests/bit_helpers_test.cpp @@ -518,6 +519,7 @@ if(PANDA_TARGET_32) COMMAND ${PANDA_RUN_PREFIX} ${PANDA_BINARY_ROOT}/bin-gtests/memory_literals_test ) endif() +endif() # if(false) panda_gen_options(TARGET arkbase_obj YAML_FILE options.yaml GENERATED_HEADER base_options.h) diff --git a/static_core/libpandafile/CMakeLists.txt b/static_core/libpandafile/CMakeLists.txt index 6320f69db09bd3dcd27e897fbc4543c338cbc034..5a9fd36707204eae1366d48b45e4bda149f772b3 100644 --- a/static_core/libpandafile/CMakeLists.txt +++ b/static_core/libpandafile/CMakeLists.txt @@ -91,8 +91,7 @@ add_dependencies(arkfile isa_gen_${PROJECT_NAME} type_gen_${PROJECT_NAME}) panda_target_link_libraries(arkfile ${LINK_LIBRARIES}) -# NOTE(aakmaev): Enable when #14728 internal issue will be fixed -if (NOT PANDA_TARGET_ARM64) +if (false) panda_add_gtest( NAME arkfile_tests SOURCES @@ -117,7 +116,7 @@ if (NOT PANDA_TARGET_ARM64) panda_target_include_directories(arkfile_tests PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include/tests) endif() -endif() +endif() # if(false) panda_add_sanitizers(TARGET arkfile SANITIZERS ${PANDA_SANITIZERS_LIST}) diff --git a/static_core/libziparchive/CMakeLists.txt b/static_core/libziparchive/CMakeLists.txt index a434764cc69c8ded5396a5f23f9e0917105ab7bc..7fa529dceede7852b784caf624fa26e7f2edc516 100644 --- a/static_core/libziparchive/CMakeLists.txt +++ b/static_core/libziparchive/CMakeLists.txt @@ -32,6 +32,7 @@ if(NOT PANDA_USE_PREBUILT_TARGETS) panda_target_link_libraries(arkziparchive zlib) endif() +if(false) panda_add_gtest( NAME arkziparchive_tests SOURCES @@ -44,5 +45,6 @@ panda_add_gtest( SANITIZERS ${PANDA_SANITIZERS_LIST} ) +endif() # if(false) panda_add_sanitizers(TARGET arkziparchive SANITIZERS ${PANDA_SANITIZERS_LIST}) diff --git a/static_core/plugins/ets/CMakeLists.txt b/static_core/plugins/ets/CMakeLists.txt index aa939c5aa4c5fd2817e363760d6132b41399e100..40530c4a857de0ad6313e0e15544d6addf8bbcc6 100644 --- a/static_core/plugins/ets/CMakeLists.txt +++ b/static_core/plugins/ets/CMakeLists.txt @@ -126,10 +126,19 @@ endif() if(PANDA_WITH_COMPILER) add_subdirectory(compiler) - set (COMPILER_OPTIONS "--compiler-check-final=true") + if(PANDA_LLVM_AOT) + set(STDLIB_PAOC_MODE "llvm") + set(COMPILER_OPTIONS "--compiler-check-final=true" "--llvm-gc-check=true" "--llvm-pre-opt=2") + if (NOT PANDA_ENABLE_THREAD_SANITIZER) + set(COMPILER_OPTIONS ${COMPILER_OPTIONS} "--llvmaot-threads=4" "--llvmaot-methods-per-module=512") + endif() + else() + set(STDLIB_PAOC_MODE "aot") + set(COMPILER_OPTIONS "--compiler-check-final=true") + endif() add_custom_target(ets-compile-stdlib-default COMMENT "Running ark_aot compilation for etsstdlib with default options" - COMMAND ${CMAKE_SOURCE_DIR}/plugins/ets/compiler/tools/paoc_compile_stdlib.sh --prefix="${PANDA_RUN_PREFIX}" --binary-dir=${CMAKE_BINARY_DIR} -compiler-options="${COMPILER_OPTIONS}" -paoc-output=${CMAKE_CURRENT_BINARY_DIR}/etsstdlib.an + COMMAND ${CMAKE_SOURCE_DIR}/plugins/ets/compiler/tools/paoc_compile_stdlib.sh --prefix="${PANDA_RUN_PREFIX}" --binary-dir=${CMAKE_BINARY_DIR} -compiler-options="${COMPILER_OPTIONS}" --paoc-mode=${STDLIB_PAOC_MODE} -paoc-output=${CMAKE_CURRENT_BINARY_DIR}/etsstdlib.an DEPENDS ark_aot etsstdlib ) endif() diff --git a/static_core/plugins/ets/irtoc_scripts/string.irt b/static_core/plugins/ets/irtoc_scripts/string.irt index f52165a556e83979da21a78bceb159977f4a97a4..d8356784dc998fb179716f86ff302795043d992f 100644 --- a/static_core/plugins/ets/irtoc_scripts/string.irt +++ b/static_core/plugins/ets/irtoc_scripts/string.irt @@ -1137,7 +1137,7 @@ function(:StringIndexOf, LiveOut(str_data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED_SMALL") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedSmall").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedSmall").Terminator.i32 } # 16 <= data size < 32 If(str_data_size_u16, 32).LT.Unlikely.b { @@ -1145,14 +1145,14 @@ function(:StringIndexOf, LiveOut(str_data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED_MEDIUM") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedMedium").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedMedium").Terminator.i32 } # 32 <= data size LiveOut(str_data).DstReg(regmap[:arg0]).ptr LiveOut(str_data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressed").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressed").Terminator.i32 } IfImm(Compare(ch, Constants::MAX_U8_VALUE).A.b).Imm(0).NE.Unlikely.b { @@ -1166,7 +1166,7 @@ function(:StringIndexOf, LiveOut(str_data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_SMALL") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedSmall").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedSmall").Terminator.i32 } # 8 <= data size < 16 If(str_data_size_u8, 16).LT.Unlikely.b { @@ -1174,7 +1174,7 @@ function(:StringIndexOf, LiveOut(str_data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_MEDIUM") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedMedium").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedMedium").Terminator.i32 } # 16 <= data size < 32 If(str_data_size_u8, 32).LT.Unlikely.b { @@ -1182,14 +1182,14 @@ function(:StringIndexOf, LiveOut(str_data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_LARGE") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedLarge").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedLarge").Terminator.i32 } # 32 <= data size LiveOut(str_data).DstReg(regmap[:arg0]).ptr LiveOut(str_data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressed").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressed").Terminator.i32 } @@ -1237,7 +1237,7 @@ function(:StringIndexOfAfter, LiveOut(data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED_SMALL") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedSmall").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedSmall").Terminator.i32 } # 16 <= data size < 32 If(data_size_u16, 32).LT.Unlikely.b { @@ -1245,14 +1245,14 @@ function(:StringIndexOfAfter, LiveOut(data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED_MEDIUM") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedMedium").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressedMedium").Terminator.i32 } # 32 <= data size LiveOut(data_ptr_u16).DstReg(regmap[:arg0]).ptr LiveOut(data_size_u16).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u16 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_UNCOMPRESSED") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressed").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfUncompressed").Terminator.i32 } IfImm(Compare(ch, Constants::MAX_U8_VALUE).A.b).Imm(0).NE.Unlikely.b { @@ -1268,7 +1268,7 @@ function(:StringIndexOfAfter, LiveOut(data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_SMALL") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedSmall").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedSmall").Terminator.i32 } # 8 <= data size < 16 If(data_size_u8, 16).LT.Unlikely.b { @@ -1276,7 +1276,7 @@ function(:StringIndexOfAfter, LiveOut(data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_MEDIUM") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedMedium").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedMedium").Terminator.i32 } # 16 <= data size < 32 If(data_size_u8, 32).LT.Unlikely.b { @@ -1284,12 +1284,12 @@ function(:StringIndexOfAfter, LiveOut(data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED_LARGE") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedLarge").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressedLarge").Terminator.i32 } # 32 <= data size LiveOut(data_ptr_u8).DstReg(regmap[:arg0]).ptr LiveOut(data_size_u8).DstReg(regmap[:arg1]).u32 LiveOut(ch).DstReg(regmap[:arg2]).u8 entrypoint = get_entrypoint_offset("STRING_INDEX_OF_COMPRESSED") - Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressed").Terminator.b + Intrinsic(:TAIL_CALL).AddImm(entrypoint).MethodAsImm("StringIndexOfCompressed").Terminator.i32 } diff --git a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl index dd1ccbd7054d1e48243e26ca08fea9b8855cd2c2..79305121e01c15786407d6de654accaa7b299e44 100644 --- a/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl +++ b/static_core/plugins/ets/libllvmbackend/ets_llvm_ir_constructor_gen.inl @@ -48,7 +48,7 @@ bool LLVMIrConstructor::EmitArrayCopyTo(Inst *inst) bool LLVMIrConstructor::EmitStdStringSubstring(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::SUB_STRING_FROM_STRING_TLAB_COMPRESSED, 3U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::SUB_STRING_FROM_STRING_TLAB_COMPRESSED); } bool LLVMIrConstructor::EmitStringBuilderAppendBool(Inst *inst) @@ -160,7 +160,7 @@ bool LLVMIrConstructor::EmitStringBuilderAppendStrings(Inst *inst) default: UNREACHABLE(); } - return EmitFastPath(inst, eid, inst->GetInputsCount() - 1U); // -1 to skip save state + return EmitFastPath(inst, eid); } bool LLVMIrConstructor::EmitStringBuilderToString(Inst *inst) @@ -311,7 +311,7 @@ void LLVMIrConstructor::StringBuilderAppendStringMain(Inst *inst, llvm::Value *s bool LLVMIrConstructor::EmitDoubleToStringDecimal(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::DOUBLE_TO_STRING_DECIMAL, 3U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::DOUBLE_TO_STRING_DECIMAL); } bool LLVMIrConstructor::EmitStringTrimLeft(Inst *inst) @@ -340,17 +340,17 @@ bool LLVMIrConstructor::EmitStringTrim(Inst *inst) bool LLVMIrConstructor::EmitCharIsWhiteSpace(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::CHAR_IS_WHITE_SPACE, 1U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::CHAR_IS_WHITE_SPACE); } bool LLVMIrConstructor::EmitStringStartsWith(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_STARTS_WITH, 3U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_STARTS_WITH); } bool LLVMIrConstructor::EmitStringEndsWith(Inst *inst) { - return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_ENDS_WITH, 3U); + return EmitFastPath(inst, RuntimeInterface::EntrypointId::STRING_ENDS_WITH); } bool LLVMIrConstructor::EmitStringGetBytesTlab(Inst *inst) @@ -358,10 +358,8 @@ bool LLVMIrConstructor::EmitStringGetBytesTlab(Inst *inst) auto offset = GetGraph()->GetRuntime()->GetArrayU8ClassPointerTlsOffset(GetGraph()->GetArch()); auto klass = llvmbackend::runtime_calls::LoadTLSValue(&builder_, arkInterface_, offset, builder_.getPtrTy()); auto eid = RuntimeInterface::EntrypointId::STRING_GET_BYTES_TLAB; - auto result = CreateEntrypointCall(eid, inst, - {GetInputValue(inst, 0), GetInputValue(inst, 1), GetInputValue(inst, 2), klass}); - ASSERT(result->getCallingConv() == llvm::CallingConv::C); - result->setCallingConv(llvm::CallingConv::ArkFast4); + auto result = + CreateFastPathCall(inst, eid, {GetInputValue(inst, 0), GetInputValue(inst, 1), GetInputValue(inst, 2), klass}); result->addRetAttr(llvm::Attribute::NonNull); result->addRetAttr(llvm::Attribute::NoAlias); ValueMapAdd(inst, result); diff --git a/static_core/plugins/ets/tests/CMakeLists.txt b/static_core/plugins/ets/tests/CMakeLists.txt index e5e1ddaa8dcd898546d3afa337e3555279ffaeb5..a738b060b1badb87f286ccf48583db47f78b80a6 100644 --- a/static_core/plugins/ets/tests/CMakeLists.txt +++ b/static_core/plugins/ets/tests/CMakeLists.txt @@ -432,51 +432,32 @@ endfunction() set (COMPILER_OPTIONS_OSR "--compiler-ignore-failures=true" ${COMPILER_OPTIONS}) function(compile_stdlib TARGET_ARCH) - add_custom_target(ets-compile-stdlib-aot-${TARGET_ARCH} - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with default options" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=aot -compiler-options="${COMPILER_OPTIONS}" -paoc-output=etsstdlib_aot_${TARGET_ARCH}.an - DEPENDS ark_aot etsstdlib - ) - add_custom_target(ets-compile-stdlib-jit-${TARGET_ARCH} - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with jit mode" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=jit -compiler-options="${COMPILER_OPTIONS}" -paoc-output=etsstdlib_jit_${TARGET_ARCH}.an - DEPENDS ark_aot etsstdlib - ) - add_custom_target(ets-compile-stdlib-aot-${TARGET_ARCH}-no-inline - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} without inlining" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=aot -compiler-options="${COMPILER_OPTIONS_NO_INLINE}" -paoc-output=etsstdlib_aot_${TARGET_ARCH}_no_inline.an - DEPENDS ark_aot etsstdlib - ) - add_custom_target(ets-compile-stdlib-aot-${TARGET_ARCH}-stw - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with gc stw" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=aot -compiler-options="${COMPILER_OPTIONS_GC_STW}" -paoc-output=etsstdlib_aot_${TARGET_ARCH}_stw.an - DEPENDS ark_aot etsstdlib - ) - add_dependencies(ets-compile-stdlib ets-compile-stdlib-aot-${TARGET_ARCH} ets-compile-stdlib-jit-${TARGET_ARCH} ets-compile-stdlib-aot-${TARGET_ARCH}-no-inline ets-compile-stdlib-aot-${TARGET_ARCH}-stw) if (PANDA_LLVM_AOT) - add_custom_target(ets-compile-stdlib-llvm-${TARGET_ARCH} - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with llvm" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS_LLVM}" -paoc-output=etsstdlib_llvmaot_${TARGET_ARCH}.an + add_custom_target(ets-compile-stdlib-llvmaot-${TARGET_ARCH} + COMMENT "Running LLVMAOT compilation for etsstdlib for ${TARGET_ARCH}" + COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS}" -paoc-output=etsstdlib_llvmaot_${TARGET_ARCH}.an DEPENDS ark_aot etsstdlib ) - add_custom_target(ets-compile-stdlib-llvm-pre-opt-2-${TARGET_ARCH} - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with llvm pre-opt" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS_LLVM_PRE_OPT}" -paoc-output=etsstdlib_llvmaot_pre_opt_2_${TARGET_ARCH}.an + add_custom_target(ets-compile-stdlib-llvmaot-${TARGET_ARCH}-no-inline + COMMENT "Running LLVMAOT compilation for etsstdlib for ${TARGET_ARCH} without inlining" + COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS_NO_INLINE}" -paoc-output=etsstdlib_llvmaot_${TARGET_ARCH}_no_inline.an DEPENDS ark_aot etsstdlib ) - add_dependencies( - ets-compile-stdlib - ets-compile-stdlib-llvm-${TARGET_ARCH} - ets-compile-stdlib-llvm-pre-opt-2-${TARGET_ARCH} + add_custom_target(ets-compile-stdlib-llvmaot-${TARGET_ARCH}-no-pre-opt + COMMENT "Running LLVMAOT compilation for etsstdlib for ${TARGET_ARCH} with llvm without pre-opt" + COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS_NO_PRE_OPT}" -paoc-output=etsstdlib_llvmaot_${TARGET_ARCH}_no_pre_opt.an + DEPENDS ark_aot etsstdlib ) - endif() - if (TARGET_ARCH STREQUAL "arm64") - add_custom_target(ets-compile-stdlib-osr-${TARGET_ARCH} - COMMENT "Running ark_aot compilation for etsstdlib for ${TARGET_ARCH} with osr mode" - COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=osr -compiler-options="${COMPILER_OPTIONS_OSR}" -paoc-output=etsstdlib_osr_${TARGET_ARCH}.an + add_custom_target(ets-compile-stdlib-llvmaot-${TARGET_ARCH}-stw + COMMENT "Running LLVMAOT compilation for etsstdlib for ${TARGET_ARCH} with gc stw" + COMMAND ${ARK_AOT_RUNNER} --binary-dir=${CMAKE_BINARY_DIR} --target-arch=${TARGET_ARCH} --paoc-mode=llvm -compiler-options="${COMPILER_OPTIONS_GC_STW}" -paoc-output=etsstdlib_llvmaot_${TARGET_ARCH}_stw.an DEPENDS ark_aot etsstdlib ) - add_dependencies(ets-compile-stdlib ets-compile-stdlib-osr-${TARGET_ARCH}) + add_dependencies(ets-compile-stdlib + ets-compile-stdlib-llvmaot-${TARGET_ARCH} + ets-compile-stdlib-llvmaot-${TARGET_ARCH}-no-inline + ets-compile-stdlib-llvmaot-${TARGET_ARCH}-no-pre-opt + ets-compile-stdlib-llvmaot-${TARGET_ARCH}-stw) endif() endfunction() @@ -495,23 +476,13 @@ endif() if(PANDA_TEST_COMPILE_STDLIB) set (ARK_AOT_RUNNER ${CMAKE_SOURCE_DIR}/plugins/ets/compiler/tools/paoc_compile_stdlib.sh) - if (NOT PANDA_CI_TESTING_MODE STREQUAL "Nightly") - set (COMPILER_OPTIONS "--compiler-check-final=true") - if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set (COMPILER_OPTIONS ${COMPILER_OPTIONS} "--compiler-inst-graph-coloring-limit=2000") - endif() + set (COMPILER_OPTIONS "--compiler-check-final=true" "--llvm-gc-check=true" "--llvm-pre-opt=2") + if (NOT PANDA_ENABLE_THREAD_SANITIZER) + set (COMPILER_OPTIONS ${COMPILER_OPTIONS} "--llvmaot-threads=4" "--llvmaot-methods-per-module=512") endif() set (COMPILER_OPTIONS_NO_INLINE "--compiler-inlining=false" ${COMPILER_OPTIONS}) set (COMPILER_OPTIONS_GC_STW "--gc-type=stw" ${COMPILER_OPTIONS}) - if (PANDA_LLVM_AOT) - set (COMPILER_OPTIONS_LLVM ${COMPILER_OPTIONS}) - set (COMPILER_OPTIONS_LLVM_PRE_OPT "--llvm-pre-opt=2" ${COMPILER_OPTIONS}) - # NOTE(zdenis): False positives come from libLLVM.so - if (NOT PANDA_ENABLE_THREAD_SANITIZER) - set (COMPILER_OPTIONS_LLVM "--llvmaot-threads=4" "--llvmaot-methods-per-module=512" ${COMPILER_OPTIONS_LLVM}) - set (COMPILER_OPTIONS_LLVM_PRE_OPT "--llvmaot-threads=4" "--llvmaot-methods-per-module=512" ${COMPILER_OPTIONS_LLVM_PRE_OPT}) - endif() - endif () + set (COMPILER_OPTIONS_NO_PRE_OPT ${COMPILER_OPTIONS} "--llvm-pre-opt=0") add_custom_target(ets-compile-stdlib) if (PANDA_COMPILER_TARGET_X86_64) compile_stdlib(x86_64) diff --git a/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt index cdf84a5f60f9a5a7bc0e55cc23115dd930ce1df3..b1806c4d47af867c7798f7a7a5cbad2d65c2a324 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/CMakeLists.txt @@ -45,12 +45,12 @@ function(add_ets_test test_suite) set(target ${test_suite}_${ARG_TEST_NAME}-ets-aot) LIST(APPEND targets ${target}) run_aot_ets_code(aot ${test_in} ${test_out_dir} ${target} RUNTIME_EXTRA_OPTIONS ${ARG_OPTIONS}) - endif() - if ("LLVMAOT" IN_LIST ARG_MODE AND PANDA_LLVM_AOT) - set(target ${test_suite}_${ARG_TEST_NAME}-ets-llvmaot) - LIST(APPEND targets ${target}) - run_aot_ets_code(llvm ${test_in} ${test_out_dir} ${target} RUNTIME_EXTRA_OPTIONS ${ARG_OPTIONS}) + if (PANDA_LLVM_AOT) + set(llvm_target ${test_suite}_${ARG_TEST_NAME}-ets-llvmaot) + LIST(APPEND targets ${llvm_target}) + run_aot_ets_code(llvm ${test_in} ${test_out_dir} ${llvm_target} RUNTIME_EXTRA_OPTIONS ${ARG_OPTIONS}) + endif() endif() if ("JIT" IN_LIST ARG_MODE) diff --git a/static_core/plugins/ets/tests/ets_test_suite/containers/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/containers/CMakeLists.txt index 734be4679b03460ee1d40e76927b6c09943c4c3d..c7fd0bec844f0ee8f8e35e3b53986b9957751933 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/containers/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/containers/CMakeLists.txt @@ -24,7 +24,7 @@ add_custom_target(ets_test_suite_containers) # OPTION_SETS_THREADED "DEFAULT" # OPTION_SETS_STACKFUL "DEFAULT" "JS" "POOL" "JS_POOL" # WORKERS "AUTO" "ONE" -# MODE "INT" "JIT" "AOT" "LLVMAOT" "JITOSR" +# MODE "INT" "JIT" "AOT" "JITOSR" # ) # SKIP_ARM32_COMPILER and OPTIONS will apply to all tests function(add_ets_containers_test) diff --git a/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt index cecb39207b953bebd45a4f8096ad32a1b9eded94..b2fd259ba5bbe93de2efa94b74e670dfaf72039f 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/coroutines/CMakeLists.txt @@ -24,7 +24,7 @@ add_custom_target(ets_test_suite_coroutines) # OPTION_SETS_THREADED "DEFAULT" # OPTION_SETS_STACKFUL "DEFAULT" "JS" "POOL" "JS_POOL" # WORKERS "AUTO" "ONE" -# MODE "INT" "JIT" "AOT" "LLVMAOT" "JITOSR" +# MODE "INT" "JIT" "AOT" "JITOSR" # ) # This funciont will create a number of tests as a cartesian product of IMPL, OPTION_SETS_${IMPL}, WORKERS, and MODES, e.g. # THREADED DEFAULT AUTO INT diff --git a/static_core/plugins/ets/tests/ets_test_suite/gc/CMakeLists.txt b/static_core/plugins/ets/tests/ets_test_suite/gc/CMakeLists.txt index 00b03e90b9dd74bcb48e2653fc20b4b40f786265..7ac5034d9d38d4df1f3a26593408b8558d2a7616 100644 --- a/static_core/plugins/ets/tests/ets_test_suite/gc/CMakeLists.txt +++ b/static_core/plugins/ets/tests/ets_test_suite/gc/CMakeLists.txt @@ -86,8 +86,7 @@ add_dependencies(mm_tests bouncing_pandas_ets-ets-jit bouncing_peas_ets-ets-int bouncing_peas_ets-ets-int-cpp - bouncing_peas_ets-ets-jit - etsnapi_test_suite) + bouncing_peas_ets-ets-jit) if(NOT CMAKE_CROSSCOMPILING) add_dependencies(mm_tests bouncing_pandas_ets-ets-aot diff --git a/static_core/plugins/ets/tests/micro-benchmarks/CMakeLists.txt b/static_core/plugins/ets/tests/micro-benchmarks/CMakeLists.txt index b8ef1806ce89d399e81802d8fc40b4094446acf9..c1fd5be6dacc6077f4348e923e4a410efacfefb2 100644 --- a/static_core/plugins/ets/tests/micro-benchmarks/CMakeLists.txt +++ b/static_core/plugins/ets/tests/micro-benchmarks/CMakeLists.txt @@ -75,5 +75,3 @@ if(PANDA_WITH_BENCHMARKS) endforeach() endforeach() endif() - -add_dependencies(ets_tests sampler_etsnapi_test_suite) diff --git a/static_core/plugins/ets/tests/napi/CMakeLists.txt b/static_core/plugins/ets/tests/napi/CMakeLists.txt index d375c3a9fc146a13d73b2d4cd0640dbb0095d6df..6b4dd514942d7d27d6718ad584c3d5fcca27095b 100644 --- a/static_core/plugins/ets/tests/napi/CMakeLists.txt +++ b/static_core/plugins/ets/tests/napi/CMakeLists.txt @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(false) add_subdirectory(bridges) add_subdirectory(etsnative) add_subdirectory(sampler) @@ -97,3 +98,4 @@ foreach(t ${ets_tests_list}) endforeach() add_dependencies(ets_tests etsnapi_test_suite) +endif() # if(false) diff --git a/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt b/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt index 032ec992b0df1d8f0b158cb77405c9714a77e35a..7e04d682601970e73fc2f7fbc1a502eeaa1317bb 100644 --- a/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt +++ b/static_core/plugins/ets/tests/runtime/tooling/CMakeLists.txt @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(false) if (NOT TARGET es2panda OR PANDA_TARGET_ARM32) return() endif() @@ -45,3 +46,4 @@ add_custom_target(es2panda_convert_ets_debug_info DEPENDS es2panda_ets_stdlib_debug_info ) add_dependencies(debug_info_tests_ets_gtests es2panda_convert_ets_debug_info) +endif() # if(false) diff --git a/static_core/runtime/CMakeLists.txt b/static_core/runtime/CMakeLists.txt index 649f56f72a24faed436420358f830c7489018dcd..1ce098576714c167d366d807cbef3e095b91f3d0 100644 --- a/static_core/runtime/CMakeLists.txt +++ b/static_core/runtime/CMakeLists.txt @@ -744,6 +744,7 @@ if (INTRUSIVE_TESTING) add_subdirectory(${PANDA_ROOT}/runtime/tests/intrusive-tests ${CMAKE_BINARY_DIR}/runtime/tests/intrusive_tests) endif() +if(false) function(add_multithread_gtests test_name) panda_add_gtest( NAME ${test_name} @@ -945,6 +946,7 @@ add_gtests( tests/regexp_test.cpp tests/dyn_buffer_test.cpp ) +endif() # if(false) # We run irtoc tests only in host mode, because irtoc tests are intended for testing only Irtoc language capabilities. if (PANDA_WITH_TESTS OR HOST_TOOLS) @@ -979,6 +981,7 @@ if (PANDA_WITH_TESTS OR HOST_TOOLS) endif() endif() +if(false) if (NOT PANDA_PRODUCT_BUILD) add_gtests( arkruntime_intrinsics_blacklist_test @@ -1064,6 +1067,7 @@ add_gtests( ${PANDA_ROOT}/compiler/tests/panda_runner.cpp $ ) +endif() # if(false) include(intrinsics.cmake) include(icu.cmake) diff --git a/static_core/runtime/arch/aarch64/call_runtime.S b/static_core/runtime/arch/aarch64/call_runtime.S index e250e5fe244461e270fc40a3ca50dac494e4d724..e8290db930fd345fca93c126fca5c89be4fbca2e 100644 --- a/static_core/runtime/arch/aarch64/call_runtime.S +++ b/static_core/runtime/arch/aarch64/call_runtime.S @@ -81,12 +81,17 @@ CFI_RESTORE(d8) .endm -.macro SAVE_CALLER_GP_REGS fp_reg, tmp_reg, paramsnum, mode +.macro SAVE_CALLER_GP_REGS fp_reg, tmp_reg, paramsnum, mode, ret_type .if \mode != RUNTIME_MODE_STUB // parameter holding registers are saved by the caller function .ifeq \paramsnum +.ifnc \ret_type,INTEGER stp x0, x1, [\fp_reg, #-CALLER_REG0_OFFSET+8*0] .else + add \tmp_reg, \fp_reg, #-CALLER_REG0_OFFSET + str x1, [\tmp_reg, #8*1] +.endif +.else // paramsnum > 0 .if \mode == RUNTIME_MODE_ODD_SAVED .ifeq \paramsnum-1 add \tmp_reg, \fp_reg, #-CALLER_REG0_OFFSET @@ -114,7 +119,7 @@ .endif .endif // mode == RUNTIME_MODE_ODD_SAVED .endif -.endif // \mode != RUNTIME_MODE_STUB +.endif // mode != RUNTIME_MODE_STUB // Save caller saved regs // first registers are stored by user of this macro or caller which uses them for arguments @@ -236,7 +241,7 @@ SAVE_CALLEE_FP_REGS sp, BRIDGE_FRAME_SIZE .if \mode != RUNTIME_MODE_SLOW_PATH - SAVE_CALLER_GP_REGS fp, lr, \paramsnum, \mode + SAVE_CALLER_GP_REGS fp, lr, \paramsnum, \mode, \ret_type .endif ldr x19, [fp, #(-CFRAME_FLAGS_SLOT * 8)] diff --git a/static_core/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S b/static_core/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S index 6cbeb3b5dad703f7b1fa653072046c9bbbd77994..f20efa8e73a6c3a6f96de6b390e2392d21aff388 100644 --- a/static_core/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S +++ b/static_core/runtime/bridge/arch/amd64/compiled_code_to_runtime_bridge_amd64.S @@ -42,8 +42,10 @@ CFI_RESTORE(rbx) .endm -.macro SAVE_CALLER_GP_REGS fp_reg, paramsnum +.macro SAVE_CALLER_GP_REGS fp_reg, paramsnum, ret_type +.ifnc \ret_type,INTEGER movq %rax, (-CALLER_REG0_OFFSET + 0)(%\fp_reg) +.endif .ifle \paramsnum-3 movq %rcx, (-CALLER_REG0_OFFSET + 8)(%\fp_reg) .endif @@ -200,7 +202,7 @@ TYPE_FUNCTION(\name) mov %r13, MANAGED_THREAD_FRAME_OFFSET(%THREAD_REG) .if \mode != RUNTIME_MODE_SLOW_PATH - SAVE_CALLER_GP_REGS rbp, \paramsnum + SAVE_CALLER_GP_REGS rbp, \paramsnum, \ret_type .endif movq (-CFRAME_FLAGS_SLOT * 8)(%rbp), %r12 diff --git a/static_core/runtime/bridge/arch/arm/compiled_code_to_runtime_bridge_arm.S b/static_core/runtime/bridge/arch/arm/compiled_code_to_runtime_bridge_arm.S index e729a9fdcd0a36afdd95a09b78d3d24e72ed3c21..6bffcfa253482afd008825561888a4296e0ffc1f 100644 --- a/static_core/runtime/bridge/arch/arm/compiled_code_to_runtime_bridge_arm.S +++ b/static_core/runtime/bridge/arch/arm/compiled_code_to_runtime_bridge_arm.S @@ -65,17 +65,36 @@ CFI_RESTORE(d8) .endm -.macro SAVE_CALLER_GP_REGS fp_reg, tmp_reg, paramsnum +.macro SAVE_CALLER_GP_REGS fp_reg, tmp_reg, paramsnum, ret_type add \tmp_reg, \fp_reg, #-CALLER_REG0_OFFSET+4*4 .ifeq \paramsnum +#ifdef PANDA_TARGET_ARM32_ABI_HARD +.ifnc \ret_type,INTEGER +#else +.ifc \ret_type,VOID +#endif stmdb \tmp_reg, {r0-r3} +.else + stmdb \tmp_reg, {r2-r3} +.endif .endif + .ifeq \paramsnum-1 +#ifdef PANDA_TARGET_ARM32_ABI_HARD +.ifnc \ret_type,INTEGER +#else +.ifc \ret_type,VOID +#endif stmdb \tmp_reg, {r1-r3} +.else + stmdb \tmp_reg, {r2-r3} +.endif .endif + .ifeq \paramsnum-2 stmdb \tmp_reg, {r2-r3} .endif + .ifeq \paramsnum-3 str r3, [\tmp_reg, #-4] .endif @@ -217,7 +236,7 @@ #endif .if \mode != RUNTIME_MODE_SLOW_PATH - SAVE_CALLER_GP_REGS fp, lr, \paramsnum + SAVE_CALLER_GP_REGS fp, lr, \paramsnum, \ret_type .endif #ifndef PANDA_TARGET_ARM32_ABI_SOFT diff --git a/static_core/runtime/entrypoints/entrypoints.yaml b/static_core/runtime/entrypoints/entrypoints.yaml index f1d3c551fc9aa4d7204a97d90b607690db73bc1d..67000f3b9a9c016aa2f32625552275a511ac9017 100644 --- a/static_core/runtime/entrypoints/entrypoints.yaml +++ b/static_core/runtime/entrypoints/entrypoints.yaml @@ -705,6 +705,14 @@ entrypoints: - void - ark::ObjectHeader* +- name: PreWrbInterposer # "bridge" to avoid generating the excessive prologue + entrypoint: PreWrbInterposer + bridge: none + properties: [irtoc] + signature: + - void + - ark::ObjectHeader* + - name: MonitorEnterOddSaved entrypoint: LockObjectSlowPathEntrypoint bridge: odd_saved diff --git a/static_core/scripts/clang-tidy/clang-tidy_llvm_config.json b/static_core/scripts/clang-tidy/clang-tidy_llvm_config.json new file mode 100644 index 0000000000000000000000000000000000000000..ebf474cc24279fd1e7abefe17a4cdd5e67530948 --- /dev/null +++ b/static_core/scripts/clang-tidy/clang-tidy_llvm_config.json @@ -0,0 +1,10 @@ +[ + "libllvmbackend", + "irtoc/backend/", + "compiler/aot/aot_builder/aot_builder.cpp", + "compiler/aot/aot_builder/llvm_aot_builder.cpp", + "compiler/aot/aot_file.cpp", + "compiler/optimizer/ir/aot_data.cpp", + "compiler/tools/paoc/paoc.cpp", + "compiler/tools/paoc/paoc_llvm.cpp" +] diff --git a/static_core/scripts/clang-tidy/clang_tidy_check.py b/static_core/scripts/clang-tidy/clang_tidy_check.py index c6e5b34921e2c25600e81a40bd2f85f673913a90..97a5d4753591620f705c27d7ef4c43557d5cffe8 100755 --- a/static_core/scripts/clang-tidy/clang_tidy_check.py +++ b/static_core/scripts/clang-tidy/clang_tidy_check.py @@ -29,9 +29,13 @@ def get_args(): 'panda_dir', help='panda sources directory.', type=str) parser.add_argument( 'build_dir', help='panda build directory.', type=str) + parser.add_argument( + '--cfg-filter', type=str, action='store', dest='cfg_filter', + required=False, + help='Path to config with filenames to be checked. If missed all source files will be checked.') parser.add_argument( '--filename-filter', type=str, action='store', dest='filename_filter', - required=False, default="*", + required=False, help='Regexp for filename with path to it. If missed all source files will be checked.') parser.add_argument( '--full', action="store_true", help='Check all files with all compile keys.') @@ -213,7 +217,7 @@ default_disabled_checks = [ ] -def run_clang_tidy(src_path: str, config_file_path: str, build_dir: str, header_filter: str, compile_args: str) -> bool: +def run_clang_tidy(src_path: str, config_file_path: str, build_dir: str, header_filter: str, compile_args: str, delayed_stderr: list, job_num: int) -> bool: # Used by ctcache to provide a wrapper for real clang-tidy that will check the cache # before launching clang-tidy and save the result to ctcache server cmd_path = os.getenv('CLANG_TIDY_PATH') @@ -240,10 +244,14 @@ def run_clang_tidy(src_path: str, config_file_path: str, build_dir: str, header_ print("Note: bad output for ", src_path) return True - print('Failed: ' + ' '.join(cmd) + '\n' + out_msg) + failed_output = f'Failed: ' + ' '.join(cmd) + failed_output += f'\n{out_msg}\n' if e.stderr: - print(e.stderr.decode()) + failed_output += e.stderr.decode() + + delayed_stderr[job_num] = failed_output + print(failed_output) return False @@ -260,12 +268,15 @@ def get_full_path(relative_path: str, location_base: str, panda_dir: str, build_ def check_file_list(file_list: list, panda_dir: str, build_dir: str, header_filter: str, proc_count: int) -> bool: pool = multiprocessing.Pool(proc_count) jobs = [] - for src, args in file_list: + manager = multiprocessing.Manager() + delayed_stderr = manager.list([None] * len(file_list)) + for i in range(len(file_list)): + src, args = file_list[i] msg = "Done clang-tidy: %s" % (src) proc = pool.apply_async(func=run_clang_tidy, args=( - src, panda_dir, build_dir, header_filter, args)) + src, panda_dir, build_dir, header_filter, args, delayed_stderr, i)) jobs.append((proc, msg)) # Wait for jobs to complete before exiting @@ -289,6 +300,7 @@ def check_file_list(file_list: list, panda_dir: str, build_dir: str, header_filt # Safely terminate the pool pool.close() pool.join() + print('\n'.join([ds for ds in delayed_stderr if ds])) return main_ret_val @@ -409,10 +421,13 @@ def verify_uniq_element_list(uniq_element_list: list) -> bool: return len(uniq_element_list) == len(set(uniq_element_list)) -def verify_args(panda_dir: str, build_dir: str) -> str: +def verify_args(panda_dir: str, build_dir: str, filename_filter: str, cfg_filter: str): if not verify_uniq_element_list(default_disabled_checks): return "Error: Dupclicated defauls disabled checks" + if filename_filter and cfg_filter: + return "Error: --filename-filter and --cfg-filter cannot be used together, please remove one." + return "" @@ -458,6 +473,13 @@ def get_proc_count(cmd_ard : int) -> int: return multiprocessing.cpu_count() +def parse_config(cfg_filter): + cfg_data = None + with open(cfg_filter) as cfg: + cfg_data = json.load(cfg) + return f"({'|'.join(cfg_data)})" + + if __name__ == "__main__": arguments = get_args() files_list = [] @@ -470,17 +492,25 @@ if __name__ == "__main__": default_disabled_checks.append("-fuchsia-statically-constructed-objects") default_disabled_checks.append("-cert-err58-cpp") - err_msg = verify_args(arguments.panda_dir, arguments.build_dir) + err_msg = verify_args( + arguments.panda_dir, arguments.build_dir, arguments.filename_filter, arguments.cfg_filter) if err_msg: sys.exit(err_msg) - files_list = get_file_list( - arguments.panda_dir, arguments.build_dir, arguments.filename_filter) + filename_filter = "*" + + if arguments.filename_filter: + filename_filter = arguments.filename_filter + elif arguments.cfg_filter: + filename_filter = parse_config(arguments.cfg_filter) + + files_list = get_file_list(arguments.panda_dir, arguments.build_dir, filename_filter) if not files_list: sys.exit("Can't be prepaired source list." - "Please check availble in build `dir compile_commands.json`" - "and correcting of parameter `--filename-filter` if you use it.") + "Please check available in build `dir compile_commands.json`" + "and correcting of parameter `--filename-filter`" + " or `--cfg-filter` if you use it.") if not arguments.check_libabckit: check_headers_in_es2panda_sources(arguments.panda_dir) diff --git a/static_core/scripts/code_style/code_style_check.py b/static_core/scripts/code_style/code_style_check.py index b3a8ad6c506b8d8d156708113e14ff8f175658dc..f8735d1e9119cf989503e7d6a2eb71889f9d3d10 100755 --- a/static_core/scripts/code_style/code_style_check.py +++ b/static_core/scripts/code_style/code_style_check.py @@ -39,7 +39,7 @@ def get_args(): return parser.parse_args() -def run_clang_format(src_path, panda_dir, reformat, msg): +def run_clang_format(src_path, panda_dir, reformat, msg, delayed_stderr, job_num): check_cmd = [str(os.path.join(panda_dir, 'scripts', 'code_style', 'run_code_style_tools.sh'))] reformat_cmd = [CLANG_FORMAT, '-i'] @@ -56,11 +56,14 @@ def run_clang_format(src_path, panda_dir, reformat, msg): print("Note: missed output for ", src_path) return True - print('Failed: ', ' '.join(cmd)) - print(e.stdout.decode()) + failed_output = f'Failed: ' + ' '.join(cmd) + failed_output += f'\n{e.stdout.decode()}\n' if e.stderr: - print(e.stderr.decode()) + failed_output += e.stderr.decode() + + delayed_stderr[job_num] = failed_output + print(failed_output) return False @@ -84,16 +87,19 @@ def check_file_list(file_list : list, panda_dir : str, reformat : bool, proc_cou main_ret_val = True total_count = str(len(file_list)) idx = 0 - for src in file_list: + manager = multiprocessing.Manager() + delayed_stderr = manager.list([None] * len(file_list)) + for i in range(len(file_list)): + src = file_list[i] idx += 1 msg = "[%s/%s] Running clang-format: %s" % (str(idx), total_count, src) proc = pool.apply_async(func=run_clang_format, args=( - src, panda_dir, reformat, msg)) + src, panda_dir, reformat, msg, delayed_stderr, i)) jobs.append(proc) # Wait for jobs to complete before exiting while(not all([p.ready() for p in jobs])): - time.sleep(5) + time.sleep(1) for job in jobs: if not job.get(): @@ -103,6 +109,7 @@ def check_file_list(file_list : list, panda_dir : str, reformat : bool, proc_cou # Safely terminate the pool pool.close() pool.join() + print('\n'.join([ds for ds in delayed_stderr if ds])) return main_ret_val diff --git a/static_core/scripts/llvm/README.md b/static_core/scripts/llvm/README.md index 0faea914535563c8242f53e190871afa2c30b6dc..64d1348045161eb1a472b81f2a5b60e87312dc2a 100644 --- a/static_core/scripts/llvm/README.md +++ b/static_core/scripts/llvm/README.md @@ -15,6 +15,7 @@ Some variables are mandatory, others are optional. ```bash ### Required variables BUILD_DIR= +INSTALL_DIR= (default: "/opt", installing there usually requires root privileges) LLVM_SOURCES=/llvm VERSION=(default: "main") PACKAGE_VERSION=(default: $VERSION) # must match REQUIRED_LLVM_VERSION in libllvmbackend/CMakeLists.txt @@ -28,10 +29,9 @@ BUILD_OHOS_RELEASE=(default: BUILD_OHOS_RELEASE_GN=(default: false) ### Optional variables -INSTALL_DIR= (default: "") -DO_STRIPPING=(default: true) -DO_TAR=(default: true) +DO_STRIPPING=(default: true) +DO_TAR=(default: true) OHOS_SDK=, required for any OHOS build. @@ -59,21 +59,22 @@ LLVM_SOURCES="/home/user/src/llvm-for-ark/llvm" \ VERSION="15.0.4-ark99-beta9" \ PACKAGE_VERSION="15.0.4-ark99" \ OPTIMIZE_DEBUG=false \ +DO_STRIPPING=false \ BUILD_X86_DEBUG=true \ BUILD_AARCH64_DEBUG=true \ bash -x ./build_llvm.sh ``` In this example, only `x86_64` and `arm64` debug versions are built. Then, they can be specified for Ark build, like: -* host build: `-DLLVM_TARGET_PATH=/home/user/build/llvm-15.0.4-ark99-beta9-debug-x86_64` +* host build: `-DLLVM_TARGET_PATH=/home/user/inst/llvm-15.0.4-ark99-beta9-debug-x86_64` * cross-arm64 build: - * `-DLLVM_TARGET_PATH=/home/user/build/llvm-15.0.4-ark99-beta9-debug-aarch64` - * `-DLLVM_HOST_PATH=/home/user/build/llvm-15.0.4-ark99-beta9-debug-x86_64` + * `-DLLVM_TARGET_PATH=/home/user/inst/llvm-15.0.4-ark99-beta9-debug-aarch64` + * `-DLLVM_HOST_PATH=/home/user/inst/llvm-15.0.4-ark99-beta9-debug-x86_64` ## Example with packaging all necessary versions ```bash -INSTALL_DIR="/mnt/scratch/install" \ +INSTALL_DIR="/opt" \ BUILD_DIR="/mnt/scratch/build" \ LLVM_SOURCES="/mnt/scratch/src/llvm-for-ark/llvm" \ VERSION="15.0.4-ark99-beta9" \ @@ -86,5 +87,5 @@ BUILD_AARCH64_DEBUG=true \ BUILD_AARCH64_RELEASE=true \ BUILD_OHOS_RELEASE=true \ BUILD_OHOS_RELEASE_GN=true \ -bash -x ./build_llvm.sh +sudo bash -x ./build_llvm.sh ``` diff --git a/static_core/scripts/llvm/build_llvm.sh b/static_core/scripts/llvm/build_llvm.sh index df835fe1236e4dd5c29253674440dfde9d8249ac..f34c4055fc7ed42e3bef7a9d8d12875e75496348 100755 --- a/static_core/scripts/llvm/build_llvm.sh +++ b/static_core/scripts/llvm/build_llvm.sh @@ -16,15 +16,17 @@ set -euo pipefail # Required variables BUILD_DIR=${BUILD_DIR:-""} +INSTALL_DIR=${INSTALL_DIR:-"/opt"} LLVM_SOURCES=${LLVM_SOURCES:-""} + # Optional variables -INSTALL_DIR=${INSTALL_DIR:-""} # empty -- do not install VERSION=${VERSION:-"main"} # Specifies build and install directory names: PACKAGE_VERSION=${PACKAGE_VERSION:-${VERSION}} BUILD_SUFFIX=${BUILD_SUFFIX:-""} # llvm--{debug,release}-{aarch64,x86} OPTIMIZE_DEBUG=${OPTIMIZE_DEBUG:-true} # Compile debug versions with -O2 -DO_STRIPPING=${DO_STRIPPING:-true} # checked only if install -DO_TARS=${DO_TARS:-true} # checked only if install +DO_STRIPPING=${DO_STRIPPING:-true} +DO_TARS=${DO_TARS:-true} + # Select a target to build BUILD_X86_DEBUG=${BUILD_X86_DEBUG:-false} BUILD_X86_RELEASE=${BUILD_X86_RELEASE:-false} @@ -52,6 +54,11 @@ if [[ -z "${BUILD_DIR}" ]]; then exit 1 fi +if [[ -z "${INSTALL_DIR}" ]]; then + echo "Please, specify install directory with INSTALL_DIR variable" + exit 1 +fi + if [[ -z "${LLVM_SOURCES}" ]]; then echo "Please, specify llvm sources directory with LLVM_SOURCES variable" exit 1 @@ -152,9 +159,7 @@ if [[ "x${BUILD_X86_DEBUG}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" AUTO_LLVM_TABLEGEN="${BUILD_PREFIX}/bin/llvm-tblgen" if [[ ! -f "${AUTO_LLVM_TABLEGEN}" ]]; then @@ -195,9 +200,7 @@ if [[ "x${BUILD_X86_RELEASE}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" AUTO_LLVM_TABLEGEN="${BUILD_PREFIX}/bin/llvm-tblgen" if [[ ! -f "${AUTO_LLVM_TABLEGEN}" ]]; then @@ -248,9 +251,7 @@ if [[ "x${BUILD_AARCH64_DEBUG}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" fi if [[ "x${BUILD_AARCH64_RELEASE}" == "xtrue" ]]; then @@ -293,9 +294,7 @@ if [[ "x${BUILD_AARCH64_RELEASE}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" fi if [[ "x${BUILD_OHOS_RELEASE}" == "xtrue" ]]; then @@ -332,9 +331,7 @@ if [[ "x${BUILD_OHOS_RELEASE}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" fi if [[ "x${BUILD_OHOS_RELEASE_GN}" == "xtrue" ]]; then @@ -380,7 +377,5 @@ if [[ "x${BUILD_OHOS_RELEASE_GN}" == "xtrue" ]]; then "${LLVM_SOURCES}" ninja distribution - if [[ -n "${INSTALL_DIR}" ]]; then - install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" - fi + install "${INSTALL_PREFIX}" "${DO_STRIPPING}" "${DO_TARS}" fi diff --git a/static_core/scripts/sdk/build_sdk.sh b/static_core/scripts/sdk/build_sdk.sh index 09ef6720256bb0f47bda9e83084c42a64d721fd6..b721550db978d22d731e72d872720c641f6b56b6 100755 --- a/static_core/scripts/sdk/build_sdk.sh +++ b/static_core/scripts/sdk/build_sdk.sh @@ -13,6 +13,7 @@ # limitations under the License. set -eo pipefail +set -x export SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" export ARK_ROOT="$SCRIPT_DIR/../.." diff --git a/static_core/scripts/sdk/build_sdk_lib b/static_core/scripts/sdk/build_sdk_lib index f4721c5a24a2e7d9e9ab92ada607534c3f4ae262..bfcef5083e52b0f9e0cca2b037b994c4c4ccd243 100644 --- a/static_core/scripts/sdk/build_sdk_lib +++ b/static_core/scripts/sdk/build_sdk_lib @@ -26,7 +26,7 @@ function build_panda() { COMMONS_CMAKE_ARGS="\ -GNinja \ -S$ARK_ROOT \ - -DCMAKE_BUILD_TYPE=$PANDA_SDK_BUILD_TYPE \ + -DCMAKE_BUILD_TYPE=${PANDA_SDK_BUILD_TYPE} \ -DPANDA_PRODUCT_BUILD=$product_build \ -DPANDA_WITH_ECMASCRIPT=ON \ -DPANDA_WITH_ETS=ON \ @@ -66,7 +66,10 @@ function linux_arm64_tools() { local linux_arm64_build_dir="$SDK_BUILD_ROOT/linux_arm64_host_tools" local linux_arm64_cmake_args=" \ -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/cross-clang-14-qemu-aarch64.cmake \ - -DPANDA_WITH_ECMASCRIPT=ON" + -DPANDA_LLVM_BACKEND=ON \ + -DLLVM_HOST_PATH=/opt/llvm-15-${PANDA_SDK_BUILD_TYPE,,}-x86_64 \ + -DLLVM_TARGET_PATH=/opt/llvm-15-${PANDA_SDK_BUILD_TYPE,,}-aarch64" + local linux_arm64_build_targets="ark ark_aot ark_disasm ark_link es2panda e2p_test_plugin etsnative" build_panda "$linux_arm64_build_dir" "$linux_arm64_cmake_args" "$linux_arm64_build_targets" copy_into_sdk "$linux_arm64_build_dir" "$PANDA_SDK_PATH/linux_arm64_host_tools" "$SCRIPT_DIR"/linux_arm64_host_tools.txt @@ -79,7 +82,10 @@ function linux_tools() { -DPANDA_CROSS_AARCH64_TOOLCHAIN_FILE=cmake/toolchain/cross-ohos-musl-aarch64.cmake \ -DTOOLCHAIN_SYSROOT=$OHOS_SDK_NATIVE/sysroot \ -DTOOLCHAIN_CLANG_ROOT=$OHOS_SDK_NATIVE/llvm \ - -DPANDA_WITH_ECMASCRIPT=ON" + -DPANDA_WITH_ECMASCRIPT=ON \ + -DPANDA_LLVM_BACKEND=ON \ + -DLLVM_TARGET_PATH=/opt/llvm-15-${PANDA_SDK_BUILD_TYPE,,}-x86_64" + local linux_build_targets="ark ark_aot ark_disasm ark_link es2panda e2p_test_plugin etsnative" build_panda "$linux_build_dir" "$linux_cmake_args" "$linux_build_targets" copy_into_sdk "$linux_build_dir" "$PANDA_SDK_PATH/linux_host_tools" "$SCRIPT_DIR"/linux_host_tools.txt @@ -103,7 +109,11 @@ function ohos() { -DTOOLCHAIN_SYSROOT=$OHOS_SDK_NATIVE/sysroot \ -DTOOLCHAIN_CLANG_ROOT=$OHOS_SDK_NATIVE/llvm \ -DPANDA_ETS_INTEROP_JS=ON \ - -DPANDA_WITH_ECMASCRIPT=ON" + -DPANDA_WITH_ECMASCRIPT=ON \ + -DPANDA_LLVM_BACKEND=ON \ + -DLLVM_HOST_PATH=/opt/llvm-15-${PANDA_SDK_BUILD_TYPE,,}-x86_64 \ + -DLLVM_TARGET_PATH=/opt/llvm-15-release-ohos" + local ohos_build_targets="ark ark_aot arkruntime arkassembler ets_interop_js_napi e2p_test_plugin etsnative" build_panda "$ohos_build_dir" "$target_cmake_args" "$ohos_build_targets" copy_into_sdk "$ohos_build_dir" "$taget_sdk_dir" "$SCRIPT_DIR"/ohos_arm64.txt diff --git a/static_core/scripts/sdk/linux_arm64_host_tools.txt b/static_core/scripts/sdk/linux_arm64_host_tools.txt index 2f9de0b7e63d803ec448a211cf7c256a9ecee6f8..58fb69af081c9344b23aa8ef569cb5a556228bda 100644 --- a/static_core/scripts/sdk/linux_arm64_host_tools.txt +++ b/static_core/scripts/sdk/linux_arm64_host_tools.txt @@ -22,3 +22,5 @@ lib/libhmicui18n.z.so lib/libhmicuuc.z.so lib/libinit_icu.so lib/libirtoc.so +lib/libLLVM-15.so +lib/libllvmbackend.so diff --git a/static_core/scripts/sdk/linux_host_tools.txt b/static_core/scripts/sdk/linux_host_tools.txt index 2f9de0b7e63d803ec448a211cf7c256a9ecee6f8..58fb69af081c9344b23aa8ef569cb5a556228bda 100644 --- a/static_core/scripts/sdk/linux_host_tools.txt +++ b/static_core/scripts/sdk/linux_host_tools.txt @@ -22,3 +22,5 @@ lib/libhmicui18n.z.so lib/libhmicuuc.z.so lib/libinit_icu.so lib/libirtoc.so +lib/libLLVM-15.so +lib/libllvmbackend.so diff --git a/static_core/scripts/sdk/ohos_arm64.txt b/static_core/scripts/sdk/ohos_arm64.txt index e53fb9b4693e97af7c480eb1d1b550a6ab60c76f..0a39a3e46ecf5e3c89fc0b588760909c97ada3f9 100644 --- a/static_core/scripts/sdk/ohos_arm64.txt +++ b/static_core/scripts/sdk/ohos_arm64.txt @@ -20,4 +20,6 @@ lib/libets_interop_js_napi.so lib/libhmicui18n.z.so lib/libhmicuuc.z.so lib/libinit_icu.a +lib/libLLVM-15.so +lib/libllvmbackend.so plugins/ecmascript/ecmastdlib/ecmastdlib.abc diff --git a/static_core/scripts/sdk/test2_file_list_expected.txt b/static_core/scripts/sdk/test2_file_list_expected.txt index 6b3e624e9fcbb3ddd76026e71a95ce0c401201a9..a220e623dbf446a0397e243d2e2ed3412ed424e3 100644 --- a/static_core/scripts/sdk/test2_file_list_expected.txt +++ b/static_core/scripts/sdk/test2_file_list_expected.txt @@ -14,6 +14,7 @@ build-sdk/sdk/linux_arm64_host_tools/bin/ark_disasm build-sdk/sdk/linux_arm64_host_tools/bin/ark_link build-sdk/sdk/linux_arm64_host_tools/bin/es2panda build-sdk/sdk/linux_arm64_host_tools/lib +build-sdk/sdk/linux_arm64_host_tools/lib/libLLVM-15.so build-sdk/sdk/linux_arm64_host_tools/lib/libarkaotmanager.so build-sdk/sdk/linux_arm64_host_tools/lib/libarkassembler.so build-sdk/sdk/linux_arm64_host_tools/lib/libarkbase.so @@ -32,6 +33,7 @@ build-sdk/sdk/linux_arm64_host_tools/lib/libetsnative.so build-sdk/sdk/linux_arm64_host_tools/lib/libhmicui18n.z.so build-sdk/sdk/linux_arm64_host_tools/lib/libhmicuuc.z.so build-sdk/sdk/linux_arm64_host_tools/lib/libinit_icu.so +build-sdk/sdk/linux_arm64_host_tools/lib/libllvmbackend.so build-sdk/sdk/linux_host_tools build-sdk/sdk/linux_host_tools/bin build-sdk/sdk/linux_host_tools/bin/ark @@ -40,6 +42,7 @@ build-sdk/sdk/linux_host_tools/bin/ark_disasm build-sdk/sdk/linux_host_tools/bin/ark_link build-sdk/sdk/linux_host_tools/bin/es2panda build-sdk/sdk/linux_host_tools/lib +build-sdk/sdk/linux_host_tools/lib/libLLVM-15.so build-sdk/sdk/linux_host_tools/lib/libarkaotmanager.so build-sdk/sdk/linux_host_tools/lib/libarkassembler.so build-sdk/sdk/linux_host_tools/lib/libarkbase.so @@ -59,6 +62,7 @@ build-sdk/sdk/linux_host_tools/lib/libhmicui18n.z.so build-sdk/sdk/linux_host_tools/lib/libhmicuuc.z.so build-sdk/sdk/linux_host_tools/lib/libinit_icu.so build-sdk/sdk/linux_host_tools/lib/libirtoc.so +build-sdk/sdk/linux_host_tools/lib/libllvmbackend.so build-sdk/sdk/ohos_arm64 build-sdk/sdk/ohos_arm64/bin build-sdk/sdk/ohos_arm64/bin/ark @@ -75,6 +79,7 @@ build-sdk/sdk/ohos_arm64/include/third_party build-sdk/sdk/ohos_arm64/include/tools build-sdk/sdk/ohos_arm64/include/verification build-sdk/sdk/ohos_arm64/lib +build-sdk/sdk/ohos_arm64/lib/libLLVM-15.so build-sdk/sdk/ohos_arm64/lib/libarkaotmanager.so build-sdk/sdk/ohos_arm64/lib/libarkassembler.so build-sdk/sdk/ohos_arm64/lib/libarkbase.so @@ -95,6 +100,7 @@ build-sdk/sdk/ohos_arm64/lib/libets_interop_js_napi.so build-sdk/sdk/ohos_arm64/lib/libhmicui18n.z.so build-sdk/sdk/ohos_arm64/lib/libhmicuuc.z.so build-sdk/sdk/ohos_arm64/lib/libinit_icu.a +build-sdk/sdk/ohos_arm64/lib/libllvmbackend.so build-sdk/sdk/ohos_arm64/plugins build-sdk/sdk/ohos_arm64/plugins/ecmascript build-sdk/sdk/package.json diff --git a/static_core/static_linker/CMakeLists.txt b/static_core/static_linker/CMakeLists.txt index f57f7916afcbffd01077010f80cea9e20288ad40..973938343c218a1eea81afc56b866ddb2804d2f8 100644 --- a/static_core/static_linker/CMakeLists.txt +++ b/static_core/static_linker/CMakeLists.txt @@ -65,6 +65,8 @@ panda_target_include_directories(ark_link PUBLIC include_directories(${PANDA_ROOT}/libpandabase/) include_directories(${CMAKE_BINARY_DIR}/libpandafile/include/) +if (false) if (PANDA_WITH_TESTS) add_subdirectory(tests) endif() +endif() # if(false) diff --git a/static_core/tests/CMakeLists.txt b/static_core/tests/CMakeLists.txt index aa236767bf74c3a263ede69fe219c6000e4e32e7..20f76cfa7dbddc33a540a7ee90c72ce21e754bcb 100644 --- a/static_core/tests/CMakeLists.txt +++ b/static_core/tests/CMakeLists.txt @@ -31,6 +31,9 @@ add_dependencies(irtoc-interpreter-tests irtoc-opcode-suite) if(NOT PANDA_TARGET_AMD64 OR PANDA_TARGET_WINDOWS) add_dependencies(core_tests cts-assembly regression) add_subdirectory(cts-coverage-tool) + if(PANDA_TARGET_ARM64 AND NOT CMAKE_CROSSCOMPILING) + add_subdirectory(cts-generator) + endif() else() add_custom_target(verifier-tests COMMENT "Regression tests for verifier") add_dependencies(core_tests cts-assembly regression verifier-tests) @@ -435,6 +438,7 @@ function(add_test_file) set(language_context "core") + if(false) if (ARG_VERIFIER_FAIL_TEST) set(VERIFIER_FAIL_TEST VERIFIER_FAIL_TEST) else() @@ -454,6 +458,7 @@ function(add_test_file) ) add_dependencies(${suite} ${target}-verifier) endif() + endif() # if(false) set(gc_types "stw" "gen-gc" "g1-gc") if (NOT PANDA_TARGET_ARM32) # Arm32 is not supported in the Irtoc @@ -1102,22 +1107,82 @@ add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/tst-branch.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/tst-compare.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/tst-select.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/abs-f64-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/abs-f64-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/abs-i32-i64.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/call-static-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/call-static-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/call-static-03.pa" LLVMAOT_OPTIONS --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/call-static-04.pa" LLVMAOT_OPTIONS --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/call-virtual-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/const-f32-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/const-f64-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/const-f64-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/const-f64-03.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/const-f64-04.pa" EXPECTED_STDOUT "43.8451") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/cmp-u32-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/cmp-u64-01.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/intrinsic-f32-01.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/intrinsic-f32-02.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/intrinsic-f32-03.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/intrinsic-f32-04.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/intrinsic-f32-05.pa" EXPECTED_STDOUT "0.785398") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/load-and-init-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/load-and-init-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fadd-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fdiv-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fmod-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fmul-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fneg-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fneg-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-fsub-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-udiv.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/math-urem.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/phi-f64-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-arr.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-checkcast-normal-bug.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-01.pa" COMPILER_OPTIONS --compiler-regex=.*store_42) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-03.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-04.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-05.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/obj-null-06.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/shl31.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/sinf64.pa" LLVMAOT_OPTIONS --compiler-non-optimizing=true) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/test-max.pa" SKIP_VERIFICATION) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/test-min.pa" SKIP_VERIFICATION) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/min-max-int.pa" SKIP_VERIFICATION) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/floatcast-test-0.pa" SKIP_VERIFICATION) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/floatcast-test-1.pa" SKIP_VERIFICATION) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/floatcast-test-2.pa" COMPILER_OPTIONS --compiler-inlining=false SKIP_VERIFICATION) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/try-catch-01.pa" SKIP_VERIFICATION) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/try-catch-02.pa" SKIP_VERIFICATION) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/try-catch-03.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/try-catch-04.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/type-coercion-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/type-coercion-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/type-coercion-03.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/type-coercion-04.pa" EXPECTED_STDOUT "11111") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/type-coercion-05.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/small-fields-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/small-fields-02.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/small-static-fields-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/small-static-fields-02.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/rodatas-01.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/long-array.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/llvm-options.pa" LLVMAOT_OPTIONS --compiler-non-optimizing=true --llvm-options="--print-after-isel" AOT_DEBUG_LOG_MESSAGE "Machine code for function u1 _GLOBAL::main") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/arrays-isinstance.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/arrays-checkcast.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/no-inline-0.pa" LLVMAOT_OPTIONS --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/no-inline-1.pa" COMPILER_OPTIONS --compiler-inlining-blacklist=_GLOBAL::test LLVMAOT_OPTIONS --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/no-inline-2.pa" COMPILER_OPTIONS --compiler-inlining=false LLVMAOT_OPTIONS --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/cts-assembly/no-inline-3.pa" LLVMAOT_OPTIONS --llvm-pre-opt=0 --llvm-inlining=false --llvm-dump-after AOT_DEBUG_LOG_MESSAGE "call.*statepoint.*_GLOBAL::test") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/allocate-252-params.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/bitops-bitwise-and.pa" COMPILER_OPTIONS --compiler-print-stats) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/math-partial-sums.pa" COMPILER_OPTIONS --compiler-print-stats DISABLE_LIMIT_STD_ALLOC) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/fmod.pa" COMPILER_OPTIONS --compiler-inlining=false) +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/fmodf.pa" COMPILER_OPTIONS --compiler-inlining=false) add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/stack-4-params.pa" COMPILER_OPTIONS --compiler-inlining=false VERIFIER_FAIL_TEST SEARCH_STDERR "Bad register type") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/stack-9-params.pa" COMPILER_OPTIONS --compiler-inlining=false VERIFIER_FAIL_TEST SEARCH_STDERR "Bad register type") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/regression/fcmp.pa" VERIFIER_FAIL_TEST SEARCH_STDERR "Bad register type") @@ -1148,6 +1213,10 @@ add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/multiarr # Lots of runtime calls with enabled '--verify-entrypoints' option cause lots of standard allocations add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/barriers.pa" DISABLE_LIMIT_STD_ALLOC SKIP_CROSS "arm32" G1_GC_SIZE_LIMITS "--heap-size-limit=4718592 --young-space-size=324288") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/array-npe-1.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/array-npe-2.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/array-oob-1.pa") +add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/array-oob-2.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/irtoc-opcode-suite/ldai.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/irtoc-opcode-suite/and.pa") add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/irtoc-opcode-suite/andi.pa") @@ -1197,6 +1266,7 @@ add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/irtoc-op add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/irtoc-interpreter-tests/irtoc-opcode-suite/throw.pa") if (TARGET verifier-tests) +if(false) # Verifier regression tests # Negative (must fail) add_verifier_test(FILE @@ -1267,6 +1337,7 @@ add_verifier_test(FILE "${CMAKE_CURRENT_SOURCE_DIR}/verifier-tests/bug_6434.pa" add_verifier_test(FILE "${CMAKE_CURRENT_SOURCE_DIR}/verifier-tests/initobj-bad-03.pa" VERIFIER_FAIL_TEST SEARCH_STDERR "Initobj calls not constructor") add_verifier_test(FILE "${CMAKE_CURRENT_SOURCE_DIR}/verifier-tests/access_field_nomodifier_core.pa") add_verifier_test(FILE "${CMAKE_CURRENT_SOURCE_DIR}/verifier-tests/exception_type.pa") +endif() # if(false) # Test for verification fail during runtime add_test_file(FILE "${CMAKE_CURRENT_SOURCE_DIR}/verifier-tests/fail_in_runtime_ahead_of_time.pa" diff --git a/static_core/tests/checked/CMakeLists.txt b/static_core/tests/checked/CMakeLists.txt index 280b1e50976d05eac5e50667014e65b1481f16bd..7fc5cf0d666b86d940b4b3898c8c8a536cca64fd 100644 --- a/static_core/tests/checked/CMakeLists.txt +++ b/static_core/tests/checked/CMakeLists.txt @@ -174,19 +174,29 @@ if (PANDA_TARGET_AMD64 OR (PANDA_TARGET_ARM64 AND NOT PANDA_ENABLE_ADDRESS_SANIT panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/verify_aot_tests/verify_aot_test.pa AUX_FILES verify_aot_tests_file1 verify_aot_tests_file2) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/zero_const_in_save_state.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/loop-unroll-constant.pa) - panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm_devirt_external.pa AUX_FILES vcalls_aux.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/memory-coalescing.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/memory-coalescing1.pa) if (PANDA_LLVM_AOT) + panda_add_checked_test(NAME external_inline + FILE ${CMAKE_CURRENT_SOURCE_DIR}/external_inline/a.pa + EXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/external_inline/b.pa) + panda_add_checked_test(NAME external_call + FILE ${CMAKE_CURRENT_SOURCE_DIR}/external_call/external-call-01.pa + EXT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/external_call/external-call-02.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/virtual_to_static.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/memset.pa) + panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm_devirt_external.pa AUX_FILES vcalls_aux.pa) + panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm_stack_overflow_undef.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-optlevel.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-broken-ir.pa) + panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-gc-intrusion.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-gc-liveness.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-tracking.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-inlines-from-split-module.pa) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/llvmaot-gc-int-vs-ptr.pa) + panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/wrb-arr.pa) + panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/wrb-obj.pa) if (PANDA_TARGET_AMD64) panda_add_checked_test(FILE ${CMAKE_CURRENT_SOURCE_DIR}/fill-const-array/fill-const-array-513.pa) endif() diff --git a/static_core/tests/checked/aot.pa b/static_core/tests/checked/aot.pa index 25052085d6c80e0179988fc0785a19917113bf98..19f8295ea4dae3c80661cb4b6d986a66e077200b 100644 --- a/static_core/tests/checked/aot.pa +++ b/static_core/tests/checked/aot.pa @@ -20,6 +20,15 @@ #! EVENT "AotEntrypointFound,_GLOBAL::func2" #! EVENT "AotEntrypointFound,_GLOBAL::func3" +#! CHECKER All methods found - LLVM +#! RUN_LLVM options: "--compiler-inlining false" +#! RUN options: "", entry: "_GLOBAL::main", result: 52 +#! EVENT_NOT /Inline.*/ +#! EVENT "AotEntrypointFound,_GLOBAL::func1" +#! EVENT "AotEntrypointFound,_GLOBAL::func2" +#! EVENT "AotEntrypointFound,_GLOBAL::func3" + + #! CHECKER Various methods compiled #! RUN_PAOC options: "--compiler-inlining false --compiler-regex '(_GLOBAL::func[13]|Test::f[23])'" #! RUN options: "", entry: "_GLOBAL::main2", result: 58 @@ -30,6 +39,16 @@ #! EVENT "AotEntrypointFound,Test::f3" #! EVENT_NOT "AotEntrypointFound,Test::f1" +#! CHECKER Various methods compiled - LLVM +#! RUN_LLVM options: "--compiler-inlining false --compiler-regex '(_GLOBAL::func[13]|Test::f[23])'" +#! RUN options: "", entry: "_GLOBAL::main2", result: 58 +#! EVENT "AotEntrypointFound,_GLOBAL::func1" +#! EVENT "AotEntrypointFound,_GLOBAL::func3" +#! EVENT_NOT "AotEntrypointFound,_GLOBAL::func2" +#! EVENT "AotEntrypointFound,Test::f2" +#! EVENT "AotEntrypointFound,Test::f3" +#! EVENT_NOT "AotEntrypointFound,Test::f1" + .record Test {} .function i32 Test.f1() { diff --git a/static_core/tests/checked/cast_bool.pa b/static_core/tests/checked/cast_bool.pa index 0aced8b7e08e19ba1e4826e367b70a552e3d859f..ae88cd9a3db6572c9a3fe3bb7561263f2665280b 100644 --- a/static_core/tests/checked/cast_bool.pa +++ b/static_core/tests/checked/cast_bool.pa @@ -12,9 +12,17 @@ # limitations under the License. #! CHECKER Check that cast in bool work for all arch -#! RUN force_jit: true, options: "", entry: "_GLOBAL::main_all", result: 0 +#! RUN force_jit: true, options: "", entry: "_GLOBAL::main_all" #! EVENT /Compilation,_GLOBAL::main_all,.*COMPILED/ +#! CHECKER Check that cast in bool work for all arch at Regular AOT +#! RUN_PAOC options: "" +#! RUN entry: "_GLOBAL::main_all" + +#! CHECKER Check that cast in bool work for all arch at LLVM AOT +#! RUN_LLVM options: "" +#! RUN entry: "_GLOBAL::main_all" + .function u1 main_all() { movi v2, 0xF1F1 call __noinline__cast_i32, v2 diff --git a/static_core/tests/checked/checkcast_elimination_test.pa b/static_core/tests/checked/checkcast_elimination_test.pa index be327d6c093d1331f720a0d3c42ddb7e85f191d6..77408fadd05f0ef3b4464bd694aabb6ff1082ffb 100644 --- a/static_core/tests/checked/checkcast_elimination_test.pa +++ b/static_core/tests/checked/checkcast_elimination_test.pa @@ -24,6 +24,22 @@ #! INST_NOT "CheckCast" #! INST "Deoptimize" +#! CHECKER CheckCast Elimination applied, replaced on deoptimize at Regular AOT. +#! RUN_PAOC options: "--compiler-regex=_GLOBAL.*" +#! METHOD "_GLOBAL::main1" +#! PASS_AFTER "Inline" +#! INST_NOT "CheckCast" +#! INST "Deoptimize" +#! RUN entry: "_GLOBAL::main1" + +#! CHECKER CheckCast Elimination applied, replaced on deoptimize at LLVM AOT. +#! RUN_LLVM options: "--compiler-regex=_GLOBAL.*" +#! METHOD "_GLOBAL::main1" +#! PASS_AFTER "Inline" +#! INST_NOT "CheckCast" +#! INST "Deoptimize" +#! RUN entry: "_GLOBAL::main1" + .function u1 main1() { newobj v0, A lda.obj v0 @@ -52,6 +68,20 @@ catch_block2_begin: #! PASS_AFTER "Inline" #! INST_NOT "CheckCast" +#! CHECKER CheckCast Elimination applied, remove redundant checkcast at Regular AOT. +#! RUN_PAOC options: "--compiler-regex=_GLOBAL.*" +#! METHOD "_GLOBAL::main2" +#! PASS_AFTER "Inline" +#! INST_NOT "CheckCast" +#! RUN entry: "_GLOBAL::main2" + +#! CHECKER CheckCast Elimination applied, remove redundant checkcast at LLVM AOT. +#! RUN_LLVM options: "--compiler-regex=_GLOBAL.*" +#! METHOD "_GLOBAL::main2" +#! PASS_AFTER "Inline" +#! INST_NOT "CheckCast" +#! RUN entry: "_GLOBAL::main2" + .function u1 main2() { newobj v0, B lda.obj v0 @@ -79,6 +109,13 @@ catch_block2_begin: #! CHECKER CheckCast Elimination applied, remove redundant checkcast, inline. #! RUN force_jit: true, options: "--compiler-regex=_GLOBAL.*", entry: "_GLOBAL::main3" +#! CHECKER CheckCast Elimination applied, remove redundant checkcast, Inline at Regular AOT. +#! RUN_PAOC options: "--compiler-regex=_GLOBAL.*" +#! RUN entry: "_GLOBAL::main3" + +#! CHECKER CheckCast Elimination applied, remove redundant checkcast, Inline at LLVM AOT. +#! RUN_LLVM options: "--compiler-regex=_GLOBAL.*" +#! RUN entry: "_GLOBAL::main3" .function i32 test1() { newobj v0, B lda.obj v0 diff --git a/static_core/tests/checked/checker.rb b/static_core/tests/checked/checker.rb index 5aaec8ac32a0bdefa9560636df57f8a24f051047..7f061f2a0708d11140d8cc2581d1b5f88f371d9e 100755 --- a/static_core/tests/checked/checker.rb +++ b/static_core/tests/checked/checker.rb @@ -189,7 +189,7 @@ class Checker # Current search scope @disasm_scope = nil - Dir.mkdir(@cwd) unless File.exists?(@cwd) + Dir.mkdir(@cwd) unless File.exist?(@cwd) clear_data end diff --git a/static_core/tests/checked/const_array_test.pa b/static_core/tests/checked/const_array_test.pa index c7ab25c9e7a996611b8ddab7d66c261fee8da87f..fb703d748160b86e1f0f486c1d105537c6b6343d 100644 --- a/static_core/tests/checked/const_array_test.pa +++ b/static_core/tests/checked/const_array_test.pa @@ -16,7 +16,7 @@ # #! CHECKER Split ConstArray -#! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2", entry: "_GLOBAL::main" +#! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2", entry: "_GLOBAL::main" #! EVENT /Compilation,.*main.*/ #! METHOD "_GLOBAL::main" #! PASS_AFTER "IrBuilder" @@ -25,8 +25,16 @@ #! INST_NEXT "FillConstArray" #! INST_NOT "StoreArray" +#! CHECKER Split ConstArray AOT +#! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2" +#! RUN entry: "_GLOBAL::main" + +#! CHECKER Split ConstArray LLVM +#! RUN_LLVM options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2" +#! RUN entry: "_GLOBAL::main" + #! CHECKER Fill ConstArray -#! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4", entry: "_GLOBAL::main" +#! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4", entry: "_GLOBAL::main" #! EVENT /Compilation,.*main.*/ #! METHOD "_GLOBAL::main" #! PASS_AFTER "IrBuilder" @@ -35,12 +43,12 @@ #! INST_NOT "FillConstArray" #! INST_NOT "LoadConstArray" -#! CHECKER Split ConstArray AOT -#! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2" +#! CHECKER Fill ConstArray AOT +#! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4" #! RUN entry: "_GLOBAL::main" -#! CHECKER Fill ConstArray AOT -#! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4" +#! CHECKER Fill ConstArray LLVM +#! RUN_LLVM options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4" #! RUN entry: "_GLOBAL::main" .record panda.String @@ -150,4 +158,4 @@ loop_error_9: label: lda a0 return -} \ No newline at end of file +} diff --git a/static_core/tests/checked/cross_peephole.pa b/static_core/tests/checked/cross_peephole.pa index 897d49c5c91b74ef872436145b58826c0df47fc5..c1fc6d265089563bfdf98cf4e7d9c2c017b224e1 100644 --- a/static_core/tests/checked/cross_peephole.pa +++ b/static_core/tests/checked/cross_peephole.pa @@ -25,6 +25,10 @@ #! RUN_PAOC options: "--compiler-cross-arch=arm" #! RUN_PAOC options: "--compiler-cross-arch=arm64" +#! CHECKER Compiling a method arm/arm64 on amd64 in LLVM AOT +#! SKIP_IF @architecture != "x64" +#! RUN_LLVM options: "--compiler-cross-arch=arm64" + # Check, that need second peephole for lowering @@ -41,7 +45,7 @@ #! CHECKER Check that lowering is applied for Return in AOT #! SKIP_IF @architecture == "arm32" -#! RUN_PAOC options:"" +#! RUN_PAOC options: "" #! METHOD "_GLOBAL::main" #! PASS_AFTER "DeoptimizeElimination" #! INST "Return " diff --git a/static_core/tests/checked/disasm_and_log_demo.pa b/static_core/tests/checked/disasm_and_log_demo.pa index 9be9bbf80d8c9f18daa5fb2d5ab8b14cf3b16092..1fcf9ab16f2e49e443fd6d3739078a8668bd9f9f 100644 --- a/static_core/tests/checked/disasm_and_log_demo.pa +++ b/static_core/tests/checked/disasm_and_log_demo.pa @@ -15,6 +15,10 @@ #! RUN force_jit: true, options: "--compiler-disasm-dump", entry: "_GLOBAL::main" #! EVENT /Compilation,_GLOBAL::main,.*COMPILED/ +#! CHECKER Check that MmapMemPool: Try to free arena Regular AOT +#! RUN_PAOC options: "--compiler-disasm-dump" +#! RUN entry: "_GLOBAL::main" + .function u1 main (){ ldai 0 return diff --git a/static_core/tests/checked/external_call/external-call-01.pa b/static_core/tests/checked/external_call/external-call-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..f141b38fa61f13727cfc17d127879301772a0141 --- /dev/null +++ b/static_core/tests/checked/external_call/external-call-01.pa @@ -0,0 +1,49 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! CHECKER External call Regular AOT +#! RUN_PAOC options: "--paoc-panda-files=../external-call-02.bin" +#! RUN options: "", entry: "_GLOBAL::main" + +#! CHECKER External call LLVM AOT +#! RUN_LLVM options: "--compiler-non-optimizing=true --paoc-panda-files=../external-call-02.bin" +#! RUN options: "", entry: "_GLOBAL::main" + +.record Functional { +} + +.function i32 Functional.identity(i32 a0) { + lda a0 + return +} + +.record B +.function i32 B.foo() + +.function i32 main() { + movi v0, 44 + call.short B.foo + jne v0, failure_b_foo_call + call.short Functional.identity, v0 + jne v0, failure_identity_call + + ldai 0 + return +failure_identity_call: + ldai 1 + return + +failure_b_foo_call: + ldai 2 + return +} diff --git a/static_core/tests/checked/external_call/external-call-02.pa b/static_core/tests/checked/external_call/external-call-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..7a0fb655d8615dc51954cb56602c81983ccab629 --- /dev/null +++ b/static_core/tests/checked/external_call/external-call-02.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Functional + +.function i32 Functional.identity(i32 a0) + +.record B { +} + +.function i32 B.foo() { + movi v0, 44 + call.short Functional.identity, v0 + return +} diff --git a/static_core/tests/checked/external_inline/a.pa b/static_core/tests/checked/external_inline/a.pa new file mode 100644 index 0000000000000000000000000000000000000000..7404d6858033912603833fb0ba9176055d734fd7 --- /dev/null +++ b/static_core/tests/checked/external_inline/a.pa @@ -0,0 +1,28 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! CHECKER External Inline +#! RUN_PAOC options: "--paoc-panda-files ../b.bin" +#! RUN options: "", entry: "_GLOBAL::main", result: 10 + +#! CHECKER External Inline LLVM +#! RUN_LLVM options: "--paoc-panda-files ../b.bin" +#! RUN options: "", entry: "_GLOBAL::main", result: 10 + +.record InlineTestExt +.function i32 InlineTestExt.small_func() + +.function i32 main() { + call.short InlineTestExt.small_func + return +} diff --git a/static_core/tests/checked/external_inline/b.pa b/static_core/tests/checked/external_inline/b.pa new file mode 100644 index 0000000000000000000000000000000000000000..38fde3814eff683dc5a7aa724ee746e339a52149 --- /dev/null +++ b/static_core/tests/checked/external_inline/b.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record InlineTestExt <> {} +.record Foo { + i32 f +} + +.function i32 InlineTestExt.small_func() { + newobj v0, Foo + ldai 10 + stobj v0, Foo.f + ldobj v0, Foo.f + return +} diff --git a/static_core/tests/checked/float_zero.pa b/static_core/tests/checked/float_zero.pa index 27549543631e0b0aa757daff841732499897c2de..f5fa13250e8128967186fac204a02d602750074a 100644 --- a/static_core/tests/checked/float_zero.pa +++ b/static_core/tests/checked/float_zero.pa @@ -24,6 +24,31 @@ #! INST_NOT "Constant" #! INST_NOT "Return " +#! CHECKER Check float zero Regular AOT +#! RUN_PAOC options: "" +#! METHOD "_GLOBAL::__noinline__call_foo" +#! PASS_AFTER "IrBuilder" +#! INST "Constant" +#! INST "Return" +#! INST_NOT "ReturnI" +#! PASS_AFTER "Codegen" +#! INST "ReturnI" +#! INST_NOT "Constant" +#! INST_NOT "Return " +#! RUN entry: "_GLOBAL::main" + +#! CHECKER Check float zero LLVM AOT +#! RUN_LLVM options: "--llvm-dump-before" +#! READ_FILE "console.out" +#! INST /define weak protected.*GLOBAL::__noinline__call_foo/ +#! INST_NEXT "ret double 0.0" +#! METHOD "_GLOBAL::__noinline__call_foo" +#! PASS_AFTER "IrBuilder" +#! INST "Constant" +#! INST "Return" +#! INST_NOT "ReturnI" +#! RUN entry: "_GLOBAL::main" + .function f64 __noinline__call_foo(f64 a0) { fldai.64 0.0 return.64 diff --git a/static_core/tests/checked/implicit_nullcheck_tests.pa b/static_core/tests/checked/implicit_nullcheck_tests.pa index a9a749ea99b66991ac1601e67758b330b19bb255..2f83c429f515f4bb83fae67219ca45fa1f2aa4ad 100644 --- a/static_core/tests/checked/implicit_nullcheck_tests.pa +++ b/static_core/tests/checked/implicit_nullcheck_tests.pa @@ -34,10 +34,6 @@ #! CHECKER Use implicit NullCheck for array and object in AOT #! SKIP_IF @architecture == "arm32" #! RUN_PAOC options: "" -#! EVENT /Compilation,.*__noinline__call_ldarray.*/ -#! EVENT /Compilation,.*__noinline__call_starray.*/ -#! EVENT /Compilation,.*__noinline__call_ldobj_i32.*/ -#! EVENT /Compilation,.*__noinline__call_stobj_i32.*/ #! RUN options: "", entry: "_GLOBAL::main" #! EVENT /ImplicitNullcheck,.*/ #! EVENT_NEXT /Exception,.*__noinline__call_ldarray.*NULL_CHECK/ diff --git a/static_core/tests/checked/irreducible_loop_test.pa b/static_core/tests/checked/irreducible_loop_test.pa index 3bbbfea85dbca5ab099ebaa69554c6d2125be65d..82ff336dc1a67bbdcfff3c7fc1dd8d89bf8791ee 100644 --- a/static_core/tests/checked/irreducible_loop_test.pa +++ b/static_core/tests/checked/irreducible_loop_test.pa @@ -11,12 +11,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -#! CHECKER Irreduceble loop test +#! CHECKER Irreducible loop test #! RUN_PAOC options: "--compiler-regex=.*try_to_reproduce.*" #! RUN options: "", entry: "_GLOBAL::main", result: 1 #! EVENT /AotEntrypointFound,_GLOBAL::try_to_reproduce/ -#! CHECKER Irreduceble loop test with reg maps on safepoints +#! CHECKER Irreducible loop test LLVM AOT +#! RUN_LLVM options: "--compiler-regex=.*try_to_reproduce.*" +#! RUN options: "", entry: "_GLOBAL::main", result: 1 +#! EVENT /AotEntrypointFound,_GLOBAL::try_to_reproduce/ + +#! CHECKER Irreducible loop test with reg maps on safepoints #! RUN_PAOC options: "--compiler-regex=.*try_to_reproduce.* --compiler-safe-points-require-reg-map=true" #! RUN options: "", entry: "_GLOBAL::main", result: 1 #! EVENT /AotEntrypointFound,_GLOBAL::try_to_reproduce/ diff --git a/static_core/tests/checked/isinstance_elimination_test.pa b/static_core/tests/checked/isinstance_elimination_test.pa index 4bab2db44babd9d1659ecb749a7a33088b31bde3..c6ce8ebbb152d388357a2c50273b92f918301da4 100644 --- a/static_core/tests/checked/isinstance_elimination_test.pa +++ b/static_core/tests/checked/isinstance_elimination_test.pa @@ -17,6 +17,17 @@ #! PASS_AFTER "TryCatchResolving" #! INST_NOT "IsInstance" +#! CHECKER IsInstance Elimination applied at Regular AOT. +#! RUN_PAOC options: "--compiler-regex=_GLOBAL.*" +#! METHOD "_GLOBAL::main" +#! PASS_AFTER "Cleanup" +#! INST_NOT "IsInstance" +#! RUN entry: "_GLOBAL::main" + +#! CHECKER IsInstance Elimination applied at LLVM AOT. +#! RUN_LLVM options: "--compiler-regex=_GLOBAL.*" +#! RUN entry: "_GLOBAL::main" + .record A1 {} .record B1 {} .record C1 {} @@ -41,4 +52,4 @@ exit_failure: ldai 1 return -} \ No newline at end of file +} diff --git a/static_core/tests/checked/ldarray_obj.pa b/static_core/tests/checked/ldarray_obj.pa index acf34303e242faa2b7f22eaa690bf01c95c1ada9..c7be88e1355c3397268a091f06b15011e2a4d9cc 100644 --- a/static_core/tests/checked/ldarray_obj.pa +++ b/static_core/tests/checked/ldarray_obj.pa @@ -16,6 +16,14 @@ #! EVENT /Compilation,_GLOBAL::test,.*COMPILED/ #! METHOD "_GLOBAL::test" +#! CHECKER Regular AOT rewrite index value +#! RUN_PAOC options: "" +#! RUN entry: "_GLOBAL::main", result: 1 + +#! CHECKER LLVM AOT rewrite index value +#! RUN_LLVM options: "" +#! RUN entry: "_GLOBAL::main", result: 1 + .function i64 test(i64[] a0, i32 a1) { lda a1 ldarr.64 a0 diff --git a/static_core/tests/checked/llvm_stack_overflow_undef.pa b/static_core/tests/checked/llvm_stack_overflow_undef.pa new file mode 100644 index 0000000000000000000000000000000000000000..93f6a01e74f5dbd8227b78c81a5870b34e0f3a9e --- /dev/null +++ b/static_core/tests/checked/llvm_stack_overflow_undef.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! CHECKER Should be no undef in LLVM AOT in case of stack overflow +#! RUN_LLVM options: "--llvm-dump-after" +#! READ_FILE "console.out" +#! LLVM_METHOD /define.*\".*myCall.*\"/ +#! INST_NEXT_NOT "ret ptr addrspace(271) undef" + +.record A { +} + +.function A A.myCall(A a0) { + call.short A.myCall, a0 + return.obj +} diff --git a/static_core/tests/checked/llvmaot-gc-intrusion.pa b/static_core/tests/checked/llvmaot-gc-intrusion.pa new file mode 100644 index 0000000000000000000000000000000000000000..545c781c93e191f08315ca23db9054550a9b2473 --- /dev/null +++ b/static_core/tests/checked/llvmaot-gc-intrusion.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record A { } + +#! CHECKER Do not relocate if not needed +#! RUN_LLVM options: "--llvm-dump-after" +#! READ_FILE "console.out" +#! INST_NOT "llvm.experimental.gc.relocate" +.function i32 main() { + newobj v1, A + newobj v2, A + ldai 42 + return +} diff --git a/static_core/tests/checked/monitor.pa b/static_core/tests/checked/monitor.pa index 74c7b841190d7873a7e01648ab03274a0e48b58c..10abc0a8de2a648a4d8faefb5ea11674f861a47a 100644 --- a/static_core/tests/checked/monitor.pa +++ b/static_core/tests/checked/monitor.pa @@ -31,6 +31,27 @@ #! INST "LoadObject" #! INST "Monitor" +#! CHECKER Check monitors for inlined functions: lse isn't applied at Regulat AOT +#! RUN_PAOC options: "--compiler-regex='(_GLOBAL::main|_GLOBAL::foo)'" +#! EVENT /Inline,_GLOBAL::main,_GLOBAL::foo,.*STATIC,SUCCESS/ +#! METHOD "_GLOBAL::main" +#! PASS_AFTER "LSE" +#! INST "CallStatic.Inlined" +#! INST "Monitor" +#! INST "LoadObject" +#! INST "Monitor" + +# Check that foo was inlined into main. Then check first Monitor, LoadObject and second Monitor. +#! CHECKER Check monitors for inlined functions: lse isn't applied at LLVM AOT +#! RUN_LLVM options: "--compiler-regex='(_GLOBAL::main|_GLOBAL::foo)' --llvm-dump-after" +#! READ_FILE "console.out" +#! INST "LLVM IR module AFTER LLVM optimizations" +#! INST_NEXT /define protected.*_GLOBAL::main/ +#! INST_NEXT "%__panda_entrypoint_MonitorEnterFastPath_addr" +#! INST_NEXT "getelementptr inbounds i8" +#! INST_NEXT "load i32, ptr addrspace(271)" +#! INST_NEXT "%__panda_entrypoint_MonitorExitFastPath_addr" + .function i32 foo(Obj a0) { call Object.monitorEnter, a0 ldobj a0, Obj.data @@ -63,8 +84,34 @@ #! INST_NOT "CallStatic.Inlined" #! INST_NOT "Monitor" #! INST_NOT "LoadObject" + +#! CHECKER Check monitors for inlined functions: lse is applied at Regular AOT +#! RUN_PAOC options: "--compiler-regex='(_GLOBAL::main1|_GLOBAL::foo)'" +#! EVENT /Inline,_GLOBAL::main1,_GLOBAL::foo,.*STATIC,SUCCESS/ +#! METHOD "_GLOBAL::main1" +#! PASS_AFTER "Inline" +#! INST "CallStatic.Inlined" +#! INST "Monitor" +#! INST_COUNT /LoadObject/,3 +#! INST "Monitor" +#! PASS_AFTER "LSE" +#! INST_COUNT /LoadObject/,1 +#! PASS_AFTER "Lowering" +#! INST_NOT "CallStatic.Inlined" +#! INST_NOT "Monitor" +#! INST_NOT "LoadObject" # Inlined function removed on second BranchElimination after LSE, so Lowering is used +# Check there are no monitors and LoadObject after optimizations in main1 because that is dead code. +#! CHECKER Check monitors for inlined functions: lse isn't applied at LLVM AOT 1 +#! RUN_LLVM options: "--compiler-regex='(_GLOBAL::main1|_GLOBAL::foo)' --llvm-dump-after" +#! READ_FILE "console.out" +#! INST "LLVM IR module AFTER LLVM optimizations" +#! INST_NEXT /define protected.*_GLOBAL::main1/ +#! INST_NEXT_NOT "%__panda_entrypoint_MonitorEnterFastPath_addr" +#! INST_NEXT_NOT "load i32, i32 addrspace(271)" +#! INST_NEXT_NOT "%__panda_entrypoint_MonitorExitFastPath_addr" + .function u1 main1() { newobj v0, Obj ldai 0 diff --git a/static_core/tests/checked/parameter_test.pa b/static_core/tests/checked/parameter_test.pa index 8eb980b01fb3f2873922dd412435ff871d0b7f65..46accb5a58c6b060da25327510f4bc727e2805e2 100644 --- a/static_core/tests/checked/parameter_test.pa +++ b/static_core/tests/checked/parameter_test.pa @@ -22,6 +22,14 @@ #! EVENT /Compilation,.*foo_u32.*/ #! EVENT /Compilation,.*foo_u64.*/ +#! CHECKER Check method parameters Regular AOT +#! RUN_PAOC options: "--compiler-inlining=false" +#! RUN entry: "_GLOBAL::main" + +#! CHECKER Check method parameters LLVM AOT +#! RUN_LLVM options: "--compiler-inlining=false" +#! RUN entry: "_GLOBAL::main" + .function f32 foo_f32(f32 a0) { fmovi v0, 1.0 lda a0 @@ -144,4 +152,4 @@ exit_failure_6: exit_failure_7: ldai 7 return -} \ No newline at end of file +} diff --git a/static_core/tests/checked/ref_check_elim_test.pa b/static_core/tests/checked/ref_check_elim_test.pa index a4f9fe358375bc922ba5fbebf1e0b631010903fd..ab8d91370944eef61628d1cd81d6b1e95028e63c 100644 --- a/static_core/tests/checked/ref_check_elim_test.pa +++ b/static_core/tests/checked/ref_check_elim_test.pa @@ -25,7 +25,33 @@ #! PASS_AFTER "ChecksElimination" #! INST "LoadString" #! INST "NewArray" -#! INST_NOT "RefTypeCheck " +#! INST_NOT "RefTypeCheck" + +#! CHECKER Removing RefTypeCheck for string arrays Regular AOT +#! RUN_PAOC options: "--compiler-regex='_GLOBAL::main'" +#! METHOD "_GLOBAL::main" +#! PASS_AFTER "IrBuilder" +#! INST "RefTypeCheck" +#! INST "LoadString" +#! INST "NewArray" +#! PASS_AFTER "ChecksElimination" +#! INST "LoadString" +#! INST "NewArray" +#! INST_NOT "RefTypeCheck" +#! RUN entry: "_GLOBAL::main" + +#! CHECKER Removing RefTypeCheck for string arrays LLVM AOT +#! RUN_LLVM options: "--compiler-regex='_GLOBAL::main'" +#! METHOD "_GLOBAL::main" +#! PASS_AFTER "IrBuilder" +#! INST "RefTypeCheck" +#! INST "LoadString" +#! INST "NewArray" +#! PASS_AFTER "ChecksElimination" +#! INST "LoadString" +#! INST "NewArray" +#! INST_NOT "RefTypeCheck" +#! RUN entry: "_GLOBAL::main" .function u1 main() { movi v0, 1 #sizeof(array) @@ -48,7 +74,30 @@ #! INST "NewArray" #! PASS_AFTER "ChecksElimination" #! INST "NewArray" -#! INST_NOT "RefTypeCheck " +#! INST_NOT "RefTypeCheck" + +#! CHECKER Removing RefTypeCheck for panda.Object Regular AOT +#! RUN_PAOC options: "--compiler-regex='(_GLOBAL::main1|_GLOBAL::store_string__noinline__)'" +#! METHOD "_GLOBAL::store_string__noinline__" +#! PASS_AFTER "IrBuilder" +#! INST "RefTypeCheck" +#! INST "NewArray" +#! PASS_AFTER "ChecksElimination" +#! INST "NewArray" +#! INST_NOT "RefTypeCheck" +#! RUN entry: "_GLOBAL::main" + +#! CHECKER Removing RefTypeCheck for panda.Object LLVM AOT +#! RUN_LLVM options: "--compiler-regex='(_GLOBAL::main1|_GLOBAL::store_string__noinline__)'" +#! METHOD "_GLOBAL::store_string__noinline__" +#! PASS_AFTER "IrBuilder" +#! INST "RefTypeCheck" +#! INST "NewArray" +#! PASS_AFTER "ChecksElimination" +#! INST "NewArray" +#! INST_NOT "RefTypeCheck" +#! RUN entry: "_GLOBAL::main" + .function panda.Object[] store_string__noinline__(panda.String a0) { movi v0, 1 #sizeof(array) newarr v1, v0, panda.Object[] diff --git a/static_core/tests/checked/stack_overflow.pa b/static_core/tests/checked/stack_overflow.pa index 393cdcc79e4ef2c3a3178d735af83955306514d7..f8a0d9087457a1f92d6628c2e61f2bf3bc817f48 100644 --- a/static_core/tests/checked/stack_overflow.pa +++ b/static_core/tests/checked/stack_overflow.pa @@ -12,8 +12,16 @@ # limitations under the License. #! CHECKER Stack overflow -#! RUN force_jit: true, options: "--compiler-regex _GLOBAL::__noinline__inc_recursive", entry: "_GLOBAL::main", result: 0 -#! EVENT /Compilation,_GLOBAL::__noinline__inc_recursive,.*,COMPILED/ +#! RUN force_jit: true, options: "--compiler-regex _GLOBAL::__noinline__inc_recursive", entry: "_GLOBAL::main" +#! EVENT /Compilation,_GLOBAL::__noinline__inc_recursive,.*,COMPILED/ + +#! CHECKER Stack overflow at Regular AOT +#! RUN_PAOC options: "--compiler-regex _GLOBAL::__noinline__inc_recursive" +#! RUN entry: "_GLOBAL::main" + +#! DISABLED_CHECKER Stack overflow at LLVM AOT +#! RUN_LLVM options: "--compiler-regex _GLOBAL::__noinline__inc_recursive" +#! RUN entry: "_GLOBAL::main" .record panda.StackOverflowException @@ -49,6 +57,14 @@ catch_stackoverflow_begin: #! RUN force_jit: true, options: "--compiler-regex _GLOBAL::__noinline__inc_recursive", entry: "_GLOBAL::main_no_catch", result: 1 #! EVENT /Compilation,_GLOBAL::__noinline__inc_recursive,.*,COMPILED/ +#! CHECKER Stack overflow unhandled at Regular AOT +#! RUN_PAOC options: "--compiler-regex _GLOBAL::__noinline__inc_recursive" +#! RUN entry: "_GLOBAL::main_no_catch", result: 1 + +#! DISABLED_CHECKER Stack overflow unhandled at LLVM AOT +#! RUN_LLVM options: "--compiler-regex _GLOBAL::__noinline__inc_recursive" +#! RUN entry: "_GLOBAL::main_no_catch", result: 1 + .function i32 main_no_catch() { movi v0, 0 call.short __noinline__inc_recursive, v0 diff --git a/static_core/tests/checked/tlab_test.pa b/static_core/tests/checked/tlab_test.pa index 72d3ff5ef1b2a5b6207ee6f4ec94722a4bfdf374..e27104a6cd2dcbd3e792a6186f49f8f496cfdb76 100644 --- a/static_core/tests/checked/tlab_test.pa +++ b/static_core/tests/checked/tlab_test.pa @@ -38,6 +38,17 @@ #! EVENT_NEXT /TlabAlloc,.*,16/ #! EVENT_NEXT /TlabAlloc,.*,24/ +#! CHECKER Use TLAB for array and object in LLVMAOT +#! RUN_LLVM options: "--compiler-enable-tlab-events=true --compiler-regex=.*tlab.* --young-shared-space-size=0" +#! RUN options: "--compiler-enable-tlab-events=true", entry: "_GLOBAL::main" +#! TRUE EVENT_COUNT(/SlowpathAlloc,.*/) <= 2 +#! EVENT /TlabAlloc,.*,24/ +#! EVENT_NEXT /TlabAlloc,.*,32/ +#! EVENT_NEXT /TlabAlloc,.*,40/ +#! EVENT_NEXT /TlabAlloc,.*,56/ +#! EVENT_NEXT /TlabAlloc,.*,16/ +#! EVENT_NEXT /TlabAlloc,.*,24/ + #! CHECKER Don't Use TLAB for array and object for STW #! RUN options: "--compiler-hotness-threshold=0 --no-async-jit=false --compiler-enable-jit=true --compiler-enable-tlab-events=true --compiler-check-final=true --gc-type=stw --compiler-regex=.*tlab.* --young-shared-space-size=0", entry: "_GLOBAL::main" #! EVENT /Compilation,.*tlab_array_u64.*/ @@ -49,6 +60,18 @@ #! EVENT /SlowpathAlloc,.*/ #! EVENT_NOT /TlabAlloc,.*/ +#! CHECKER Don't Use TLAB for array and object for STW in AOT +#! RUN_PAOC options: "--compiler-enable-tlab-events=true --gc-type=stw --compiler-regex=.*tlab.*" +#! RUN options: "--compiler-enable-tlab-events=true --gc-type=stw", entry: "_GLOBAL::main" +#! EVENT /SlowpathAlloc,.*/ +#! EVENT_NOT /TlabAlloc,.*/ + +#! CHECKER Don't Use TLAB for array and object for STW in LLVMAOT +#! RUN_LLVM options: "--compiler-enable-tlab-events=true --gc-type=stw --compiler-regex=.*tlab.*" +#! RUN options: "--compiler-enable-tlab-events=true --gc-type=stw", entry: "_GLOBAL::main" +#! EVENT /SlowpathAlloc,.*/ +#! EVENT_NOT /TlabAlloc,.*/ + .record System .record panda.String diff --git a/static_core/tests/checked/verify_aot_tests/verify_aot_test.pa b/static_core/tests/checked/verify_aot_tests/verify_aot_test.pa index a974a1bbe432e44b0c04f8b29280a4ab48c9da59..972d3156452725967e410788ed0cc6a46c01727d 100644 --- a/static_core/tests/checked/verify_aot_tests/verify_aot_test.pa +++ b/static_core/tests/checked/verify_aot_tests/verify_aot_test.pa @@ -64,7 +64,7 @@ #! EVENT /AotManager,.*test.*,CHA_VERIFY_FAILED/ #! CHECKER Test on boot-locations -#! RUN_PAOC options: " --paoc-use-cha=true --paoc-boot-panda-locations /dev/null/arkstdlib.abc" +#! RUN_PAOC options: "--paoc-use-cha=true --paoc-boot-panda-locations /dev/null/arkstdlib.abc" #! EVENT_NOT /Paoc,.*different files/ #! EVENT_NOT /Paoc,.*number of locations/ @@ -82,9 +82,8 @@ #! EVENT /AotManager,.*test.*,ADDED/ #! EVENT /AotManager,.*test.*,VERIFIED/ - #! CHECKER Wrong AOT file with relative path #! RUN_PAOC options: "--panda-files=../../verify_aot_tests_file1.checked/test.abc --paoc-use-cha=true" #! RUN options: "--panda-files=../../verify_aot_tests_file1.checked/test.abc --aot-verify-abs-path=false", entry: "VerifyAotTest::main", abort: 6 #! EVENT /AotManager,.*test.*,ADDED/ -#! EVENT /AotManager,.*test.*,CHA_VERIFY_FAILED/ \ No newline at end of file +#! EVENT /AotManager,.*test.*,CHA_VERIFY_FAILED/ diff --git a/static_core/tests/checked/wrb-arr.pa b/static_core/tests/checked/wrb-arr.pa new file mode 100644 index 0000000000000000000000000000000000000000..34b91e02b435c8046cb5cf35254f045a7da2d5f9 --- /dev/null +++ b/static_core/tests/checked/wrb-arr.pa @@ -0,0 +1,45 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! CHECKER wrb-arr in LLVM AOT mode +#! RUN_LLVM options: "--llvm-builtin-wrb=true --llvm-dump-after" +#! READ_FILE "console.out" +#! INST_NEXT /define protected.*_GLOBAL::main.*/ +#! INST_NEXT "%__panda_entrypoint_PreWrbFuncNoBridge_addr = load" +#! INST_NEXT /call.*%__panda_entrypoint_PreWrbFuncNoBridge_addr/ +#! INST_NEXT_NOT "%__panda_entrypoint_PreWrbFuncNoBridge_addr2 = load" + +.record Asm{ + u1 asm1 + i32 asm2 +} + +.function i32 main(i32 a0){ + movi v0, 7 + movi v3, 2 + newarr v1, v0, Asm[] + newobj v0, Asm + lda a0 + movi v2, 5 + jeq v2, ok + lda.obj v0 + starr.obj v1, v3 + ldai 0 + jmp exit +ok: + lda.obj v0 + starr.obj v1, v3 + ldai 0 +exit: + return +} diff --git a/static_core/tests/checked/wrb-obj.pa b/static_core/tests/checked/wrb-obj.pa new file mode 100644 index 0000000000000000000000000000000000000000..579bacb5dd755ff343642d6d0fcce3c8ece546ee --- /dev/null +++ b/static_core/tests/checked/wrb-obj.pa @@ -0,0 +1,42 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#! CHECKER wrb-obj in LLVM AOT mode +#! RUN_LLVM options: "--llvm-builtin-wrb=true --llvm-dump-after --llvm-pre-opt=0" +#! READ_FILE "console.out" +#! INST_NEXT /define protected.*_GLOBAL::main.*/ +#! INST_NEXT "%__panda_entrypoint_PreWrbFuncNoBridge_addr = load" +#! INST_NEXT /call.*%__panda_entrypoint_PreWrbFuncNoBridge_addr/ +#! INST_NEXT_NOT /%__panda_entrypoint_PreWrbFuncNoBridge_addr.* = load/ + +.record Foo { + Foo f +} + +.function i32 main(i32 a0){ + newobj v0, Foo + newobj v1, Foo + lda a0 + movi v2, 5 + jeq v2, ok + lda.obj v1 + stobj v0, Foo.f + ldai 0 + jmp exit +ok: + lda.obj v1 + stobj v0, Foo.f + ldai 0 +exit: + return +} diff --git a/static_core/tests/checked/zero_const_in_save_state.pa b/static_core/tests/checked/zero_const_in_save_state.pa index 11a8920ed021bdf169668894c7bf186eb7d9d2b8..9702427b3273f588a0926f130a9d7ac578e5537a 100644 --- a/static_core/tests/checked/zero_const_in_save_state.pa +++ b/static_core/tests/checked/zero_const_in_save_state.pa @@ -15,10 +15,26 @@ #! RUN force_jit: true, options: "--compiler-non-optimizing=true", entry: "_GLOBAL::main0" #! EVENT /Compilation,_GLOBAL::main0,.*COMPILED/ +#! CHECKER Check that save state gracefully handle 0 when optimizations are disabled, test for 5372 at Regular AOT +#! RUN_PAOC options: "--compiler-non-optimizing=true" +#! RUN entry: "_GLOBAL::main0" + +#! CHECKER Check that save state gracefully handle 0 when optimizations are disabled, test for 5372 at LLVM AOT +#! RUN_LLVM options: "--compiler-non-optimizing=true" +#! RUN entry: "_GLOBAL::main0" + #! CHECKER Check that save state correctly propogated in presense of null ref, test for 5372 #! RUN force_jit: true, options: "--compiler-lowering=false --gc-trigger-type=debug", entry: "_GLOBAL::main1" #! EVENT /Compilation,_GLOBAL::main1,.*COMPILED/ +#! CHECKER Check that save state correctly propogated in presense of null ref, test for 5372 at Regular AOT +#! RUN_PAOC options: "--compiler-non-optimizing=false" +#! RUN entry: "_GLOBAL::main0" + +#! CHECKER Check that save state correctly propogated in presense of null ref, test for 5372 at LLVM AOT +#! RUN_LLVM options: "--compiler-non-optimizing=false" +#! RUN entry: "_GLOBAL::main1" + .record E {} .function void __noinline__call(u64 a0) { @@ -66,4 +82,4 @@ catch_begin: ldai 0 return .catchall try_begin, try_end, catch_begin -} \ No newline at end of file +} diff --git a/static_core/tests/cts-assembly/abs-f64-01.pa b/static_core/tests/cts-assembly/abs-f64-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..8c08f026a7bee8d43e0ba3cc822892210379093e --- /dev/null +++ b/static_core/tests/cts-assembly/abs-f64-01.pa @@ -0,0 +1,31 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Assert that intrinsic Math.absF64 works fine +.record Math + +.function f64 Math.absF64(f64 a0) + +.function u1 main() { + fmovi.64 v0, -2.0 + call.short Math.absF64, v0 + fmovi.64 v0, 2.0 + fcmpl.64 v0 + + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/abs-f64-02.pa b/static_core/tests/cts-assembly/abs-f64-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..690d21bc4f865b8fc699d9cacfd98201b5dd59b2 --- /dev/null +++ b/static_core/tests/cts-assembly/abs-f64-02.pa @@ -0,0 +1,31 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Assert that intrinsic Math.absF64 works fine +.record Math + +.function f64 Math.absF64(f64 a0) + +.function u1 main() { + fmovi.64 v0, -2.0 + call.short Math.absF64, v0, v0 + fmovi.64 v0, 2.0 + fcmpl.64 v0 + + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/abs-i32-i64.pa b/static_core/tests/cts-assembly/abs-i32-i64.pa new file mode 100644 index 0000000000000000000000000000000000000000..09da85d93b6fd9abebff6c8f296342ed8a2a0ec4 --- /dev/null +++ b/static_core/tests/cts-assembly/abs-i32-i64.pa @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Math +.function i32 Math.absI32(i32 a0) +.function i64 Math.absI64(i64 a0) + +.function u1 main(){ + movi v0, 0x80000000 + call.short Math.absI32, v0, v0 + jne v0, exit_failure + movi.64 v0, 0x8000000000000000 + call.short Math.absI64, v0, v0 + jne v0, exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/arrays-checkcast.pa b/static_core/tests/cts-assembly/arrays-checkcast.pa new file mode 100644 index 0000000000000000000000000000000000000000..737320abaf2611718b8ed46f3cbab702de9d5a4b --- /dev/null +++ b/static_core/tests/cts-assembly/arrays-checkcast.pa @@ -0,0 +1,90 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.Object +.record panda.String +.record panda.ClassCastException +.record IO + +.function panda.String panda.ClassCastException.getMessage(panda.ClassCastException a0) +.function void IO.printString(panda.String a0) + +.record A {} + +# Assert that operation checkcast works fine (only throwing an error when cast is not valid) + +.function u1 good_checkcast() { + movi v0, 5 + newarr v1, v0, i64[] + lda.obj v1 + +try_begin: + checkcast i64[] + lda.obj v1 + newarr v2, v0, A[] + lda.obj v2 + checkcast panda.Object[] + ldai 0 + return +try_end: + +catch_block1_begin: + sta.obj v0 + call.virt panda.ClassCastException.getMessage, v0 + sta.obj v0 + call IO.printString, v0 + ldai 1 + return + +catch_block2_begin: + ldai 2 + return + +.catch panda.ClassCastException, try_begin, try_end, catch_block1_begin +.catchall try_begin, try_end, catch_block2_begin +} + +.function u1 main(){ + call.short good_checkcast + jnez exit_failure + movi v0, 5 + newarr v1, v0, i64[] + lda.obj v1 + +try_begin: + # Bad checkcast - throw ClassCastException + checkcast i32[] + ldai 2 + return +try_end: + +catch_block1_begin: + sta.obj v0 + call.virt panda.ClassCastException.getMessage, v0 + sta.obj v0 + call IO.printString, v0 + ldai 0 + return + +catch_block2_begin: + ldai 1 + return + +exit_failure: + ldai 1 + return + +.catch panda.ClassCastException, try_begin, try_end, catch_block1_begin +.catchall try_begin, try_end, catch_block2_begin +} + diff --git a/static_core/tests/cts-assembly/arrays-isinstance.pa b/static_core/tests/cts-assembly/arrays-isinstance.pa new file mode 100644 index 0000000000000000000000000000000000000000..8b78868ac788ebcb8e942d5e87c55c8fe85a267b --- /dev/null +++ b/static_core/tests/cts-assembly/arrays-isinstance.pa @@ -0,0 +1,41 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.Object + +# Assert that operation isinstance works fine + +.record A {} + +.function u1 main(){ + movi v0, 5 + newarr v1, v0, i64[] + lda.obj v1 + isinstance i64[] + jeqz exit_failure + lda.obj v1 + isinstance i32[] + jnez exit_failure + lda.obj v1 + isinstance panda.Object[] + jnez exit_failure + newarr v2, v0, A[] + lda.obj v2 + isinstance panda.Object[] + jeqz exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/call-static-01.pa b/static_core/tests/cts-assembly/call-static-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..3b444112370469926657efe29e6b995ab5411074 --- /dev/null +++ b/static_core/tests/cts-assembly/call-static-01.pa @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i64 main() { + movi.64 v0, 999 + movi.64 v1, 69 + call.short foo, v0, v1 + sub2.64 v1 + return.64 +} + +.function i64 foo(i64 a0, i64 a1) { + call.short bar, a1, a0 + return.64 +} + +.function i64 bar(i64 a0, i64 a1) { + lda.64 a0 + return.64 +} diff --git a/static_core/tests/cts-assembly/call-static-02.pa b/static_core/tests/cts-assembly/call-static-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..640f5868cc447d92ead2acc6ab079ea65a0f338b --- /dev/null +++ b/static_core/tests/cts-assembly/call-static-02.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i32 main() { + movi v0, 42 + call.short test, v0 + sub2 v0 + + return +} + +.function i32 test(i32 a0) { + lda a0 + return +} diff --git a/static_core/tests/cts-assembly/call-static-03.pa b/static_core/tests/cts-assembly/call-static-03.pa new file mode 100644 index 0000000000000000000000000000000000000000..6c3dfe37119d88845b31a9661b2710cd848ba234 --- /dev/null +++ b/static_core/tests/cts-assembly/call-static-03.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i32 main() { + movi v0, 42 + call.short test__noinline__, v0 + sub2 v0 + + return +} + +.function i32 test__noinline__(i32 a0) { + lda a0 + return +} + diff --git a/static_core/tests/cts-assembly/call-static-04.pa b/static_core/tests/cts-assembly/call-static-04.pa new file mode 100644 index 0000000000000000000000000000000000000000..7954fdc0d2e730f6192243d789dbf8c81359fec1 --- /dev/null +++ b/static_core/tests/cts-assembly/call-static-04.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i32 main() { + movi v0, 42 + call.short test__noinline__, v0 + sub2 v0 + + return +} + +.function i32 test__noinline__(i32 a0) { + ldai 42 + return +} + diff --git a/static_core/tests/cts-assembly/call-virtual-01.pa b/static_core/tests/cts-assembly/call-virtual-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..2f799db1de302ae2490edbf0ac29f4143789f582 --- /dev/null +++ b/static_core/tests/cts-assembly/call-virtual-01.pa @@ -0,0 +1,44 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.String +.record IO +.function void IO.printString(panda.String a0) +.function void IO.printI32(i32 a0) + +.record Factory { + i32 i +} + +.function Factory Factory.newFactory(Factory a0) { + newobj v0, Factory + ldai 42 + stobj v0, Factory.i + lda.obj v0 + + return.obj +} + +.function i32 main() { + newobj v0, Factory + call.virt Factory.newFactory, v0 + sta.obj v0 + call.virt Factory.newFactory, v0 + sta.obj v0 + + movi.64 v1, 42 + ldobj v0, Factory.i + i32toi64 + cmp.64 v1 + return +} diff --git a/static_core/tests/cts-assembly/cmp-u32-01.pa b/static_core/tests/cts-assembly/cmp-u32-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..5b37837dd8d45a913697e0997f17449f61088873 --- /dev/null +++ b/static_core/tests/cts-assembly/cmp-u32-01.pa @@ -0,0 +1,27 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert ucmp 0xFFFFFFFF, 1 == 1 operation --> ucmp +.function u1 main() { + ldai 0xFFFFFFFF + movi v0, 1 + ucmp v0 + + jltz exit_failure + + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/cmp-u64-01.pa b/static_core/tests/cts-assembly/cmp-u64-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..5979e450ef38145bd7edb926529733f3c3ab81e7 --- /dev/null +++ b/static_core/tests/cts-assembly/cmp-u64-01.pa @@ -0,0 +1,27 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert ucmp 0xFFFFFFFFFFFFFFFF, 1 == 1 operation --> ucmp.64 +.function u1 main() { + ldai.64 0xFFFFFFFFFFFFFFFF + movi.64 v0, 1 + ucmp.64 v0 + + jltz exit_failure + + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/const-f32-01.pa b/static_core/tests/cts-assembly/const-f32-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..13092967779316b46bd52c7749c0977ba5afece5 --- /dev/null +++ b/static_core/tests/cts-assembly/const-f32-01.pa @@ -0,0 +1,18 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# return f32 (0.0) +.function f32 main() { + ldai 0 + return +} diff --git a/static_core/tests/cts-assembly/const-f64-01.pa b/static_core/tests/cts-assembly/const-f64-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..5c617c32731335c05be2736e537c18d242727b14 --- /dev/null +++ b/static_core/tests/cts-assembly/const-f64-01.pa @@ -0,0 +1,18 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# return f64 (0.0) +.function f64 main() { + fldai.64 0.0 + return.64 +} diff --git a/static_core/tests/cts-assembly/const-f64-02.pa b/static_core/tests/cts-assembly/const-f64-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..31c7801fc343b0f977cebddbbba36012ac9f4e26 --- /dev/null +++ b/static_core/tests/cts-assembly/const-f64-02.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# return f64 (0.0) + +.function f64 getPi() { + fldai.64 3.1415926 + return.64 +} + +.function i32 main() { + fmovi.64 v0, 3.1415926 + call.short getPi + fcmpl.64 v0 + return +} diff --git a/static_core/tests/cts-assembly/const-f64-03.pa b/static_core/tests/cts-assembly/const-f64-03.pa new file mode 100644 index 0000000000000000000000000000000000000000..6da187b24848a55fa2848a1832995b6cb91da2e0 --- /dev/null +++ b/static_core/tests/cts-assembly/const-f64-03.pa @@ -0,0 +1,39 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function f64 getPi() { + fldai.64 3.1415926 + return.64 +} + +.function f64 getOtherNumber() { + fldai.64 2.0405926 + return.64 +} + +.function f64 getPiAndOtherNumberDifference() { + fldai.64 1.101 + return.64 +} + +.function i32 main() { + call.short getOtherNumber + sta.64 v0 + call.short getPi + fsub2.64 v0 + sta.64 v0 + call.short getPiAndOtherNumberDifference + fcmpl.64 v0 + + return +} diff --git a/static_core/tests/cts-assembly/const-f64-04.pa b/static_core/tests/cts-assembly/const-f64-04.pa new file mode 100644 index 0000000000000000000000000000000000000000..e02d5b04cb3d1aafa85bc2e007a636da7465f1aa --- /dev/null +++ b/static_core/tests/cts-assembly/const-f64-04.pa @@ -0,0 +1,919 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record IO +.function void IO.printF64(f64 a0) + +.function f64 getConstant0() { + fldai.64 30.927746268321755 + return.64 +} +.function f64 getConstant0_mirror() { + fldai.64 30.927746268321755 + return.64 +} +.function f64 getConstant1() { + fldai.64 24.84225600662112 + return.64 +} +.function f64 getConstant1_mirror() { + fldai.64 24.84225600662112 + return.64 +} +.function f64 getConstant2() { + fldai.64 55.875992273436005 + return.64 +} +.function f64 getConstant2_mirror() { + fldai.64 55.875992273436005 + return.64 +} +.function f64 getConstant3() { + fldai.64 14.647906742287475 + return.64 +} +.function f64 getConstant3_mirror() { + fldai.64 14.647906742287475 + return.64 +} +.function f64 getConstant4() { + fldai.64 24.456779676852868 + return.64 +} +.function f64 getConstant4_mirror() { + fldai.64 24.456779676852868 + return.64 +} +.function f64 getConstant5() { + fldai.64 17.26475469040577 + return.64 +} +.function f64 getConstant5_mirror() { + fldai.64 17.26475469040577 + return.64 +} +.function f64 getConstant6() { + fldai.64 42.899292167474066 + return.64 +} +.function f64 getConstant6_mirror() { + fldai.64 42.899292167474066 + return.64 +} +.function f64 getConstant7() { + fldai.64 80.19101549361777 + return.64 +} +.function f64 getConstant7_mirror() { + fldai.64 80.19101549361777 + return.64 +} +.function f64 getConstant8() { + fldai.64 31.544109682554257 + return.64 +} +.function f64 getConstant8_mirror() { + fldai.64 31.544109682554257 + return.64 +} +.function f64 getConstant9() { + fldai.64 98.66912140143351 + return.64 +} +.function f64 getConstant9_mirror() { + fldai.64 98.66912140143351 + return.64 +} +.function f64 getConstant10() { + fldai.64 32.79445084683281 + return.64 +} +.function f64 getConstant10_mirror() { + fldai.64 32.79445084683281 + return.64 +} +.function f64 getConstant11() { + fldai.64 0.04935188431176574 + return.64 +} +.function f64 getConstant11_mirror() { + fldai.64 0.04935188431176574 + return.64 +} +.function f64 getConstant12() { + fldai.64 45.466886412846485 + return.64 +} +.function f64 getConstant12_mirror() { + fldai.64 45.466886412846485 + return.64 +} +.function f64 getConstant13() { + fldai.64 42.181858428374156 + return.64 +} +.function f64 getConstant13_mirror() { + fldai.64 42.181858428374156 + return.64 +} +.function f64 getConstant14() { + fldai.64 79.19164409854154 + return.64 +} +.function f64 getConstant14_mirror() { + fldai.64 79.19164409854154 + return.64 +} +.function f64 getConstant15() { + fldai.64 53.297024609470135 + return.64 +} +.function f64 getConstant15_mirror() { + fldai.64 53.297024609470135 + return.64 +} +.function f64 getConstant16() { + fldai.64 59.57958923579125 + return.64 +} +.function f64 getConstant16_mirror() { + fldai.64 59.57958923579125 + return.64 +} +.function f64 getConstant17() { + fldai.64 24.4739766239915 + return.64 +} +.function f64 getConstant17_mirror() { + fldai.64 24.4739766239915 + return.64 +} +.function f64 getConstant18() { + fldai.64 15.227385364177392 + return.64 +} +.function f64 getConstant18_mirror() { + fldai.64 15.227385364177392 + return.64 +} +.function f64 getConstant19() { + fldai.64 10.234142992968842 + return.64 +} +.function f64 getConstant19_mirror() { + fldai.64 10.234142992968842 + return.64 +} +.function f64 getConstant20() { + fldai.64 2.3092305496996923 + return.64 +} +.function f64 getConstant20_mirror() { + fldai.64 2.3092305496996923 + return.64 +} +.function f64 getConstant21() { + fldai.64 56.722262435776926 + return.64 +} +.function f64 getConstant21_mirror() { + fldai.64 56.722262435776926 + return.64 +} +.function f64 getConstant22() { + fldai.64 84.10061219490417 + return.64 +} +.function f64 getConstant22_mirror() { + fldai.64 84.10061219490417 + return.64 +} +.function f64 getConstant23() { + fldai.64 33.105230267946375 + return.64 +} +.function f64 getConstant23_mirror() { + fldai.64 33.105230267946375 + return.64 +} +.function f64 getConstant24() { + fldai.64 70.45692293849578 + return.64 +} +.function f64 getConstant24_mirror() { + fldai.64 70.45692293849578 + return.64 +} +.function f64 getConstant25() { + fldai.64 2.046039088340257 + return.64 +} +.function f64 getConstant25_mirror() { + fldai.64 2.046039088340257 + return.64 +} +.function f64 getConstant26() { + fldai.64 26.75013908258427 + return.64 +} +.function f64 getConstant26_mirror() { + fldai.64 26.75013908258427 + return.64 +} +.function f64 getConstant27() { + fldai.64 5.274590374504829 + return.64 +} +.function f64 getConstant27_mirror() { + fldai.64 5.274590374504829 + return.64 +} +.function f64 getConstant28() { + fldai.64 0.33524057240039706 + return.64 +} +.function f64 getConstant28_mirror() { + fldai.64 0.33524057240039706 + return.64 +} +.function f64 getConstant29() { + fldai.64 25.32086025735528 + return.64 +} +.function f64 getConstant29_mirror() { + fldai.64 25.32086025735528 + return.64 +} +.function f64 getConstant30() { + fldai.64 54.122370512261796 + return.64 +} +.function f64 getConstant30_mirror() { + fldai.64 54.122370512261796 + return.64 +} +.function f64 getConstant31() { + fldai.64 93.4027470663071 + return.64 +} +.function f64 getConstant31_mirror() { + fldai.64 93.4027470663071 + return.64 +} +.function f64 getConstant32() { + fldai.64 86.68094596038769 + return.64 +} +.function f64 getConstant32_mirror() { + fldai.64 86.68094596038769 + return.64 +} +.function f64 getConstant33() { + fldai.64 64.33706791079362 + return.64 +} +.function f64 getConstant33_mirror() { + fldai.64 64.33706791079362 + return.64 +} +.function f64 getConstant34() { + fldai.64 3.470767632687888 + return.64 +} +.function f64 getConstant34_mirror() { + fldai.64 3.470767632687888 + return.64 +} +.function f64 getConstant35() { + fldai.64 54.296866031899214 + return.64 +} +.function f64 getConstant35_mirror() { + fldai.64 54.296866031899214 + return.64 +} +.function f64 getConstant36() { + fldai.64 57.81780032610487 + return.64 +} +.function f64 getConstant36_mirror() { + fldai.64 57.81780032610487 + return.64 +} +.function f64 getConstant37() { + fldai.64 7.462497628387621 + return.64 +} +.function f64 getConstant37_mirror() { + fldai.64 7.462497628387621 + return.64 +} +.function f64 getConstant38() { + fldai.64 28.226276464703638 + return.64 +} +.function f64 getConstant38_mirror() { + fldai.64 28.226276464703638 + return.64 +} +.function f64 getConstant39() { + fldai.64 8.362089753743485 + return.64 +} +.function f64 getConstant39_mirror() { + fldai.64 8.362089753743485 + return.64 +} +.function f64 getConstant40() { + fldai.64 42.20437617613848 + return.64 +} +.function f64 getConstant40_mirror() { + fldai.64 42.20437617613848 + return.64 +} +.function f64 getConstant41() { + fldai.64 12.285055612738772 + return.64 +} +.function f64 getConstant41_mirror() { + fldai.64 12.285055612738772 + return.64 +} +.function f64 getConstant42() { + fldai.64 99.20057028781359 + return.64 +} +.function f64 getConstant42_mirror() { + fldai.64 99.20057028781359 + return.64 +} +.function f64 getConstant43() { + fldai.64 14.959555636530364 + return.64 +} +.function f64 getConstant43_mirror() { + fldai.64 14.959555636530364 + return.64 +} +.function f64 getConstant44() { + fldai.64 16.286878655766333 + return.64 +} +.function f64 getConstant44_mirror() { + fldai.64 16.286878655766333 + return.64 +} +.function f64 getConstant45() { + fldai.64 2.152266803156322 + return.64 +} +.function f64 getConstant45_mirror() { + fldai.64 2.152266803156322 + return.64 +} +.function f64 getConstant46() { + fldai.64 1.2315635654959856 + return.64 +} +.function f64 getConstant46_mirror() { + fldai.64 1.2315635654959856 + return.64 +} +.function f64 getConstant47() { + fldai.64 1.4807704450392478 + return.64 +} +.function f64 getConstant47_mirror() { + fldai.64 1.4807704450392478 + return.64 +} +.function f64 getConstant48() { + fldai.64 6.487206892045638 + return.64 +} +.function f64 getConstant48_mirror() { + fldai.64 6.487206892045638 + return.64 +} +.function f64 getConstant49() { + fldai.64 33.09131326476377 + return.64 +} +.function f64 getConstant49_mirror() { + fldai.64 33.09131326476377 + return.64 +} +.function f64 getConstant50() { + fldai.64 93.85339532340599 + return.64 +} +.function f64 getConstant50_mirror() { + fldai.64 93.85339532340599 + return.64 +} +.function f64 getConstant51() { + fldai.64 17.576984261106233 + return.64 +} +.function f64 getConstant51_mirror() { + fldai.64 17.576984261106233 + return.64 +} +.function f64 getConstant52() { + fldai.64 29.191589917165807 + return.64 +} +.function f64 getConstant52_mirror() { + fldai.64 29.191589917165807 + return.64 +} +.function f64 getConstant53() { + fldai.64 32.284510587862805 + return.64 +} +.function f64 getConstant53_mirror() { + fldai.64 32.284510587862805 + return.64 +} +.function f64 getConstant54() { + fldai.64 67.17064782759999 + return.64 +} +.function f64 getConstant54_mirror() { + fldai.64 67.17064782759999 + return.64 +} +.function f64 getConstant55() { + fldai.64 8.736008070666589 + return.64 +} +.function f64 getConstant55_mirror() { + fldai.64 8.736008070666589 + return.64 +} +.function f64 getConstant56() { + fldai.64 91.76532703304538 + return.64 +} +.function f64 getConstant56_mirror() { + fldai.64 91.76532703304538 + return.64 +} +.function f64 getConstant57() { + fldai.64 71.09152692972367 + return.64 +} +.function f64 getConstant57_mirror() { + fldai.64 71.09152692972367 + return.64 +} +.function f64 getConstant58() { + fldai.64 64.83931487976083 + return.64 +} +.function f64 getConstant58_mirror() { + fldai.64 64.83931487976083 + return.64 +} +.function f64 getConstant59() { + fldai.64 29.277945606143074 + return.64 +} +.function f64 getConstant59_mirror() { + fldai.64 29.277945606143074 + return.64 +} +.function f64 getConstant60() { + fldai.64 44.904282728168795 + return.64 +} +.function f64 getConstant60_mirror() { + fldai.64 44.904282728168795 + return.64 +} +.function f64 getConstant61() { + fldai.64 50.55111188669653 + return.64 +} +.function f64 getConstant61_mirror() { + fldai.64 50.55111188669653 + return.64 +} +.function f64 getConstant62() { + fldai.64 64.90459499445636 + return.64 +} +.function f64 getConstant62_mirror() { + fldai.64 64.90459499445636 + return.64 +} +.function f64 getConstant63() { + fldai.64 43.84512261239283 + return.64 +} +.function f64 getConstant63_mirror() { + fldai.64 43.84512261239283 + return.64 +} +.function i32 main() { + call.short getConstant0 + sta.64 v0 + call.short getConstant0_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant1 + sta.64 v0 + call.short getConstant1_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant2 + sta.64 v0 + call.short getConstant2_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant3 + sta.64 v0 + call.short getConstant3_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant4 + sta.64 v0 + call.short getConstant4_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant5 + sta.64 v0 + call.short getConstant5_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant6 + sta.64 v0 + call.short getConstant6_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant7 + sta.64 v0 + call.short getConstant7_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant8 + sta.64 v0 + call.short getConstant8_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant9 + sta.64 v0 + call.short getConstant9_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant10 + sta.64 v0 + call.short getConstant10_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant11 + sta.64 v0 + call.short getConstant11_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant12 + sta.64 v0 + call.short getConstant12_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant13 + sta.64 v0 + call.short getConstant13_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant14 + sta.64 v0 + call.short getConstant14_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant15 + sta.64 v0 + call.short getConstant15_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant16 + sta.64 v0 + call.short getConstant16_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant17 + sta.64 v0 + call.short getConstant17_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant18 + sta.64 v0 + call.short getConstant18_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant19 + sta.64 v0 + call.short getConstant19_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant20 + sta.64 v0 + call.short getConstant20_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant21 + sta.64 v0 + call.short getConstant21_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant22 + sta.64 v0 + call.short getConstant22_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant23 + sta.64 v0 + call.short getConstant23_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant24 + sta.64 v0 + call.short getConstant24_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant25 + sta.64 v0 + call.short getConstant25_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant26 + sta.64 v0 + call.short getConstant26_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant27 + sta.64 v0 + call.short getConstant27_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant28 + sta.64 v0 + call.short getConstant28_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant29 + sta.64 v0 + call.short getConstant29_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant30 + sta.64 v0 + call.short getConstant30_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant31 + sta.64 v0 + call.short getConstant31_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant32 + sta.64 v0 + call.short getConstant32_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant33 + sta.64 v0 + call.short getConstant33_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant34 + sta.64 v0 + call.short getConstant34_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant35 + sta.64 v0 + call.short getConstant35_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant36 + sta.64 v0 + call.short getConstant36_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant37 + sta.64 v0 + call.short getConstant37_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant38 + sta.64 v0 + call.short getConstant38_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant39 + sta.64 v0 + call.short getConstant39_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant40 + sta.64 v0 + call.short getConstant40_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant41 + sta.64 v0 + call.short getConstant41_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant42 + sta.64 v0 + call.short getConstant42_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant43 + sta.64 v0 + call.short getConstant43_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant44 + sta.64 v0 + call.short getConstant44_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant45 + sta.64 v0 + call.short getConstant45_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant46 + sta.64 v0 + call.short getConstant46_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant47 + sta.64 v0 + call.short getConstant47_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant48 + sta.64 v0 + call.short getConstant48_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant49 + sta.64 v0 + call.short getConstant49_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant50 + sta.64 v0 + call.short getConstant50_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant51 + sta.64 v0 + call.short getConstant51_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant52 + sta.64 v0 + call.short getConstant52_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant53 + sta.64 v0 + call.short getConstant53_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant54 + sta.64 v0 + call.short getConstant54_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant55 + sta.64 v0 + call.short getConstant55_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant56 + sta.64 v0 + call.short getConstant56_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant57 + sta.64 v0 + call.short getConstant57_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant58 + sta.64 v0 + call.short getConstant58_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant59 + sta.64 v0 + call.short getConstant59_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant60 + sta.64 v0 + call.short getConstant60_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant61 + sta.64 v0 + call.short getConstant61_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant62 + sta.64 v0 + call.short getConstant62_mirror + fcmpl.64 v0 + jnez exit_failure + + call.short getConstant63 + sta.64 v0 + call.short IO.printF64, v0, v0 + call.short getConstant63_mirror + fcmpl.64 v0 + jnez exit_failure + + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/floatcast-test-1.pa b/static_core/tests/cts-assembly/floatcast-test-1.pa new file mode 100644 index 0000000000000000000000000000000000000000..8e219cb4d62291e71bce3502bedd947c12eeafdc --- /dev/null +++ b/static_core/tests/cts-assembly/floatcast-test-1.pa @@ -0,0 +1,207 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i64 func_f64toi64(f64 a0) { + lda.64 a0 + f64toi64 + return.64 +} + +.function i64 func_f64tou64(f64 a0) { + lda.64 a0 + f64tou64 + return.64 +} + +.function i64 func_f32toi64(f32 a0) { + lda a0 + f32toi64 + return.64 +} + +.function i64 func_f32tou64(f32 a0) { + lda a0 + f32tou64 + return.64 +} + +.function i32 func_f64toi32(f64 a0) { + lda.64 a0 + f64toi32 + return +} + +.function i32 func_f64tou32(f64 a0) { + lda.64 a0 + f64tou32 + return +} + +.function i32 func_f32toi32(f32 a0) { + lda a0 + f32toi32 + return +} + +.function i32 func_f32tou32(f32 a0) { + lda a0 + f32tou32 + return +} + +.function i32 main() { + + # f32toi32 (NaN to 0 check) + fmovi v0, 0x7FFFFFFF + call func_f32toi32, v0 + movi v0, 0 + jne v0, exit_failure + + # f64toi64 (NaN to 0 check) + fmovi.64 v0, 0x7FF8000000000000 + call func_f64toi64, v0 + movi.64 v0, 0 + jne v0, exit_failure + + # f32tou32 (NaN to 0 check) + fmovi v0, 0x7FFFFFFF + call func_f32tou32, v0 + movi v0, 0 + jne v0, exit_failure + + # f64tou64 (NaN to 0 check) + fmovi.64 v0, 0x7FF8000000000000 + call func_f64tou64, v0 + movi.64 v0, 0 + jne v0, exit_failure + + # f32toi64 (NaN to 0 check) + fmovi v0, 0x7FFFFFFF + call func_f32toi64, v0 + movi.64 v0, 0 + jne v0, exit_failure + + # f32tou64 (NaN to 0 check) + fmovi v0, 0x7FFFFFFF + call func_f32tou64, v0 + movi.64 v0, 0 + jne v0, exit_failure + + # f32toi32 (MAX_INT32 + 1F to MAX_INT32 check) + fmovi v0, 0x4F000001 + call func_f32toi32, v0 + movi v0, 2147483647 + jne v0, exit_failure + + # f32toi32 (MIN_INT32 + 1F to MIN_INT32 (0x80000000) check) + # (sign bit set to 1 so if we sum float(MIN_INT32) with 1F + # we will get result < float(MIN_INT32)) + fmovi v0, 0xCF000001 + call func_f32toi32, v0 + movi v0, 0x80000000 + jne v0, exit_failure + + # f32tou32 (MAX_UINT32 + 1F to MAX_UINT32 check) + fmovi v0, 0x4F800001 + call func_f32tou32, v0 + movi v0, 4294967295 + jne v0, exit_failure + + # f32tou32 (-1 to 0 check) + fmovi v0, 0xBF800000 + call func_f32tou32, v0 + movi v0, 0 + jne v0, exit_failure + + # f32toi64 (MAX_INT64 + 1F to MAX_INT64 check) + fmovi v0, 0x5F000001 + call func_f32toi64, v0 + movi.64 v0, 9223372036854775807 + jne v0, exit_failure + + # f32toi64 (MIN_INT64 - 1 to MIN_INT64 (0x8000000000000000) check) + # (sign bit set to 1 so if we sum float(MIN_INT64) with 1F + # we will get result < float(MIN_INT64)) + fmovi v0, 0xDF000001 + call func_f32toi64, v0 + movi.64 v0, 0x8000000000000000 + jne v0, exit_failure + + # f32tou64 (MAX_UINT64 + 1F to MAX_UINT64 check) + fmovi v0, 0x5F800001 + call func_f32tou64, v0 + movi.64 v0, 18446744073709551615 + jne v0, exit_failure + + # f32tou64 (-1 to 0 check) + fmovi v0, 0xBF800000 + call func_f32tou64, v0 + movi v0, 0 + jne v0, exit_failure + + # f64toi32 (+inf to MAX_INT32 check) + fmovi.64 v0, 0x7FF0000000000000 + call func_f64toi32, v0 + movi v0, 2147483647 + jne v0, exit_failure + + # f64toi32 (-inf to MIN_INT32 (0x80000000) check) + fmovi.64 v0, 0xFFF0000000000000 + call func_f64toi32, v0 + movi v0, 0x80000000 + jne v0, exit_failure + + # f64tou32 (+inf to UMAX_INT32 check) + fmovi.64 v0, 0x7FF0000000000000 + call func_f64tou32, v0 + movi v0, 4294967295 + jne v0, exit_failure + + # f64tou32 (-inf to 0 check) + fmovi.64 v0, 0xFFF0000000000000 + call func_f64tou32, v0 + movi v0, 0 + jne v0, exit_failure + + # f32toi32 (+inf to MAX_INT32 check) + fmovi v0, 0x7F800000 + call func_f32toi32, v0 + movi v0, 2147483647 + jne v0, exit_failure + + # f32toi32 (-inf to MIN_INT32 (0x80000000) check) + fmovi v0, 0xFF800000 + call func_f32toi32, v0 + movi v0, 0x80000000 + jne v0, exit_failure + + # f32tou32 (+inf to UMAX_INT32 check) + fmovi v0, 0x7F800000 + call func_f32tou32, v0 + movi v0, 4294967295 + jne v0, exit_failure + + # f32tou32 (-inf to 0 check) + fmovi v0, 0xFF800000 + call func_f32tou32, v0 + movi v0, 0 + jne v0, exit_failure + + # All tests done + ldai 0 + return + +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/floatcast-test-2.pa b/static_core/tests/cts-assembly/floatcast-test-2.pa new file mode 120000 index 0000000000000000000000000000000000000000..267924fa252d26146cd1f7e0410553cb4408122d --- /dev/null +++ b/static_core/tests/cts-assembly/floatcast-test-2.pa @@ -0,0 +1 @@ +floatcast-test-1.pa \ No newline at end of file diff --git a/static_core/tests/cts-assembly/llvm-options.pa b/static_core/tests/cts-assembly/llvm-options.pa new file mode 100644 index 0000000000000000000000000000000000000000..4c1b83a08b51e20e450908fa478b08fd310d6ae0 --- /dev/null +++ b/static_core/tests/cts-assembly/llvm-options.pa @@ -0,0 +1,17 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function u1 main(){ + ldai 0 + return +} diff --git a/static_core/tests/cts-assembly/load-and-init-01.pa b/static_core/tests/cts-assembly/load-and-init-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..7eb73f1c62681cde3fa957c55281db9c19429183 --- /dev/null +++ b/static_core/tests/cts-assembly/load-and-init-01.pa @@ -0,0 +1,32 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Globals { + i32 flag +} + +.function i32 main(){ + ldai 0 + ststatic Globals.flag + ldai 32 + jnez if + jeqz merge +if: + ldai 1 + ststatic Globals.flag + +merge: + ldai 0 + + return +} diff --git a/static_core/tests/cts-assembly/load-and-init-02.pa b/static_core/tests/cts-assembly/load-and-init-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..dcc2e17929be9cf9438958e0f515b5f5412ce9b1 --- /dev/null +++ b/static_core/tests/cts-assembly/load-and-init-02.pa @@ -0,0 +1,41 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Globals { + i32 x +} + +.function i32 foo(i32 a0) { + lda a0 + jgtz positive + ststatic Globals.x + movi v1, -1 + jmp exit +positive: + ldai 2 + mul2 a0 + ststatic Globals.x + movi v1, 1 +exit: + lda v1 + return +} + +.function i32 main() { + movi v0, 20 + call.short foo, v0 + i32toi64 + movi.64 v0, 1 + cmp.64 v0 + return +} diff --git a/static_core/tests/cts-assembly/long-array.pa b/static_core/tests/cts-assembly/long-array.pa new file mode 100644 index 0000000000000000000000000000000000000000..cd6582828c3c676fc9688d215f521dd78b32c5e7 --- /dev/null +++ b/static_core/tests/cts-assembly/long-array.pa @@ -0,0 +1,38 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#.array long i32 49 { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 } +.array long i32 999 { 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 } + + +.function i32 main() { + lda.const v0, long + movi v3, 999 + + movi v1, 0 #loop_counter + movi v2, 0 #sum + lda v1 +loop: + jeq v3, loop_exit + lda v1 + ldarr v0 + add2 v2 + sta v2 + inci v1, 1 + lda v1 + jmp loop +loop_exit: + lda v2 + subi 499500 + return +} diff --git a/static_core/tests/cts-assembly/math-fadd-01.pa b/static_core/tests/cts-assembly/math-fadd-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..8b6e232c79f29b2942abbde67084d71a9cc06346 --- /dev/null +++ b/static_core/tests/cts-assembly/math-fadd-01.pa @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(5.1 + 7.2 == 12.3) operation --> fadd2.64 +# The difference between this file and math-22.pa is in the absence of abs function +# This file should be considered temporal until we will have call support in +# LLVM AOT +.function u1 main(){ + fldai.64 5.1 + fmovi.64 v0, 7.2 + fadd2.64 v0 + fmovi.64 v0, 12.3 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fdiv-01.pa b/static_core/tests/cts-assembly/math-fdiv-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..7a01bfae47d721fc4acce4ca387327756b23943c --- /dev/null +++ b/static_core/tests/cts-assembly/math-fdiv-01.pa @@ -0,0 +1,27 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(5.0 / 2.5 == 2.0) operation --> fdiv2.64 +.function u1 main() { + fldai.64 5.0 + fmovi.64 v0, 2.5 + fdiv2.64 v0 + fmovi.64 v0, 2.0 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fmod-01.pa b/static_core/tests/cts-assembly/math-fmod-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..c62bb6d893d96fdfae2a0698120e47c7160050d3 --- /dev/null +++ b/static_core/tests/cts-assembly/math-fmod-01.pa @@ -0,0 +1,27 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(12.8 mod 12.3 == 0.5) operation --> fmod2.64 +.function u1 main() { + fldai.64 12.8 + fmovi.64 v0, 12.3 + fmod2.64 v0 + fmovi.64 v0, 0.5 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fmul-01.pa b/static_core/tests/cts-assembly/math-fmul-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..67344321b780c5cfac5c503f9f9676c51f9203e6 --- /dev/null +++ b/static_core/tests/cts-assembly/math-fmul-01.pa @@ -0,0 +1,29 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(5 * 2.5 == 12.5) operation --> fmul2.64 +# This file is heavily influenced by ../cts-assembly/math-25.pa +# The difference between this file and math-25.pa is in the absence of abs function +.function u1 main(){ + fldai.64 5.0 + fmovi.64 v0, 2.5 + fmul2.64 v0 + fmovi.64 v0, 12.5 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fneg-01.pa b/static_core/tests/cts-assembly/math-fneg-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..1298a0b4af12a5f9ec6c3c125fbde38027ed58db --- /dev/null +++ b/static_core/tests/cts-assembly/math-fneg-01.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(fneg 12.8 == -12.8) operation --> fneg.64 +.function u1 main() { + fldai.64 12.8 + fneg.64 + fmovi.64 v0, -12.8 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fneg-02.pa b/static_core/tests/cts-assembly/math-fneg-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..dfc740e4aa2280d5e957a3b8b27137ba14483a88 --- /dev/null +++ b/static_core/tests/cts-assembly/math-fneg-02.pa @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(fneg -12.8 == 12.8) operation --> fneg.64 +.function u1 main() { + fldai.64 -12.8 + fneg.64 + fmovi.64 v0, 12.8 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-fsub-01.pa b/static_core/tests/cts-assembly/math-fsub-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..491953c527a9d6fbdd4a990c8a21be0f8ae1a5ea --- /dev/null +++ b/static_core/tests/cts-assembly/math-fsub-01.pa @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# assert(8.3 - 3.4 == 4.9) operation --> fsub2 +# The difference between this file and math-23.pa is in the absence of abs function +# This file should be considered temporal until we will have call support in +# LLVM AOT +.function u1 main(){ + fldai.64 8.3 + fmovi.64 v0, 3.4 + fsub2.64 v0 + fmovi.64 v0, 4.9 + fcmpl.64 v0 + jnez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-udiv.pa b/static_core/tests/cts-assembly/math-udiv.pa new file mode 100644 index 0000000000000000000000000000000000000000..5ce7a38d5a7234de02b39b078f09c658499bebe2 --- /dev/null +++ b/static_core/tests/cts-assembly/math-udiv.pa @@ -0,0 +1,30 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Assert that operation divu works fine + +.function u1 main(){ + movi v0, 4294967294 + movi v1, 4294967292 + lda v0 + divu2 v1 + sta v2 + movi v3, 1 + lda v2 + jne v3, exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/math-urem.pa b/static_core/tests/cts-assembly/math-urem.pa new file mode 100644 index 0000000000000000000000000000000000000000..e18573b8122e4ac1f481b0ff2ee35a43c7537bd1 --- /dev/null +++ b/static_core/tests/cts-assembly/math-urem.pa @@ -0,0 +1,33 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Assert that operation divu works fine + +.record IO +.function void IO.printI32(i32 a0) + +.function u1 main(){ + movi v0, 4294967294 + movi v1, 4294967292 + lda v0 + modu2 v1 + sta v2 + movi v3, 2 + lda v2 + jne v3, exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/min-max-int.pa b/static_core/tests/cts-assembly/min-max-int.pa new file mode 100644 index 0000000000000000000000000000000000000000..0022115dbcbf7a08afd9d0e74f25a2f9fe55171e --- /dev/null +++ b/static_core/tests/cts-assembly/min-max-int.pa @@ -0,0 +1,54 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Math +.function i64 Math.minI64(i64 a0, i64 a1) +.function i32 Math.minI32(i32 a0, i32 a1) +.function i64 Math.maxI64(i64 a0, i64 a1) +.function i32 Math.maxI32(i32 a0, i32 a1) +.function i64 main() { + movi.64 v0, 0x1 + movi.64 v1, 0x2 + call.short Math.minI32, v0, v1 + jne v0, exit_failure + call.short Math.maxI32, v0, v1 + jne v1, exit_failure + + movi.64 v0, -3 + movi.64 v1, -2 + call.short Math.minI32, v0, v1 + jne v0, exit_failure + call.short Math.maxI32, v0, v1 + jne v1, exit_failure + + movi.64 v0, 2147483648 + movi.64 v1, 2147483649 + call.short Math.minI64, v0, v1 + jne v0, exit_failure + call.short Math.maxI64, v0, v1 + jne v1, exit_failure + + movi.64 v0, -2147483650 + movi.64 v1, -2147483649 + call.short Math.minI64, v0, v1 + jne v0, exit_failure + call.short Math.maxI64, v0, v1 + jne v1, exit_failure + + ldai 0 + return + +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/no-inline-0.pa b/static_core/tests/cts-assembly/no-inline-0.pa new file mode 100644 index 0000000000000000000000000000000000000000..bd7614a07e4add9ee2523ecfc3e4baa66713f8c6 --- /dev/null +++ b/static_core/tests/cts-assembly/no-inline-0.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i32 main() { + movi v0, 42 + call.short test__noinline__, v0 + sub2 v0 + + return +} + +.function i32 test__noinline__(i32 a0) { + lda a0 + return +} diff --git a/static_core/tests/cts-assembly/no-inline-1.pa b/static_core/tests/cts-assembly/no-inline-1.pa new file mode 100644 index 0000000000000000000000000000000000000000..640f5868cc447d92ead2acc6ab079ea65a0f338b --- /dev/null +++ b/static_core/tests/cts-assembly/no-inline-1.pa @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function i32 main() { + movi v0, 42 + call.short test, v0 + sub2 v0 + + return +} + +.function i32 test(i32 a0) { + lda a0 + return +} diff --git a/static_core/tests/cts-assembly/no-inline-2.pa b/static_core/tests/cts-assembly/no-inline-2.pa new file mode 120000 index 0000000000000000000000000000000000000000..12053482ad78a00407663fa33d0f8b8af7ba3a51 --- /dev/null +++ b/static_core/tests/cts-assembly/no-inline-2.pa @@ -0,0 +1 @@ +no-inline-1.pa \ No newline at end of file diff --git a/static_core/tests/cts-assembly/no-inline-3.pa b/static_core/tests/cts-assembly/no-inline-3.pa new file mode 120000 index 0000000000000000000000000000000000000000..12053482ad78a00407663fa33d0f8b8af7ba3a51 --- /dev/null +++ b/static_core/tests/cts-assembly/no-inline-3.pa @@ -0,0 +1 @@ +no-inline-1.pa \ No newline at end of file diff --git a/static_core/tests/cts-assembly/obj-arr.pa b/static_core/tests/cts-assembly/obj-arr.pa new file mode 100644 index 0000000000000000000000000000000000000000..c0a83be509748683caf196c92fb13867e9cdfb4b --- /dev/null +++ b/static_core/tests/cts-assembly/obj-arr.pa @@ -0,0 +1,158 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record IO +.function void IO.printI32(i32 a0) +.record Body{ + i32 x + } + +.function Body Crt (i32 a0) { + newobj v0, Body + lda a0 + stobj v0, Body.x + lda.obj v0 + return.obj +} + +.function void Sum(Body[] a0){ + lenarr a0 + sta v3 #size + #inci v3, 2 + movi v4, 0 #loop_counter +loop: + lda v4 + jeq v3, loop_exit + ldarr.obj a0 + sta.obj v5 + ldobj v5, Body.x + sta v0 + call.short IO.printI32, v0, v0 + inci v4, 1 + jmp loop +loop_exit: + return.void +} + +.function void parr(i32[] a0){ + lenarr a0 + sta v3 #size + #movi v3, 32 + movi v4, 0 #loop_counter +loop: + movi v0, 0 + call.short IO.printI32, v0, v0 + movi v0, 77 + call.short IO.printI32, v0, v0 + movi v0, 0 + call.short IO.printI32, v0, v0 + lda v4 + jeq v3, loop_exit + ldarr a0 + sta v0 + call.short IO.printI32, v0, v0 + inci v4, 1 + jmp loop +loop_exit: + return.void +} + +.function void parr1(i32[] a0){ + lenarr a0 + sta v3 #size + #movi v3, 32 + #inci v3, 2 + movi v4, 0 #loop_counter +loop: + movi v0, 0 + call.short IO.printI32, v0, v0 + movi v0, 88 + call.short IO.printI32, v0, v0 + movi v0, 0 + call.short IO.printI32, v0, v0 + lda v4 + jeq v3, loop_exit + ldarr a0 + sta v0 + call.short IO.printI32, v0, v0 + inci v4, 1 + jmp loop +loop_exit: + return.void +} + + + +.function u1 main(){ + movi v0, 1 + newarr v6, v0, i32[] + call.short IO.printI32, v0, v0 + ldai 4444 + movi v2, 0 + starr v6, v2 + movi v2, 4 + newarr v4, v2, Body[] + call.short IO.printI32, v2, v2 + movi v2, 3 + newarr v5, v2, i32[] + ldai 3333 + movi v2, 0 + starr v5, v2 + ldai 2222 + movi v2, 1 + starr v5, v2 + ldai 1111 + movi v2, 2 + starr v5, v2 + # + movi v3, 2 + movi v7, 152 + call.short Crt, v7, v7 + starr.obj v4, v3 + movi v3, 0 + movi v7, 150 + call.short Crt, v7, v7 + starr.obj v4, v3 + movi v3, 1 + movi v7, 151 + call.short Crt, v7, v7 + starr.obj v4, v3 + movi v3, 3 + movi v7, 153 + call.short Crt, v7, v7 + starr.obj v4, v3 + call.short Sum, v4, v4 + call.short IO.printI32, v2, v2 + movi v2, 0 + call.short IO.printI32, v2, v2 + movi v2, 66 + call.short IO.printI32, v2, v2 + movi v2, 0 + call.short IO.printI32, v2, v2 + lenarr v5 + sta v2 #size + call.short IO.printI32, v2, v2 + call.short parr, v6 + + movi v2, 3 + lenarr v5 + jne v2, fail + call.short parr1, v5, v5 + ldai 0 + return +fail: + movi v2, -1 + call.short IO.printI32, v2, v2 + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/obj-checkcast-normal-bug.pa b/static_core/tests/cts-assembly/obj-checkcast-normal-bug.pa new file mode 100644 index 0000000000000000000000000000000000000000..00a009e244e22ebc02e6723cbbc4304706aed1de --- /dev/null +++ b/static_core/tests/cts-assembly/obj-checkcast-normal-bug.pa @@ -0,0 +1,47 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.String +.record panda.ClassCastException +.record IO + +.function panda.String panda.ClassCastException.getMessage(panda.ClassCastException a0) +.function void IO.printString(panda.String a0) + +.record R1 {} +.record R2 {} + +# check ClassCastException + +.function i32 main() { + newobj v0, R1 + lda.obj v0 + +try_begin: + checkcast R2 +try_end: + ldai 10 + jmp end_label + +catch_block_begin: + sta.obj v0 + call.virt panda.ClassCastException.getMessage, v0 + sta.obj v0 + call IO.printString, v0 + ldai 0 + +end_label: + return + +.catch panda.ClassCastException, try_begin, try_end, catch_block_begin +} diff --git a/static_core/tests/cts-assembly/obj-null-01.pa b/static_core/tests/cts-assembly/obj-null-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..4b1fd91e96f87b3ab78691d49dc3c93055d5a885 --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-01.pa @@ -0,0 +1,46 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException + +.record R { + i32 f1 +} + +.function void store_42(R a0) { + ldai 42 + stobj a0, R.f1 + return.void +} + +.function u1 main() { + mov.null v0 + ldai 0 + +try_begin: + call store_42, v0 + ldai 2 + return +try_end: + +catch_block1_begin: + ldai 0 + return + +catch_block2_begin: + ldai 1 + return + +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +.catchall try_begin, try_end, catch_block2_begin +} diff --git a/static_core/tests/cts-assembly/obj-null-02.pa b/static_core/tests/cts-assembly/obj-null-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..5ed7c139f3bad915f64dc412562f059025a88b96 --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-02.pa @@ -0,0 +1,48 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.String +.record panda.NullPointerException + +.function panda.String panda.NullPointerException.getMessage(panda.NullPointerException a0) + +.record R { + i32 f1 +} + +# check correct frame restoration after NullPointerException. v1 should be restored properly. + +.function u1 main() { + mov.null v0 + newobj v1, R + ldai 42 + stobj v1, R.f1 + +try_begin: + ldobj v0, R.f1 + return +try_end: + +catch_block1_begin: + ldobj v1, R.f1 + movi v2, 42 + sub2 v2 + return + +catch_block2_begin: + ldai 1 + return + +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +.catchall try_begin, try_end, catch_block2_begin +} diff --git a/static_core/tests/cts-assembly/obj-null-03.pa b/static_core/tests/cts-assembly/obj-null-03.pa new file mode 100644 index 0000000000000000000000000000000000000000..9445769cdfe872f2a7c7caa9e2fa2bed0c6d1d34 --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-03.pa @@ -0,0 +1,53 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.String +.record panda.NullPointerException + +.function panda.String panda.NullPointerException.getMessage(panda.NullPointerException a0) + +.record R { + i32 f1 +} + +# check correct frame restoration after NullPointerException. v1 should be restored properly. + +.function i32 throw_npe__noinline__(R a0) { + ldobj a0, R.f1 + return +} + +.function u1 main() { + mov.null v0 + newobj v1, R + ldai 42 + stobj v1, R.f1 + +try_begin: + call throw_npe__noinline__, v0 + return +try_end: + +catch_block1_begin: + ldobj v1, R.f1 + movi v2, 42 + sub2 v2 + return + +catch_block2_begin: + ldai 1 + return + +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +.catchall try_begin, try_end, catch_block2_begin +} diff --git a/static_core/tests/cts-assembly/obj-null-04.pa b/static_core/tests/cts-assembly/obj-null-04.pa new file mode 100644 index 0000000000000000000000000000000000000000..13b51ec19a00e06ed0aaa2a642c61c1000018882 --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-04.pa @@ -0,0 +1,49 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException + +.record R { + i32 f1 +} + +.function i32 store_42(R a0) { + ldai 42 + stobj a0, R.f1 + return +} + +.function i32 will_be_deoptimized() { + mov.null v0 + +try_begin: + call store_42, v0 + ldai 1 + return +try_end: + +catch_block1_begin: + ldai 0 + return + +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +} + +.function u1 main() { + call will_be_deoptimized + jnez fail + return +fail: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/obj-null-05.pa b/static_core/tests/cts-assembly/obj-null-05.pa new file mode 100644 index 0000000000000000000000000000000000000000..e64c1728018cd3b7110ba4d019aae785049433ff --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-05.pa @@ -0,0 +1,49 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException + +.record R { + i32 f1 +} + +.function i32 store_42(R a0) { + ldai 42 + stobj a0, R.f1 + return +} + +.function i32 will_be_deoptimized() { + mov.null v0 + +try_begin: + call store_42, v0 +try_end: + ldai 1 + return + +catch_block1_begin: + ldai 0 + return + +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +} + +.function u1 main() { + call will_be_deoptimized + jnez fail + return +fail: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/obj-null-06.pa b/static_core/tests/cts-assembly/obj-null-06.pa new file mode 100644 index 0000000000000000000000000000000000000000..1b1e0360b0ee46a84414b36b7b943b83e57e03bd --- /dev/null +++ b/static_core/tests/cts-assembly/obj-null-06.pa @@ -0,0 +1,50 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException +.record R { + i32 f1 +} +.function i32 store_42(R a0) { + ldai 42 + stobj a0, R.f1 + return +} +.function i32 will_be_deoptimized(R a0) { +try_begin: + call store_42, a0 +try_end: + newobj v1, R + jeqz skip + call store_42, v1 +skip: + call store_42, v1 + ldai 1 + return + +catch_block1_begin: + ldai 0 + return +.catch panda.NullPointerException, try_begin, try_end, catch_block1_begin +} + +.function u1 main() { + mov.null v0 + call will_be_deoptimized, v0 + jnez fail + return +fail: + ldai 1 + return +} + diff --git a/static_core/tests/cts-assembly/phi-f64-01.pa b/static_core/tests/cts-assembly/phi-f64-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..b81b790036e68832552c11f56c4ed78d5471e07a --- /dev/null +++ b/static_core/tests/cts-assembly/phi-f64-01.pa @@ -0,0 +1,22 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.function f64 main() { + fmovi.64 v0, 2.0 + ldai -1 + jgez _exit + fmovi.64 v0, 1.0 +_exit: + lda.64 v0 + return.64 +} \ No newline at end of file diff --git a/static_core/tests/cts-assembly/shl31.pa b/static_core/tests/cts-assembly/shl31.pa new file mode 100644 index 0000000000000000000000000000000000000000..0641281bc425ccedb9c60f72ca3a65d015515888 --- /dev/null +++ b/static_core/tests/cts-assembly/shl31.pa @@ -0,0 +1,71 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ==================== +# METHODS +.function u1 main() { + movi v0, 0x1 + mov v4, v0 + movi v0, 0x1f + mov v5, v0 + mov v0, v4 + movi v1, 0xffffffffffffffff + shl v0, v1 + sta v0 + mov v1, v4 + movi v2, 0xffffffffffffffff + mov v3, v5 + and v3, v2 + sta v2 + shl v1, v2 + sta v1 + lda v0 + jeq v1, jump_label_0 + movi v0, 0x2 + lda v0 + return + jump_label_0: mov v0, v4 + movi v1, 0xf0 + shl v0, v1 + sta v0 + mov v1, v4 + movi v2, 0xf0 + mov v3, v5 + and v3, v2 + sta v2 + shl v1, v2 + sta v1 + lda v0 + jeq v1, jump_label_1 + movi v0, 0x2 + lda v0 + return + jump_label_1: mov v0, v4 + movi v1, 0x80 + shl v0, v1 + sta v0 + mov v1, v4 + movi v2, 0x80 + mov v3, v5 + and v3, v2 + sta v2 + shl v1, v2 + sta v1 + lda v0 + jne v1, jump_label_2 + movi v0, 0x0 + jmp jump_label_3 + jump_label_2: movi v0, 0x2 + jump_label_3: lda v0 + return +} diff --git a/static_core/tests/cts-assembly/sinf64.pa b/static_core/tests/cts-assembly/sinf64.pa new file mode 100644 index 0000000000000000000000000000000000000000..4d1eab91df844119adefa0dbfeb1bc7f8636a7dd --- /dev/null +++ b/static_core/tests/cts-assembly/sinf64.pa @@ -0,0 +1,33 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Math +.function f64 Math.sin(f64 a0) +.function f64 Math.absF64(f64 a0) + +.function u1 main(){ + fmovi.64 v0, -0.20944 + fmovi.64 v1, -0.2079120 + fmovi.64 v2, 1e-6 + call.short Math.sin, v0, v0 + fsub2.64 v1 + sta.64 v1 + call.short Math.absF64, v1, v1 + fcmpl.64 v2 + jgez exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/small-fields-01.pa b/static_core/tests/cts-assembly/small-fields-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..2f728970f92b35097413451f74e03cafa92613a1 --- /dev/null +++ b/static_core/tests/cts-assembly/small-fields-01.pa @@ -0,0 +1,53 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record R { + u1 field1 + u1 field2 + u1 field3 +} + +.function void R.ctor(R a0, u1 a1, u1 a2) { + lda a1 + stobj a0, R.field1 + lda a2 + stobj a0, R.field2 + lda a1 + stobj a0, R.field3 + return.void +} + +.function u1 main() { + movi v0, 1 + movi v1, 0 + initobj R.ctor, v0, v1 + sta.obj v8 + + ldobj v8, R.field1 + jne v0, error1 + ldobj v8, R.field2 + jne v1, error2 + ldobj v8, R.field3 + jne v0, error3 + ldai 0 + return +error1: + ldai 1 + return +error2: + ldai 2 + return +error3: + ldai 3 + return +} diff --git a/static_core/tests/cts-assembly/small-fields-02.pa b/static_core/tests/cts-assembly/small-fields-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..92c1621c14ede1f1f2f35b23944f66269002771d --- /dev/null +++ b/static_core/tests/cts-assembly/small-fields-02.pa @@ -0,0 +1,41 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record R { + u16 field +} + +.function void R.ctor(R a0) { + ldai 65535 + stobj a0, R.field + return.void +} + +.function i32 main(){ + initobj R.ctor + sta.obj v0 + + movi v1, 1 + ldobj v0, R.field + add2 v1 + sta v2 + ldai 65536 + jne v2, exit_error + + ldai 0 + return + +exit_error: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/small-static-fields-01.pa b/static_core/tests/cts-assembly/small-static-fields-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..c00c35bae6c93c0489f22b2da1d9ea878c5b3aee --- /dev/null +++ b/static_core/tests/cts-assembly/small-static-fields-01.pa @@ -0,0 +1,38 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Globals{ + i8 flag0 + i8 flag1 + i8 flag2 +} + +.function i32 main(){ + ldai 1 + ststatic Globals.flag1 + + ldstatic Globals.flag0 + jnez exit_error + + ldstatic Globals.flag2 + jnez exit_error + + ldai 0 + return + +exit_error: + ldai 1 + + return +} + diff --git a/static_core/tests/cts-assembly/small-static-fields-02.pa b/static_core/tests/cts-assembly/small-static-fields-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..0168f09aef92fe31a1c8246a7e7cd84246789f61 --- /dev/null +++ b/static_core/tests/cts-assembly/small-static-fields-02.pa @@ -0,0 +1,35 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record R { + u16 field +} + +.function i32 main(){ + ldai 65535 + ststatic R.field + + movi v0, 1 + ldstatic R.field + add2 v0 + sta v2 + ldai 65536 + jne v2, exit_error + + ldai 0 + return + +exit_error: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/test-max.pa b/static_core/tests/cts-assembly/test-max.pa new file mode 100644 index 0000000000000000000000000000000000000000..6bec439f3c4018df8fcbf747fd03cfe2f214c849 --- /dev/null +++ b/static_core/tests/cts-assembly/test-max.pa @@ -0,0 +1,88 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Math +.function f32 Math.maxF32(f32 a0, f32 a1) + +.function i32 main() { + + fmovi v5, 0x7fffffff + fmovi v6, 0x7fffffff + call.short Math.maxF32, v6, v5 + sta v7 + fcmpl v5 + movi v8, -1 + jne v8, exit_failure + lda v7 + fcmpg v5 + movi v8, 1 + jne v8, exit_failure + + fmovi v5, 0x7fffffff + fmovi v6, 0x00000000 + call.short Math.maxF32, v6, v5 + sta v7 + fcmpl v5 + movi v8, -1 + jne v8, exit_failure + lda v7 + fcmpg v5 + movi v8, 1 + jne v8, exit_failure + + fmovi v5, 0x00000000 + fmovi v6, 0x00000000 + fmovi v7, 0.00001 + fmovi v8, -0.00001 + call.short Math.maxF32, v6, v5 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + fmovi v5, -15.7 + fmovi v6, -25.45 + fmovi v7, -15.6999 + fmovi v8, -15.7001 + + call.short Math.maxF32, v5, v6 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + fmovi v5, 1.14 + fmovi v6, 2.57 + fmovi v7, 2.57001 + fmovi v8, 2.56999 + call.short Math.maxF32, v6, v5 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + ldai 0 + return +exit_failure: + ldai 1 + return +} + + + diff --git a/static_core/tests/cts-assembly/test-min.pa b/static_core/tests/cts-assembly/test-min.pa new file mode 100644 index 0000000000000000000000000000000000000000..07309d89eac836f75079b21afe95cf0a25248e4f --- /dev/null +++ b/static_core/tests/cts-assembly/test-min.pa @@ -0,0 +1,88 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record Math +.function f32 Math.minF32(f32 a0, f32 a1) + +.function i32 main() { + + fmovi v5, 0x7fffffff + fmovi v6, 0x7fffffff + call.short Math.minF32, v6, v5 + sta v7 + fcmpl v5 + movi v8, -1 + jne v8, exit_failure + lda v7 + fcmpg v5 + movi v8, 1 + jne v8, exit_failure + + fmovi v5, 0x7fffffff + fmovi v6, 0x00000000 + call.short Math.minF32, v6, v5 + sta v7 + fcmpl v5 + movi v8, -1 + jne v8, exit_failure + lda v7 + fcmpg v5 + movi v8, 1 + jne v8, exit_failure + + fmovi v5, 0x00000000 + fmovi v6, 0x00000000 + fmovi v7, 0.00001 + fmovi v8, -0.00001 + call.short Math.minF32, v6, v5 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + fmovi v5, -15.7 + fmovi v6, 5.45 + fmovi v7, -15.6999 + fmovi v8, -15.7001 + + call.short Math.minF32, v5, v6 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + fmovi v5, 3.14 + fmovi v6, 2.57 + fmovi v7, 2.57001 + fmovi v8, 2.56999 + call.short Math.minF32, v6, v5 + sta v9 + fcmpg v7 + jgtz exit_failure + lda v9 + fcmpg v8 + jltz exit_failure + + ldai 0 + return +exit_failure: + ldai 1 + return +} + + + diff --git a/static_core/tests/cts-assembly/type-coercion-01.pa b/static_core/tests/cts-assembly/type-coercion-01.pa new file mode 100644 index 0000000000000000000000000000000000000000..1fec628693ccf3734860366e3d4aa242dd2d0136 --- /dev/null +++ b/static_core/tests/cts-assembly/type-coercion-01.pa @@ -0,0 +1,33 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Call foo, multiply it by 2 and expect the result to be equal to 26 +.function u1 foo() { + ldai 13 + return +} + +.function i32 main() { + call.short foo + sta v0 + add2 v0 + movi v1, 26 + jeq v1, exit_ok + + ldai 1 + return + +exit_ok: + ldai 0 + return +} \ No newline at end of file diff --git a/static_core/tests/cts-assembly/type-coercion-02.pa b/static_core/tests/cts-assembly/type-coercion-02.pa new file mode 100644 index 0000000000000000000000000000000000000000..1974c7b29dc10348db01229ec90b9e12b74c773a --- /dev/null +++ b/static_core/tests/cts-assembly/type-coercion-02.pa @@ -0,0 +1,51 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Assert that operations with array of u8 works fine +# Same as arrays-02.pa but against u8[] + +# for (i64 i = 0; i < 5; i++) { +# array[i] = i; +# } +# for (i64 i = 4; i >= 0; i--) { +# assert_eq(i, array[i]); +# } + +.function u1 main(){ + movi v0, 5 + newarr v1, v0, u8[] + movi v2, 0 + ldai 0 +loop: + jeq v0, loop_exit + starr.8 v1, v2 + inci v2, 1 + lda v2 + jmp loop +loop_exit: + subi 1 + sta v2 +loop2: + jltz loop2_exit + ldarru.8 v1 + jne v2, exit_failure + inci v2, -1 + lda v2 + jmp loop2 +loop2_exit: + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/type-coercion-03.pa b/static_core/tests/cts-assembly/type-coercion-03.pa new file mode 100644 index 0000000000000000000000000000000000000000..5ad5f524ad23e582f0ac9ef3abb6a39af02445fb --- /dev/null +++ b/static_core/tests/cts-assembly/type-coercion-03.pa @@ -0,0 +1,43 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The test intends to check if we're widening array elements correctly in ldarr.* instructions. +# We have to do it to conform the specification: +# > If element size is smaller then 32 bits, it will be zero or sign extended (depending on bytecode) to i32 + +# short[] array = new short[1]; +# array[0] = 1000; +# int result = 8; +# result = array[0] + result +# assert(result == 1008) + +.function u1 main() { + movi v0, 1 # sizeof(array) + newarr v1, v0, i16[] + movi v2, 0 + ldai 1000 + starr.16 v1, v2 # array[0] = 1000 + + movi v2, 8 + ldai 0 + ldarr.16 v1 + add2 v2 + sta v3 + ldai 1008 + jne v3, exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/type-coercion-04.pa b/static_core/tests/cts-assembly/type-coercion-04.pa new file mode 100644 index 0000000000000000000000000000000000000000..6f1dedad2577f8a128461fc098bdbb05978e6984 --- /dev/null +++ b/static_core/tests/cts-assembly/type-coercion-04.pa @@ -0,0 +1,64 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# u8 array = new u8[5]; +# for (i64 i = 0; i < 5; i++) { +# array[i] = (implicit truncation to u8) 257; +# } +# for (i64 i = 4; i >= 0; i--) { +# assert(1 == array[i]); +# } + +.record IO +.function void IO.printI32(i32 a0) + +.function u1 main() { + movi v0, 5 # sizeof(array) + newarr v1, v0, u8[] + movi v2, 0 + movi v3, 257 + lda v2 +loop: + jeq v0, loop_exit + + lda v3 + starr.8 v1, v2 + inci v2, 1 + lda v2 + jmp loop +loop_exit: + subi 1 + sta v2 + movi v3, 1 + +loop2: + lda v2 + jltz loop2_exit + ldarru.8 v1 + + sta v4 + + call.short IO.printI32, v4 + + lda v4 + + jne v3, exit_failure + inci v2, -1 + jmp loop2 +loop2_exit: + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-assembly/type-coercion-05.pa b/static_core/tests/cts-assembly/type-coercion-05.pa new file mode 100644 index 0000000000000000000000000000000000000000..46991de0dc12d4869a0b8d85ab21cfaf4580b840 --- /dev/null +++ b/static_core/tests/cts-assembly/type-coercion-05.pa @@ -0,0 +1,43 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The test intends to check if we're widening array elements correctly in ldarr.* instructions. +# We have to do it to conform the specification: +# > If element size is smaller then 32 bits, it will be zero or sign extended (depending on bytecode) to i32 + +# u16[] array = new u16[1]; +# array[0] = 65535; +# int result = 1; +# result = array[0] + result +# assert(result == 65536) + +.function u1 main() { + movi v0, 1 # sizeof(array) + newarr v1, v0, u16[] + movi v2, 0 + ldai 65535 + starr.16 v1, v2 # array[0] = 65535 + + movi v2, 1 + ldai 0 + ldarru.16 v1 + add2 v2 + sta v3 + ldai 65536 + jne v3, exit_failure + ldai 0 + return +exit_failure: + ldai 1 + return +} diff --git a/static_core/tests/cts-generator/CMakeLists.txt b/static_core/tests/cts-generator/CMakeLists.txt index 92b74363cff3b4aa321e90fe3493f976036c570e..755b8cc9ee70a90fc34798310163c485a71cc3e7 100644 --- a/static_core/tests/cts-generator/CMakeLists.txt +++ b/static_core/tests/cts-generator/CMakeLists.txt @@ -85,12 +85,12 @@ if(NOT CMAKE_CROSSCOMPILING) if (NOT DEFINED CTS_TEST_SELECT_OPTION) if (CMAKE_BUILD_TYPE STREQUAL "Release") if (PANDA_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER OR PANDA_ENABLE_ADDRESS_SANITIZER OR PANDA_ENABLE_THREAD_SANITIZER) - set(CTS_TEST_SELECT_OPTION "--exclude-tag sanitizer-fail") + set(CTS_TEST_SELECT_OPTION "--exclude-tag sanitizer-fail --exclude-tag verifier") else() - set(CTS_TEST_SELECT_OPTION "--exclude-tag release") + set(CTS_TEST_SELECT_OPTION "--exclude-tag release --exclude-tag verifier") endif() else() - set(CTS_TEST_SELECT_OPTION " ") + set(CTS_TEST_SELECT_OPTION "--exclude-tag verifier") endif() endif() @@ -98,12 +98,12 @@ if(NOT CMAKE_CROSSCOMPILING) if (NOT DEFINED CTS_TEST_SELECT_OPTION_JIT) if (CMAKE_BUILD_TYPE STREQUAL "Release") if (PANDA_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER OR PANDA_ENABLE_ADDRESS_SANITIZER OR PANDA_ENABLE_THREAD_SANITIZER) - set(CTS_TEST_SELECT_OPTION_JIT "--exclude-tag sanitizer-fail") + set(CTS_TEST_SELECT_OPTION_JIT "--exclude-tag sanitizer-fail --exclude-tag verifier") else() - set(CTS_TEST_SELECT_OPTION_JIT "--exclude-tag release") + set(CTS_TEST_SELECT_OPTION_JIT "--exclude-tag release --exclude-tag verifier") endif() else() - set(CTS_TEST_SELECT_OPTION_JIT " ") + set(CTS_TEST_SELECT_OPTION_JIT "--exclude-tag verifier") endif() endif() @@ -157,19 +157,7 @@ if(NOT CMAKE_CROSSCOMPILING) -p "${PROJECT_BINARY_DIR}/../../" -x "${CTS_TEMP_DIR}" -v 1 - ${QUICKENER_ARGLAUNCH} - --global-timeout ${PANDA_CTS_TESTING_TIMEOUT} - --timeout ${PANDA_CTS_TEST_TIMEOUT} - -j ${PANDA_CTS_JOBS_NUMBER} - --verifier-config "${PROJECT_BINARY_DIR}/verifier.config" - ${CTS_TEST_PRLIMIT_OPTIONS} - ${CTS_TEST_SELECT_OPTION_ARGS} VERBATIM - COMMAND ${CTS_TEST_RUNNER} - -t "${CTS_GENERATED_DIR}" - -p "${PROJECT_BINARY_DIR}/../../" - -x "${CTS_TEMP_DIR}" - -v 1 - -o "--interpreter-type=cpp" + -o "--compiler-enable-jit=false" ${QUICKENER_ARGLAUNCH} --global-timeout ${PANDA_CTS_TESTING_TIMEOUT} --timeout ${PANDA_CTS_TEST_TIMEOUT} @@ -178,21 +166,6 @@ if(NOT CMAKE_CROSSCOMPILING) ${CTS_TEST_PRLIMIT_OPTIONS} --exclude-tag verifier ${CTS_TEST_SELECT_OPTION_ARGS} VERBATIM - COMMAND ${CTS_TEST_RUNNER} - -t "${CTS_GENERATED_DIR}" - -p "${PROJECT_BINARY_DIR}/../../" - -x "${CTS_TEMP_DIR}" - -v 1 - ${QUICKENER_ARGLAUNCH} - --global-timeout ${PANDA_CTS_TESTING_TIMEOUT} - --timeout ${PANDA_CTS_TEST_TIMEOUT} - -j ${PANDA_CTS_JOBS_NUMBER} - --verifier-config "${PROJECT_BINARY_DIR}/verifier.config" - -o "--compiler-hotness-threshold=0" - -o "--no-async-jit" - ${CTS_TEST_PRLIMIT_OPTIONS} - --exclude-tag verifier - ${CTS_TEST_SELECT_OPTION_JIT_ARGS} VERBATIM DEPENDS "$" "$" "${TARGETFILE_ARKQUICK}" "$" "${OUTPUT_FILES}" ) diff --git a/static_core/tests/irtoc-interpreter-tests/array-npe-1.pa b/static_core/tests/irtoc-interpreter-tests/array-npe-1.pa new file mode 100644 index 0000000000000000000000000000000000000000..2ca737dbcf66c2a06c0096971735eb82a0fe5c6e --- /dev/null +++ b/static_core/tests/irtoc-interpreter-tests/array-npe-1.pa @@ -0,0 +1,34 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException + +.function i32 main() { + mov.null v0 + movi v1, 0x1 + + try_begin: + ldai 2 + starr v0, v1 + jmp try_end + + catch_block_begin: + ldai 0 + return + + try_end: + ldai 1 + return + + .catch panda.NullPointerException, try_begin, try_end, catch_block_begin +} \ No newline at end of file diff --git a/static_core/tests/irtoc-interpreter-tests/array-npe-2.pa b/static_core/tests/irtoc-interpreter-tests/array-npe-2.pa new file mode 100644 index 0000000000000000000000000000000000000000..826aae24974c4a31c45b50335f91e96a67e5e888 --- /dev/null +++ b/static_core/tests/irtoc-interpreter-tests/array-npe-2.pa @@ -0,0 +1,39 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.NullPointerException + +.function void foo(i32[] a0, i32 a1) { + ldai 2 + starr a0, a1 + return.void +} + +.function i32 main() { + mov.null v0 + movi v1, 0x1 + + try_begin: + call foo, v0, v1 + jmp try_end + + catch_block_begin: + ldai 0 + return + + try_end: + ldai 1 + return + + .catch panda.NullPointerException, try_begin, try_end, catch_block_begin +} \ No newline at end of file diff --git a/static_core/tests/irtoc-interpreter-tests/array-oob-1.pa b/static_core/tests/irtoc-interpreter-tests/array-oob-1.pa new file mode 100644 index 0000000000000000000000000000000000000000..060289ade9b5a49bf1941b50dcdd1a034d3dd49e --- /dev/null +++ b/static_core/tests/irtoc-interpreter-tests/array-oob-1.pa @@ -0,0 +1,35 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.ArrayIndexOutOfBoundsException + +.function i32 main() { + movi v0, 0x5 + newarr v1, v0, i32[] + movi v2, 0x10 + + try_begin: + ldai 2 + starr v1, v2 + jmp try_end + + catch_block_begin: + ldai 0 + return + + try_end: + ldai 1 + return + + .catch panda.ArrayIndexOutOfBoundsException, try_begin, try_end, catch_block_begin +} \ No newline at end of file diff --git a/static_core/tests/irtoc-interpreter-tests/array-oob-2.pa b/static_core/tests/irtoc-interpreter-tests/array-oob-2.pa new file mode 100644 index 0000000000000000000000000000000000000000..1bf9c0112fa23a98292cac264eb951646ce71b6f --- /dev/null +++ b/static_core/tests/irtoc-interpreter-tests/array-oob-2.pa @@ -0,0 +1,40 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +.record panda.ArrayIndexOutOfBoundsException + +.function void foo(i32[] a0, i32 a1) { + ldai 2 + starr a0, a1 + return.void +} + +.function i32 main() { + movi v0, 0x5 + newarr v1, v0, i32[] + movi v2, 0x10 + + try_begin: + call foo, v1, v2 + jmp try_end + + catch_block_begin: + ldai 0 + return + + try_end: + ldai 1 + return + + .catch panda.ArrayIndexOutOfBoundsException, try_begin, try_end, catch_block_begin +} \ No newline at end of file diff --git a/static_core/tests/panda/CMakeLists.txt b/static_core/tests/panda/CMakeLists.txt index fbb6538c53e8f13f868f2fe0ec4015414c41e783..eb6563f18e7ff96e6674408f99bd2af37d7886cd 100644 --- a/static_core/tests/panda/CMakeLists.txt +++ b/static_core/tests/panda/CMakeLists.txt @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(false) if (NOT PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS) set(TEST_SOURCE_SUBDIR "sources") @@ -70,3 +71,4 @@ panda_add_gtest( add_dependencies(panda_cli_run_tests ark panda_cli_test_suites) endif() +endif() # if(false) diff --git a/static_core/tests/regression/fmodf.pa b/static_core/tests/regression/fmodf.pa new file mode 100644 index 0000000000000000000000000000000000000000..81508fbf3c2948e42204d7843325929e1d07e6a2 --- /dev/null +++ b/static_core/tests/regression/fmodf.pa @@ -0,0 +1,54 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# fmodf(a0, a1) == a2 +.function i32 fmod(f32 a0, f32 a1, f32 a2) { + lda a0 + fmod2 a1 + fcmpl a2 + return +} + +.function i32 main() { + fmovi v0, 5.3 + fmovi v1, 2.0 + fmovi v2, 1.3000002 + call fmod, v0, v1, v2 + jnez end + + fmovi v0, -18.5 + fmovi v1, 4.2 + fmovi v2, -1.7000008 + call fmod, v0, v1, v2 + jnez end + + fmovi v0, 2.1 + fmovi v1, 4.2 + fmovi v2, 2.0999999 + call fmod, v0, v1, v2 + jnez end + + fmovi v0, 18.5 + fmovi v1, 4.2 + fmovi v2, 1.7000008 + call fmod, v0, v1, v2 + jnez end + + fmovi v0, 4.0 + fmovi v1, 4.0 + fmovi v2, 0.0 + call fmod, v0, v1, v2 + +end: + return +} diff --git a/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-AMD64-AOT.txt b/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-AMD64-AOT.txt index 4874bc64fad9ff59002c00d931edb20df0838fb6..138b0a14be762a08b0fdb7a094d65b3cc3e28da0 100644 --- a/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-AMD64-AOT.txt +++ b/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-AMD64-AOT.txt @@ -1,3 +1,6 @@ +# LLVM AOT removes unused allocation +17.experimental_features/02.array_creation_expressions/01.runtime_evaluation_of_array_creation_expressions/expr_5.sts + # 17881 Skip these, because the run fails if multiple files are connected. The connection is necessary, because of the export tests. 13.compilation_units_packages_and_modules/04.import_directives/05.type_import_binding/type_binding_class.sts 13.compilation_units_packages_and_modules/04.import_directives/05.type_import_binding/type_binding_class_alias.sts diff --git a/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-ARM64-AOT.txt b/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-ARM64-AOT.txt index be70e269a584080a945282c71b0db8f41c55e442..705a5b0bb592ec916da534d3b61e99bfcc929414 100644 --- a/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-ARM64-AOT.txt +++ b/static_core/tests/tests-u-runner/test-lists/ets-cts/ets-cts-ignored-ARM64-AOT.txt @@ -1,3 +1,6 @@ +# LLVM AOT removes unused allocation +17.experimental_features/02.array_creation_expressions/01.runtime_evaluation_of_array_creation_expressions/expr_5.sts + # 17881 Skip these, because the run fails if multiple files are connected. The connection is necessary, because of the export tests. 13.compilation_units_packages_and_modules/04.import_directives/05.type_import_binding/type_binding_class.sts 13.compilation_units_packages_and_modules/04.import_directives/05.type_import_binding/type_binding_class_alias.sts diff --git a/static_core/tests/vm-benchmarks/src/vmb/cli.py b/static_core/tests/vm-benchmarks/src/vmb/cli.py index 1aa21f7cbb9f75ea207589d4e6f246a8a06f4f9b..010470e7cf8a050c1db4c700ea82be739cf62d5a 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/cli.py +++ b/static_core/tests/vm-benchmarks/src/vmb/cli.py @@ -61,7 +61,11 @@ def add_measurement_opts(parser: argparse.ArgumentParser) -> None: help='If >= 0 invoke GC twice ' 'and wait ms before iteration') parser.add_argument("-aot-co", "--aot-compiler-options", default=[], - type=str, action="append", help="aot-compiler options") + type=str, action="append", + help="Sets ahead-of-time compiler options") + parser.add_argument("-aot-lib-co", "--aot-lib-compiler-options", default=[], + type=str, action="append", + help="Sets ahead-of-time compiler options for libraries") parser.add_argument("-c", "--concurrency-level", default=None, type=str, help="Concurrency level (DEPRECATED)") @@ -272,8 +276,16 @@ class Args(argparse.Namespace): mode = ToolMode(self.get('mode')) if ToolMode.AOT == mode: flags |= OptFlags.AOT + elif ToolMode.LLVMAOT == mode: + flags |= OptFlags.AOT | OptFlags.LLVMAOT elif ToolMode.INT == mode: flags |= OptFlags.INT + elif ToolMode.INT_CPP == mode: + flags |= OptFlags.INT | OptFlags.INT_CPP + elif ToolMode.INT_IRTOC == mode: + flags |= OptFlags.INT | OptFlags.INT_IRTOC + elif ToolMode.INT_LLVM == mode: + flags |= OptFlags.INT | OptFlags.INT_LLVM elif ToolMode.JIT == mode: flags |= OptFlags.JIT if self.get('dry_run', False): diff --git a/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_device.py b/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_device.py index 268f2d8a564426c917c11c1702ef3e631f080dd1..9e354d09d0cad8b27541fa7bd6241f4cd67da3c7 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_device.py +++ b/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_device.py @@ -41,9 +41,11 @@ class Platform(PlatformBase): log.info('Skipping aot compilation of libs') else: an = Path(self.ark.etsstdlib).with_suffix('.an') - log.info('AOT-Compiling %s. This may took a long time...', + aot_lib_opts = ' '.join(args.aot_lib_compiler_options) + log.info('AOT-Compiling %s. This may take a long time...', self.ark.etsstdlib) - res = self.paoc.run_paoc(self.ark.etsstdlib, an, timeout=1800) + res = self.paoc.run_paoc(self.ark.etsstdlib, an, + opts=aot_lib_opts, timeout=1800) if not self.ext_info.get('etsstdlib', {}): self.ext_info['etsstdlib'] = {} self.ext_info['etsstdlib']['etsstdlib.an'] = \ diff --git a/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_host.py b/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_host.py index e6e9e419e9e4ebe403a0afba6c910ba7963121aa..5b3120d5da657ec0969228428b67ffa6405cdbeb 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_host.py +++ b/static_core/tests/vm-benchmarks/src/vmb/plugins/platforms/arkts_host.py @@ -43,9 +43,11 @@ class Platform(PlatformBase): else: an = ToolBase.libs.joinpath( Path(self.ark.etsstdlib).with_suffix('.an').name) - log.info('AOT-Compiling %s. This may took a long time...', + aot_lib_opts = ' '.join(args.aot_lib_compiler_options) + log.info('AOT-Compiling %s. This may take a long time...', self.ark.etsstdlib) - res = self.paoc.run_paoc(self.ark.etsstdlib, an, timeout=1800) + res = self.paoc.run_paoc(self.ark.etsstdlib, an, + opts=aot_lib_opts, timeout=1800) if not self.ext_info.get('etsstdlib', {}): self.ext_info['etsstdlib'] = {} self.ext_info['etsstdlib']['etsstdlib.an'] = \ diff --git a/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/ark.py b/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/ark.py index 3f4084b056d6e305a80c379eac9892cc2a17dab8..536e0bbf6f9d60e3c0aa6b0571c5c8e4aac890a7 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/ark.py +++ b/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/ark.py @@ -50,6 +50,12 @@ class Tool(ToolBase): an_files.append(stdlib) if OptFlags.INT in self.flags: opts += '--compiler-enable-jit=false ' + if OptFlags.INT_CPP in self.flags: + opts += '--interpreter-type=cpp ' + if OptFlags.INT_IRTOC in self.flags: + opts += '--interpreter-type=irtoc ' + if OptFlags.INT_LLVM in self.flags: + opts += '--interpreter-type=llvm ' if OptFlags.GC_STATS in self.flags: opts += '--print-gc-statistics --log-components=gc ' \ '--log-level=info --log-stream=file ' \ diff --git a/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/paoc.py b/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/paoc.py index 43bc2b616caa82dd1b96a144816241b562673d45..b8b87ec72ff6223930d20280a910cb8fdee6b8b5 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/paoc.py +++ b/static_core/tests/vm-benchmarks/src/vmb/plugins/tools/paoc.py @@ -50,8 +50,12 @@ class Tool(ToolBase): aot_stats = '--compiler-dump-stats-csv={an}.dump.csv ' else: aot_stats = '' + if OptFlags.LLVMAOT in self.flags: + aot_mode = '--paoc-mode=llvm ' + else: + aot_mode = '--paoc-mode=aot ' self.cmd = f'LD_LIBRARY_PATH={self.ark_lib} {self.paoc} ' \ - f'--boot-panda-files={self.etsstdlib} ' \ + f'--boot-panda-files={self.etsstdlib} {aot_mode} ' \ '--load-runtimes=ets {opts} ' \ f'{self.custom} {aot_stats}' \ '--paoc-panda-files={abc} ' \ diff --git a/static_core/tests/vm-benchmarks/src/vmb/tool.py b/static_core/tests/vm-benchmarks/src/vmb/tool.py index dad6d25e8bcc8a7184750245796e6a29a77c7e39..e814add66fcdba421b729082cb96c0c603ac6f0b 100644 --- a/static_core/tests/vm-benchmarks/src/vmb/tool.py +++ b/static_core/tests/vm-benchmarks/src/vmb/tool.py @@ -47,6 +47,10 @@ class ToolMode(StringEnum): AOT = 'aot' INT = 'int' JIT = 'jit' + INT_CPP = 'int-cpp' + INT_IRTOC = 'int-irtoc' + INT_LLVM = 'int-llvm' + LLVMAOT = 'llvmaot' DEFAULT = 'default' @@ -58,10 +62,13 @@ class OptFlags(Flag): AOT_SKIP_LIBS = auto() DRY_RUN = auto() DISABLE_INLINING = auto() - # these 3 flags are mutually exclusive (this is guarantied by ToolMode) AOT = auto() INT = auto() JIT = auto() + INT_CPP = auto() + INT_IRTOC = auto() + INT_LLVM = auto() + LLVMAOT = auto() class ToolBase(CrossShell, ABC): diff --git a/static_core/verification/CMakeLists.txt b/static_core/verification/CMakeLists.txt index 888c027d8ae6f2b764217641e5508474bc561368..69c4cd332d3bf7d270087cce39fa8f2bb8f45464 100644 --- a/static_core/verification/CMakeLists.txt +++ b/static_core/verification/CMakeLists.txt @@ -62,6 +62,7 @@ panda_gen( TEMPLATES verifier_messages_data_gen.cpp.erb ) +if(false) if ((PANDA_TARGET_X86 OR PANDA_TARGET_AMD64) AND PANDA_WITH_TESTS) panda_add_gtest( NO_CORES @@ -101,3 +102,4 @@ if ((PANDA_TARGET_X86 OR PANDA_TARGET_AMD64) AND PANDA_WITH_TESTS) panda_add_sanitizers(TARGET pandaverification_rapidcheck_gtest_tests SANITIZERS ${PANDA_SANITIZERS_LIST}) endif() endif() +endif() # if(false)