GCC with patches for OS216
修订版 | ad3f0ec1a80ba6930fd17ad45a9e3ecd793e3f67 (tree) |
---|---|
时间 | 2020-06-18 06:47:31 |
作者 | Thomas Schwinge <thomas@code...> |
Commiter | Thomas Schwinge |
[HSA] Avoid ICE when "HSA does not implement indirect calls"
Made apparent by recent commit dc703151d4f4560e647649506d5b4ceb0ee11e90
"openmp: Implement discovery of implicit declare target to clauses":
This is in a '--enable-offload-targets=[...],hsa' build, with '-foffload=hsa'
enabled (by default).
GDB:
The problem is present already since 2016-11-23 commit
56b1c60e412fcf1245b4780871553cbdebb956a3 (r242761) "Merge from HSA branch to
trunk", and the fix obvious enough.
gcc/
* hsa-gen.c (gen_hsa_insns_for_call): Move 'function_decl ==
NULL_TREE' check earlier.
gcc/testsuite/
* c-c++-common/gomp/hsa-indirect-call-1.c: New file.
(cherry picked from commit 973bce0fb50bbfd91f47238b82b99935525716ad)
@@ -5299,10 +5299,6 @@ gen_hsa_insns_for_call (gimple *stmt, hsa_bb *hbb) | ||
5299 | 5299 | if (!gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) |
5300 | 5300 | { |
5301 | 5301 | tree function_decl = gimple_call_fndecl (stmt); |
5302 | - /* Prefetch pass can create type-mismatching prefetch builtin calls which | |
5303 | - fail the gimple_call_builtin_p test above. Handle them here. */ | |
5304 | - if (fndecl_built_in_p (function_decl, BUILT_IN_PREFETCH)) | |
5305 | - return; | |
5306 | 5302 | |
5307 | 5303 | if (function_decl == NULL_TREE) |
5308 | 5304 | { |
@@ -5311,6 +5307,11 @@ gen_hsa_insns_for_call (gimple *stmt, hsa_bb *hbb) | ||
5311 | 5307 | return; |
5312 | 5308 | } |
5313 | 5309 | |
5310 | + /* Prefetch pass can create type-mismatching prefetch builtin calls which | |
5311 | + fail the gimple_call_builtin_p test above. Handle them here. */ | |
5312 | + if (fndecl_built_in_p (function_decl, BUILT_IN_PREFETCH)) | |
5313 | + return; | |
5314 | + | |
5314 | 5315 | if (hsa_callable_function_p (function_decl)) |
5315 | 5316 | gen_hsa_insns_for_direct_call (stmt, hbb); |
5316 | 5317 | else if (!gen_hsa_insns_for_known_library_call (stmt, hbb)) |
@@ -0,0 +1,24 @@ | ||
1 | +/* Instead of ICE, we'd like "HSA does not implement indirect calls". */ | |
2 | + | |
3 | +/* Reduced from 'libgomp.c/target-39.c'. */ | |
4 | + | |
5 | +/* { dg-require-effective-target offload_hsa } */ | |
6 | +/* { dg-additional-options "-Whsa" } to override '{gcc,g++}.dg/gomp/gomp.exp'. */ | |
7 | + | |
8 | +typedef void (*fnp) (void); | |
9 | +void f1 (void) { } | |
10 | +fnp f2 (void) { return f1; } | |
11 | +#pragma omp declare target to (f1, f2) | |
12 | + | |
13 | +int | |
14 | +main () | |
15 | +{ | |
16 | + #pragma omp target | |
17 | + { | |
18 | + fnp fnp = f2 (); | |
19 | + fnp (); /* { dg-message "note: support for HSA does not implement indirect calls" } */ | |
20 | + } | |
21 | + return 0; | |
22 | +} | |
23 | + | |
24 | +/* { dg-warning "could not emit HSAIL for the function" "" { target *-*-* } 0 } */ |