mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Revert "Fix linkage of 'static inline' Clang-imported definitions"
This reverts commit r31763, as it was breaking the bots: Swift SVN r31765
This commit is contained in:
@@ -348,14 +348,10 @@ struct SILDeclRef {
|
|||||||
/// True if the referenced entity is some kind of thunk.
|
/// True if the referenced entity is some kind of thunk.
|
||||||
bool isThunk() const;
|
bool isThunk() const;
|
||||||
|
|
||||||
/// True if the referenced entity is emitted by Swift on behalf of the Clang
|
/// True if the referenced entity is generated on behalf of the Clang
|
||||||
/// importer.
|
/// importer.
|
||||||
bool isClangImported() const;
|
bool isClangImported() const;
|
||||||
|
|
||||||
/// True if the referenced entity is emitted by Clang on behalf of the Clang
|
|
||||||
/// importer.
|
|
||||||
bool isClangGenerated() const;
|
|
||||||
|
|
||||||
bool isImplicit() const {
|
bool isImplicit() const {
|
||||||
if (hasDecl())
|
if (hasDecl())
|
||||||
return getDecl()->isImplicit();
|
return getDecl()->isImplicit();
|
||||||
|
|||||||
@@ -120,13 +120,11 @@ private:
|
|||||||
/// The linkage of the function.
|
/// The linkage of the function.
|
||||||
unsigned Linkage : NumSILLinkageBits;
|
unsigned Linkage : NumSILLinkageBits;
|
||||||
|
|
||||||
/// This flag indicates if a function can be eliminated by dead function
|
/// This flags indicates if a function can be
|
||||||
/// elimination. If it is unset, DFE will preserve the function and make
|
/// eliminated by dead function elimination.
|
||||||
/// it public.
|
/// If it is unset, DFE will preserve the function
|
||||||
unsigned KeepAsPublic : 1;
|
/// and make it public.
|
||||||
|
unsigned KeepAsPublic: 1;
|
||||||
/// This flag indicates if a function has a body generated by Clang.
|
|
||||||
unsigned ForeignBody : 1;
|
|
||||||
|
|
||||||
/// This is the number of uses of this SILFunction inside the SIL.
|
/// This is the number of uses of this SILFunction inside the SIL.
|
||||||
/// It does not include references from debug scopes.
|
/// It does not include references from debug scopes.
|
||||||
@@ -423,10 +421,6 @@ public:
|
|||||||
bool isKeepAsPublic() const { return KeepAsPublic; }
|
bool isKeepAsPublic() const { return KeepAsPublic; }
|
||||||
void setKeepAsPublic(bool keep) { KeepAsPublic = keep; }
|
void setKeepAsPublic(bool keep) { KeepAsPublic = keep; }
|
||||||
|
|
||||||
/// Get this function's foreign body attribute.
|
|
||||||
HasForeignBody_t hasForeignBody() const { return HasForeignBody_t(ForeignBody); }
|
|
||||||
void setForeignBody(HasForeignBody_t foreign) { ForeignBody = foreign; }
|
|
||||||
|
|
||||||
/// Retrieve the generic parameter list containing the contextual archetypes
|
/// Retrieve the generic parameter list containing the contextual archetypes
|
||||||
/// of the function.
|
/// of the function.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -84,18 +84,12 @@ enum {
|
|||||||
NumSILLinkageBits = 3
|
NumSILLinkageBits = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Related to linkage: flag if a function or global variable is fragile.
|
/// Reslated to linkage: flag if a function or global variable is fragle.
|
||||||
enum IsFragile_t {
|
enum IsFragile_t {
|
||||||
IsNotFragile,
|
IsNotFragile,
|
||||||
IsFragile
|
IsFragile
|
||||||
};
|
};
|
||||||
|
|
||||||
/// True if we have an inline body generated by Clang.
|
|
||||||
enum HasForeignBody_t {
|
|
||||||
DoesNotHaveForeignBody,
|
|
||||||
HasForeignBody
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Strip external from public_external, hidden_external. Otherwise just return
|
/// Strip external from public_external, hidden_external. Otherwise just return
|
||||||
/// the linkage.
|
/// the linkage.
|
||||||
inline SILLinkage stripExternalFromLinkage(SILLinkage linkage) {
|
inline SILLinkage stripExternalFromLinkage(SILLinkage linkage) {
|
||||||
|
|||||||
@@ -215,9 +215,6 @@ bool SILDeclRef::isClangImported() const {
|
|||||||
DeclContext *moduleContext = d->getDeclContext()->getModuleScopeContext();
|
DeclContext *moduleContext = d->getDeclContext()->getModuleScopeContext();
|
||||||
|
|
||||||
if (isa<ClangModuleUnit>(moduleContext)) {
|
if (isa<ClangModuleUnit>(moduleContext)) {
|
||||||
if (isClangGenerated())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (isa<ConstructorDecl>(d) || isa<EnumElementDecl>(d))
|
if (isa<ConstructorDecl>(d) || isa<EnumElementDecl>(d))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -229,21 +226,6 @@ bool SILDeclRef::isClangImported() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SILDeclRef::isClangGenerated() const {
|
|
||||||
if (!hasDecl())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (auto *FD = dyn_cast<FuncDecl>(getDecl())) {
|
|
||||||
auto clangNode = FD->getClangNode().getAsDecl();
|
|
||||||
if (auto fd = dyn_cast_or_null<clang::FunctionDecl>(clangNode)) {
|
|
||||||
if (fd->hasBody())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
|
SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
|
||||||
// Anonymous functions have local linkage.
|
// Anonymous functions have local linkage.
|
||||||
if (auto closure = getAbstractClosureExpr())
|
if (auto closure = getAbstractClosureExpr())
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ SILFunction::SILFunction(SILModule &Module, SILLinkage Linkage,
|
|||||||
InlineStrategy(inlineStrategy),
|
InlineStrategy(inlineStrategy),
|
||||||
Linkage(unsigned(Linkage)),
|
Linkage(unsigned(Linkage)),
|
||||||
KeepAsPublic(false),
|
KeepAsPublic(false),
|
||||||
ForeignBody(false),
|
|
||||||
EK(E) {
|
EK(E) {
|
||||||
if (InsertBefore)
|
if (InsertBefore)
|
||||||
Module.functions.insert(SILModule::iterator(InsertBefore), this);
|
Module.functions.insert(SILModule::iterator(InsertBefore), this);
|
||||||
|
|||||||
@@ -359,14 +359,10 @@ SILFunction *SILModule::getOrCreateFunction(SILLocation loc,
|
|||||||
F->setDebugScope(new (*this) SILDebugScope(loc, *F));
|
F->setDebugScope(new (*this) SILDebugScope(loc, *F));
|
||||||
|
|
||||||
F->setGlobalInit(constant.isGlobal());
|
F->setGlobalInit(constant.isGlobal());
|
||||||
if (constant.hasDecl()) {
|
if (constant.hasDecl())
|
||||||
if (constant.isForeign && constant.isClangGenerated())
|
|
||||||
F->setForeignBody(HasForeignBody);
|
|
||||||
|
|
||||||
if (auto SemanticsA =
|
if (auto SemanticsA =
|
||||||
constant.getDecl()->getAttrs().getAttribute<SemanticsAttr>())
|
constant.getDecl()->getAttrs().getAttribute<SemanticsAttr>())
|
||||||
F->setSemanticsAttr(SemanticsA->Value);
|
F->setSemanticsAttr(SemanticsA->Value);
|
||||||
}
|
|
||||||
|
|
||||||
F->setDeclContext(constant.hasDecl() ? constant.getDecl() : nullptr);
|
F->setDeclContext(constant.hasDecl() ? constant.getDecl() : nullptr);
|
||||||
|
|
||||||
|
|||||||
@@ -2947,21 +2947,16 @@ public:
|
|||||||
verifySILFunctionType(FTy);
|
verifySILFunctionType(FTy);
|
||||||
|
|
||||||
if (F->isExternalDeclaration()) {
|
if (F->isExternalDeclaration()) {
|
||||||
if (F->hasForeignBody())
|
|
||||||
return;
|
|
||||||
|
|
||||||
assert(F->isAvailableExternally() &&
|
assert(F->isAvailableExternally() &&
|
||||||
"external declaration of internal SILFunction not allowed");
|
"external declaration of internal SILFunction not allowed");
|
||||||
assert(!hasSharedVisibility(F->getLinkage()) &&
|
assert(!hasSharedVisibility(F->getLinkage()) &&
|
||||||
"external declarations of SILFunctions with shared visibility is not "
|
"external declarations of SILFunctions with shared visiblity is not "
|
||||||
"allowed");
|
"allowed");
|
||||||
// If F is an external declaration, there is nothing further to do,
|
// If F is an external declaration, there is nothing further to do,
|
||||||
// return.
|
// return.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!F->hasForeignBody());
|
|
||||||
|
|
||||||
// Make sure that our SILFunction only has context generic params if our
|
// Make sure that our SILFunction only has context generic params if our
|
||||||
// SILFunctionType is non-polymorphic.
|
// SILFunctionType is non-polymorphic.
|
||||||
if (F->getContextGenericParams()) {
|
if (F->getContextGenericParams()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import c_layout
|
|||||||
func blackHole<T>(t: T) { }
|
func blackHole<T>(t: T) { }
|
||||||
|
|
||||||
// CHECK: @staticFloat = internal global float 1.700000e+01, align 4
|
// CHECK: @staticFloat = internal global float 1.700000e+01, align 4
|
||||||
// CHECK: define internal void @doubleTrouble() [[CLANG_FUNC_ATTR:#[0-9]+]] {
|
// CHECK: define {{.*}}void @doubleTrouble() [[CLANG_FUNC_ATTR:#[0-9]+]] {
|
||||||
|
|
||||||
public func testStaticGlobal() {
|
public func testStaticGlobal() {
|
||||||
blackHole(c_layout.staticFloat)
|
blackHole(c_layout.staticFloat)
|
||||||
|
|||||||
@@ -4,14 +4,8 @@
|
|||||||
- (Ansible*)initWithBellsOn:(id)theBells;
|
- (Ansible*)initWithBellsOn:(id)theBells;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static Ansible *NSAnse(Ansible *x) {
|
Ansible *NSAnse(Ansible *x) {
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ansible *NSAnseExternal(Ansible *x) {
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hasNoPrototype();
|
void hasNoPrototype();
|
||||||
|
|
||||||
static void staticForwardDeclaration(void);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user