LLVM is smart that it can synthesize llvm.memset, llvm.memcpy etc. from loops, which can be lowered into calls to memset, memcpy and so on. Is there an option that can disable this optimization? For some cases, I do not want the code to depend on libc.
Thanks in advance!
If you’re using just LLVM, you can simply not run optimizations like LoopIdiomRecognizer that synthesize these operations.
Assuming you mean clang+LLVM, you can use -ffreestanding to achieve most of what you want, but note that LLVM matches GCC in that it requires certain functions to have expansions available for linking. If that’s not workable for your target, you’ll need to modify clang itself to omit those optimizations.
GCC requires the freestanding environment provide
You can use -fno-builtin, if that suits your needs.