mirror of https://github.com/ARMmbed/mbed-os.git
GCC: remove -fno-delete-null-pointer-checks
For GCC we're being cautious by passing the `-fno-delete-null-pointer-checks`. This option prevents some optimisation opportunities, so removing it can reduce code size. One particular optimisation loss occurs in `Callback` where a test similar to this occurs: extern void myfunc(); inline void foo(void (*fnptr)()) { if (fnptr) { do A; } else { do B; } }; foo(myfunc); With `-fno-delete-null-pointer-checks`, the compiler does not assume that `&myfunc` is non-null, and inserts the "null check" - seeing if the address is 0. But performing that test of the address is incorrect anyway - if myfunc actually could be at address 0, we'd still want to do A. Anyway, we do not have an equivalent option enabled for either Clang or IAR, and we have performed clean-ups avoiding issues with apparently-null vector tables in Clang already, for example #10534. Therefore it should(TM) be safe to remove the option for GCC. We do not have general data or code at address 0, only vectors are likely to be there, so it does not make sense to be globally restricting code generation for that.pull/12023/head
parent
888dfffabf
commit
ea2ec8d4f6
|
@ -4,7 +4,7 @@
|
|||
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
|
||||
"-fmessage-length=0", "-fno-exceptions",
|
||||
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
|
||||
"-MMD", "-fno-delete-null-pointer-checks",
|
||||
"-MMD",
|
||||
"-fomit-frame-pointer", "-Og", "-g3", "-DMBED_DEBUG",
|
||||
"-DMBED_TRAP_ERRORS_ENABLED=1"],
|
||||
"asm": ["-x", "assembler-with-cpp"],
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
|
||||
"-fmessage-length=0", "-fno-exceptions",
|
||||
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
|
||||
"-MMD", "-fno-delete-null-pointer-checks",
|
||||
"-MMD",
|
||||
"-fomit-frame-pointer", "-Os", "-g", "-DMBED_TRAP_ERRORS_ENABLED=1"],
|
||||
"asm": ["-x", "assembler-with-cpp"],
|
||||
"c": ["-std=gnu11"],
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
|
||||
"-fmessage-length=0", "-fno-exceptions",
|
||||
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
|
||||
"-MMD", "-fno-delete-null-pointer-checks",
|
||||
"-MMD",
|
||||
"-fomit-frame-pointer", "-Os", "-DNDEBUG", "-g"],
|
||||
"asm": ["-x", "assembler-with-cpp"],
|
||||
"c": ["-std=gnu11"],
|
||||
|
|
Loading…
Reference in New Issue