On Mon, Nov 14, 2022 at 09:46:15PM -0700, Sandra Loosemore wrote:
> --- a/gcc/omp-simd-clone.cc
> +++ b/gcc/omp-simd-clone.cc
> @@ -51,6 +51,210 @@ along with GCC; see the file COPYING3.  If not see
>  #include "stringpool.h"
>  #include "attribs.h"
>  #include "omp-simd-clone.h"
> +#include "omp-low.h"
> +#include "omp-general.h"
> +
> +/* Print debug info for ok_for_auto_simd_clone to the dump file, logging
> +   failure reason EXCUSE for function DECL.  Always returns false.  */
> +static bool
> +auto_simd_fail (tree decl, const char *excuse)
> +{
> +  if (dump_file && (dump_flags & TDF_DETAILS))
> +    fprintf (dump_file, "\nNot auto-cloning %s because %s\n",
> +          IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
> +          excuse);
> +  return false;
> +}
> +
> +/* Helper function for ok_for_auto_simd_clone; return false if the statement
> +   violates restrictions for an "omp declare simd" function.  Specifically,
> +   the function must not
> +   - throw or call setjmp/longjmp
> +   - write memory that could alias parallel calls
> +   - read volatile memory
> +   - include openmp directives or calls
> +   - call functions that might do those things */
> +
> +static bool
> +auto_simd_check_stmt (gimple *stmt, tree outer)
> +{
> +  tree decl;
> +
> +  switch (gimple_code (stmt))
> +    {
> +    case GIMPLE_CALL:
> +
> +      /* Calls to functions that are CONST or PURE are ok, even if they
> +      are internal functions without a decl.  Reject other internal
> +      functions.  */
> +      if (gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE))
> +     break;
> +      if (gimple_call_internal_p (stmt))
> +     return auto_simd_fail (outer,
> +                            "body contains internal function call");

Just a note, this kind of building sentences from separate parts is
not ok for translations, but in the fprintf case the string isn't translated
anyway, so it is ok in this case.  But if we wanted to emit a
warning/inform, it wouldn't be.

The patch LGTM, thanks.

        Jakub

Reply via email to