[llvm-dev] Get Source Code Location of a Loop

Michael Kruse via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 8 16:14:04 PST 2021


Loop::getStartLoc() looks up the DebugLoc in the metadata attached to
the loop. It is up to the language frontend (classic flang? f18 flang?
Dragonegg?). Therefore, it is up to the frontend to correctly set that
information.

However, getStartLoc() also has a fallback strategy to look for debug
info of the pre-header. After loop-rotation of the outer loop, the
inner loop's pre-header would might have been merged with the exit
condition of the outer loop.

> How to get the proper beginning line in the source?

This is the responsibility of your Fortran front-end.

Michael


More information about the llvm-dev mailing list