<div dir="ltr">Everyone else has said good/important things here, but for the original problem I'm not quite sure why you were trying to search through to find the uses, rather than walking the Function's use list?<br><br>- David</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 21, 2015 at 9:11 PM, Russell Wallace via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I need to track down all pointers anywhere in a module that could be pointing to functions (because some of the optimizations I want to do, require either identifying every use of a function, or conservatively identifying when such cannot be done).<br><br>A starting point is to look at all the global variables:<br><br>  for (auto &G : M.globals())<br>    for (auto &V : G.operands())<br>      if (auto F = dyn_cast<Function>(V))<br><br>Of course, instructions can also refer to functions, both as direct calls and otherwise:<br><br>  for (auto &F : M) {<br>    for (auto &I : inst_range(F)) {<br>      for (auto &V : I.operands())<br>        if (auto F = dyn_cast<Function>(V))<br><br>But there are other things as well, for example it seems there is something called a personality function that can be a pointer to another function, so need to add that<br><br>    if (F.hasPersonalityFn())<br><br>It seems there are other things called prefix data and prologue data, which are pointers to constants, which could contain pointers to functions, so would need to include those as well.<br><br>Am I correct in thinking that prefix data and prologue data will not be included in the global variables list, so do need special handling?<br><br>Could they be recursive? That is, could those constants contain pointers to other constants... which end up containing pointers to functions... such that none of the intermediate constant objects are in the global variable list?<br><br>Is there anything else I'm missing?<br></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>