summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pirama Arumuga Nainar <pirama@google.com> 2024-10-17 06:33:49 +0000
committer Yi Kong <yikong@google.com> 2024-10-17 09:40:47 +0000
commitd5a09b3adf930729ccb17c1e466c9c5eb053082a (patch)
tree20358f6e84710dc9fb27b021ccdd695543291543
parentbcf966c6c46aae2a3bf5455ea878789876de0a42 (diff)
Fix ambiguous FillVRegs template specializations
The two specializations with <char FirstArgType, char...ArgType> and <char ...ArgType> are ambiguous after https://github.com/llvm/llvm-project/pull/100692. For e.g., MaterializeVRegs<'L', 'L'> can match both specializations: ArgType = <'L', 'L'>, and FirstArgType = 'L', ArgType = <'L'> The first (now-deleted) specialization can match calls with any number of template parameters, including zero. The second specialization matches calls with one or more parameters. To avoid the ambiguity, delete the first specialization and explicitly avoid calls with zero template parameters. Bug: http://b/363682086 Test: mmma art with ToT clang; and presubmit Change-Id: I4a3737b4098180faa1f889c2bba475846acc8a51
-rw-r--r--runtime/art_method-inl.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 2b88b733f7..05d819577b 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -150,18 +150,14 @@ constexpr size_t NumberOfVRegs() {
return sum;
}
-template <char... ArgType>
-inline ALWAYS_INLINE void FillVRegs([[maybe_unused]] uint32_t* vregs,
- [[maybe_unused]] typename ShortyTraits<ArgType>::Type... args)
- REQUIRES_SHARED(Locks::mutator_lock_) {}
-
template <char FirstArgType, char... ArgType>
inline ALWAYS_INLINE void FillVRegs(uint32_t* vregs,
typename ShortyTraits<FirstArgType>::Type first_arg,
typename ShortyTraits<ArgType>::Type... args)
REQUIRES_SHARED(Locks::mutator_lock_) {
ShortyTraits<FirstArgType>::Set(vregs, first_arg);
- FillVRegs<ArgType...>(vregs + ShortyTraits<FirstArgType>::kVRegCount, args...);
+ if constexpr (sizeof...(args) > 0)
+ FillVRegs<ArgType...>(vregs + ShortyTraits<FirstArgType>::kVRegCount, args...);
}
template <char... ArgType>
@@ -169,7 +165,8 @@ inline ALWAYS_INLINE auto MaterializeVRegs(typename ShortyTraits<ArgType>::Type.
REQUIRES_SHARED(Locks::mutator_lock_) {
constexpr size_t kNumVRegs = NumberOfVRegs<ArgType...>();
std::array<uint32_t, kNumVRegs> vregs;
- FillVRegs<ArgType...>(vregs.data(), args...);
+ if constexpr (sizeof...(args) > 0)
+ FillVRegs<ArgType...>(vregs.data(), args...);
return vregs;
}