From 0ad06e951e9ae93ad039325e58a569e56b3c610d Mon Sep 17 00:00:00 2001 From: Kwok Cheung Yeung Date: Thu, 14 Apr 2022 21:21:11 +0100 Subject: [PATCH] Fix ICE in OpenACC kernel testcases This is due to sequences like this occurring: : .data_dep.8_27 = .UNIQUE (OACC_TAIL_MARK, .data_dep.8_16, 2); : .data_dep.8_29 = .UNIQUE (OACC_JOIN, .data_dep.8_27, -1); ... : .UNIQUE (OACC_TAIL_MARK, .data_dep.8_33); The final tail mark has no LHS, causing code that assumes its presence to segfault. The LHS and the assignment appear to have been removed as dead code by the cddce1 stage. Fixed by checking for the presence of the LHS before using it. 2022-04-14 Kwok Cheung Yeung gcc/ * graphite-oacc.cc (find_oacc_tail_marks): Check that data_dep is non-NULL before testing it. (reduction_use_in_outer_loop_p): Likewise. --- gcc/ChangeLog.omp | 6 ++++++ gcc/graphite-oacc.cc | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index eba48717ee8d..1a9d3c507b55 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,9 @@ +2022-04-14 Kwok Cheung Yeung + + * graphite-oacc.cc (find_oacc_tail_marks): Check that data_dep is + non-NULL before testing it. + (reduction_use_in_outer_loop_p): Likewise. + 2022-05-12 Jakub Jelinek Backport from mainline: diff --git a/gcc/graphite-oacc.cc b/gcc/graphite-oacc.cc index 6ba5d0f293a1..3ca13597a5f1 100644 --- a/gcc/graphite-oacc.cc +++ b/gcc/graphite-oacc.cc @@ -253,7 +253,7 @@ find_oacc_tail_marks (loop_p loop) tree data_dep = gimple_call_lhs (top_tail_mark); gimple *stmt = top_tail_mark; - while (has_single_use (data_dep)) + while (data_dep && has_single_use (data_dep)) { use_operand_p use_p; single_imm_use (data_dep, &use_p, &stmt); @@ -313,7 +313,7 @@ reduction_use_in_outer_loop_p (gcall *call) /* The IFN_GOACC_REDUCTION_CALLS are linked in a chain through immediate uses. Move to the end of this chain. */ gimple *stmt = call; - while (has_single_use (data_dep)) + while (data_dep && has_single_use (data_dep)) { use_operand_p use_p; single_imm_use (data_dep, &use_p, &stmt); -- 2.47.2