I have a function
void X(Object o)
{
....
}
When I compile it, I see, that clang changes its signature to
void X(Object* o)
It is inconvenient, because I use this function from some llvm IR code directly. How to forbid it from doing this optimization?
Edit: Minimal working example:
#include <stdio.h>
class Object
{
public:
Object();
~Object();
int* pointer;
};
void Function(Object o)
{
o.pointer = 0;
}
int main()
{
Object a;
Function(a);
return 0;
}
By the following command line:
clang++ tst.cpp -emit-llvm -O0 tst.cpp -S -std=c++11
The Function
is translated into:
define void @_Z8Function6Object(%class.Object* %o) nounwind uwtable {
%1 = getelementptr inbounds %class.Object* %o, i32 0, i32 0
store i32* null, i32** %1, align 8
ret void
}