[llvm-dev] getting code ranges of multiple blocks and prevent reordering?

Jay K via llvm-dev llvm-dev at lists.llvm.org
Tue May 29 12:52:36 PDT 2018


Hi. I'm very new to LLVM.

For reasons to do with custom exception handling, we have a need to check IP/PC at runtime against code ranges. This can encompass multiple logically adjacent blocks.

How to do this?

I'm guessing:
  insert a label at end of every block, takes it address, store that somewhere in our data; preferably as an offset from module or function start, but full address with relocation would work
  take address of start of every block, similarly
   That is not allowed as I understand for function-entry block, so add an extra dummy block as entry, that branches to actual start.

And then, somehow, ask LLVM not to reorder anything, with functions with such labels?

Does this make sense and can anyone fill in details?

Also, of course some reordering would be ok, as long as start of first block is first, and end of last block is last. The order of the blocks between doesn't matter.

I realize, there is another approach, something like assigning our own numbers  to scopes, have a local volatile integer, that we assign as we enter/leave scopes. i.e. "NT/x86 EH style". But that is a bigger and less efficient change compared to what we have (a non-LLVM less-optimizing codegen that lets us do what I describe).

Thank you,
 - Jay




More information about the llvm-dev mailing list