[llvm-dev] strdup vs __strdup?

carr27 via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 14 15:04:12 PDT 2015


For background, I'm writing a pass and would like to find all 
instructions that could allocate memory, but this question mainly 
concerns strdup.

I'm seeing that calls to strdup are getting replaced by calls to 
__strdup when I compile with -O2.  Can anyone tell me why and what the 
difference is?

The replacement is a minor issue for me because isAllocationFn doesn't 
return true for calls to __strdup (but it does for strdup). My current 
workaround is to check the name of every called function.

Also, if there are any other functions that are replaced (like strdup is 
with __strdup), that'd be useful information to me.

My test case is [1].  I'm getting the bitcode using Module.print inside 
my pass. [2] is without -O2 and [3] is with -O2.  My pass is in CodeGen 
in case that is relevant.


[1] http://pastebin.com/LedrcAE3
[2] http://pastebin.com/3hkgNu60
[3] http://pastebin.com/uS0uD0Lk

Maybe this has been asked before but it's difficult to Google :)

More information about the llvm-dev mailing list