Polyspace "Maximum Stack Usage" calculation on ARM systems wrong

조회 수: 6 (최근 30일)
Mario
Mario 2023년 1월 25일
편집: Anirban 2023년 2월 3일
Hi,
I'm wonder about the Maximum Stack Usage results in Polyspace, because they are not divisible by 4, e.g.73 bytes. I've configured -align=32 and -target=arm but this does not help. I'm pretty sure that the target compiler is using for stack allocation always 4 bytes, even if I use a byte, because of architecture needs.
I'm missing some configuration in Polyspace?
Thank you in advance.
Best Mario

답변 (1개)

Anirban
Anirban 2023년 2월 3일
편집: Anirban 2023년 2월 3일
Hi,
-target=arm uses these settings (for the armcc compiler for instance):
As you can see, char is 1 byte for this target. The alignment applies only to char-s embedded in a structure and not to isolated char-s. Let's take this example:
typedef struct {
char charVal;
int intVal;
}Record;
Record globalRecord;
void init (void) {
Record localRecord = globalRecord;
}
Here, if you calculate stack usage of the function init with these options:
-main-generator -main-generator-calls unused -align 8 -stack-usage
You see that the stack usage is 5 (char = 1 + int = 4).
If you change to:
-main-generator -main-generator-calls unused -align 32 -stack-usage
You see that the stack usage is 8 (multiple of 4, as you expect). 3 additional bytes were added as padding for storage.
But in either case, if there is an individual char not embedded in an aggregate type, it contributes 1 byte. The requirement for alignment does not apply.

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by