[PATCH] Allow isDereferencablePointer to look through BitCast ConstantExprs
David Majnemer
david.majnemer at gmail.com
Wed Feb 4 10:37:51 PST 2015
================
Comment at: lib/IR/Value.cpp:502-511
@@ +501,12 @@
+
+ if (const BitCastInst *BC = dyn_cast<BitCastInst>(V)) {
+ SrcVal = BC->getOperand(0);
+ STy = BC->getSrcTy()->getPointerElementType();
+ DTy = BC->getDestTy()->getPointerElementType();
+ } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
+ if (CE->getOpcode() == Instruction::BitCast) {
+ SrcVal = CE->getOperand(0);
+ STy = SrcVal->getType()->getPointerElementType();
+ DTy = CE->getType()->getPointerElementType();
+ }
+ }
----------------
I think you can reduce the code duplication by using `Operator`: http://llvm.org/docs/doxygen/html/classllvm_1_1Operator.html
Perhaps:
if (const auto *BC = dyn_cast<ConcreteOperator<Operator, Instruction::BitCast>>(V)) {
SrcVal = BC->getOperand(0);
STy = BC->getSrcTy()->getPointerElementType();
DTy = BC->getDestTy()->getPointerElementType();
}
http://reviews.llvm.org/D7411
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list