From: Fangrui Song Date: Sun, 14 Apr 2019 05:48:13 +0000 (+0000) Subject: [Mem2Reg] Simplify rewriteSingleStoreAlloca X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1481cdaa58e9ca4893270682f88cad747e40c0c0;p=llvm [Mem2Reg] Simplify rewriteSingleStoreAlloca git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358349 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 74019c5d302..28462e8c8b6 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -362,10 +362,8 @@ static bool rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, for (auto UI = AI->user_begin(), E = AI->user_end(); UI != E;) { Instruction *UserInst = cast(*UI++); - if (!isa(UserInst)) { - assert(UserInst == OnlyStore && "Should only have load/stores"); + if (UserInst == OnlyStore) continue; - } LoadInst *LI = cast(UserInst); // Okay, if we have a load from the alloca, we want to replace it with the @@ -385,8 +383,7 @@ static bool rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, Info.UsingBlocks.push_back(StoreBB); continue; } - } else if (LI->getParent() != StoreBB && - !DT.dominates(StoreBB, LI->getParent())) { + } else if (!DT.dominates(StoreBB, LI->getParent())) { // If the load and store are in different blocks, use BB dominance to // check their relationships. If the store doesn't dom the use, bail // out.