- Add missing cc clobber to __PCPU_ADD (which is currently unused).
- Allow the compiler the opportunity to marginally improve code generation from __PCPU_PTR by letting it figure out how to do the add (also removing the addition fixes a missing cc clobber).
- Quiet gcc -Warray-bounds by using constant operands instead of bogus memory references.
- Remove the struct s s temporaries, just cast through the type.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Test patch used to examine codegen:
(I also #if 0'd the __SEG_GS section of amd64's pcpu.h in order to check the changes.)
Disassembly before the patch for amd64 clang, amd64 gcc, i386 clang, and i386 gcc:
Disassembly after both D45826 and D45827 for amd64 clang, amd64 gcc, i386 clang, and i386 gcc:
diff -u1000 of the above before/after disassemblies:
By the way, I thought about also making these strict-aliasing safe with a union. It's straightforward and also gets rid of the casts. However, since we explicitly build with -fno-strict-aliasing, there's not much motivation. But in case you'd prefer that, I can tweak these patches.
Yes, I think you're right that the memory clobbers avoid any actual strict aliasing safety issue.
Gcc would still issue a diagnostic (despite the clobbers) if we didn't use -fno-strict-aliasing, but we do, so, it would be an exercise in suppressing a diagnostic that's not being issued. And I agree that sounds pointless.