Iterating over all uses of a Function

Hi,

I try to iterate over all uses of a Function with the following
code (simplified):

for (Value::use_iterator UI = F->use_begin(), UE = F->use_end();
                         UI != UE; ++UI) {

    if (CallInst* I = dyn_cast<CallInst>(*UI)) {
    // do something interesting
    }
}

This works on Linux, but on Windows the dyn_cast fails, even
though the only use of F in that module is a 'call'. However,
dyn_cast<Instruction>(*UI) works, and returns a pointer
to "<Invalid operator>" instruction.

Is this a bug or am I doing something incorrectly?

Hi Mikhail,

Can you please attach a simple .bc file that is subject to this problem?

Anthony

Hi,

I try to iterate over all uses of a Function with the following
code (simplified):

This should work. Perhaps you have a memory stomper problem?

-Chris

Chris Lattner <clattner <at> apple.com> writes:

This should work. Perhaps you have a memory stomper problem?

Then I guess that this is a bug. I wrote a simple test pass
that exhibits this behaviour, and also manages to crash opt:

http://llvm.org/bugs/show_bug.cgi?id=4028

Hi Anthony,

Can you please attach a simple .bc file that is subject to this
problem?

See http://llvm.org/bugs/show_bug.cgi?id=4028

This is generated from the following C code:

void interesting_function();

int main() {
  interesting_function();
}

I use the SVN version of LLVM, built with current MinGW (3.4.5).