[RFC] omp.module and omp.function vs dialect attributes to encode openmp properties

It seems like it would be an intrinsic attribute which means an op is recommended, but it also seems like a big thing to add a new op.

If all you want is a “flag”, add a global.

extern weak_odr OpenMP_Device_Code;

In the translator to IR you transform it into what clang uses:

!11 = !{"openmp", 51}
!12 = !{"openmp-device"}

We really don’t need more.

Having the frontend ignore (remove?) everything that is not going to be compiled may not be desirable. For example, an input to a target region could be determined to be constant if the host code can be analyzed (may be through interprocedural analysis).

That doesn’t work (as easily as one might think). And we rehash this discussion every few months.
The easiest example to break this is using pre-processor directives.

#ifdef __SSE2
const int VF = 4
#else
const int VF = 1
endif

Now if you use the macros defined for one target to determine values used on the other target you will create mismatches.

Other things likely to break (or cause trouble) if you start mixing code targeting different architectures:
(unavailable or different) types, builtins, predefined macros, predefined/library functions, …