Skip to content

Commit 1cb7962

Browse files
Fix passing Fortran objects
Fortran objects should be passed as i64* Signed-off-by: Dominik Adamski <[email protected]>
1 parent 6737371 commit 1cb7962

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

tools/flang2/flang2exe/expand.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,18 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
507507
int store_instr;
508508
int load_instr;
509509
for (unsigned i = 0; i < num_of_symbols; ++i) {
510-
if (!DT_ISSCALAR(DTYPEG(orig_symbols->symbols[i].device_sym)))
511-
continue;
510+
if (!DT_ISSCALAR(DTYPEG(orig_symbols->symbols[i].device_sym))
511+
&& STYPEG(orig_symbols->symbols[i].host_sym) != ST_STRUCT) {
512+
continue;
513+
}
512514
snprintf(allocated_symbol_name, sizeof(allocated_symbol_name),
513515
".allocated_symbol_%d", i);
514516
allocated_symbol = getsymbol(allocated_symbol_name);
515517
STYPEP(allocated_symbol, ST_VAR);
516-
DTYPEP(allocated_symbol,
518+
if (STYPEG(orig_symbols->symbols[i].host_sym) == ST_STRUCT)
519+
DTYPEP(allocated_symbol,DT_CPTR);
520+
else
521+
DTYPEP(allocated_symbol,
517522
get_type(2,TY_PTR,DTYPEG(orig_symbols->symbols[i].device_sym)));
518523
SCP(allocated_symbol, SC_AUTO);
519524
store_instr = ad4ili(IL_ST,

tools/flang2/flang2exe/kmpcutil.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,8 +1770,10 @@ ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR he
17701770
ad_icon(0),
17711771
FALSE);
17721772
int j = 0;
1773+
17731774
for (unsigned i = 0; i < n_symbols; ++i) {
1774-
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym))) {
1775+
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym)) ||
1776+
STYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].host_sym) == ST_STRUCT) {
17751777
ilix = mk_ompaccel_store(symbols[j++],
17761778
DT_INT8,
17771779
nme_args,

tools/flang2/flang2exe/outliner.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,6 +2690,9 @@ ll_make_helper_function_for_kmpc_parallel_51(SPTR scope_sptr, OMPACCEL_TINFO *or
26902690
if(DT_ISSCALAR( DTYPEG(symbols->device_sym))
26912691
&& DTYPEG(symbols->device_sym) != DT_CMPLX)
26922692
func_args[k] = DT_CPTR;
2693+
else if (STYPEG(symbols->host_sym) == ST_STRUCT) {
2694+
func_args[k] = DT_CPTR;
2695+
}
26932696
else
26942697
func_args[k] = DTYPEG(symbols->device_sym);
26952698
PASSBYVALP(symbols->device_sym, false);

0 commit comments

Comments
 (0)