[llvm] r210205 - Add a Constant version of stripPointerCasts.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jun 4 12:01:49 PDT 2014
Author: rafael
Date: Wed Jun 4 14:01:48 2014
New Revision: 210205
URL: http://llvm.org/viewvc/llvm-project?rev=210205&view=rev
Log:
Add a Constant version of stripPointerCasts.
Thanks to rnk for the suggestion.
Modified:
llvm/trunk/include/llvm/IR/Constant.h
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
Modified: llvm/trunk/include/llvm/IR/Constant.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Constant.h?rev=210205&r1=210204&r2=210205&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Constant.h (original)
+++ llvm/trunk/include/llvm/IR/Constant.h Wed Jun 4 14:01:48 2014
@@ -163,6 +163,14 @@ public:
/// that want to check to see if a global is unused, but don't want to deal
/// with potentially dead constants hanging off of the globals.
void removeDeadConstantUsers() const;
+
+ Constant *stripPointerCasts() {
+ return cast<Constant>(Value::stripPointerCasts());
+ }
+
+ const Constant *stripPointerCasts() const {
+ return const_cast<Constant*>(this)->stripPointerCasts();
+ }
};
} // End llvm namespace
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=210205&r1=210204&r2=210205&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Jun 4 14:01:48 2014
@@ -706,7 +706,7 @@ static Constant *CastGEPIndices(ArrayRef
static Constant* StripPtrCastKeepAS(Constant* Ptr) {
assert(Ptr->getType()->isPointerTy() && "Not a pointer type");
PointerType *OldPtrTy = cast<PointerType>(Ptr->getType());
- Ptr = cast<Constant>(Ptr->stripPointerCasts());
+ Ptr = Ptr->stripPointerCasts();
PointerType *NewPtrTy = cast<PointerType>(Ptr->getType());
// Preserve the address space number of the pointer.
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=210205&r1=210204&r2=210205&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Wed Jun 4 14:01:48 2014
@@ -687,7 +687,7 @@ void *JITResolver::JITCompilerFn(void *S
//
static GlobalObject *getSimpleAliasee(Constant *C) {
- C = cast<Constant>(C->stripPointerCasts());
+ C = C->stripPointerCasts();
return dyn_cast<GlobalObject>(C);
}
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=210205&r1=210204&r2=210205&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Jun 4 14:01:48 2014
@@ -2108,7 +2108,7 @@ Instruction *InstCombiner::visitLandingP
if (LI.isCatch(i)) {
// A catch clause.
Constant *CatchClause = LI.getClause(i);
- Constant *TypeInfo = cast<Constant>(CatchClause->stripPointerCasts());
+ Constant *TypeInfo = CatchClause->stripPointerCasts();
// If we already saw this clause, there is no point in having a second
// copy of it.
@@ -2181,8 +2181,8 @@ Instruction *InstCombiner::visitLandingP
// catch-alls. If so, the filter can be discarded.
bool SawCatchAll = false;
for (unsigned j = 0; j != NumTypeInfos; ++j) {
- Value *Elt = Filter->getOperand(j);
- Constant *TypeInfo = cast<Constant>(Elt->stripPointerCasts());
+ Constant *Elt = Filter->getOperand(j);
+ Constant *TypeInfo = Elt->stripPointerCasts();
if (isCatchAll(Personality, TypeInfo)) {
// This element is a catch-all. Bail out, noting this fact.
SawCatchAll = true;
More information about the llvm-commits
mailing list