[llvm-dev] Using target-specific flags register directly in LLVM
Taras Zakharko via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 2 03:49:50 PDT 2019
I have originally posted this on StackOverflow (https://stackoverflow.com/questions/58084302/reading-and-producing-an-extra-return-value-in-flags-in-llvm <https://stackoverflow.com/questions/58084302/reading-and-producing-an-extra-return-value-in-flags-in-llvm>), but there were no replies, so I am trying my luck here.
I was watching Herb Sutter's talk on CppCon 2019, and one idea is to use control flag register bits to mark that an exception has been produced during a function call. E.g. (assuming x86 target) a function that raises an error could emit a stc instruction just before returning, and the caller could execute a conditional jump immediately after it returns to check if an error should be handled. It's smart, its efficient (much better than returning the condition flag in a separate register), and it's simple.
However, how would one go about implementing something like this within LLVM? I suppose that one can use MachineBasicBlock to emit flag set intructions, but does one have a guarantee that LLVM won't insert an instruction afterwards that might change the flag value? Also, how would one test for the flag value and jump to a LLVM IR block?
Note that my motivation is purely curiosity. I am not actually working on a compiler — I just want to know how these things work.
Thank you,
Taras
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191002/c70f444f/attachment.html>
More information about the llvm-dev
mailing list