1
Fork 0

Replace the \01__gnu_mcount_nc to LLVM intrinsic for ARM

Current `-Zinstrument-mcount` for ARM32 use the `\01__gnu_mcount_nc`
directly for its instrumentation function.

However, the LLVM does not use this mcount function directly, but it wraps
it to intrinsic, `llvm.arm.gnu.eabi.mcount` and the transform pass also
only handle the intrinsic.

As a result, current `-Zinstrument-mcount` not work on ARM32.
Refer: https://github.com/namhyung/uftrace/issues/1764

This commit replaces the mcount name from native function to the
LLVM intrinsic so that the transform pass can handle it.

Signed-off-by: ChoKyuWon <kyuwoncho18@gmail.com>
This commit is contained in:
ChoKyuWon 2023-07-18 14:01:33 +09:00
parent ec362f0ae8
commit 3bd54c14bc
No known key found for this signature in database
GPG key ID: 165811B5F40647D8
8 changed files with 16 additions and 1 deletions

View file

@ -128,7 +128,10 @@ fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'ll Attr
// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
let mcount_name = cx.sess().target.mcount.as_ref();
let mcount_name = match &cx.sess().target.llvm_mcount_intrinsic {
Some(llvm_mcount_intrinsic) => llvm_mcount_intrinsic.as_ref(),
None => cx.sess().target.mcount.as_ref(),
};
attrs.push(llvm::CreateAttrStringValue(
cx.llcx,