Skip to content

Commit fdcf2bc

Browse files
authored
Merge pull request #790 from ThePortlandGroup/nv_stage
Pull 2019-08-28T15-45 Recent NVIDIA Changes
2 parents f5a11a3 + 222b54d commit fdcf2bc

File tree

5 files changed

+39
-26
lines changed

5 files changed

+39
-26
lines changed

tools/flang1/flang1exe/semfunc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,8 @@ gen_pointer_result(int array_value, int dscptr, int nactuals,
21112111
MIDNUMP(arr_tmp, pvar);
21122112
NODESCP(arr_tmp, 0);
21132113
ddt = DDTG(dt);
2114-
if (DTY(dt) == TY_CHAR || DTY(dt) == TY_NCHAR) {
2114+
if ((DTY(dt) == TY_CHAR && dt != DT_DEFERCHAR) ||
2115+
(DTY(dt) == TY_NCHAR && dt != DT_DEFERNCHAR)) {
21152116
add_auto_len(arr_tmp, 0);
21162117
if (CVLENG(arr_tmp))
21172118
ERLYSPECP(CVLENG(arr_tmp), 1);

tools/flang2/flang2exe/cgllvm.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2018, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 2010-2019, NVIDIA CORPORATION. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,10 +26,10 @@
2626

2727
void cprintf(char *s, const char *format, INT *val);
2828

29-
#define SNAME(sptr) (sptr_array[sptr])
30-
#define LLTYPE(sptr) (sptr_type_array[sptr])
31-
#define LLTYPE_kind(sptr) (sptr_type_array[sptr]->kind)
32-
#define LLTYPE_size(sptr) (sptr_type_array[sptr]->size)
29+
#define SNAME(sptr) (sptrinfo.array.stg_base[sptr])
30+
#define LLTYPE(sptr) (sptrinfo.type_array.stg_base[sptr])
31+
#define LLTYPE_kind(sptr) (sptrinfo.type_array.stg_base[sptr]->kind)
32+
#define LLTYPE_size(sptr) (sptrinfo.type_array.stg_base[sptr]->size)
3333

3434
#define AGGREGATE_STYPE(s) \
3535
((s) == ST_STRUCT || (s) == ST_UNION || (s) == ST_ARRAY)
@@ -104,8 +104,12 @@ typedef enum {
104104

105105
#define IS_OLD_STYLE_CAND(s) (DEFDG(sptr) || CCSYMG(sptr))
106106

107-
extern char **sptr_array;
108-
extern LL_Type **sptr_type_array;
107+
typedef struct{
108+
STG_DECLARE(array, char*);
109+
STG_DECLARE(type_array, LL_Type*);
110+
}SPTRINFO_T;
111+
112+
extern SPTRINFO_T sptrinfo;
109113

110114
void cg_llvm_init(void);
111115
void cg_llvm_end(void);

tools/flang2/flang2exe/cgmain.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "llutil.h"
3535
#include "lldebug.h"
3636
#include "go.h"
37+
#include "sharedefs.h"
3738
#include <stdlib.h>
3839
#include <stdio.h>
3940
#include "llassem.h"
@@ -193,15 +194,15 @@ static unsigned addressElementSize;
193194

194195
/* Exported variables */
195196

196-
char **sptr_array = NULL;
197+
SPTRINFO_T sptrinfo;
197198

198199
/* This should live in llvm_info, but we need to access this module from other
199200
* translation units temporarily */
200201
LL_Module *cpu_llvm_module = NULL;
201202
#ifdef OMP_OFFLOAD_LLVM
202203
LL_Module *gpu_llvm_module = NULL;
203204
#endif
204-
LL_Type **sptr_type_array = NULL;
205+
205206

206207
/* File static variables */
207208

@@ -13056,10 +13057,6 @@ static void
1305613057
update_llvm_sym_arrays(void)
1305713058
{
1305813059
const int new_size = stb.stg_avail + MEM_EXTRA;
13059-
int old_last_sym_avail = llvm_info.last_sym_avail; // NEEDB assigns
13060-
NEEDB(stb.stg_avail, sptr_array, char *, llvm_info.last_sym_avail, new_size);
13061-
NEEDB(stb.stg_avail, sptr_type_array, LL_Type *, old_last_sym_avail,
13062-
new_size);
1306313060
if ((flg.debug || XBIT(120, 0x1000)) && cpu_llvm_module) {
1306413061
lldbg_update_arrays(cpu_llvm_module->debug_info, llvm_info.last_dtype_avail,
1306513062
stb.dt.stg_avail + MEM_EXTRA);
@@ -13107,11 +13104,14 @@ cg_llvm_init(void)
1310713104
/* last_sym_avail is used for all the arrays below */
1310813105
llvm_info.last_sym_avail = stb.stg_avail + MEM_EXTRA;
1310913106

13110-
NEW(sptr_array, char *, stb.stg_avail + MEM_EXTRA);
13111-
BZERO(sptr_array, char *, stb.stg_avail + MEM_EXTRA);
13112-
/* set up the type array shadowing the symbol table */
13113-
NEW(sptr_type_array, LL_Type *, stb.stg_avail + MEM_EXTRA);
13114-
BZERO(sptr_type_array, LL_Type *, stb.stg_avail + MEM_EXTRA);
13107+
if (sptrinfo.array.stg_base) {
13108+
STG_CLEAR_ALL(sptrinfo.array);
13109+
STG_CLEAR_ALL(sptrinfo.type_array);
13110+
} else {
13111+
STG_ALLOC_SIDECAR(stb, sptrinfo.array);
13112+
/* set up the type array shadowing the symbol table */
13113+
STG_ALLOC_SIDECAR(stb, sptrinfo.type_array);
13114+
}
1311513115

1311613116
Globals = NULL;
1311713117
recorded_Globals = NULL;

tools/flang2/flang2exe/expand.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,17 @@ eval_ilm(int ilmx)
494494
* For each operand which is a link to another ilm, recurse (evaluate it)
495495
* if not already evaluated
496496
*/
497-
for (tmp = 1, noprs = ilms[opcx].oprs; noprs > first_op; ++tmp, --noprs) {
498-
if (IM_OPRFLAG(opcx, noprs) == OPR_LNK) {
499-
eval_ilm_argument1(noprs, ilmpx, ilmx);
497+
if (opcx == IM_DCMPLX || opcx == IM_CMPLX) {
498+
for (tmp = 1, noprs = 1; noprs <= ilms[opcx].oprs; ++tmp, ++noprs) {
499+
if (IM_OPRFLAG(opcx, noprs) == OPR_LNK) {
500+
eval_ilm_argument1(noprs, ilmpx, ilmx);
501+
}
502+
}
503+
} else {
504+
for (tmp = 1, noprs = ilms[opcx].oprs; noprs > first_op; ++tmp, --noprs) {
505+
if (IM_OPRFLAG(opcx, noprs) == OPR_LNK) {
506+
eval_ilm_argument1(noprs, ilmpx, ilmx);
507+
}
500508
}
501509
}
502510

tools/flang2/flang2exe/lldebug.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,19 +3118,19 @@ lldbg_function_end(LL_DebugInfo *db, int func)
31183118
if (!REFG(i)) {
31193119
// generate unreferenced variables
31203120
// add these to DWARF output as <optimized out> variables
3121-
LL_Type *cache = sptr_type_array[i];
3121+
LL_Type *cache = LLTYPE(i);
31223122
const DTYPE dtype = DTYPEG(i);
31233123
process_dtype_struct(dtype); // make sure type is emitted
31243124
type = make_lltype_from_dtype(dtype);
31253125
value = ll_create_value_from_type(db->module, type, "undef");
31263126
lldbg_emit_global_variable(db, i, 0, 1, value);
3127-
sptr_type_array[i] = cache;
3127+
LLTYPE(i) = cache;
31283128
} else if ((!SNAME(i)) && REFG(i)) {
31293129
// add referenced variables not discovered as yet
31303130
const char *sname;
31313131
const char *name;
31323132
char *buff;
3133-
LL_Type *cache = sptr_type_array[i];
3133+
LL_Type *cache = LLTYPE(i);
31343134
const DTYPE dtype = DTYPEG(i);
31353135
process_dtype_struct(dtype); // make sure type is emitted
31363136
type = ll_get_pointer_type(make_lltype_from_dtype(dtype));
@@ -3142,7 +3142,7 @@ lldbg_function_end(LL_DebugInfo *db, int func)
31423142
sprintf(buff, "bitcast (%%struct%s* @%s to %s)", sname, name, type->str);
31433143
value = ll_create_value_from_type(db->module, type, (const char *)buff);
31443144
lldbg_emit_global_variable(db, i, 0, 1, value);
3145-
sptr_type_array[i] = cache;
3145+
LLTYPE(i) = cache;
31463146
}
31473147
}
31483148
}

0 commit comments

Comments
 (0)