IR: Fix ConstantExpr::replaceUsesOfWithOnConstant()
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 19 Aug 2014 20:03:35 +0000 (20:03 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Tue, 19 Aug 2014 20:03:35 +0000 (20:03 +0000)
commitb03916a88b336046be2ed14c61a5e35fa0b2f644
tree87c899cd78b9521f8aa8b543fd6d19b2214735fa
parente2215571e55bec0e7d6a08a970e53b931a894203
IR: Fix ConstantExpr::replaceUsesOfWithOnConstant()

Change `ConstantExpr` to follow the model the other constants are using:
only malloc a replacement if it's going to be used.  This fixes a subtle
bug where if an API user had used `ConstantExpr::get()` already to
create the replacement but hadn't given it any users, we'd delete the
replacement.

This relies on r216015 to thread `OnlyIfReduced` through
`ConstantExpr::getWithOperands()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216016 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/Constants.h
lib/IR/Constants.cpp
unittests/IR/ConstantsTest.cpp