Skip to content

Commit ea2ec8d

Browse files
committed
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.
1 parent 888dfff commit ea2ec8d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

tools/profiles/debug.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
7-
"-MMD", "-fno-delete-null-pointer-checks",
7+
"-MMD",
88
"-fomit-frame-pointer", "-Og", "-g3", "-DMBED_DEBUG",
99
"-DMBED_TRAP_ERRORS_ENABLED=1"],
1010
"asm": ["-x", "assembler-with-cpp"],

tools/profiles/develop.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
7-
"-MMD", "-fno-delete-null-pointer-checks",
7+
"-MMD",
88
"-fomit-frame-pointer", "-Os", "-g", "-DMBED_TRAP_ERRORS_ENABLED=1"],
99
"asm": ["-x", "assembler-with-cpp"],
1010
"c": ["-std=gnu11"],

tools/profiles/release.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"-Wno-unused-parameter", "-Wno-missing-field-initializers",
55
"-fmessage-length=0", "-fno-exceptions",
66
"-ffunction-sections", "-fdata-sections", "-funsigned-char",
7-
"-MMD", "-fno-delete-null-pointer-checks",
7+
"-MMD",
88
"-fomit-frame-pointer", "-Os", "-DNDEBUG", "-g"],
99
"asm": ["-x", "assembler-with-cpp"],
1010
"c": ["-std=gnu11"],

0 commit comments

Comments
 (0)