earlence
earlence

Reputation: 333

Array Detection in Function arg list LLVM opt pass

suppose I have the following LLVM IR

define void @foo(i32* %a, i32* %m) nounwind { ...

and I call foo by passing an array for the first arg and passing a variable's address for m. Now, I need to analyse the arg list of foo and determine which arg is passed an array, and which is simply a pointer address. I know that both are in fact addresses, but does LLVM provide some sort of metadata so that I can statically determine the type passed in.

Note: I am writing an opt pass

Upvotes: 0

Views: 139

Answers (1)

user2512323
user2512323

Reputation:

You probably can use the "pointer to array" type instead:

define void @foo([0 x i32]* %a, i32* %m)

Zero-sized array is perfectly valid and the llvm documentation says that:

There is no restriction on indexing beyond the end of the array implied by a static type

Upvotes: 1

Related Questions