Hi everyone,
I am having a small problem as follows, please help me:
Implement, using LLVM/Clang, to count the number of memory operations
executed in a given function (recording reads and writes of fields and
arrays elements) of C programs. Here is an example:
int* test(int* b, int* c) {
...
for (int i=0; i<10; i++) {
a[i] =b[i] + c[i];
}
return a;
}
After execution of the whole program, the output of the instrumentation
should return something like this for each method: "function test: reads
= 20; writes = 10".
Thank you very much!
Are you interested in counting access to any objects or only particular objects? If only particular objects: you can use C++ to create a class behaving like your array, but override operators to count usage. The rest of your program could be kept in C as it is, usually without modifications.
Guest
#4069416
> you can use C++ to create a class behaving > like your array, but override operators to count usage. That's nothing to do with instrumentation: instrumenting code does not require to change the sources.
... ok, but it would answer his question "how man reads/writes?"
Guest
#4069620
> ok, but it would answer his question "how man reads/writes?"
But this was not the question :-)
Apart from that the numer of reads / writes can be determined by just
looking at the function: "function test: reads = 20; writes = 10".
The question is: How to change Clang so that Clang can determine the
number of reads / writes for any input (program), either by statically
analyzing the input or by instrumenting the generated code without
changing its semantics.
In general, you don't even know the input to clang as you are writing a
specific analysis or transformaton, the given source is just a sample
code to explain the issue w.r.t. changing clang.
Guest
#4093976
Static analysis only will not help you:
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
Reply
Please log in before posting.