This patch disables frame pointer elimination and leaf frame pointer elimination when mcount instrumentation is requested ("-pg").
Currently we catch the case when -fomit-frame-pointer and -pg are explicitly used together, but we miss:
- Explicit use of -momit-leaf-frame-pointer.
- Defaults enabling mentioned optimizations on given optimization level or triple.
This also emits unused argument warnings when -fno-omit-frame-pointer or -mno-omit-leaf-frame-pointer are combined with -pg. It can be changed very simply, but I am not sure if this is desirable or not?
clang -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -pg
clang: warning: argument unused during compilation: '-fno-omit-frame-pointer'
clang: warning: argument unused during compilation: '-mno-omit-leaf-frame-pointer'