Bug 42774 - [4.4/4.5 Regression] ICE in get_aligned_mem, at config/alpha/alpha.c:1484
Summary: [4.4/4.5 Regression] ICE in get_aligned_mem, at config/alpha/alpha.c:1484
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P4 normal
Target Milestone: 4.3.5
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-01-17 11:22 UTC by Debian GCC Maintainers
Modified: 2010-01-18 21:48 UTC (History)
2 users (show)

See Also:
Host:
Target: alpha-linux-gnu
Build:
Known to work:
Known to fail: 4.3.4 4.4.3 4.5.0
Last reconfirmed:


Attachments
preprocessed source (17.01 KB, application/x-gzip)
2010-01-17 11:22 UTC, Debian GCC Maintainers
Details
reduced test case (125 bytes, text/plain)
2010-01-17 19:52 UTC, Mikael Pettersson
Details
Patch to teach {,un}aligned_memory_operand about unaligned offsets (478 bytes, patch)
2010-01-17 20:25 UTC, Uroš Bizjak
Details | Diff
Patch for 4.3 and 4.4 branch. (478 bytes, patch)
2010-01-17 21:50 UTC, Uroš Bizjak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2010-01-17 11:22:27 UTC
works with 4.3 branch, fails with 4.4 branch and trunk 20100109, not seen with -O1

  Matthias

$ gcc-4.4 -c -g -O2 fs_ntfs.i
fs_ntfs.c: In function 'ntfs_getinfo':
fs_ntfs.c:102: internal compiler error: in get_aligned_mem, at config/alpha/alpha.c:1466
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Debian GCC Maintainers 2010-01-17 11:22:50 UTC
Created attachment 19633 [details]
preprocessed source
Comment 2 Mikael Pettersson 2010-01-17 19:08:54 UTC
Reproduced with an alpha-unknown-linux cross hosted on i686, built from gcc-4.4-20100112.
Comment 3 Uroš Bizjak 2010-01-17 19:47:35 UTC
Well, gcc would just generate invalid code without this assert.

Reduced test:

--cut here--
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
enum
{ FSYSHEADKEY_NULL =
    0, FSYSHEADKEY_FILESYSTEM, FSYSHEADKEY_MNTPATH, FSYSHEADKEY_BYTESTOTAL,
    FSYSHEADKEY_MINFSAVERSION, FSYSHEADKEY_MOUNTINFO, FSYSHEADKEY_ORIGDEV,
    FSYSHEADKEY_FSEXTEOPTRAIDSTRIDE };
typedef struct s_dico
{
}
cdico;
struct s_ntfsinfo
{
  u32 bytes_per_sector;
  u64 uuid;
};
enum
{ MSG_FORCE = 0, MSG_VERB1 = 1, MSG_VERB2 = 2, MSG_STACK = 3, MSG_DEBUG1 =
    4, MSG_DEBUG2 = 5, MSG_DEBUG3 = 6, MSG_DEBUG4 = 7, MSG_DEBUG5 = 8 };
ntfs_getinfo (cdico * d, char *devname)
{
  struct s_ntfsinfo info;
  char bootsect[512];
  int fd = -1;

  info.bytes_per_sector = ((u16) (*((u16 *) (bootsect + 0xB))));

  foo (info.bytes_per_sector);
  info.uuid = ((u64) (*((u64 *) (bootsect + 0x48))));
  fsaprintf (MSG_VERB2, 0, MSG_VERB2 >= 3, "fs_ntfs.c", __FUNCTION__, 107,
	     "bytes_per_sector=[%lld]\n", (long long) info.bytes_per_sector);
  fsaprintf (MSG_VERB2, 0, MSG_VERB2 >= 3, "fs_ntfs.c", __FUNCTION__, 109,
	     "uuid=[%016llX]\n", (long long unsigned int) info.uuid);
  dico_add_u64 (d, 0, FSYSHEADKEY_MINFSAVERSION,
		((u64)
		 ((((u64) 0 & 0xFFFF) << 48) + (((u64) 6 & 0xFFFF) << 32) +
		  (((u64) 4 & 0xFFFF) << 16) + (((u64) 0 & 0xFFFF) << 0))));
}
--cut here--

