[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 Tom de Vries changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Target Milestone|--- |12.0 Resolution|--- |FIXED --- Comment #5 from Tom de Vries --- Using the test-case from comment 0 and: ... /* { dg-additional-options "-foffload=-malias -foffload=-mptx=6.3 -O0" } */ ... I get: ... $ strings test.exe | grep -i alias.alias _ZN1VILi1EEC1ImvEET_,_ZN1VILi1EEC2ImvEET_; ... so I see a normal alias, not a weak alias. The test-case still fails in the abort. Note that I get the same result with: ... /* { dg-additional-options "-foffload=-mno-alias -foffload=-mptx=6.3 -O2" } */ ... There may be a problem with the test-case, there may be a problem with nvptx c++ support, but the alias issue seems to have been addresses, so I'm closing this one.
[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 Bug 97106 depends on bug 97102, which changed state. Bug 97102 Summary: [nvptx] PTX JIT compilation failed when using aliases https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97102 What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 --- Comment #4 from Tom de Vries --- This: ... $ cat alias.c void __f () { __builtin_printf ("hello\n"); } void f () __attribute__ ((alias ("__f"))); int main (void) { f (); return 0; } ... works fine at -O0 and -O1: ... $ ./gcc.sh -O0 ./alias.c $ ./install/bin/nvptx-none-run a.out hello $ ./gcc.sh -O1 ./alias.c $ ./install/bin/nvptx-none-run a.out hello ... but at -O2 we have: ... $ ./gcc.sh -O2 ./alias.c $ ./install/bin/nvptx-none-run a.out fatal : Internal error: reference to deleted section nvptx-run: cuLinkComplete failed: unknown error (CUDA_ERROR_UNKNOWN, 999) ... This seems to be due to f/__f being inlined into main, after which we have an alias declaration which is unused: ... .visible .func f; .alias f,__f; ... Removing these two lines make the executable run fine again. Note: same thing when using nvptx-none-run -O0. Fixed by: ... diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index ab1f62359d4b..3e51bf15776c 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -77,6 +77,7 @@ #include "opts.h" #include "tree-pretty-print.h" #include "rtl-iter.h" +#include "cgraph.h" /* This file should be included last. */ #include "target-def.h" @@ -7396,6 +7397,10 @@ nvptx_mem_local_p (rtx mem) void nvptx_asm_output_def_from_decls (FILE *stream, tree name, tree value) { + if (!cgraph_node::get (name)->referred_to_p ()) +/* Prevent "Internal error: reference to deleted section". */ +return; + std::stringstream s; write_fn_proto (s, false, get_fnname_from_decl (name), name); fputs (s.str().c_str(), stream); ...
[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 --- Comment #3 from Tom de Vries --- With this additionally: ... diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc index 1a89c1bc77f..2e1a2dad9fe 100644 --- a/gcc/config/nvptx/nvptx.cc +++ b/gcc/config/nvptx/nvptx.cc @@ -968,7 +968,8 @@ static void write_fn_proto_1 (std::stringstream , bool is_defn, const char *name, const_tree decl) { - write_fn_marker (s, is_defn, TREE_PUBLIC (decl), name); + if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)) == NULL) +write_fn_marker (s, is_defn, TREE_PUBLIC (decl), name); /* PTX declaration. */ if (DECL_EXTERNAL (decl)) ... I get a simplified libgomp/testsuite/libgomp.c-c++-common/pr96390.c to work. That is, using only one level of alias indirection: ... #pragma omp target map(from:n) n = bar (); ... With the original, two level alias indirection I get: ... libgomp: Link error log ptxas fatal : Internal error: alias to unknown symbol ... That seems to be consistent with the ptx manual, which dictates: ... .alias fAlias, fAliasee; Identifier fAliasee is a function symbol which must be defined in the same module as .alias declaration. ...
[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 --- Comment #2 from Tom de Vries --- Created attachment 52606 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52606=edit Tentative patch With this patch and: - current trunk - misa default set to sm_75 (so 3.1 multilib disabled, because sm_75 is not supported there) - patch "middle-end: Support ABIs that pass FP values as wider integers" to fix the build with sm_75 default - Tentative patch "[nvptx] Add warp sync at simt exit" from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104783#c6 I get 100% pass rate on and sm_75 board for ovo testsuite: ... + ./ovo.sh report >> Overall result for test_result/2022-03-11_13-10_delia pass rate(%)test(#)success(#)compilation error(#)runtime error(#)wrong value(#)timeout(#) -- - -- -- 100%910 910 0 0 0 0 ...
[Bug target/97106] [nvptx] Issues with weak aliases introduced by C++
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97106 --- Comment #1 from Tobias Burnus --- Suggested fix: 14:11 < amonakov> Tobias__: I think the proper way to solve this is define hooks for the backend to print something for aliases, and then have nvptx-ld.c resolve them 14:12 < amonakov> (right now the backend prints nothing without crashing, which is pretty bad: unhandled stuff should at least emit a diagnostic) That would be an alternative to CUDA 10's/ISA 6.3's .alias