Dear Krishna,
On 07.04.21 17:55, Krishna Kariya wrote:
1.
Do we need to create the global variables __gfortran_called_proc,
__gfortran_called_interface during compilation? If yes, how would these
global variables be initialized, the module containing the caller’s source
code or the module containing the callee’s source code?
I was thinking NULL initialized static variables (pointers to the actual
data/called function) – as weak symbol, i.e. in every translation unit
which is compiled with the arg-checking flag. The linker will choose one
of the identical symbols and place it (on most systems) in the BSS.
Do we plan to do the instrumentation for runtime check inline in the IR
itself (inline monitoring)? Or can we write a runtime library that does the
checking, and we just insert calls to the runtime library routine at
compile time?
Either works – but I think it might be simpler to write and avoids a lot
of string constants if the actual check is done in libgfortran.
3.
Do we need to handle multithreaded programs? How will we handle the race
condition in which two different threads call an external procedure at the
same time?
Shouldn't that work if we use a thread local/private variable ('__thread',
"set_decl_tls_model (decl, decl_default_tls_model (decl));").
In any case, it would be useful:
(a) combining code which does argument checking with code which does not
This means we cannot simply add anything which changes the ABI unless it
is guaranteed to also work when the called procedure is not instrumented
or when an instrumented procedure is called.
(b) avoid race conditions
4.
How will we identify the procedures which require the run-time check? I
mean, do we need to write a static analysis to figure out which functions
are called externally?
My idea was that -fcheck=argcheck will simply annotate all calls and
procedures, except
intrinsic procedures, internal procedures, module procedures – we could
argue about bind(C)
and about procedures in the same translation unit (that's known).
Tobias