Reputation: 147
I am using llvm DependenceAnalysisWrapperPass to obtain the dependence between two IR instructions. But it seems like this analysis only output dependence between load/store instructions, but not say dependence between a load and a arithmetic instructions. Is there any pass in LLVM can output a more comprehensive dependence among instructions?
For example:
%retval = alloca i32, align 4
%a = alloca i32, align 4
%b = alloca i32, align 4
%r = alloca i32, align 4
store i32 0, i32* %retval, align 4
store i32 1, i32* %a, align 4
store i32 2, i32* %b, align 4
%0 = load i32, i32* %a, align 4
%1 = load i32, i32* %b, align 4
%add = add nsw i32 %0, %1
store i32 %add, i32* %r, align 4
%2 = load i32, i32* %r, align 4
ret i32 %2
By using the DependenceAnalysisWrapperPass, it outputs the following dependency graph
It shows that the two load instructions depend on the two store instructions, respectively. However it does not show the dependency between, say, the two load instructions and the following add instruction. This is expected, since the code of DependenceAnalysisWrapperPass says that it only shows the dependence between store and load instructions. My question is that is there any pass available showing other dependences as well?
Upvotes: 0
Views: 982
Reputation: 9685
The source code shows the information you want.
Each instruction's operands are precisely those instructions (or other values) on which it depends. This is a general principle of LLVM. The pass you've seen exists because loads and stores are an exception. However, loads and stores are the only exception.
Upvotes: 1