Skip to content

Commit a073813

Browse files
Fix passing args to helper function
Fixed passing scalars which type is different than int64. Fixed passing allocatable arrays. Signed-off-by: Dominik Adamski <[email protected]>
1 parent 8bde362 commit a073813

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

tools/flang2/flang2exe/expand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static std::vector<int> get_allocated_symbols(OMPACCEL_TINFO *orig_symbols)
502502
int store_instr;
503503
int load_instr;
504504
for (unsigned i = 0; i < num_of_symbols; ++i) {
505-
if (DTYPEG(orig_symbols->symbols[i].device_sym) != DT_INT8)
505+
if (!DT_ISSCALAR(DTYPEG(orig_symbols->symbols[i].device_sym)))
506506
continue;
507507
snprintf(allocated_symbol_name, sizeof(allocated_symbol_name),
508508
".allocated_symbol_%d", i);

tools/flang2/flang2exe/kmpcutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ ll_make_kmpc_parallel_51(int global_tid_sptr, std::vector<int> &symbols, SPTR he
17711771
FALSE);
17721772
int j = 0;
17731773
for (unsigned i = 0; i < n_symbols; ++i) {
1774-
if (DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym) == DT_INT8) {
1774+
if (DT_ISSCALAR(DTYPEG(ompaccel_tinfo_get(gbl.currsub)->symbols[i].device_sym))) {
17751775
ilix = mk_ompaccel_store(symbols[j++],
17761776
DT_INT8,
17771777
nme_args,

tools/flang2/flang2exe/outliner.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ ll_make_ftn_outlined_params(int func_sptr, int paramct, DTYPE *argtype, OMPACCEL
492492
aux.dpdsc_size + paramct + 100);
493493

494494
while (paramct--) {
495-
sprintf(name, "%sArg%d", SYMNAME(func_sptr), count++);
495+
if (current_tinfo && cnt >= 2)
496+
sprintf(name, "%s", SYMNAME(ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym));
497+
else
498+
sprintf(name, "%sArg%d", SYMNAME(func_sptr), count++);
496499
sym = getsymbol(name);
497500
SCP(sym, SC_DUMMY);
498501
if (*argtype == DT_CPTR) { /* either i8* or actual type( pass by value). */
@@ -510,12 +513,13 @@ ll_make_ftn_outlined_params(int func_sptr, int paramct, DTYPE *argtype, OMPACCEL
510513
{
511514
NEED((current_tinfo->n_symbols + 1), current_tinfo->symbols, OMPACCEL_SYM,
512515
current_tinfo->sz_symbols, current_tinfo->sz_symbols * 2);
513-
current_tinfo->symbols[current_tinfo->n_symbols].device_sym = static_cast<SPTR>(sym);
514516
if (cnt >= 2) {
515517
PASSBYVALP(sym, false);
516518
PASSBYREFP(sym, true);
517519
current_tinfo->symbols[current_tinfo->n_symbols].host_sym =
518520
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
521+
current_tinfo->symbols[current_tinfo->n_symbols].device_sym =
522+
ompaccel_tinfo_get(gbl.currsub)->symbols[cnt-2].device_sym;
519523
}
520524
current_tinfo->symbols[current_tinfo->n_symbols].map_type = 0;
521525
current_tinfo->symbols[current_tinfo->n_symbols].in_map = 0;
@@ -2683,7 +2687,10 @@ ll_make_helper_function_for_kmpc_parallel_51(SPTR scope_sptr, OMPACCEL_TINFO *or
26832687
func_args[1] = get_type(2, TY_PTR, DT_INT8);//DT_CPTR; // bound_tid
26842688

26852689
for (int k = 2; k < func_args_cnt; k++) {
2686-
func_args[k] = DTYPEG(symbols->device_sym);
2690+
if(DT_ISSCALAR( DTYPEG(symbols->device_sym)))
2691+
func_args[k] = DT_CPTR;
2692+
else
2693+
func_args[k] = DTYPEG(symbols->device_sym);
26872694
PASSBYVALP(symbols->device_sym, false);
26882695
symbols++;
26892696
}

0 commit comments

Comments
 (0)