diff --git a/lib/IRGen/GenCall.cpp b/lib/IRGen/GenCall.cpp index 941a359577abd..3737081959255 100644 --- a/lib/IRGen/GenCall.cpp +++ b/lib/IRGen/GenCall.cpp @@ -3204,26 +3204,6 @@ llvm::CallBase *CallEmission::emitCallSite() { return call; } -static llvm::AttributeList -assertTypesInByValAndStructRetAttributes(llvm::FunctionType *fnType, - llvm::AttributeList attrList) { - auto &context = fnType->getContext(); - if (context.supportsTypedPointers()) { - for (unsigned i = 0; i < fnType->getNumParams(); ++i) { - auto paramTy = fnType->getParamType(i); - assert( - !attrList.hasParamAttr(i, llvm::Attribute::StructRet) || - llvm::cast(paramTy)->isOpaqueOrPointeeTypeMatches( - attrList.getParamStructRetType(i))); - assert( - !attrList.hasParamAttr(i, llvm::Attribute::ByVal) || - llvm::cast(paramTy)->isOpaqueOrPointeeTypeMatches( - attrList.getParamByValType(i))); - } - } - return attrList; -} - llvm::CallBase *IRBuilder::CreateCallOrInvoke( const FunctionPointer &fn, ArrayRef args, llvm::BasicBlock *invokeNormalDest, llvm::BasicBlock *invokeUnwindDest) { @@ -3265,7 +3245,7 @@ llvm::CallBase *IRBuilder::CreateCallOrInvoke( } } } - call->setAttributes(assertTypesInByValAndStructRetAttributes(fnTy, attrs)); + call->setAttributes(attrs); call->setCallingConv(fn.getCallingConv()); return call; } @@ -3462,10 +3442,6 @@ void CallEmission::emitToExplosion(Explosion &out, bool isOutlined) { resultTy = func->getParamStructRetType(0); } auto temp = IGF.createAlloca(resultTy, Alignment(), "indirect.result"); - if (IGF.IGM.getLLVMContext().supportsTypedPointers()) { - temp = IGF.Builder.CreateElementBitCast( - temp, fnType->getParamType(0)->getNonOpaquePointerElementType()); - } emitToMemory(temp, substResultTI, isOutlined); return; } @@ -3492,10 +3468,6 @@ void CallEmission::emitToExplosion(Explosion &out, bool isOutlined) { auto resultTy = func->getParamStructRetType(1); auto temp = IGF.createAlloca(resultTy, Alignment(/*safe alignment*/ 16), "indirect.result"); - if (IGF.IGM.getLLVMContext().supportsTypedPointers()) { - temp = IGF.Builder.CreateElementBitCast( - temp, fnType->getParamType(1)->getNonOpaquePointerElementType()); - } emitToMemory(temp, substResultTI, isOutlined); return; } @@ -5940,8 +5912,6 @@ llvm::FunctionType *FunctionPointer::getFunctionType() const { } if (awaitSignature) { - assert(llvm::cast(Value->getType()) - ->isOpaqueOrPointeeTypeMatches(awaitSignature)); return cast(awaitSignature); } @@ -5949,25 +5919,17 @@ llvm::FunctionType *FunctionPointer::getFunctionType() const { if (auto *constant = dyn_cast(Value)) { auto *gv = dyn_cast(Value); if (!gv) { - assert(llvm::cast(Value->getType()) - ->isOpaqueOrPointeeTypeMatches(Sig.getType())); return Sig.getType(); } if (useSignature) { // Because of various casting (e.g thin_to_thick) the // signature of the function Value might mismatch // (e.g no context argument). - assert(llvm::cast(Value->getType()) - ->isOpaqueOrPointeeTypeMatches(Sig.getType())); return Sig.getType(); } - assert(llvm::cast(Value->getType()) - ->isOpaqueOrPointeeTypeMatches(gv->getValueType())); return cast(gv->getValueType()); } - assert(llvm::cast(Value->getType()) - ->isOpaqueOrPointeeTypeMatches(Sig.getType())); return Sig.getType(); } diff --git a/lib/IRGen/GenDistributed.cpp b/lib/IRGen/GenDistributed.cpp index d6e0d1a22b6ba..6ab1248c7355d 100644 --- a/lib/IRGen/GenDistributed.cpp +++ b/lib/IRGen/GenDistributed.cpp @@ -712,12 +712,6 @@ void DistributedAccessor::emit() { // Generic arguments associated with the distributed thunk directly // e.g. `distributed func echo(...)` - assert( - !IGM.getLLVMContext().supportsTypedPointers() || - expandedSignature.numTypeMetadataPtrs == - llvm::count_if(targetGenericArguments, [&](const llvm::Type *type) { - return type == IGM.TypeMetadataPtrTy; - })); for (unsigned index = 0; index < expandedSignature.numTypeMetadataPtrs; ++index) { auto offset = diff --git a/lib/IRGen/GenFunc.cpp b/lib/IRGen/GenFunc.cpp index 16cb84433980a..9a003eea85117 100644 --- a/lib/IRGen/GenFunc.cpp +++ b/lib/IRGen/GenFunc.cpp @@ -225,13 +225,6 @@ namespace { bool isOutlined) const override { auto *fn = src.claimNext(); - // We might be presented with a value of the more precise pointer to - // function type "void(*)*" rather than the generic "i8*". Downcast to the - // more general expected type. - if (fn->getContext().supportsTypedPointers() && - fn->getType()->getNonOpaquePointerElementType()->isFunctionTy()) - fn = IGF.Builder.CreateBitCast(fn, getStorageType()); - Explosion tmp; tmp.add(fn); PODSingleScalarTypeInfo::initialize(IGF, tmp, addr, isOutlined); diff --git a/lib/IRGen/GenObjC.cpp b/lib/IRGen/GenObjC.cpp index 42049cddb32b2..dbe6111dcc17f 100644 --- a/lib/IRGen/GenObjC.cpp +++ b/lib/IRGen/GenObjC.cpp @@ -459,20 +459,7 @@ getProtocolRefsList(llvm::Constant *protocol) { return std::make_pair(0, nullptr); } - if (!protocol->getContext().supportsTypedPointers()) { - auto protocolRefsVar = cast(objCProtocolList); - auto sizeListPair = - cast(protocolRefsVar->getInitializer()); - auto size = - cast(sizeListPair->getOperand(0))->getZExtValue(); - auto protocolRefsList = - cast(sizeListPair->getOperand(1)); - return std::make_pair(size, protocolRefsList); - } - - auto bitcast = cast(objCProtocolList); - assert(bitcast->getOpcode() == llvm::Instruction::BitCast); - auto protocolRefsVar = cast(bitcast->getOperand(0)); + auto protocolRefsVar = cast(objCProtocolList); auto sizeListPair = cast(protocolRefsVar->getInitializer()); auto size = diff --git a/lib/IRGen/GenStruct.cpp b/lib/IRGen/GenStruct.cpp index dbe600ee0160f..edb0fb9b67519 100644 --- a/lib/IRGen/GenStruct.cpp +++ b/lib/IRGen/GenStruct.cpp @@ -463,14 +463,6 @@ namespace { clang::QualType(clangDecl->getTypeForDecl(), 0)); auto *dstValue = dst.getAddress(); auto *srcValue = src.getAddress(); - if (IGF.IGM.getLLVMContext().supportsTypedPointers()) { - dstValue = IGF.coerceValue( - dst.getAddress(), copyFunction->getFunctionType()->getParamType(0), - IGF.IGM.DataLayout); - srcValue = IGF.coerceValue( - src.getAddress(), copyFunction->getFunctionType()->getParamType(1), - IGF.IGM.DataLayout); - } IGF.Builder.CreateCall(copyFunction->getFunctionType(), copyFunction, {dstValue, srcValue}); } @@ -634,12 +626,6 @@ namespace { clangFnAddr = emitCXXConstructorThunkIfNeeded( IGF.IGM, signature, copyConstructor, name, clangFnAddr); callee = cast(clangFnAddr); - if (IGF.IGM.getLLVMContext().supportsTypedPointers()) { - dest = IGF.coerceValue(dest, callee->getFunctionType()->getParamType(0), - IGF.IGM.DataLayout); - src = IGF.coerceValue(src, callee->getFunctionType()->getParamType(1), - IGF.IGM.DataLayout); - } llvm::Value *args[] = {dest, src}; if (clangFnAddr == origClangFnAddr) { // Ensure we can use 'invoke' to trap on uncaught exceptions when @@ -705,10 +691,6 @@ namespace { SmallVector args; auto *thisArg = address.getAddress(); - if (IGF.IGM.getLLVMContext().supportsTypedPointers()) - thisArg = IGF.coerceValue(address.getAddress(), - destructorFnAddr->getArg(0)->getType(), - IGF.IGM.DataLayout); args.push_back(thisArg); llvm::Value *implicitParam = clang::CodeGen::getCXXDestructorImplicitParam( diff --git a/lib/IRGen/GenType.cpp b/lib/IRGen/GenType.cpp index 348935bd428a5..c43762122dd78 100644 --- a/lib/IRGen/GenType.cpp +++ b/lib/IRGen/GenType.cpp @@ -115,8 +115,6 @@ TypeInfo::~TypeInfo() { } Address TypeInfo::getAddressForPointer(llvm::Value *ptr) const { - assert(cast(ptr->getType()) - ->isOpaqueOrPointeeTypeMatches(getStorageType())); return Address(ptr, getStorageType(), getBestKnownAlignment()); } diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp index 26816af0e76a6..2bded1625f19c 100644 --- a/lib/LLVMPasses/LLVMMergeFunctions.cpp +++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp @@ -1261,29 +1261,6 @@ void SwiftMergeFunctions::writeThunk(Function *ToFunc, Function *Thunk, ++NumSwiftThunksWritten; } -static llvm::AttributeList -fixUpTypesInByValAndStructRetAttributes(llvm::FunctionType *fnType, - llvm::AttributeList attrList) { - auto &context = fnType->getContext(); - if (!context.supportsTypedPointers()) - return attrList; - - for (unsigned i = 0; i < fnType->getNumParams(); ++i) { - auto paramTy = fnType->getParamType(i); - auto attrListIndex = llvm::AttributeList::FirstArgIndex + i; - if (attrList.hasParamAttr(i, llvm::Attribute::StructRet) && - paramTy->getNonOpaquePointerElementType() != attrList.getParamStructRetType(i)) - attrList = attrList.replaceAttributeTypeAtIndex( - context, attrListIndex, llvm::Attribute::StructRet, - paramTy->getNonOpaquePointerElementType()); - if (attrList.hasParamAttr(i, llvm::Attribute::ByVal) && - paramTy->getNonOpaquePointerElementType() != attrList.getParamByValType(i)) - attrList = attrList.replaceAttributeTypeAtIndex( - context, attrListIndex, llvm::Attribute::ByVal, - paramTy->getNonOpaquePointerElementType()); - } - return attrList; -} /// Replace direct callers of Old with New. Also add parameters to the call to /// \p New, which are defined by the FuncIdx's value in \p Params. bool SwiftMergeFunctions::replaceDirectCallers(Function *Old, Function *New, @@ -1356,7 +1333,6 @@ bool SwiftMergeFunctions::replaceDirectCallers(Function *Old, Function *New, auto newAttrList = AttributeList::get(Context, /*FnAttrs=*/AttributeSet(), NewPAL.getRetAttrs(), NewArgAttrs); - newAttrList = fixUpTypesInByValAndStructRetAttributes(FType, newAttrList); NewCI->setAttributes(newAttrList); Value *retVal = createCast(Builder, NewCI, CI->getType()); CI->replaceAllUsesWith(retVal);