In my llvm jit project I needed to lookup BB addresses at execution time and then jump to the corresponding BB. A C++ routine called at runtime from IR finds the right BB, gets its BlockAddress and returns it as an i8*. The IR does an indirectbr on this value... Well, not really. The routine returns the address of a BlockAddress node. Is there any way to get the real runtime code address for the indirect jump at runtime? Thanks for any advice. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101211/b2d27a36/attachment.html>
On Sat, Dec 11, 2010 at 1:19 PM, Maurice Marks <maurice.marks at gmail.com> wrote:> In my llvm jit project I needed to lookup BB addresses at execution time and > then jump to the corresponding BB. A C++ routine called at runtime from IR > finds the right BB, gets its BlockAddress and returns it as an i8*. The IR > does an indirectbr on this value... > Well, not really. The routine returns the address of a BlockAddress node. Is > there any way to get the real runtime code address for the indirect jump at > runtime?If you're having trouble with the correctness of your program, don't use indirectbr; the semantics are tricky and it's usually unnecessary. The only advantage over a "switch" instruction is a slight performance boost for certain kinds of loops. -Eli
On Sat, Dec 11, 2010 at 4:19 PM, Maurice Marks <maurice.marks at gmail.com> wrote:> In my llvm jit project I needed to lookup BB addresses at execution time and > then jump to the corresponding BB. A C++ routine called at runtime from IR > finds the right BB, gets its BlockAddress and returns it as an i8*. The IR > does an indirectbr on this value... > Well, not really. The routine returns the address of a BlockAddress node. Is > there any way to get the real runtime code address for the indirect jump at > runtime?IIRC indirectbr isn't supported in the JIT: http://llvm.org/bugs/show_bug.cgi?id=6744 Our first cut for implementing Python generators was to simply put a switch in the entry block and number the re-entry points of the generator. On exit, we update the next entrance to use. Reid
Thanks very to all of you much for your advice. I think I can use a switch to do what I want, at least for now. I do like the idea of creating virtual entry points to a function with a switch. That solves a problem for us. thanks On Sun, Dec 12, 2010 at 10:25 AM, Reid Kleckner <reid.kleckner at gmail.com>wrote:> On Sat, Dec 11, 2010 at 4:19 PM, Maurice Marks <maurice.marks at gmail.com> > wrote: > > In my llvm jit project I needed to lookup BB addresses at execution time > and > > then jump to the corresponding BB. A C++ routine called at runtime from > IR > > finds the right BB, gets its BlockAddress and returns it as an i8*. The > IR > > does an indirectbr on this value... > > Well, not really. The routine returns the address of a BlockAddress node. > Is > > there any way to get the real runtime code address for the indirect jump > at > > runtime? > > IIRC indirectbr isn't supported in the JIT: > http://llvm.org/bugs/show_bug.cgi?id=6744 > > Our first cut for implementing Python generators was to simply put a > switch in the entry block and number the re-entry points of the > generator. On exit, we update the next entrance to use. > > Reid >-- Not sent from my Blackberry, Raspberry or Gooseberry! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101215/fde917b8/attachment.html>
Possibly Parallel Threads
- [LLVMdev] indirectbr/blockaddress question
- [LLVMdev] LLVM tries to remove labels used in blockaddress()
- [LLVMdev] LLVM tries to remove labels used in blockaddress()
- [LLVMdev] LLVM tries to remove labels used in blockaddress()
- [LLVMdev] LLVM tries to remove labels used in blockaddress()