[cfe-dev] Avoiding removal of a builtin call
Rafael EspĂndola
rafael.espindola at gmail.com
Tue May 20 09:57:06 PDT 2014
In particular, the attached patch seems to work.
On 20 May 2014 12:40, Rafael EspĂndola <rafael.espindola at gmail.com> wrote:
> The problem I think is that llvm.write_register.i64 is being marked
> readnone. We don't have physical registers as first class items in
> llvm, so as a small hack we probably need to have doesNotAccessMemory
> return false for llvm.write_register (i.e., don't add ReadNone to it).
>
> On 20 May 2014 09:57, Renato Golin <renato.golin at linaro.org> wrote:
>> Hi Reid, Rafael,
>>
>> I'm having trouble keeping the call to @llvm.write_register() in the
>> IR on higher levels of optimization.
>>
>> At O0:
>>
>> define void @set_stack_pointer_addr(i64 %addr) #0 {
>> entry:
>> %addr.addr = alloca i64, align 8
>> store i64 %addr, i64* %addr.addr, align 8
>> %0 = load i64* %addr.addr, align 8
>> call void @llvm.write_register.i64(metadata !0, i64 %0)
>> ret void
>> }
>>
>> At O1:
>>
>> define void @set_stack_pointer_addr(i64 %addr) #0 {
>> entry:
>> ret void
>> }
>>
>> I tried marking the function (or the call) with "builtin" attribute,
>> but the validation fails:
>>
>> Attribute 'builtin' only applies to functions!
>> void (metadata, i64)* @llvm.write_register.i64
>> Attribute 'builtin' only applies to functions!
>> call builtin void @llvm.write_register.i64(metadata !0, i64 %0)
>>
>> Is there a way to avoid that call from being removed without marking
>> the symbol as extern or other tricks?
>>
>> cheers,
>> --renato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140520/8ee56a67/attachment.obj>
More information about the cfe-dev
mailing list