From d9c09c674655d32038dbfb360b1add866840a4ff Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Mon, 14 Jun 2021 18:56:53 -0700 Subject: [PATCH] add new function property flag kFuncPropHasAsm; make inline and mplme skip such functions --- src/mapleall/maple_ipa/src/inline.cpp | 1 + src/mapleall/maple_ir/include/mir_function.h | 3 +++ src/mapleall/maple_ir/src/bin_func_import.cpp | 1 + src/mapleall/maple_ir/src/mir_function.cpp | 9 +++++++++ src/mapleall/maple_ir/src/mir_parser.cpp | 1 + src/mapleall/maple_me/src/me_phase_manager.cpp | 4 ++++ 6 files changed, 19 insertions(+) diff --git a/src/mapleall/maple_ipa/src/inline.cpp b/src/mapleall/maple_ipa/src/inline.cpp index 575a994b07..fb9c4d9a54 100644 --- a/src/mapleall/maple_ipa/src/inline.cpp +++ b/src/mapleall/maple_ipa/src/inline.cpp @@ -1379,6 +1379,7 @@ void MInline::MarkUnInlinableFunction() const { for (CGNode *node : (*it)->GetCGNodes()) { std::string name = node->GetMIRFunction()->GetName(); if (node->IsMustNotBeInlined() || + node->GetMIRFunction()->HasAsm() || StringUtils::StartsWith(name, kDalvikSystemStr) || StringUtils::StartsWith(name, kJavaLangThreadStr)) { node->SetMustNotBeInlined(); diff --git a/src/mapleall/maple_ir/include/mir_function.h b/src/mapleall/maple_ir/include/mir_function.h index c95a705fb7..0ccc689803 100644 --- a/src/mapleall/maple_ir/include/mir_function.h +++ b/src/mapleall/maple_ir/include/mir_function.h @@ -390,6 +390,9 @@ class MIRFunction { void SetHasSetjmp(); bool HasSetjmp() const; + void SetHasAsm(); + bool HasAsm() const; + void SetReturnStruct(const MIRType *retType); bool IsEmpty() const; diff --git a/src/mapleall/maple_ir/src/bin_func_import.cpp b/src/mapleall/maple_ir/src/bin_func_import.cpp index 41c226782f..9373500603 100644 --- a/src/mapleall/maple_ir/src/bin_func_import.cpp +++ b/src/mapleall/maple_ir/src/bin_func_import.cpp @@ -775,6 +775,7 @@ BlockNode *BinaryMplImport::ImportBlockNode(MIRFunction *func) { } case OP_asm: { AsmNode *s = mod.CurFuncCodeMemPool()->New(&mod.GetCurFuncCodeMPAllocator()); + mod.CurFunction()->SetHasAsm(); s->qualifiers = ReadNum(); string str; ReadAsciiStr(str); diff --git a/src/mapleall/maple_ir/src/mir_function.cpp b/src/mapleall/maple_ir/src/mir_function.cpp index 83408f5fc8..1f12087a3d 100644 --- a/src/mapleall/maple_ir/src/mir_function.cpp +++ b/src/mapleall/maple_ir/src/mir_function.cpp @@ -31,6 +31,7 @@ enum FuncProp : uint32_t { // can only be printed at the beginning of a block kFuncPropNeverReturn = 1U << 4, // the function when called never returns kFuncPropHasSetjmp = 1U << 5, // the function contains call to setjmp + kFuncPropHasAsm = 1U << 6, // the function has use of inline asm }; } // namespace @@ -198,6 +199,14 @@ bool MIRFunction::HasSetjmp() const { return flag & kFuncPropHasSetjmp; } +void MIRFunction::SetHasAsm() { + flag |= kFuncPropHasAsm; +} + +bool MIRFunction::HasAsm() const { + return flag & kFuncPropHasAsm; +} + void MIRFunction::SetAttrsFromSe(uint8 specialEffect) { // NoPrivateDefEffect if ((specialEffect & kDefEffect) == kDefEffect) { diff --git a/src/mapleall/maple_ir/src/mir_parser.cpp b/src/mapleall/maple_ir/src/mir_parser.cpp index 2bc7f8d157..52ea8dd4ac 100644 --- a/src/mapleall/maple_ir/src/mir_parser.cpp +++ b/src/mapleall/maple_ir/src/mir_parser.cpp @@ -1083,6 +1083,7 @@ bool MIRParser::ParseCallReturns(CallReturnVector &retsvec) { bool MIRParser::ParseStmtAsm(StmtNodePtr &stmt) { AsmNode *asmNode = mod.CurFuncCodeMemPool()->New(&mod.GetCurFuncCodeMPAllocator()); + mod.CurFunction()->SetHasAsm(); lexer.NextToken(); // parse qualifiers while (lexer.GetTokenKind() == TK_volatile || diff --git a/src/mapleall/maple_me/src/me_phase_manager.cpp b/src/mapleall/maple_me/src/me_phase_manager.cpp index f1ea55af1c..b0fdc2ad42 100644 --- a/src/mapleall/maple_me/src/me_phase_manager.cpp +++ b/src/mapleall/maple_me/src/me_phase_manager.cpp @@ -210,6 +210,10 @@ void MeFuncPhaseManager::Run(MIRFunction *mirFunc, uint64 rangeNum, const std::s LogInfo::MapleLogger() << "Function < " << mirFunc->GetName() << " not optimized because it has setjmp\n"; return; } + if (mirFunc->HasAsm()) { + LogInfo::MapleLogger() << "Function < " << mirFunc->GetName() << " not optimized because it has inline asm\n"; + return; + } MPLTimer runPhasetimer; MPLTimer funcPrepareTimer; MPLTimer iteratorTimer; -- Gitee