[LLVMdev] DCE and external function

Duncan Sands baldrick at free.fr
Wed Oct 13 00:25:09 PDT 2010


>>> If I have:
>>>
>>> %x = call @externalFunc
>>> ... ; other codes where %x is not used
>>> ret ; assume void function
>>>
>>> and use dce optimization, will the call gets eliminated?
>>
>> only if the compiler can prove that the called function has
>> no side effects (such as modifying some global variables or
>> causing the program to exit).
>
> Wasn't there some efforts/investigation to support marking
> of (body-less) functions as 'pure'? Is this on the roadmap?

At the level of the original C source you can do this using gcc's "pure" and
"const" attributes.  At the level of LLVM IR, you can use the "readonly" and
"readnone" attributes.

Ciao,

Duncan.



More information about the llvm-dev mailing list