Skip to content

Commit eab3991

Browse files
authored
Merge pull request #820 from ThePortlandGroup/nv_stage
Pull 2019-10-25T18-58 Recent NVIDIA Changes
2 parents e6a9276 + bc273a2 commit eab3991

File tree

32 files changed

+576
-99
lines changed

32 files changed

+576
-99
lines changed

test/f90_correct/inc/fs11.mk

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@
1818

1919
# Determine call instruction used
2020
INSN=call
21-
LLFLAG=
2221
OPT=
2322
ifeq ($(findstring aarch64, $(UNAME)), aarch64)
2423
INSN=bl
25-
ifeq ($(findstring O0, $(OPT)), O0)
26-
LLFLAG=-Mkeepll
27-
endif
2824
endif
2925
ifeq ($(findstring ppc64le, $(UNAME)), ppc64le)
3026
INSN=bl
@@ -36,34 +32,23 @@ build: $(SRC)/fs11.f90
3632
-$(RM) fs11.$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.*
3733
@echo ------------------------------------ building test $@
3834
-$(CC) -c $(CFLAGS) $(SRC)/check.c -o check.$(OBJX)
39-
-$(FC) $(FFLAGS) $(LLFLAG) $(LDFLAGS) $(SRC)/fs11.f90 -S
40-
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/fs11.f90 -o fs11.$(OBJX)
35+
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/fs11.f90 -o fs11.$(OBJX) -Minfo > fs11.txt 2>&1
4136
-$(FC) $(FFLAGS) $(LDFLAGS) fs11.$(OBJX) check.$(OBJX) $(LIBS) -o fs11.$(EXESUFFIX)
4237

4338
# rank2 should not be inlined (except with -Minline=reshape).
4439
# Verify that by checking for exactly 3 calls to mmul.
45-
# This check isn't valid for flang because it allows LLVM to inline.
40+
# Due to the complexity of counting specific function calls in assembly
41+
# or .ll files, we are now checking -Minfo messages about whether rank2 is
42+
# being inlined.
4643
run:
4744
@echo ------------------------------------ executing test fs11
48-
ifeq ($(LLFLAG), -Mkeepll)
49-
@mmul_calls=`grep -c 'void (.*)\*.*mmul' fs11.ll`; \
50-
if [ $$mmul_calls -ne 3 ]; then \
51-
echo "RESULT: FAIL - expected exactly 3 calls to mmul, got $$mmul_calls in fs11.ll" ; \
45+
@mmul_calls=`grep -c 'rank2.*inlined' fs11.txt`; \
46+
if [ $$mmul_calls -ne 0 ]; then \
47+
echo "RESULT: FAIL" ; \
5248
exit 1; \
5349
else \
54-
echo "RESULT: PASS - got exactly 3 calls to mmul in fs11.ll" ; \
55-
fi
56-
else
57-
ifneq ($(FC), flang)
58-
@mmul_calls=`grep -c '$(INSN).*mmul' fs11.s`; \
59-
if [ $$mmul_calls -ne 3 ]; then \
60-
echo "RESULT: FAIL - expected exactly 3 calls to mmul, got $$mmul_calls in fs11.s" ; \
61-
exit 1; \
62-
else \
63-
echo "RESULT: PASS - got exactly 3 calls to mmul in fs11.s" ; \
50+
echo "RESULT: PASS" ; \
6451
fi
65-
endif
66-
endif
6752
fs11.$(EXESUFFIX)
6853

6954
verify: ;

