Reduce array abstraction on apple platforms dealing with literals (#13665)

* Reduce array abstraction on apple platforms dealing with literals

Part of the ongoing quest to reduce swift array literal abstraction
penalties: make the SIL optimizer able to eliminate bridging overhead
 when dealing with array literals.

Introduce a new classify_bridge_object SIL instruction to handle the
logic of extracting platform specific bits from a Builtin.BridgeObject
value that indicate whether it contains a ObjC tagged pointer object,
or a normal ObjC object. This allows the SIL optimizer to eliminate
these, which allows constant folding a ton of code. On the example
added to test/SILOptimizer/static_arrays.swift, this results in 4x
less SIL code, and also leads to a lot more commonality between linux
and apple platform codegen when passing an array literal.

This also introduces a couple of SIL combines for patterns that occur
in the array literal passing case.
This commit is contained in:
Chris Lattner
2018-01-02 15:23:48 -08:00
committed by GitHub
parent d847bf5ddd
commit 415cd50ba2
32 changed files with 263 additions and 13 deletions

View File

@@ -93,7 +93,11 @@ public:
hash_code visitBridgeObjectToWordInst(BridgeObjectToWordInst *X) {
return llvm::hash_combine(X->getKind(), X->getType(), X->getOperand());
}
hash_code visitClassifyBridgeObjectInst(ClassifyBridgeObjectInst *X) {
return llvm::hash_combine(X->getKind(), X->getOperand());
}
hash_code visitRefToBridgeObjectInst(RefToBridgeObjectInst *X) {
OperandValueArrayRef Operands(X->getAllOperands());
return llvm::hash_combine(
@@ -930,6 +934,7 @@ bool CSE::canHandle(SILInstruction *Inst) {
case SILInstructionKind::RefToBridgeObjectInst:
case SILInstructionKind::BridgeObjectToRefInst:
case SILInstructionKind::BridgeObjectToWordInst:
case SILInstructionKind::ClassifyBridgeObjectInst:
case SILInstructionKind::ThinFunctionToPointerInst:
case SILInstructionKind::PointerToThinFunctionInst:
case SILInstructionKind::MarkDependenceInst: