[LLVMdev] Iterating over all uses of a Function

Chris Lattner clattner at apple.com
Tue Apr 21 11:10:58 PDT 2009


On Apr 21, 2009, at 4:33 AM, Mikhail Glushenkov wrote:

> 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

>
>
> 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?
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list