the case that store instruction does not have node
Hi.
In the following case, the store instruction which is corresponding to tag.a[i].a[j] = 1;
does not have psnode. (pta->getNode returns null)
I don't know why the instruction does not have node . Under what condition such case occurs ?
And what does it mean ?
Thanks
int i, j; struct { struct { int a[10]; int b; } a [10]; } tag; main() { tag.a[i].a[j] = 1; f(); }
Hi,
if an instruction does not have corresponding PSNode, it means that it can not keep any pointer. Therefore, it is OK that the store does not have a PSNode attached, as store instruction itself cannot hold a pointer value. Only loads, getelementptr, etc. can hold value (i.e. those instructions that return value to a register).
Example (output of ./llvm-slicer -c f -annotate=pta)
define i32 @main() #0 {
; PTR: null + 0
%1 = load i32, i32* @j, align 4
%2 = sext i32 %1 to i64
; PTR: null + 0
%3 = load i32, i32* @i, align 4
%4 = sext i32 %3 to i64
; PTR: tag + UNKNOWN
%5 = getelementptr inbounds [10 x %struct.anon.0], [10 x %struct.anon.0]* getelementptr inbounds (%struct.anon, %struct.anon* @tag, i32 0, i32 0), i64 0, i64 %4
; PTR: tag + UNKNOWN
%6 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %5, i32 0, i32 0
; PTR: tag + UNKNOWN
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %2
store i32 1, i32* %7, align 4
%8 = call i32 (...) @f()
ret i32 0
}
You can see that the pointers are in %6 and %7, but the store itself does not contain any pointer, because it is not of the form %val = store .... You can obtain pointers of its arguments, though (%7).
I see. I have to find source pointer by finding definition point of second operand. Thank you for your answer!
Exactly! No problem ;)