efriedma added a comment. read_register only allows reading reserved registers because reading an allocatable register is meaningless (the compiler can store arbitrary data in allocatable registers).
The same applies to __getReg; given that, I would assume real code doesn't use anything other than `__getReg(18)` or `__getReg(31)`, so we can just reject any other constant. ================ Comment at: lib/CodeGen/CGBuiltin.cpp:6589 + CGM.Error(E->getArg(0)->getBeginLoc(), + "__getReg expects a constant input parameter"); + ---------------- Semantic checks belong in SemaChecking, not here. IIRC you can request constant checking in the .def file, although I don't remember the syntax off the top of my head. ================ Comment at: lib/CodeGen/CGBuiltin.cpp:6598 + Value.toString(StrVal); + std::string Reg = "x" + std::string(StrVal.c_str()); + ---------------- There is no register named x31. Maybe you need a special case here to use "sp" if the input is 31? Repository: rC Clang https://reviews.llvm.org/D52838 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits