<div dir="ltr">Thanks very much for looking at this.<div><br></div><div>Given the comments on this proposal from Peter on llvmdev, I've changed this mechanism a fair bit. I just posted a patch to llvm-commits that gives one option that uses intrinsics only for the jmp-statement lowering. And I'm going to revise that patch as per more comments from Peter to do the actual generation in the AsmPrinter. So, you can consider this patch obsolete. :)</div>

<div><br></div><div>Tom</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 3, 2014 at 4:58 AM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Seems interesting, haven't looked too much, but I'm in favor of<br>
anything that stops people from writing inline asm from passes :)<br>
<br>
Nick? Chris?<br>
<br>
-eric<br>
<div><div class="h5"><br>
On Thu, Mar 20, 2014 at 4:15 PM, Tom Roeder <<a href="mailto:tmroeder@google.com">tmroeder@google.com</a>> wrote:<br>
> On Thu, Mar 20, 2014 at 2:37 PM, Tom Roeder <<a href="mailto:tmroeder@google.com">tmroeder@google.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> This patch adds an intrinsic for creating jump-instruction table entries<br>
>> of the form:<br>
>><br>
>>   .type f_JT,@function<br>
>>   f_JT:<br>
>>     jmp f@PLT<br>
>><br>
>> It adds an intrinsic void @llvm.jump.instr.table.entry(i8*) and X86<br>
>> backend support for this intrinsic. The intrinsic takes a bitcast function<br>
>> pointer as input and generates the jump-instruction table entry. Note that<br>
>> while jump tables are supported in CodeGen, they are a different kind of<br>
>> jump table, AFAICT: one that uses indices rather than one that contains jump<br>
>> instructions.<br>
>><br>
>> This intrinsic would allow me to remove the inline assembly that I<br>
>> currently use for control-flow integrity (CFI), as discussed on llvmdev;<br>
>> these intrinsics would be generated by the CFI pass along with declarations<br>
>> of the jump-table functions (required because the CFI pass replaces<br>
>> address-taken functions with the address of the _JT function).<br>
>><br>
>> I couldn't find any way to do this above the arch-specific Targets, given<br>
>> that it violates the IR branch semantics of jumping to a block; and even so,<br>
>> I had to add a check to one of the X86 optimizations that was assuming that<br>
>> all JMP_4 instructions had a MachineBasicBlock as an operand.<br>
>><br>
>> The patch also adds another kind of label, JUMP_FUNCTION_LABEL, which<br>
>> produces a label that looks like the start of a function (with MCSA_Global<br>
>> and sometimes MCSA_ELF_TypeFunction). So, the intrinsic lowers to a<br>
>> JUMP_FUNCTION_LABEL and a JMP_4.<br>
>><br>
>> I was able to do much of the work in the target-independent portions of<br>
>> the code, so I don't think it will take much effort to add support to some<br>
>> other architectures (like ARM), and I intend to do that if this patch is<br>
>> acceptable.<br>
>><br>
>> One question: what's the right way to do the mangling (the "_JT") for the<br>
>> jump-table functions? For my purposes in CFI, I'd like to have a way of<br>
>> naming these jump entries that a pass at the IR level could also discover or<br>
>> reproduce. Is there a standard mangling facility for specialized suffixes?<br>
>><br>
>> Please let me know what you think.<br>
>><br>
>> Thanks,<br>
>><br>
>> Tom<br>
><br>
><br>
> Just realized that there were a few line-length violations that I hadn't<br>
> cleaned up in the code. Here's a slightly tweaked patch.<br>
><br>
> Tom<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
</blockquote></div><br></div>