[ARMCLANG 6.16]: [Cortex-M] Code generation with only privileged instructions

Hi,

Query:

Is there a way to generate object code that avoids using unprivileged instructions - `ldrbt`, `ldrsht`, `ldrt` - using ARMCLANG compiler (version 6.16) ?

Some light on how the compiler chooses to generate one of the two variants (privileged / unprivileged ) instructions for a given code would also be helpful.


Background:

We have a specific case where we see that an application using a library built using ARMCLANG for Cortex-M55 is crashing on our test board.

On debugging the root cause for the crash, we see that the crash is happening at a unprivileged access (ldrbt, ldrsht, ldrt) ARM instruction.

The same library(source) from GCC build works perfectly fine.

We have another observation with ARMCLANG build.

When we break the build steps: a particular C source file is converted to assembly first (using ARMCLANG again) and converted to object code later, the resulting library build does not have unprivileged access instructions and works without any crash.


TL;DR - Same source compiled with GCC build works fine whereas ARMCLANG build produces a crash - suspecting unprivileged access ARM instructions to be root cause. Any suggestions on avoiding such instructions in build is highly appreciated.


Thanks!