<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56337>56337</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Compiler crash on armv7 FreeBSD 13.1 (SIGBUS)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          clausecker
      </td>
    </tr>
</table>

<pre>
    Compiling the following minimised test case with the system C compiler at optimisation level `-O2` or higher causes a compiler crash:

```
extern int a, d, i[], e[];
_Noreturn int c(void);
void f() {
  d <= 3 ? 0 : c();
  for (int h = 1; h < d; ++h)
    i[h] = a % e[h - 1] / e[h];
}
```

This crash does not occur on other architectures and does not reproduce with Clang 12.0.1 from ports (though it does reproduce with clang 13.0.1 from ports), but also reproduces with Clang 14.0.0 from ports.  From the crash being due to a `SIGBUS`, I assume it's some sort of misaligned pointer that is being dereferenced (which wouldn't cause a crash on architectures where that is legal):

```
$ cc --version
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: armv7-unknown-freebsd13.1-gnueabihf
Thread model: posix
InstalledDir: /usr/bin
$ cc -O2 -c blosc2-zfp-4dfe58.c
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: cc -O2 -c blosc2-zfp-4dfe58.c
1.      <eof> parser at end of file
2.      Optimizer
#0 0x03c83de4 PrintStackTrace /usr/src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:573:7
#1 0x03c81d70 RunSignalHandlers /usr/src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:0:5
#2 0x03c2220c HandleCrash /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:76:5
#3 0x03c2220c CrashRecoverySignalHandler /usr/src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:389:51
#4 0x450ebfdc handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
cc: error: clang frontend command failed with exit code 138 (use -v to see invocation)
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: armv7-unknown-freebsd13.1-gnueabihf
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
cc: note: diagnostic msg: /tmp/blosc2-zfp-4dfe58-d33f94.c
cc: note: diagnostic msg: /tmp/blosc2-zfp-4dfe58-d33f94.sh
cc: note: diagnostic msg: 

********************
```

Here is the content of these two files:

## blosc2-zfp-4dfe58-d33f94.c

```
# 1 "<built-in>"
# 1 "blosc2-zfp-4dfe58.c"
extern int a, d, i[], e[];
_Noreturn int c(void);
void f() {
  d <= 3 ? 0 : c();
  for (int h = 1; h < d; ++h)
    i[h] = a % e[h - 1] / e[h];
}
```

## blosc2-zfp-4dfe58-d33f94.sh

```
# Crash reproducer for FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
# Driver args: "-O2" "-c" "blosc2-zfp-4dfe58.c"
# Original command:  "/usr/bin/cc" "-cc1" "-triple" "armv7-unknown-freebsd13.1-gnueabihf" "-emit-obj" "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "blosc2-zfp-4dfe58.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "cortex-a8" "-target-feature" "+vfp2" "-target-feature" "+vfp2sp" "-target-feature" "+vfp3" "-target-feature" "+vfp3d16" "-target-feature" "+vfp3d16sp" "-target-feature" "+vfp3sp" "-target-feature" "-fp16" "-target-feature" "-vfp4" "-target-feature" "-vfp4d16" "-target-feature" "-vfp4d16sp" "-target-feature" "-vfp4sp" "-target-feature" "-fp-armv8" "-target-feature" "-fp-armv8d16" "-target-feature" "-fp-armv8d16sp" "-target-feature" "-fp-armv8sp" "-target-feature" "-fullfp16" "-target-feature" "+fp64" "-target-feature" "+d32" "-target-feature" "+neon" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-feature" "-fp16fml" "-target-feature" "+strict-align" "-target-abi" "aapcs-linux" "-mfloat-abi" "hard" "-fallow-half-arguments-and-returns" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/usr/home/fuz/blosc2-crash" "-resource-dir" "/usr/lib/clang/13.0.0" "-O2" "-fdebug-compilation-dir=/usr/home/fuz/blosc2-crash" "-ferror-limit" "19" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "blosc2-zfp-4dfe58.o" "-x" "c" "blosc2-zfp-4dfe58.c"
 "/usr/bin/cc" "-cc1" "-triple" "armv7-unknown-freebsd13.1-gnueabihf" "-emit-obj" "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "blosc2-zfp-4dfe58.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "cortex-a8" "-target-feature" "+vfp2" "-target-feature" "+vfp2sp" "-target-feature" "+vfp3" "-target-feature" "+vfp3d16" "-target-feature" "+vfp3d16sp" "-target-feature" "+vfp3sp" "-target-feature" "-fp16" "-target-feature" "-vfp4" "-target-feature" "-vfp4d16" "-target-feature" "-vfp4d16sp" "-target-feature" "-vfp4sp" "-target-feature" "-fp-armv8" "-target-feature" "-fp-armv8d16" "-target-feature" "-fp-armv8d16sp" "-target-feature" "-fp-armv8sp" "-target-feature" "-fullfp16" "-target-feature" "+fp64" "-target-feature" "+d32" "-target-feature" "+neon" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-feature" "-fp16fml" "-target-feature" "+strict-align" "-target-abi" "aapcs-linux" "-mfloat-abi" "hard" "-fallow-half-arguments-and-returns" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/usr/home/fuz/blosc2-crash" "-O2" "-fdebug-compilation-dir=/usr/home/fuz/blosc2-crash" "-ferror-limit" "19" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "blosc2-zfp-4dfe58-d33f94.c"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtT47gS_jXhRaWUY-dCHvIACRmoml2ogdl9pBRJvuw4lkuSAzO_fj9JthNYIJzinPOwRRU4stTdanW3vm7JGyV-LpZqWxdlUWXE5pKkqizVg3vbFlWxLYwUxEpjCWdGkofC5p7M_DRWbsmScM8tNWGWqNo6DmYLVZFS7mRJBtOIXsd4EqVJXmQ5KDlrjDSE7Xm5ZiYfJGeDaDWIuuc0av_8q3y0UlekqCxhg3hJhHsUg8n5YLJyTdk2k_NAf_-70tI2LQsfxKc7VYBp3lO4d5JiAJ1kMGt7CRFkkCwHyYokaKxJhOeZF3DITGAoTdDppOfEkY8w6JtOOTQH8Tn-csfVshCvcA41PQMDycQrnhMKdtcdr0PH4VIGs9WLJgnPu7wwwYBEKJi1UnAE540mcIKyzuBM87ywksMczu6V2FNqWWslGt66dlkyeH4UD6PhiKRabUmttDVuoTZXTZaTwgbmZ4w8MCbPGN3i4ZxNA6-VRu25zJP5xmCLDtiGhKzdi4u0sLSNdCEpGkmscoabRrdXX86_3zpjYIIrwoxpthLqDeKZIUahbSCKqJS4kCyLrEIk1wr-gkVsjnCF3VqxUssU_xUHCZb6kBc8Jw-qKUUFcTZErAtYrwvs-tSiDzCy7GWWMmOlj5W34nkQjwnnhNKd1Ab7JfSutZTnt6vWnO1QMGvkNMuwvnGEZ95shtg-mK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