https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109580
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to David Malcolm from comment #4) > Richi: what is the mechanism (if any) for freshly-created gimple stmts to > get a location_t within gimple-match.cc? It seems to me that the stmts > ought to somehow be assigned the location_t of whatever they are simplified > from, or we'll keep running into stmts with UNKNOWN_LOCATION. Should we be > passing a location_t around in the generated match code, or have a > postprocessing phase where we copy a location_t to all freshly-created stmts? stmts generated from gimple-match.cc are all put into a sequence, the appropriate place to assign a location is when they are put into the IL. One place would be for example replace_stmt_with_simplification. There is for example annotate_all_with_location that could be used (but it has some odd behavior wrt GF_PLF_1). Note that when a match pattern combines stmts from different locations to a new stmt what the appropriate location is for the result is questionable. Though indeed assigning the location of the "root" of the simplification is reasonable. Note that otherwise UNKNOWN_LOCATION stmts inherit the location from the surrounding stmts - they leave the location that's active for debug info purposes unchanged.