test/f90_correct/inc/fs12.mk

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015-2018, NVIDIA CORPORATION. All rights reserved.
2+
# Copyright (c) 2015-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.
@@ -31,22 +31,23 @@ build: $(SRC)/fs12.f90
3131
-$(RM) fs12.$(EXESUFFIX) core *.d *.mod FOR*.DAT FTN* ftn* fort.*
3232
@echo ------------------------------------ building test $@
3333
-$(CC) -c $(CFLAGS) $(SRC)/check.c -o check.$(OBJX)
34-
-$(FC) $(FFLAGS) $(LDFLAGS) $(SRC)/fs12.f90 -S
35-
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/fs12.f90 -o fs12.$(OBJX)
34+
-$(FC) -c $(FFLAGS) $(LDFLAGS) $(SRC)/fs12.f90 -o fs12.$(OBJX) -Minfo > fs12.txt 2>&1
3635
-$(FC) $(FFLAGS) $(LDFLAGS) fs12.$(OBJX) check.$(OBJX) $(LIBS) -o fs12.$(EXESUFFIX)
3736

3837
# contig_cpy should not be inlined (except with -Minline=reshape).
3938
# Verify that by checking for exactly 3 calls to f90_mcopy.
40-
# This check isn't valid for flang because it allows LLVM to inline.
39+
# Due to the complexity of counting specific function calls in assembly
40+
# or .ll files, we are now checking -Minfo messages about whether rank2 is
41+
# being inlined.
4142
run:
4243
@echo ------------------------------------ executing modified test fs12
43-
ifneq ($(FC), flang)
44-
@mcopy_calls=`grep -ci '$(INSN).*f90_mcopy' fs12.s`; \
45-
if [ $$mcopy_calls -ne 3 ]; then \
46-
echo "RESULT: FAIL - expected exactly 3 calls to f90_mcopy, got $$mcopy_calls" ; \
44+
@mcopy_calls=`grep -ci 'contig_cpy.*inlined' fs12.txt`; \
45+
if [ $$mcopy_calls -ne 0 ]; then \
46+
echo "RESULT: FAIL" ; \
4747
exit 1; \
48+
else \
49+
echo "RESULT: PASS" ; \
4850
fi
49-
endif
5051
fs12.$(EXESUFFIX)
5152

5253
verify: ;

