@@ -14,33 +14,34 @@ namespace mlir::triton {
1414LogicalResult
1515FuncArgRenamer::apply (Type type, FunctionOpInterface funcOp, int index,
1616 TypeConverter::SignatureConversion &conversion) const {
17- if ( auto mapping = conversion.getInputMapping (index)) {
18- for ( auto &renamer : llvm::reverse (renamers)) {
19- llvm::SmallVector<std::string, 8 > out_suffix ;
20- if (std::optional<LogicalResult> result = renamer (type, out_suffix)) {
21- if ( failed (*result )) {
22- return failure () ;
23- }
24- int newIndex = mapping-> inputNo ;
25- auto loc = funcOp. getArgument (newIndex). getLoc ();
26- std::string baseName;
27- if (isa<NameLoc>(loc)) {
28- baseName = cast<NameLoc>(loc). getName (). getValue ();
29- } else {
30- baseName = " arg_ " + std::to_string (index);
31- }
32- assert (out_suffix. size () == mapping-> size );
33- for ( auto [i, suffix] : llvm::enumerate (out_suffix)) {
34- if (!suffix. empty ()) {
35- auto newLoc =
36- NameLoc::get ( StringAttr::get (funcOp. getContext (),
37- baseName + delimiter + suffix),
38- loc) ;
39- funcOp. getArgument (newIndex + i). setLoc (newLoc);
40- }
41- }
42- return success (); // early return
17+ auto mapping = conversion.getInputMapping (index);
18+ if (!mapping)
19+ return success () ;
20+
21+ for ( auto &renamer : llvm::reverse (renamers )) {
22+ llvm::SmallVector<std::string, 8 > out_suffix ;
23+ if (std::optional<LogicalResult> result = renamer (type, out_suffix)) {
24+ if ( failed (*result)) {
25+ return failure ();
26+ }
27+ int newIndex = mapping-> inputNo ;
28+ auto loc = funcOp. getArgument (newIndex). getLoc ();
29+ std::string baseName;
30+ if (isa<NameLoc>(loc)) {
31+ baseName = cast<NameLoc>(loc). getName (). getValue ();
32+ } else {
33+ baseName = " arg_ " + std::to_string (index);
34+ }
35+ assert (out_suffix. size () == mapping-> size );
36+ for ( auto [i, suffix] : llvm::enumerate (out_suffix)) {
37+ if ( suffix. empty ())
38+ continue ;
39+ auto newLoc = NameLoc::get (
40+ StringAttr::get (funcOp. getContext (), baseName + delimiter + suffix),
41+ loc);
42+ funcOp. getArgument (newIndex + i). setLoc (newLoc);
4343 }
44+ return success (); // early return
4445 }
4546 }
4647 return success ();
0 commit comments