Using isConfused() method for LLVM Dependence Analysis


I am trying to find out instances of confused dependencies in my program. According to LLVM's doxygen page, 'confused dependencies' are detected by function isConfused() - Returns true if this dependence is confused (the compiler understands nothing and makes worst-case assumptions) (

For the following code snippet:

   for (int i = 0; i < 10; i++)
        a = 1;
        for (int j = 0; j < 9; j++)
              b = 2;
              for (int k = 0; k < 8; k++)
                      c = 3;
We are constructing dependencies between the corresponding IR of the above code and checking whether it is confused or not:

   store i32 1, i32* @a, align 4
   store i32 2, i32* @b, align 4
Confused Dependence or Not: 1

Since the variables 'a' and 'b' are in different memory locations, why is LLVM's isConfused method gives us True?


Are a, b and c globals in this example? How are you running this?

I believe depends() will return a pointer to a Dependence (technically a unique pointer to a Dependence), which should be nullptr if there are no dependencies, such as these cases that should be no-alias.

Confused dependencies are expected to come from cases where we don't know the relationship between pointers. Such as this where we don't know the relationship between a and b:
void test(int * a, int * b, int n)
  for (int i = 0; i < n; i++)
    a[i] = 1;
    b[i] = 2;