tools/flang1/flang1exe/ast.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,8 @@ replace_memsym_of_ast(int ast, SPTR sptr)
28522852
switch (A_TYPEG(ast)) {
28532853
case A_ID:
28542854
return mk_id(sptr);
2855+
case A_FUNC:
2856+
return mk_func_node(A_FUNC, mk_id(sptr), A_ARGCNTG(ast), A_ARGSG(ast));
28552857
case A_MEM:
28562858
if (A_TYPEG(A_MEMG(ast)) == A_ID) {
28572859
return mk_member(A_PARENTG(ast), mk_id(sptr), A_DTYPEG(ast));

tools/flang1/flang1exe/dinit.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ dinit_val(int sptr, int dtype, int dtypev, int astval, int op)
951951
if (A_ALIASG(astval))
952952
astval = A_ALIASG(astval);
953953

954+
if (is_procedure_ptr(sptr)) {
955+
/* TBD: Eventually do this for regular pointers? */
956+
return astval;
957+
}
954958
if (POINTERG(sptr)) {
955959
error(457, 3, gbl.lineno, SYMNAME(sptr), CNULL);
956960
return 0;
@@ -1533,6 +1537,20 @@ sym_is_dinitd(int sptr)
15331537
if (no_dinitp)
15341538
return;
15351539
DINITP(sptr, 1);
1540+
if (is_procedure_ptr(sptr)) {
1541+
/* TBD: Eventually do this for regular pointers? */
1542+
SPTR ptr, sdsc, off;
1543+
ptr = MIDNUMG(sptr);
1544+
DINITP(MIDNUMG(sptr), 1);
1545+
sdsc = SDSCG(sptr);
1546+
if (sdsc && STYPEG(sdsc) != ST_PARAM) {
1547+
DINITP(sdsc, 1);
1548+
}
1549+
off = PTROFFG(sptr);
1550+
if (off && STYPEG(off) != ST_PARAM) {
1551+
DINITP(off, 1);
1552+
}
1553+
}
15361554
if (ST_ISVAR(STYPEG(sptr)) && SCG(sptr) == SC_CMBLK)
15371555
/* set DINIT flag for common block: */
15381556
DINITP(CMBLKG(sptr), 1);

tools/flang1/flang1exe/exterf.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997-2018, NVIDIA CORPORATION. All rights reserved.
2+
* Copyright (c) 1997-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.
@@ -1820,8 +1820,16 @@ queue_symbol(int sptr)
18201820

18211821
case ST_ENTRY:
18221822
case ST_PROC:
1823-
if (STYPEG(sptr) == ST_PROC && IS_PROC_DUMMYG(sptr) && SDSCG(sptr)){
1824-
queue_symbol(SDSCG(sptr));
1823+
if (STYPEG(sptr) == ST_PROC) {
1824+
if (ASSOC_PTRG(sptr) > NOSYM) {
1825+
queue_symbol(ASSOC_PTRG(sptr));
1826+
}
1827+
if (PTR_TARGETG(sptr) > NOSYM) {
1828+
queue_symbol(PTR_TARGETG(sptr));
1829+
}
1830+
if (IS_PROC_DUMMYG(sptr) && SDSCG(sptr)){
1831+
queue_symbol(SDSCG(sptr));
1832+
}
18251833
}
18261834
if (FVALG(sptr)) {
18271835
queue_symbol(FVALG(sptr));

tools/flang1/flang1exe/interf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5393,6 +5393,9 @@ fill_sym(SYMITEM *ps, int sptr)
53935393
GETFIELD(w34);
53945394
GETFIELD(w35);
53955395
GETFIELD(w36);
5396+
GETFIELD(lineno);
5397+
GETFIELD(w39);
5398+
GETFIELD(w40);
53965399
#undef GETFIELD
53975400
stb.stg_base[sptr].uname = 0;
53985401
} /* fill_sym */
@@ -5903,6 +5906,12 @@ fill_links_symbol(SYMITEM *ps, WantPrivates wantPrivates)
59035906
ALTNAMEP(sptr, new_symbol(ALTNAMEG(sptr)));
59045907
break;
59055908
case ST_PROC:
5909+
if (ASSOC_PTRG(sptr)) {
5910+
ASSOC_PTRP(sptr, new_symbol(ASSOC_PTRG(sptr)));
5911+
}
5912+
if (PTR_TARGETG(sptr)) {
5913+
PTR_TARGETP(sptr, new_symbol(PTR_TARGETG(sptr)));
5914+
}
59065915
if (IS_PROC_DUMMYG(sptr) && SDSCG(sptr)) {
59075916
SDSCP(sptr, new_symbol(SDSCG(sptr)));
59085917
}

tools/flang1/flang1exe/lower.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,14 @@
131131
* Add has_alias bit, and length and name of the alias for Fortran
132132
* module variable when it is on the ONLY list of a USE statement.
133133
* This is for Fortran LLVM compiler only.
134+
*
135+
* 19.10 -- 1.54
136+
* All of 1.53 +
137+
* pass allocptr and ptrtarget values for default initialization
138+
* of standalone pointers.
134139
*/
135140
#define VersionMajor 1
136-
#define VersionMinor 53
141+
#define VersionMinor 54
137142

138143
void lower(int);
139144
void lower_end_contains(void);

tools/flang1/flang1exe/lowerilm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6390,13 +6390,16 @@ lower_data_stmts(void)
63906390
int sptr = A_SPTRG(ivl->u.varref.ptr);
63916391
if (!XBIT(7, 0x100000) && !DINITG(sptr))
63926392
continue;
6393+
63936394
/*
6394-
* DO NOT emit dinit info for POINTERs -- delete as part of
6395+
* Emit dinit info for procedure pointers.
6396+
*
6397+
* DO NOT emit dinit info for regular POINTERs -- delete as part of
63956398
* the fix to place init'd pointers in the STATIC# container
63966399
* (data section)
63976400
*/
6398-
if (SCG(sptr) == SC_BASED ||
6399-
(SCG(sptr) == SC_CMBLK && POINTERG(sptr))) {
6401+
if (!is_procedure_ptr(sptr) && (SCG(sptr) == SC_BASED ||
6402+
(SCG(sptr) == SC_CMBLK && POINTERG(sptr)))) {
64006403
continue;
64016404
}
64026405
}

tools/flang1/flang1exe/lowersym.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,11 @@ lower_pointer_init(void)
11841184
/* 64-bit pointers */
11851185
} else {
11861186
}
1187-
rilm = lower_null();
1187+
if (!PTR_TARGETG(sptr)) {
1188+
rilm = lower_null();
1189+
} else {
1190+
rilm = plower("oS", "BASE", PTR_TARGETG(sptr));
1191+
}
11881192
if (!XBIT(49, 0x20000000)) {
11891193
plower("oii", "PST", lilm, rilm);
11901194
} else if (XBIT(49, 0x100)) {
@@ -4034,8 +4038,11 @@ lower_symbol(int sptr)
40344038
* emit this bit only if emitting ST_MODULE as ST_PROC
40354039
* this conversion happens in putstype()
40364040
*/
4037-
if (sptr != gbl.currsub)
4041+
if (sptr != gbl.currsub) {
40384042
putbit("is_interface", IS_INTERFACEG(sptr));
4043+
putval("assocptr", ASSOC_PTRG(sptr));
4044+
putval("ptrtarget",PTR_TARGETG(sptr));
4045+
}
40394046

40404047
strip = 1;
40414048
}
@@ -4262,6 +4269,8 @@ lower_symbol(int sptr)
42624269
#else
42634270
putbit("tpalloc", 0);
42644271
#endif
4272+
putval("assocptr", ASSOC_PTRG(sptr));
4273+
putval("ptrtarget", PTR_TARGETG(sptr));
42654274
strip = 1;
42664275
break;
42674276

@@ -4309,6 +4318,8 @@ lower_symbol(int sptr)
43094318
putbit("has_opts", 0);
43104319
putbit("parref", 0);
43114320
putbit("is_interface", 0);
4321+
putval("assocptr", 0);
4322+
putval("ptrtarget", 0);
43124323
strip = 1;
43134324
break;
43144325

@@ -4508,6 +4519,8 @@ lower_symbol(int sptr)
45084519
putbit("is_interface", IS_INTERFACEG(sptr));
45094520
if (SCG(sptr) == SC_DUMMY)
45104521
putval("descriptor", IS_PROC_DUMMYG(sptr) ? SDSCG(sptr) : 0);
4522+
putsym("assocptr", ASSOC_PTRG(sptr));
4523+
putsym("ptrtarget", PTR_TARGETG(sptr));
45114524
if (gbl.stbfil && DTY(DTYPEG(sptr) + 2)) {
45124525
if (fvalfirst) {
45134526
putsym(NULL, FVALG(sptr));
@@ -4741,6 +4754,18 @@ lower_symbols(void)
47414754
if (VISITG(sptr) && STYPEG(sptr) == ST_TYPEDEF && BASETYPEG(sptr)) {
47424755
lower_put_datatype_stb(BASETYPEG(sptr));
47434756
}
4757+
if (VISITG(sptr) && STYPEG(sptr) == ST_PROC) {
4758+
SPTR sym = ASSOC_PTRG(sptr);
4759+
if (sym > NOSYM && !VISITG(sym)) {
4760+
lower_symbol(sym);
4761+
VISITP(sym, 1);
4762+
}
4763+
sym = PTR_TARGETG(sptr);
4764+
if (sym > NOSYM && !VISITG(sym)) {
4765+
lower_symbol(sym);
4766+
VISITP(sym, 1);
4767+
}
4768+
}
47444769
if (VISITG(sptr) && is_procedure_ptr(sptr)) {
47454770
/* make sure we lower type and subtype of procedure ptr */
47464771
int dtype = DTYPEG(sptr);

0 commit comments

Comments
 (0)