<div dir="ltr"><div dir="ltr"><div dir="ltr">It sounds a bit like you're looking for code-coverage (and in particular branch-coverage)? ie. <a href="https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#branch-regions">https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#branch-regions</a> Or other fuzzer frameworks, such as using concolic testing?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 26, 2021 at 11:08 AM Johannes Doerfert via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Could you elaborate what you mean with "mark" here?<br>
<br>
You want to create a flow sensitive static analysis or profile which<br>
branch has been taken at runtime, or both?<br>
<br>
FWIW, if you tell LLVM x > 0, e.g., `__builtin_assume(x > 0)` in your <br>
source,<br>
the branches should be folded away.<br>
<br>
~ Johannes<br>
<br>
<br>
On 2/26/21 9:15 AM, Joseph via llvm-dev wrote:<br>
> Hey. I realize this question is a bit out-of-place, but I feel someone in<br>
> the LLVM community might've ran into a similar topic before.<br>
><br>
> I'd like to find a way to run LLVM IR and mark all branches taken, given a<br>
> specific input.<br>
><br>
> Take this example:<br>
><br>
> ```<br>
> int get_sign(int x) {<br>
> if (x == -1234) return -1234;<br>
> if (x < 0) return -1;<br>
> else return 1;<br>
> }<br>
> ```<br>
><br>
> It's clear that the `x == -1234` branch is useless if x > 0. Does the LLVM<br>
> project have a way of marking the taken branches, so that one can reason<br>
> about them later, possibly in an LLVM pass?<br>
><br>
> I do realize KLEE exists, but SMT solvers require quite a bit of "plugging"<br>
> of functions to limit the scope. Not to mention the path explosion that a<br>
> real binary would entail. What I was looking for was possibly an lldb/lli<br>
> mechanism to allow "marking" the taken branches, in a real execution<br>
> environment.<br>
><br>
> Has someone encountered such an issue before?<br>
><br>
> Many thanks<br>
><br>
> -- J<br>
><br>
><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>