@@ -248,7 +248,7 @@ void mlir::NVVM::countPlaceholderNumbers(
248248 while (!rest.empty () && rx.match (rest, &m)) {
249249 unsigned num = 0 ;
250250 (void )m[2 ].getAsInteger (10 , num);
251-
251+ // Insert it into the vector only the first time we see this number
252252 if (m[1 ].equals_insensitive (kReadWritePrefix )) {
253253 if (seenRW.insert (num).second )
254254 rwNums.push_back (num);
@@ -318,23 +318,23 @@ static std::string rewriteAsmPlaceholders(llvm::StringRef ptxCode) {
318318 out.reserve (ptxCode.size ());
319319 size_t prev = 0 ;
320320 StringRef rest = ptxCode;
321- SmallVector<StringRef, 3 > m ;
321+ SmallVector<StringRef, 3 > matches ;
322322 llvm::Regex rx = getPredicateMappingRegex ();
323- while (!rest.empty () && rx.match (rest, &m )) {
323+ while (!rest.empty () && rx.match (rest, &matches )) {
324324 // Compute absolute match bounds in the original buffer.
325- size_t absStart = (size_t )(m [0 ].data () - ptxCode.data ());
326- size_t absEnd = absStart + m [0 ].size ();
325+ size_t absStart = (size_t )(matches [0 ].data () - ptxCode.data ());
326+ size_t absEnd = absStart + matches [0 ].size ();
327327
328328 // Emit text before the match.
329329 out.append (ptxCode.data () + prev, ptxCode.data () + absStart);
330330
331331 // Emit compact $K
332332 unsigned num = 0 ;
333- (void )m [2 ].getAsInteger (10 , num);
333+ (void )matches [2 ].getAsInteger (10 , num);
334334 unsigned id = 0 ;
335- if (m [1 ].equals_insensitive (kReadWritePrefix ))
335+ if (matches [1 ].equals_insensitive (kReadWritePrefix ))
336336 id = rwMap.lookup (num);
337- else if (m [1 ].equals_insensitive (kWriteOnlyPrefix ))
337+ else if (matches [1 ].equals_insensitive (kWriteOnlyPrefix ))
338338 id = wMap.lookup (num);
339339 else
340340 id = rMap.lookup (num);
@@ -344,7 +344,8 @@ static std::string rewriteAsmPlaceholders(llvm::StringRef ptxCode) {
344344
345345 prev = absEnd;
346346
347- const size_t advance = (size_t )(m[0 ].data () - rest.data ()) + m[0 ].size ();
347+ const size_t advance =
348+ (size_t )(matches[0 ].data () - rest.data ()) + matches[0 ].size ();
348349 rest = rest.drop_front (advance);
349350 }
350351
0 commit comments