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

[hexagon] loop-3c fails with -Oz #133241

Open
androm3da opened this issue Mar 27, 2025 · 3 comments
Open

[hexagon] loop-3c fails with -Oz #133241

androm3da opened this issue Mar 27, 2025 · 3 comments

Comments

@androm3da
Copy link
Member

androm3da commented Mar 27, 2025

This program (reduced slightly from llvm-test-suite's SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c) fails with -Oz but passes with -O0, -O2, -Os.

$ /local/mnt/workspace/install/clang+llvm-19.1.5-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/hexagon-unknown-linux-musl-clang -Oz -o loop3c -static ~/tmp/loop3c.c -Wno-deprecated-non-prototype -Wno-implicit-int -Wno-implicit-function-declaration
/usr2/bcain/tmp/loop3c.c:17:1: warning: non-void function does not return a value [-Wreturn-type]
   17 | }
      | ^
1 warning generated.
$ /local/mnt/workspace/install/clang+llvm-19.1.5-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/qemu-hexagon ./loop3c 
Aborted (core dumped)

#include <limits.h>

void * a[255];

f (m)
{
  int i;
  int sh = 0x100;
  i = m;
  do
    { 
      a[sh >>= 1] = ((unsigned)i << 3)  + (char*)a;
      i += 4;
    }
  while (i < INT_MAX/2 + 1 + 4 * 4);
}

main ()
{
  a[0x10] = 0;
  a[0x08] = 0;
  f (INT_MAX/2 + INT_MAX/4 + 2);
  if (a[0x10] || a[0x08])
    abort ();
}

@llvmbot
Copy link
Member

llvmbot commented Mar 27, 2025

@llvm/issue-subscribers-backend-hexagon

Author: Brian Cain (androm3da)

This program (reduced slightly from llvm-test-suite's `SingleSource/Regression/C/gcc-c-torture/execute/loop-3c.c`) fails with -Oz but passes with -O0, -O2, -Os.
#include &lt;limits.h&gt;

void * a[255];

f (m)
{
  int i;
  int sh = 0x100;
  i = m;
  do
    { 
      a[sh &gt;&gt;= 1] = ((unsigned)i &lt;&lt; 3)  + (char*)a;
      i += 4;
    }
  while (i &lt; INT_MAX/2 + 1 + 4 * 4);
}

main ()
{
  a[0x10] = 0;
  a[0x08] = 0;
  f (INT_MAX/2 + INT_MAX/4 + 2);
  if (a[0x10] || a[0x08])
    abort ();
}

@androm3da
Copy link
Member Author

cc @aankit-quic

@aankit-ca
Copy link
Contributor

Looking into this

@androm3da androm3da changed the title [hexagon] loop-3c fails with -Os [hexagon] loop-3c fails with -Oz Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants