[cfe-dev] Avoiding removal of a builtin call

Renato Golin renato.golin at linaro.org
Tue May 20 06:57:24 PDT 2014


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