[all-commits] [llvm/llvm-project] c53636: [flang] Avoid ICE in case of subprogram name clash...

Slava Zakharin via All-commits all-commits at lists.llvm.org
Mon Mar 13 10:16:49 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c5363678932a8187b06f931ea30c5d06017b1bb5
      https://github.com/llvm/llvm-project/commit/c5363678932a8187b06f931ea30c5d06017b1bb5
  Author: Slava Zakharin <szakharin at nvidia.com>
  Date:   2023-03-13 (Mon, 13 Mar 2023)

  Changed paths:
    M flang/lib/Lower/ConvertCall.cpp
    M flang/lib/Optimizer/Builder/IntrinsicCall.cpp
    M flang/test/Lower/math-lowering.f90
    A flang/test/Lower/math-name-conflict.f90

  Log Message:
  -----------
  [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




More information about the All-commits mailing list