getting object from BitCastInst?

My pass is looking at StoreInsts acting on global variable that happen
to be function pointers. From these StoreInsts I would like to get
useful information(the function used if a direct assignment, function
pointer used, etc) from the getValueOperand() method. Looking through
several examples I see that this can return several things like:
GlobalVariable, Function, LoadInst or BitCastInst depending on how
much "indirection" is used.

In the case of BitCastInst my dump shows "%ptr.addr = alloca i8*,
align 8", I would like to isolate this just to "ptr". Ive tried doing
another dyn_cast to AllocaInt, but I couldn't find any relevant
methods. How Can I do this?

                                        BitCastInst *bitcastRHS =
dyn_cast<BitCastInst>(rhs);
          if(bitcastRHS != NULL) {
            LoadInst *load = dyn_cast<LoadInst>(bitcastRHS->getOperand(0));
            if(load != NULL) {
              rhs = load->getPointerOperand();
              rhs->dump();
            }
          }

My pass is looking at StoreInsts acting on global variable that happen
to be function pointers. From these StoreInsts I would like to get
useful information(the function used if a direct assignment, function
pointer used, etc) from the getValueOperand() method. Looking through
several examples I see that this can return several things like:
GlobalVariable, Function, LoadInst or BitCastInst depending on how
much "indirection" is used.

In the case of BitCastInst my dump shows "%ptr.addr = alloca i8*,
align 8", I would like to isolate this just to "ptr". Ive tried doing
another dyn_cast to AllocaInt, but I couldn't find any relevant
methods. How Can I do this?

First, remember that you can strip away pointer casts by using the stripPointerCasts() method of llvm::Value. So, instead of using the code you have below, you can write:

if (LoadInst * load = dyn_cast<LoadInst>(rhs->stripPointerCasts()) {
     ...
}

Second, your question about the alloca is confusing. In the instruction:

%ptr.addr = alloca i8*, align 8

... there is no SSA value named %ptr that is an operand of the alloca.

I'm guessing that you're trying to find the name of the C variable for which the alloca was generated when compiling from C source code to LLVM IR. To do that, you'll need to use LLVM debug metadata.

-- John T.