mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sil-optimizer] Make compile time concatenation of constant strings work again
This guaranteed optimization got lost when a + operator for Strings was made a static method on type String. Fixes SR-4348
This commit is contained in:
@@ -687,9 +687,11 @@ bool StringConcatenationOptimizer::extractStringConcatOperands() {
|
||||
if (!Fn)
|
||||
return false;
|
||||
|
||||
if (AI->getNumOperands() != 3 || !Fn->hasSemanticsAttr("string.concat"))
|
||||
if (AI->getNumArguments() != 3 || !Fn->hasSemanticsAttr("string.concat"))
|
||||
return false;
|
||||
|
||||
assert(Fn->getRepresentation() == SILFunctionTypeRepresentation::Method);
|
||||
|
||||
// Left and right operands of a string concatenation operation.
|
||||
AILeft = dyn_cast<ApplyInst>(AI->getOperand(1));
|
||||
AIRight = dyn_cast<ApplyInst>(AI->getOperand(2));
|
||||
@@ -730,6 +732,11 @@ bool StringConcatenationOptimizer::extractStringConcatOperands() {
|
||||
AIRightOperandsNum == 5)))
|
||||
return false;
|
||||
|
||||
assert(FRILeftFun->getRepresentation() ==
|
||||
SILFunctionTypeRepresentation::Method);
|
||||
assert(FRIRightFun->getRepresentation() ==
|
||||
SILFunctionTypeRepresentation::Method);
|
||||
|
||||
SLILeft = dyn_cast<StringLiteralInst>(AILeft->getOperand(1));
|
||||
SLIRight = dyn_cast<StringLiteralInst>(AIRight->getOperand(1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user