[llvm] [BPF] expand mem intrinsics (memcpy, memmove, memset) (PR #97648)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 10:44:01 PDT 2024


eddyz87 wrote:

@yonghong-song , the memcpy is inserted by `LoopIdiomRecognizePass`.
It uses `TargetLibraryInfo` class to check if `memcpy` is available (see `LoopIdiomRecognize::runOnLoop`).
After some inspection I found two ways to customize `TargetLibraryInfo`:
- add function attributes of form `no-builtin-...` (see `explicit TargetLibraryInfo::TargetLibraryInfo` constructor);
- adapt `TargetLibraryInfo.cpp:initializeLibCalls()`.

Given that there are many builtins that we probably would like to disable, second option seems better.
On the other hand, I don't know what impact this would have on programs that use `memcpy`/`memmove`/`memset` explicitly.

There is also the following thing used by `LoopIdiomRecognizePass` in `LoopIdiomRecognize.h`:

```cpp
/// Options to disable Loop Idiom Recognize, which can be shared with other
/// passes.
struct DisableLIRP {
  /// When true, the entire pass is disabled.
  static bool All;

  /// When true, Memset is disabled.
  static bool Memset;

  /// When true, Memcpy is disabled.
  static bool Memcpy;
};
```

But this would only solve issue with loop idioms pass.

https://github.com/llvm/llvm-project/pull/97648


More information about the llvm-commits mailing list