mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rewrite BB args whose only use is in struct/tuple extract.
If we have BB args that are only used in a struct/tuple extract, and that are generated in each predecessor with a struct/tuple instruction, retype the BB arg and replace the argument with what would have been the extracted value. This provides more opportunties for jump threading to kick in. Swift SVN r16509
This commit is contained in:
@@ -72,6 +72,19 @@ void SILBasicBlock::eraseFromParent() {
|
||||
getParent()->getBlocks().erase(this);
|
||||
}
|
||||
|
||||
/// Replace the ith BB argument with a new one with type Ty (and optional
|
||||
/// ValueDecl D).
|
||||
SILArgument *SILBasicBlock::replaceBBArg(unsigned i, SILType Ty, ValueDecl *D) {
|
||||
SILModule &M = getParent()->getModule();
|
||||
assert(BBArgList[i]->use_empty() && "Expected no uses of the old BB arg!");
|
||||
|
||||
auto *NewArg = new (M) SILArgument(Ty, D);
|
||||
NewArg->setParent(this);
|
||||
BBArgList[i] = NewArg;
|
||||
|
||||
return NewArg;
|
||||
}
|
||||
|
||||
/// \brief Splits a basic block into two at the specified instruction.
|
||||
///
|
||||
/// Note that all the instructions BEFORE the specified iterator
|
||||
|
||||
Reference in New Issue
Block a user