Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

probe for broken restrict #141

Closed
rurban opened this issue Sep 8, 2019 · 2 comments
Closed

probe for broken restrict #141

rurban opened this issue Sep 8, 2019 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rurban
Copy link
Contributor

rurban commented Sep 8, 2019

with -O2 and inlining or loop-unrolling restrict is broken since gcc 5 and clang 6 until now.

in clang bug added with llvm r305938
rust-lang/rust#54878
https://bugs.llvm.org/show_bug.cgi?id=39282
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87609

Add a m4 probe and undefine it then.

@rurban rurban self-assigned this Sep 8, 2019
@rurban rurban added the bug Something isn't working label Sep 8, 2019
@rurban rurban changed the title preobe for broken restrict probe for broken restrict Sep 8, 2019
@rurban
Copy link
Contributor Author

rurban commented Sep 8, 2019

Something like this:

AC_DEFUN([AX_RESTRICT],
[
AC_CACHE_CHECK([for restrict usability], [ax_cv_restrict_usable], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
void copy(int * restrict to, int * restrict from) {
	*to = *from;
}
void test(int *a, int *b) {
	for (int i = 0; i < 4; i++) {
		copy(&b[i & 1], &a[i & 1]);
	}
}
int main() {
	int ary[] = {0, 1, 2};
	test(&ary[1], &ary[0]);
	#printf("%d %d %d\n", ary[0], ary[1], ary[2]);
	return ary[0] == 2;
}
# 2 2 2 is correct
# 1 2 2 wrong
]], [[ax_cv_restrict_usable=restrict]], [[ax_cv_restrict_usable=]])])
])
    if test -z $ax_cv_restrict_usable; then
      AC_MSG_RESULT([no])
      AC_DEFINE_UNQUOTED(restrict, $ax_cv_restrict_usable, [If restrict is usable with this compiler])
    else
      AC_MSG_RESULT([yes])
    fi
]) dnl AX_RESTRICT

rurban added a commit that referenced this issue Sep 8, 2019
new AX_RESTRICT probe.
Closes GH #141
@rurban rurban added this to the 0.9 milestone Sep 8, 2019
rurban added a commit that referenced this issue Sep 8, 2019
new AX_RESTRICT probe.
rust reports gcc broken from 5 - 10, but I can only confirm
clang 6-8 failing. gcc should not be used since 9 for other reasons.
Disabled since we don't have short restrict loops yet.

Closes GH #141
@rurban
Copy link
Contributor Author

rurban commented Sep 9, 2019

For now I disabled it, as I don't trust the restrict check (e.g. gcc-8 passes), but removed restrict from two suspicious candidate functions in decode_r2007. copy_bytes_2, copy_bytes_3.

@rurban rurban closed this as completed Sep 9, 2019
rurban added a commit that referenced this issue Dec 25, 2019
re-format docs: autoconf-archive is pretty strict
gcc-9.2 on fedora has it fixed.

enable it.  we do have several small inlined functions with loops on arrays,
so it might affects us. See GH #141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant