Change SILCloner to be able to remap additional non-instruction based SILValues such as SILUndef.

Previously we only supported SILArguments. In the process of changing this I
noticed that our densemap implementation for SILValues only hashes the wrapped
ValueBase instead of hash combining that hash with a hash of the result number.

The main use case for this is to enable the insertion of a Builtin.trap + RAUW
SILUndef of uses of an unconditional_checked_cast that is invalid after
specialization.

rdar://16490450

Swift SVN r15747
This commit is contained in:
Michael Gottesman
2014-04-01 21:09:41 +00:00
parent 0970880df3
commit 8740666034
2 changed files with 8 additions and 7 deletions

View File

@@ -118,7 +118,7 @@ protected:
SILBuilder Builder;
SILBasicBlock *InsertBeforeBB;
llvm::DenseMap<ValueBase*, SILValue> ValueMap;
llvm::DenseMap<SILValue, SILValue> ValueMap;
llvm::DenseMap<SILInstruction*, SILInstruction*> InstructionMap;
llvm::DenseMap<SILBasicBlock*, SILBasicBlock*> BBMap;
TypeSubstitutionMap OpenedExistentialSubs;
@@ -127,12 +127,9 @@ protected:
template<typename ImplClass>
SILValue
SILCloner<ImplClass>::remapValue(SILValue Value) {
auto VI = ValueMap.find(Value.getDef());
if (VI != ValueMap.end()) {
assert(Value.getResultNumber() == 0 &&
"Non-zero result number of mapped value used?");
auto VI = ValueMap.find(Value);
if (VI != ValueMap.end())
return VI->second;
}
if (SILInstruction* I = dyn_cast<SILInstruction>(Value.getDef())) {
auto II = InstructionMap.find(I);