Problematic line is bootsect + 0xB that crosses SImode aligned load.
Comment 4 Mikael Pettersson 2010-01-17 19:52:34 UTC
Created attachment 19638 [details]
reduced test case

I'm attaching a really tiny test case. The trigger appears to be a 2-byte load from the stack that crosses the boundary between two adjacent 4-byte ints.
Comment 5 H.J. Lu 2010-01-17 19:57:03 UTC
Is this related to PR 39954?
Comment 6 Uroš Bizjak 2010-01-17 20:25:56 UTC
Created attachment 19640 [details]
Patch to teach {,un}aligned_memory_operand about unaligned offsets

Mikael, can you please test attached patch on your target? Unaligned offsets should be classified as unaligned memory access.
Comment 7 Mikael Pettersson 2010-01-17 21:36:25 UTC
Uros' proposed patch fixes the ICE in gcc-4.5. It doesn't apply to 4.4 though.
Comment 8 Uroš Bizjak 2010-01-17 21:50:25 UTC
Created attachment 19642 [details]
Patch for 4.3 and 4.4 branch.
Comment 9 Mikael Pettersson 2010-01-17 22:32:19 UTC
Uros' proposed fix for 4.4 and 4.3 fixes the ICE on both branches.

The original report stated that 4.3 doesn't ICE. A vanilla 4.3-20100103 definitely ICEs for me on the reduced test case.
Comment 10 Uroš Bizjak 2010-01-18 08:42:21 UTC
Patch at http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00958.html
Comment 11 uros 2010-01-18 17:04:44 UTC
Subject: Bug 42774

Author: uros
Date: Mon Jan 18 17:04:29 2010
New Revision: 156014

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156014
Log:
	PR target/42774
	* config/alpha/predicates.md (aligned_memory_operand): Return 0 for
	memory references with unaligned offsets.  Remove CQImode handling.
	(unaligned_memory_operand): Return 1 for memory references with
	unaligned offsets.  Remove CQImode handling.

testsuite/ChangeLog:

	PR target/42774
	* gcc.target/alpha/pr42774.c: New test.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/alpha/pr42774.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/alpha/predicates.md
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 12 uros 2010-01-18 17:46:30 UTC
Subject: Bug 42774

Author: uros
Date: Mon Jan 18 17:46:17 2010
New Revision: 156017

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156017
Log:
	PR target/42774
	* config/alpha/predicates.md (aligned_memory_operand): Return 0 for
	memory references with unaligned offsets.  Remove CQImode handling.
	(unaligned_memory_operand): Return 1 for memory references with
	unaligned offsets.  Remove CQImode handling.

testsuite/ChangeLog:

	PR target/42774
	* gcc.target/alpha/pr42774.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/alpha/pr42774.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/alpha/predicates.md
    trunk/gcc/testsuite/ChangeLog

Comment 13 uros 2010-01-18 21:44:46 UTC
Subject: Bug 42774

Author: uros
Date: Mon Jan 18 21:44:32 2010
New Revision: 156024

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156024
Log:
	PR target/42774
	* config/alpha/predicates.md (aligned_memory_operand): Return 0 for
	memory references with unaligned offsets.  Remove CQImode handling.
	(unaligned_memory_operand): Return 1 for memory references with
	unaligned offsets.  Remove CQImode handling.

testsuite/ChangeLog:

	PR target/42774
	* gcc.target/alpha/pr42774.c: New test.


Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.target/alpha/pr42774.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/alpha/predicates.md
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 14 Uroš Bizjak 2010-01-18 21:48:50 UTC
Fixed.