[flang] Avoid ICE in case of subprogram name clash with runtime namespace.
This is related to llvm-project#61074. In general, it is undefined behavior if user subprogram is declared with a name that matches a name of function from any runtime library that Flang is using (e.g. FortranRuntime, libm, etc.). With this change-set we avoid ICE for invalid calls generated during math lowering by type casing the function before the call. This happens when a user function call is lowered before the math function call with the same name. To detect the name clash in cases when the math function call is lowered before the user function call we set fir.runtime attribute for the math functions and check it when we lower the user function call. The warnings are currently emitted only in debug compiler and under llvm debug options. I think they should be reported in the same way as regular Flang warnings. Note that this change-set does not resolve issues with the conversion passes that might introduce libm calls after the lowering. Differential Revision: https://reviews.llvm.org/D145653
Loading
Please sign in to comment