From 0906b1bf09769d5301e62d372b363b4cd0b5a6c7 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Sat, 6 Jun 2009 17:49:35 +0000 Subject: [PATCH] Use cast<> instead of dyn_cast<> for things that are known to be Instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73002 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/GlobalOpt.cpp | 3 +-- lib/Transforms/IPO/IPConstantPropagation.cpp | 6 +---- lib/Transforms/Scalar/PredicateSimplifier.cpp | 27 +++++++++---------- .../Scalar/ScalarReplAggregates.cpp | 3 ++- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 2c01cc30bd6..5f12825f043 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -932,8 +932,7 @@ static bool ValueIsOnlyUsedLocallyOrStoredToOneGlobal(Instruction *V, GlobalVariable *GV, SmallPtrSet &PHIs) { for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){ - Instruction *Inst = dyn_cast(*UI); - if (Inst == 0) return false; + Instruction *Inst = cast(*UI); if (isa(Inst) || isa(Inst)) { continue; // Fine, ignore. diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index 2dc85582469..e4a9deadd97 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -241,15 +241,11 @@ bool IPCP::PropagateConstantReturn(Function &F) { for (Value::use_iterator I = Call->use_begin(), E = Call->use_end(); I != E;) { - Instruction *Ins = dyn_cast(*I); + Instruction *Ins = cast(*I); // Increment now, so we can remove the use ++I; - // Not an instruction? Ignore - if (!Ins) - continue; - // Find the index of the retval to replace with int index = -1; if (ExtractValueInst *EV = dyn_cast(Ins)) diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index a7e4d6eec44..b9b5688dfdf 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -1525,12 +1525,12 @@ namespace { Instruction *I2 = dyn_cast(R); if (I2 && below(I2)) { std::vector ToNotify; - for (Value::use_iterator UI = R->use_begin(), UE = R->use_end(); + for (Value::use_iterator UI = I2->use_begin(), UE = I2->use_end(); UI != UE;) { Use &TheUse = UI.getUse(); ++UI; - if (Instruction *I = dyn_cast(TheUse.getUser())) - ToNotify.push_back(I); + Instruction *I = cast(TheUse.getUser()); + ToNotify.push_back(I); } DOUT << "Simply removing " << *I2 @@ -1658,10 +1658,9 @@ namespace { ++UI; Value *V = TheUse.getUser(); if (!V->use_empty()) { - if (Instruction *Inst = dyn_cast(V)) { - if (aboveOrBelow(Inst)) - opsToDef(Inst); - } + Instruction *Inst = cast(V); + if (aboveOrBelow(Inst)) + opsToDef(Inst); } } } @@ -2262,10 +2261,9 @@ namespace { UE = O.LHS->use_end(); UI != UE;) { Use &TheUse = UI.getUse(); ++UI; - if (Instruction *I = dyn_cast(TheUse.getUser())) { - if (aboveOrBelow(I)) - opsToDef(I); - } + Instruction *I = cast(TheUse.getUser()); + if (aboveOrBelow(I)) + opsToDef(I); } } if (Instruction *I2 = dyn_cast(O.RHS)) { @@ -2277,10 +2275,9 @@ namespace { UE = O.RHS->use_end(); UI != UE;) { Use &TheUse = UI.getUse(); ++UI; - if (Instruction *I = dyn_cast(TheUse.getUser())) { - if (aboveOrBelow(I)) - opsToDef(I); - } + Instruction *I = cast(TheUse.getUser()); + if (aboveOrBelow(I)) + opsToDef(I); } } } diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 9935f12f893..7143c7be485 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1228,7 +1228,8 @@ void SROA::CleanupAllocaUsers(AllocationInst *AI) { User *U = *UI++; if (GetElementPtrInst *GEPI = dyn_cast(U)) CleanupGEP(GEPI); - else if (Instruction *I = dyn_cast(U)) { + else { + Instruction *I = cast(U); SmallVector DbgInUses; if (!isa(I) && OnlyUsedByDbgInfoIntrinsics(I, &DbgInUses)) { // Safe to remove debug info uses.