[PATCH] D84913: [libFuzzer] Enable for SystemZ
Kostya Serebryany via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 09:20:11 PDT 2020
kcc added inline comments.
================
Comment at: compiler-rt/lib/fuzzer/FuzzerTracePC.h:198
+ if (LargeType Bundle = *reinterpret_cast<const LargeType *>(P)) {
+#if __BYTE_ORDER == __BIG_ENDIAN
+ Bundle = Bswap(Bundle);
----------------
iii wrote:
> kcc wrote:
> > please avoid #ifdefs inside functions.
> > If there is some logic that needs to depend on the platform, it needs to reside in a separate dedicated function.
> >
> > FuzzerBuiltins.h is probably the place for such a function.
> >
> > Also, what about
> > #include <endian.h>
> > uint64_t htole64(uint64_t host_64bits);
> > is that portable?
> >
> I think this might not work as expected on 32-bit systems. I'll add a separate function.
No strong preference.
I've just checked, on Linux x86_64: it inlines and works great.
Dunno if it will have portability issues.
```
% cat x.cc
#include <endian.h>
#include <stdint.h>
uint64_t foo(uint64_t x) {
return htole64(x);
}
% clang -O2 -S -o - x.cc -m32
movl 4(%esp), %eax
movl 8(%esp), %edx
retl
% clang -O2 -S -o - x.cc
movq %rdi, %rax
retq
```
`htobe64` also looks nice, it translates into one `bswapq` on 64-bit and two `bswapl` on 32-bit,
i.e. in your case this is what `htole64` will do.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84913/new/
https://reviews.llvm.org/D84913
More information about the llvm-commits
mailing list