Hi, On Mon, Oct 11, 2010 at 3:46 PM, Duncan Sands <baldrick at free.fr> wrote:> Hi leledumbo, > >> 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? Cheers, -Mahadevan.
>>> 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.
> No of course not. Nobody ever checks the return value of printf, for > example. :) > > The only special case is if you name your function something that exists > in the C standard library; if you name your function "malloc" we're > going to remove calls to it with unused results.OK, sounds I'm on the right way :)> 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.This makes things clearer. Thanks to all. -- View this message in context: http://old.nabble.com/DCE-and-external-function-tp29932485p29951053.html Sent from the LLVM - Dev mailing list archive at Nabble.com.