[llvm] [BPF] expand mem intrinsics (memcpy, memmove, memset) (PR #97648)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 11:03:15 PDT 2024
yonghong-song wrote:
Thanks @eddyz87 I think the following change is good enough for now.
```
$ git diff
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index 7d91fa8bb824..005f6affaffd 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -29,6 +29,7 @@
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Scalar.h"
+#include "llvm/Transforms/Scalar/LoopIdiomRecognize.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
#include "llvm/Transforms/Utils/SimplifyCFGOptions.h"
#include <optional>
@@ -76,6 +77,9 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT,
Subtarget(TT, std::string(CPU), std::string(FS), *this) {
initAsmInfo();
+ // Add some comments here.
+ DisableLIRP::All = true;
+
BPFMCAsmInfo *MAI =
static_cast<BPFMCAsmInfo *>(const_cast<MCAsmInfo *>(AsmInfo.get()));
MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
```
Basically, LoopIdiomRecognizePass exposed DisableLIRP::All (for memcpy/memset) so other pass can disable this transformation. This should prevent original source code from generating a library func which later is inlined again.
Note that bpf program does not like library functions since it prevents verifier from doing its work.
https://github.com/llvm/llvm-project/pull/97648
More information about the llvm-commits
mailing list