Index: lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -402,7 +402,10 @@ static bool collectUsesWithPtrTypes(Value *Val, std::vector &WorkList) { bool Success = true; for (User *User : Val->users()) { - if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end()) + if (!Success) + return false; + + if (std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end()) continue; if (CallInst *CI = dyn_cast(User)) { // TODO: We might be able to handle some cases where the callee is a @@ -429,10 +432,10 @@ continue; WorkList.push_back(User); - - Success &= collectUsesWithPtrTypes(User, WorkList); + Success = collectUsesWithPtrTypes(User, WorkList); } - return Success; + + return true; } void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {