[clang] [llvm] [memprof] Add memprof options as a clang frontend flag (PR #128615)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 09:17:38 PST 2025


ellishg wrote:

> Not opposed to adding this as a clang driver flag especially if it is needed for something other than testing/debugging, however, you could presumably always add the exported symbol when -fmemory-profiler is specified (or does the linker give an error if the specified symbol doesn't exist?).

Yeah, the linker will fail if the symbol doesn't exist.
```
Undefined symbols for architecture arm64:
  "does_not_exist", referenced from:
      <initial-undefines>
ld: symbol(s) not found for architecture arm64
```

However, right now we invariantly define the `__memprof_default_options_str` symbol and I could keep it that way.

https://github.com/llvm/llvm-project/blob/7ffeab3121c984cc00f79b0a78f372a4f7526e3b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp#L568-L580

It would be much more simple to invariantly add the `-exported_symbol ___memprof_default_options_str` flag. I'll put up a PR for review

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


More information about the llvm-commits mailing list