Peng Yu via llvm-dev
2019-Jan-23 17:13 UTC
[llvm-dev] option similar to -finstrument-functions but for code blocks
Hi, I'd like to track not just at the function level, but also at the code block level. For example, for a if-else statement, I want to know when the if-branch or else-branch is enter/exit. Is there a clang option similar to -finstrument-functions for code blocks? Alternatively, I could manually insert the code to the IR .ll file. I see the generated .ll use the following function when -finstrument-functions is enabled. Is there an equivalent function for code blocks? %1 = call i8* @llvm.returnaddress(i32 0), !dbg !10 -- Regards, Peng
Dean Michael Berris via llvm-dev
2019-Jan-24 12:37 UTC
[llvm-dev] option similar to -finstrument-functions but for code blocks
> On 24 Jan 2019, at 04:13, Peng Yu via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi, > > I'd like to track not just at the function level, but also at the code > block level. For example, for a if-else statement, I want to know when > the if-branch or else-branch is enter/exit. > > Is there a clang option similar to -finstrument-functions for code blocks? > > Alternatively, I could manually insert the code to the IR .ll file. > > I see the generated .ll use the following function when > -finstrument-functions is enabled. Is there an equivalent function for > code blocks? > > %1 = call i8* @llvm.returnaddress(i32 0), !dbg !10 >You’re probably looking for the “coverage” builds of clang which add instrumentation in the IR: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html (Details of the data you can get is at https://llvm.org/docs/CoverageMappingFormat.html). I’m not sure there’s something built into LLVM that makes that happen, but I suggest looking into what the coverage-instrumented .ll files look like when clang does it. Cheers -- Dean
David Greene via llvm-dev
2019-Jan-24 16:19 UTC
[llvm-dev] option similar to -finstrument-functions but for code blocks
Peng Yu via llvm-dev <llvm-dev at lists.llvm.org> writes:> I'd like to track not just at the function level, but also at the code > block level. For example, for a if-else statement, I want to know when > the if-branch or else-branch is enter/exit. > > Is there a clang option similar to -finstrument-functions for code blocks?Are you looking for code coverage or profile information (block execution counts)? Dean already replied with the code coverage information. LLVM has a profile instrumentation pass which is run with opt -profile-generate. This is gprof-style profiling. I don't know offhand which (if any) clang option is hooked up to -profile-generate. -David
Peng Yu via llvm-dev
2019-Jan-24 16:27 UTC
[llvm-dev] option similar to -finstrument-functions but for code blocks
On Thu, Jan 24, 2019 at 10:19 AM David Greene <dag at cray.com> wrote:> > Peng Yu via llvm-dev <llvm-dev at lists.llvm.org> writes: > > > I'd like to track not just at the function level, but also at the code > > block level. For example, for a if-else statement, I want to know when > > the if-branch or else-branch is enter/exit. > > > > Is there a clang option similar to -finstrument-functions for code blocks? > > Are you looking for code coverage or profile information (block > execution counts)? Dean already replied with the code coverage > information.Not really. I don't care really the number of times an instruction is called. I care about the control flow and I'd like to visualize it as a graph. cfg is static. I'd like something dynamic which only shows what is run. Of course, having the additional information about the count should be fine. But it is secondary.> LLVM has a profile instrumentation pass which is run with > opt -profile-generate. This is gprof-style profiling. I don't know > offhand which (if any) clang option is hooked up to -profile-generate. > > -David-- Regards, Peng