Bug 89351 - internal compiler error: in exact_div, at poly-int.h:2139 with -fgnu-tm
Summary: internal compiler error: in exact_div, at poly-int.h:2139 with -fgnu-tm
Status: RESOLVED DUPLICATE of bug 87118
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-14 13:34 UTC by Shubham Narlawar
Modified: 2021-09-23 02:00 UTC (History)
3 users (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2019-02-18 00:00:00


Attachments
Preprocessed code of file named "sam.c" which caused internal compiler error (29.13 KB, text/plain)
2019-02-14 13:34 UTC, Shubham Narlawar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shubham Narlawar 2019-02-14 13:34:12 UTC
Created attachment 45722 [details]
Preprocessed code of file named "sam.c" which caused internal compiler error

-----------------------COMMAND USED FOR COMPILATION---------------------------

~/gcc-9-trunk/build/gcc/xgcc -B ~/gcc-9-trunk/build/gcc/ sam.c -fgnu-tm -w -Icsmith-crash-test/csmith/runtime/
during RTL pass: expand
sam.c: In function ‘func_33’:
sam.c:857:139: internal compiler error: in exact_div, at poly-int.h:2139
  857 | != l_130) , ((g_133[0][1] , l_134) != (p_36 != (void*)0))) > g_100.f3)) & ((void*)0 == l_135)) || 0xAC466B2A51B1567ELL) > g_56.f0);
      |                                                              ~~~~~^~~

0x92f6f8 poly_int<1u, poly_result<long, if_nonpoly<int, int, poly_int_traits<int>::is_poly>::type, poly_coeff_pair_traits<long, if_nonpoly<int, int, poly_int_traits<int>::is_poly>::type>::result_kind>::type> exact_div<1u, long, int>(poly_int_pod<1u, long> const&, int)
	../../gcc/gcc/poly-int.h:2139
0x92f6f8 expand_expr_addr_expr_1
	../../gcc/gcc/expr.c:8041
0x9220ed expand_expr_addr_expr
	../../gcc/gcc/expr.c:8082
0x9220ed expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	../../gcc/gcc/expr.c:11237
0x7dfb37 expand_normal
	../../gcc/gcc/expr.h:285
0x7dfb37 precompute_register_parameters
	../../gcc/gcc/calls.c:967
0x7dfb37 expand_call(tree_node*, rtx_def*, int)
	../../gcc/gcc/calls.c:3998
0x7ccc0d expand_builtin(tree_node*, rtx_def*, rtx_def*, machine_mode, int)
	../../gcc/gcc/builtins.c:8337
0x921918 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
	../../gcc/gcc/expr.c:11005
0x92fb14 store_expr(tree_node*, rtx_def*, int, bool, bool)
	../../gcc/gcc/expr.c:5649
0x93194e expand_assignment(tree_node*, tree_node*, bool)
	../../gcc/gcc/expr.c:5432
0x7f4076 expand_call_stmt
	../../gcc/gcc/cfgexpand.c:2722
0x7f4076 expand_gimple_stmt_1
	../../gcc/gcc/cfgexpand.c:3691
0x7f4076 expand_gimple_stmt
	../../gcc/gcc/cfgexpand.c:3850
0x7f6ef5 expand_gimple_basic_block
	../../gcc/gcc/cfgexpand.c:5886
0x7fd1e6 execute
	../../gcc/gcc/cfgexpand.c:6509
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

-----------------------REDUCED TEST CASE-------------------------------------

struct {
  signed : 5;
  unsigned b : 7
} c[][1];
a() {}
d() {
  __transaction_relaxed { a(c[0][1].b); }
}

----------------------COMPILER BUILD OPTIONS---------------------------------

Using built-in specs.
COLLECT_GCC=build/gcc/xgcc
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++ --enable-lto --disable-bootstrap : (reconfigured) ../gcc/configure --enable-languages=c,c++ --enable-lto --disable-bootstrap
Thread model: posix
gcc version 9.0.1 20190214 (experimental) (GCC)
Comment 1 Jakub Jelinek 2019-02-14 13:58:17 UTC
Cleaned up testcase with -fgnu-tm:

struct S { int a : 5; unsigned b : 7; } c[1][1];

void
foo (int x)
{
}

void
bar (void)
{
  __transaction_relaxed {
    foo (c[0][1].b);
  }
}

Seems the TM code can't deal with bitfields properly:
  _15 = __builtin__ITM_RU1 (&c[0][1].b);
taking address of a bitfield is invalid.  Dunno what exactly it should do, perhaps tak address of the DECL_BIT_FIELD_REPRESENTATIVE and read the DECL_BIT_FIELD_REPRESENTATIVE instead and then BIT_FIELD_REF or something similar out of this?  And similarly deal somehow with the stores to bitfields (that is actually a read modify write cycle that likely would need to be exposed.

That said, -fgnu-tm is pretty much unmaintained for years, so maybe best would be to remove that support (e.g. I believe it doesn't handle internal functions at all, which appear commonly in the IL these days, doesn't handle various builtins correctly, etc.).
Comment 2 Richard Biener 2019-02-18 09:38:24 UTC
IIRC seeing dups with bitfield handling of TM.
Comment 3 Andrew Pinski 2021-09-23 02:00:03 UTC
Dup of bug 87118.

*** This bug has been marked as a duplicate of bug 87118 ***