mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Minor re-factoring: Move the logic to decide if a given instruction can be (easily) duplicated into SILInstruction. So far it was mainly used by jump-threading related optimizations. But it could be generally useful, or at least generally important, to optimizations that want to duplicate code.
Swift SVN r23213
This commit is contained in:
@@ -668,6 +668,23 @@ SILInstruction *SILInstruction::clone(SILInstruction *InsertPt) {
|
||||
return NewInst;
|
||||
}
|
||||
|
||||
/// Returns true if the instruction can be duplicated without any special
|
||||
/// additional handling. It is important to know this information when
|
||||
/// you perform such optimizations like e.g. jump-threading.
|
||||
bool SILInstruction::isTriviallyDuplicatable() const {
|
||||
if (isa<AllocStackInst>(this) || isa<DeallocStackInst>(this)) {
|
||||
return false;
|
||||
} else if (isa<OpenExistentialInst>(this) ||
|
||||
isa<OpenExistentialRefInst>(this) ||
|
||||
isa<OpenExistentialMetatypeInst>(this)) {
|
||||
// Don't know how to duplicate these properly yet. Inst.clone() per
|
||||
// instruction does not work. Because the follow-up instructions need to
|
||||
// reuse the same archetype uuid which would only work if we used a
|
||||
// cloner.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// SILInstruction Subclasses
|
||||
|
||||
Reference in New Issue
Block a user