[llvm-dev] Inst->replaceAllUsesWith and uses in ConstantExpr

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 23 11:40:19 PDT 2017


On 8/17/2017 12:01 PM, (IIIT) Siddharth Bhat via llvm-dev wrote:
> Sure. Essentially, I'm trying to replace malloc and free with custom 
> variants of these calls. However, in certain situations, we receive 
> these calls within bitcasts, for example,
>
> call void bitcast (void (i8*)* @free to void (%struct.fson_string*)*)
>     (%struct.fson_string* %13) #2
>
>
> A simple replaceAllUsesWith is not going to work, because the @free is 
> within a bitcast, which is a ConstantExpr. Unless I did something 
> wrong, this particular occurence of @free was not replaced even when I 
> called replaceAllUsesOf on the @free object.

You likely did something wrong; clang does this all the time, and it 
works.  See, for example, CodeGenModule::GetOrCreateLLVMGlobal.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170823/d7316c28/attachment.html>


More information about the llvm-dev mailing list