Skip to content

Commit d5a09b3

Browse files
pirama-arumuga-nainarkongy
authored andcommitted
Fix ambiguous FillVRegs template specializations
The two specializations with <char FirstArgType, char...ArgType> and <char ...ArgType> are ambiguous after llvm/llvm-project#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
1 parent bcf966c commit d5a09b3

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

runtime/art_method-inl.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,23 @@ constexpr size_t NumberOfVRegs() {
150150
return sum;
151151
}
152152

153-
template <char... ArgType>
154-
inline ALWAYS_INLINE void FillVRegs([[maybe_unused]] uint32_t* vregs,
155-
[[maybe_unused]] typename ShortyTraits<ArgType>::Type... args)
156-
REQUIRES_SHARED(Locks::mutator_lock_) {}
157-
158153
template <char FirstArgType, char... ArgType>
159154
inline ALWAYS_INLINE void FillVRegs(uint32_t* vregs,
160155
typename ShortyTraits<FirstArgType>::Type first_arg,
161156
typename ShortyTraits<ArgType>::Type... args)
162157
REQUIRES_SHARED(Locks::mutator_lock_) {
163158
ShortyTraits<FirstArgType>::Set(vregs, first_arg);
164-
FillVRegs<ArgType...>(vregs + ShortyTraits<FirstArgType>::kVRegCount, args...);
159+
if constexpr (sizeof...(args) > 0)
160+
FillVRegs<ArgType...>(vregs + ShortyTraits<FirstArgType>::kVRegCount, args...);
165161
}
166162

167163
template <char... ArgType>
168164
inline ALWAYS_INLINE auto MaterializeVRegs(typename ShortyTraits<ArgType>::Type... args)
169165
REQUIRES_SHARED(Locks::mutator_lock_) {
170166
constexpr size_t kNumVRegs = NumberOfVRegs<ArgType...>();
171167
std::array<uint32_t, kNumVRegs> vregs;
172-
FillVRegs<ArgType...>(vregs.data(), args...);
168+
if constexpr (sizeof...(args) > 0)
169+
FillVRegs<ArgType...>(vregs.data(), args...);
173170
return vregs;
174171
}
175172

0 commit comments

Comments
 (0)