Forum Discussion

Ben12's avatar
Ben12
Icon for New Contributor rankNew Contributor
3 years ago

NIOS IORD IOWR -O2 Optimzation Error

I have a problem with a NIOS II design, where code that incorporate IORD() and IOWR() no longer function correctly, when gcc is used with the -O2 compiler optimization.

I can work around the problem by wrapping my functions with #pragma calls, as shown below.

#pragma GCC push_options
#pragma GCC optimize ("O0")
my_function1()
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC optimize ("O0")
my_function2()
#pragma GCC pop_options
My questions are the following:
(1) Is this a known problem with GCC -O2 optimizations with the NIOS II processor's IORD() and IOWR() functions?
(2) Are there any other method I can use to prevent functional code errors, apart from wrapping my functions in a #pragma call?