diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 880e8df72c5..a26fcbefe81 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -661,7 +661,8 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) { // up. for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E; ) { - GetElementPtrInst *GEPI = cast(*UI++); + GetElementPtrInst *GEPI = dyn_cast(*UI++); + if (!GEPI) continue; gep_type_iterator I = gep_type_begin(GEPI); ++I;