[polly] r258660 - BlockGenerators: Avoid redundant map lookup [NFC]

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 12:01:19 PST 2016


On 01/25/2016 08:52 PM, David Blaikie wrote:
>
>
> On Sun, Jan 24, 2016 at 6:17 AM, Tobias Grosser via llvm-commits
> <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
>
>     Author: grosser
>     Date: Sun Jan 24 08:16:59 2016
>     New Revision: 258660
>
>     URL: http://llvm.org/viewvc/llvm-project?rev=258660&view=rev
>     Log:
>     BlockGenerators: Avoid redundant map lookup [NFC]
>
>     Modified:
>          polly/trunk/lib/CodeGen/BlockGenerators.cpp
>
>     Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
>     URL:
>     http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=258660&r1=258659&r2=258660&view=diff
>     ==============================================================================
>     --- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
>     +++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sun Jan 24 08:16:59 2016
>     @@ -338,8 +338,8 @@ Value *BlockGenerator::getOrCreateAlloca
>
>         auto Addr = Map[ScalarBase];
>
>     -  if (GlobalMap.count(Addr))
>     -    return GlobalMap[Addr];
>     +  if (auto NewAddr = GlobalMap.lookup(Addr))
>
>
> Probably best to include the '*' in auto here (if I'm understanding the
> code correctly, auto is binding to Instruction* here) to make it clear
> that it's a pointer (& that this if test is a null pointer test)?

Thanks David, this is an AssertingVH, not a plain pointer. Hence, it is
is not possible to write it this way. However, the conversion to null 
still seems to work as expected. I have no idea how to write it better.
Any suggestions?

Best,
Tobias


More information about the llvm-commits mailing list