Skip to content

Commit 4498b2b

Browse files
committed
Fix issue identified in large application
Fix a symbol table flag overloading problem with ASSOC_PTR and PTR_TARGET flags. Use a new bit flag in the Fortran back-end called PTR_INITIALIZER to distinguish the overloaded cases. Also discovered an unrelated bug with inject_arg() in semfin.c. Make sure we set the arguments' storage class to SC_DUMMY.
1 parent 16625ee commit 4498b2b

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

tools/flang1/flang1exe/semfin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ inject_arg(int func_sptr, int arg_sptr, int position)
239239
&aux.dpdsc_base[new_dsc + position],
240240
(old_args - position) * sizeof *aux.dpdsc_base);
241241
aux.dpdsc_base[new_dsc + position] = arg_sptr;
242+
SCP(arg_sptr, SC_DUMMY);
242243
DPDSCP(func_sptr, new_dsc);
243244
PARAMCTP(func_sptr, old_args + 1);
244245
}

tools/flang2/flang2exe/llassem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2758,7 +2758,7 @@ dinits(void)
27582758
item->offset += p->conval;
27592759
item->filepos = dinit_ftell();
27602760
}
2761-
if (ASSOC_PTRG(sptr)) {
2761+
if (PTR_INITIALIZERG(sptr) && ASSOC_PTRG(sptr)) {
27622762
cmblk = MIDNUMG(ASSOC_PTRG(sptr));
27632763
} else {
27642764
cmblk = MIDNUMG(sptr);
@@ -3734,7 +3734,7 @@ getsname(SPTR sptr)
37343734
#endif
37353735
break;
37363736
case ST_PROC:
3737-
if (PTR_TARGETG(sptr)) {
3737+
if (PTR_INITIALIZERG(sptr) && PTR_TARGETG(sptr)) {
37383738
sptr = (SPTR) PTR_TARGETG(sptr);
37393739
}
37403740
case ST_ENTRY:

tools/flang2/flang2exe/llassem_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ write_proc_pointer(SPTR sptr)
160160
const char *fntype = "void()";
161161
LL_Type * lt;
162162

163-
if (PTR_TARGETG(sptr)) {
163+
if (PTR_INITIALIZERG(sptr) && PTR_TARGETG(sptr)) {
164164
sptr = (SPTR) PTR_TARGETG(sptr);
165165
}
166166
LL_ABI_Info *abi = ll_proto_get_abi(ll_proto_key(sptr));

tools/flang2/flang2exe/upper.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,12 @@ read_symbol(void)
28062806
LENPARMP(newsptr, lenparm);
28072807
TPALLOCP(newsptr, tpalloc);
28082808
ASSOC_PTRP(newsptr, assocptr);
2809-
PTR_TARGETP(newsptr, ptrtarget);
2809+
if (ptrtarget > NOSYM) {
2810+
PTR_TARGETP(newsptr, ptrtarget);
2811+
}
2812+
if (assocptr > NOSYM || ptrtarget > NOSYM) {
2813+
PTR_INITIALIZERP(newsptr, 1);
2814+
}
28102815
break;
28112816

28122817
case ST_NML:
@@ -3115,6 +3120,9 @@ read_symbol(void)
31153120
if (ptrtarget > NOSYM) {
31163121
PTR_TARGETP(newsptr, ptrtarget);
31173122
}
3123+
if (assocptr > NOSYM || ptrtarget > NOSYM) {
3124+
PTR_INITIALIZERP(newsptr, 1);
3125+
}
31183126
break;
31193127

31203128
case ST_GENERIC:
@@ -3891,7 +3899,7 @@ fix_symbol(void)
38913899
sym_is_refd(sptr);
38923900
break;
38933901
case ST_PROC:
3894-
if (ASSOC_PTRG(sptr) && PTR_TARGETG(sptr)) {
3902+
if (PTR_INITIALIZERG(sptr) && ASSOC_PTRG(sptr) && PTR_TARGETG(sptr)) {
38953903
SPTR ptr = symbolxref[ASSOC_PTRG(sptr)];
38963904
ASSOC_PTRP(sptr, MIDNUMG(ptr) > NOSYM ? MIDNUMG(ptr) : ptr);
38973905
PTR_TARGETP(sptr, symbolxref[PTR_TARGETG(sptr)]);

tools/flang2/utils/symtab/symtab.n

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ variables, indicates that address has been assigned.
609609
Set if we need to "re-reference" variable (call back-end's sym_is_refd). This
610610
can occur if we have a type extension with initializations in the parent
611611
component which require a call to assn_static_off() in back end's sym_is_refd() function.
612+
.FL PTR_INITIALIZER f126
613+
Set when this symbol is used as an initializer for a pointer. Assumes
614+
ASSOC_PTR and/or PTR_TARGET are also set.
612615
.FL WEAK f119
613616
Set if this variable is a weak symbol.
614617
.FL ADDRTKN f8
@@ -1504,6 +1507,9 @@ Set if this procedure has optional arguments.
15041507
.FL LIBSYM f111
15051508
Indicates that this is a routine symbol from a standard module, such as
15061509
ieee_arithmetic or iso_c_binding, that is resolved from a system library.
1510+
.FL PTR_INITIALIZER f126
1511+
Set when this symbol is used as an initializer for a pointer. Assumes
1512+
ASSOC_PTR and/or PTR_TARGET are also set.
15071513
.ul
15081514
Other Fields
15091515
.SE SYMLK

0 commit comments

Comments
 (0)