Mohannad Ismail
Mohannad Ismail

Reputation: 23

Detecting free function inside a "combined" LLVM IR instruction?

I can easily find free in this IR call instruction with getCalledFunction():

call void @free(i8* %10) #4, !dbg !53 

However, I can't seem to know how to find it in this call instruction:

%call7 = call i32 bitcast (i32 (...)* @free to i32 (%struct.Bar*)*)(%struct.Bar* %7), !dbg !56

This instruction is combining a BitCast with a call instruction. I am not sure if "combining" is the proper phrase, but nevertheless, how can I detect free here?

I tried dyn_cast to a Bitcast and it isn't. I even used getCalledOperand() first and tried casting the Value I get from it to a BitCast and it still isn't detecting it. I would appreciate any help with this.

Thanks!

Upvotes: 1

Views: 137

Answers (1)

Mohannad Ismail
Mohannad Ismail

Reputation: 23

@arnt answered this in the comments, so I'm adding the answer for everyone else.

@arnt: The first argument to the call is a ConstantExpr, returned by getBitCast. cast(foo)->getOperand(0) will return the free.

Upvotes: 1

Related Questions