From 76d519b039fcdebf58e05dd42df4dc6cc08251e5 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Mon, 3 Apr 2023 12:34:45 +0100 Subject: Inline unimplemented intrinsics There are intrinsics that are unimplemented i.e. we didn't hand-craft code for them. Allow the inliner to inline those. Since our optimizations expect InvokeVirtual, I stopped the de-virtualization of intrinsics. That could be re-added if we modify optimizations like TryReplaceStringBuilderAppend. Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: art/test/testrunner/testrunner.py --target --64 --optimizing Test: compiling the APK in the bug and seeing the inline Bug: 262585898 Fixes: 262585898 Change-Id: I501b69c4ffd9082ca8ffacb1cd1cd5d1ab3668a8 --- compiler/optimizing/inliner.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/inliner.cc') diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index c24ac84d37..41dc5eb206 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -182,7 +182,7 @@ bool HInliner::Run() { HInstruction* next = instruction->GetNext(); HInvoke* call = instruction->AsInvoke(); // As long as the call is not intrinsified, it is worth trying to inline. - if (call != nullptr && call->GetIntrinsic() == Intrinsics::kNone) { + if (call != nullptr && !codegen_->IsImplementedIntrinsic(call)) { if (honor_noinline_directives) { // Debugging case: directives in method names control or assert on inlining. std::string callee_name = @@ -1272,6 +1272,13 @@ bool HInliner::TryDevirtualize(HInvoke* invoke_instruction, return false; } + // Don't try to devirtualize intrinsics as it breaks pattern matching from later phases. + // TODO(solanes): This `if` could be removed if we update optimizations like + // TryReplaceStringBuilderAppend. + if (invoke_instruction->IsIntrinsic()) { + return false; + } + // Don't bother trying to call directly a default conflict method. It // doesn't have a proper MethodReference, but also `GetCanonicalMethod` // will return an actual default implementation. @@ -1344,7 +1351,7 @@ bool HInliner::TryInlineAndReplace(HInvoke* invoke_instruction, ReferenceTypeInfo receiver_type, bool do_rtp, bool is_speculative) { - DCHECK(!invoke_instruction->IsIntrinsic()); + DCHECK(!codegen_->IsImplementedIntrinsic(invoke_instruction)); HInstruction* return_replacement = nullptr; if (!TryBuildAndInline( -- cgit v1.2.3-59-g8ed1b