llvm.org GIT mirror llvm / 8ec459f
[globalisel][regbank] Warn about MIR ambiguities when register bank/class names clash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317132 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 3 years ago
3 changed file(s) with 19 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1818
1919 namespace llvm {
2020
21 void PrintNote(ArrayRef NoteLoc, const Twine &Msg);
22
2123 void PrintWarning(ArrayRef WarningLoc, const Twine &Msg);
2224 void PrintWarning(const char *Loc, const Twine &Msg);
2325 void PrintWarning(const Twine &Msg);
3838 "instantiated from multiclass");
3939 }
4040
41 void PrintNote(ArrayRef NoteLoc, const Twine &Msg) {
42 PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg);
43 }
44
4145 void PrintWarning(ArrayRef WarningLoc, const Twine &Msg) {
4246 PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
4347 }
298298 Banks.push_back(Bank);
299299 }
300300
301 // Warn about ambiguous MIR caused by register bank/class name clashes.
302 for (const auto &Class : Records.getAllDerivedDefinitions("RegisterClass")) {
303 for (const auto &Bank : Banks) {
304 if (Bank.getName().lower() == Class->getName().lower()) {
305 PrintWarning(Bank.getDef().getLoc(), "Register bank names should be "
306 "distinct from register classes "
307 "to avoid ambiguous MIR");
308 PrintNote(Bank.getDef().getLoc(), "RegisterBank was declared here");
309 PrintNote(Class->getLoc(), "RegisterClass was declared here");
310 }
311 }
312 }
313
301314 emitSourceFileHeader("Register Bank Source Fragments", OS);
302315 OS << "#ifdef GET_REGBANK_DECLARATIONS\n"
303316 << "#undef GET_REGBANK_DECLARATIONS\n";