[cfe-dev] Avoiding removal of a builtin call

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue May 20 09:40:52 PDT 2014


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



More information about the cfe-dev mailing list