I want to figure out whether a call to an llvm intrinsic or C standard library function would modify the contents of the memory pointed by the pointers passed to these functions as arguments.
I tried using the
onlyReadsMemory member function provided for the AAResults as well as CallBase classes but it always returns false.
It even returned false for Standard C functions like puts and printf.
Am I using these functions the wrong way or have I misunderstood the intended use of these functions?
Those are the right methods to use. They will work out of the box for intrinsics. For library calls, you first need to run the InferFunctionAttrs pass, which will infer attributes on libcalls.
Thanks for the reply. Could you please guide me on how I can ensure that the
InferFunctionAttrs pass runs before my pass? I tried running it like this:
opt -enable-new-pm=0 --function-attrs -S foo.ll -o foo.ll
opt -enable-new-pm=0 --my-pass -S foo.ll -o foo.ll
But the function
onlyReadsMemory still returns false for printfs.