[llvm-dev] 答复: 答复: How to add new arch for llvm-cov show?
xuruobin via llvm-dev
llvm-dev at lists.llvm.org
Wed Jan 23 23:36:32 PST 2019
1. The definition is from llvm/Supprot/ELF.h. But this machine information(e_machine) is given to compiler at lib/MC/ELFObjectWriter.cpp. I greped the whole llvm project and found that e_machine was assigned at only two files. One was lib/MC/ELFObjectWriter.cpp(there was an comment said “e_machine=target”) and the other was tools/obj2yaml/elf2yaml.cpp(GDB stopped only at the former one when using x86_64 llvm-cov so I thought it was MC provide this e_machine information to compiler).
2. New error was “Failed to load coverage: No coverage data found” since the compiler cannot get NamesSection(at loadBinaryFormat in CoverageMappingReader.cpp). I thought it was my ldscript problem because I put __llvm_prf_names, __llvm_prf_cnts, __llvm_prf_data and __llvm_prf_vnds inside .rodata section. Compiler checked .rodata but not things inside .rodata. What’s the right position to put these 4 __llvm_prf_* sections?
发件人: vsk at apple.com [mailto:vsk at apple.com] 代表 Vedant Kumar
发送时间: 2019年1月24日 0:12
收件人: xuruobin <xuruobin at huawei.com>
抄送: vsk at apple.com; llvm-dev at lists.llvm.org; Yuchao (Michael) <michael.yuchao at huawei.com>
主题: Re: 答复: [llvm-dev] How to add new arch for llvm-cov show?
On Jan 23, 2019, at 1:24 AM, xuruobin <xuruobin at huawei.com<mailto:xuruobin at huawei.com>> wrote:
The program didn't pass the checking "OF->getArch() != Triple(Arch).getArch()" loadBinaryFormat in CoverageMappingReader.cpp and returned an error. It's because "OF->getArch()" returned null and "Triple(Arch).getArch()" returned XXXX(name of my arch).
The returned value of " OF->getArch()" is decided by " EF.getHeader()->e_machine" but I found "e_machine" is defined somewhere in MCAssembler
I haven’t double-checked, but I thought this definition came from llvm/Support/ELF.h?
(My compiler uses binutils as assembler) . Although I make some hacks to pass this checking, I still get other errors. So my problem is whether llvm-cov has to work with MCAssembler and is it possible to do it with binutils?
Coverage support should be / is largely compatible with binutils, but you may have to watch out for this BFD bug: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#drawbacks-and-limitations
What is the error you see?
发件人: vsk at apple.com<mailto:vsk at apple.com> [mailto:vsk at apple.com]
发送时间: 2019年1月23日 1:24
收件人: xuruobin <xuruobin at huawei.com<mailto:xuruobin at huawei.com>>
抄送: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>; Yuchao (Michael)
<michael.yuchao at huawei.com<mailto:michael.yuchao at huawei.com>>
主题: Re: [llvm-dev] How to add new arch for llvm-cov show?
On Jan 21, 2019, at 5:21 PM, xuruobin via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>>
I'm trying to support llvm-cov for a new architecture and I have successfully
built compiler-rt for my arch. Following steps shown in
https://clang.llvm.org/docs/SourceBasedCodeCoverage.html , I encountered
an error for the last step(step of llvm-cov show).
The command line was (supposed my arch is XXXX)
"llvm-cov show -arch=XXXX ./foo -instr-profile=foo.profdata"
and the error was
"Failed to load coverage: No object file for requested architecture."
I think I should add my arch information to somewhere(maybe an llvm-cov
support list?) but I don't know where to add these information. Can
someone give me some suggestions?
You’ll need to teach libObject about this architecture. Specifically, the
coverage reader checks that calling getArch() on a loaded ObjectFile matches
Triple(Arch).getArch() (see loadBinaryFormat in
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev