NVPTX: Use RAUW instead of reinventing the wheel
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 19 Aug 2014 00:20:02 +0000 (00:20 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 19 Aug 2014 00:20:02 +0000 (00:20 +0000)
commit6b863256e442f8d1df4dcbd1325ad132380de828
treee0a908bb0dedcdeb4c77cc7868465ed0c14502f9
parent165897841bdb651c9d10f4b078f5804b2ca8c30c
NVPTX: Use RAUW instead of reinventing the wheel

This code had a homemade RAUW that was incorrect when a user was a
constant: instead of calling `replaceUsersWithOnConstant()` it would
incorrectly update the operand in-place, invalidating
`LLVMContextImpl::ExprConstants`.  RAUW does the job better.

The ValueHandle that `GVMap` is holding onto needs to be removed first,
so this commit also removes each variable from the map on-the-fly.

Since deletions from `ExprConstants` use a linear search that compares
directly on the pointer value (instead of using the key), there isn't an
obvious way to expose this with a testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215953 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/NVPTX/NVPTXGenericToNVVM.cpp