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:
Dave Abrahams
2015-09-08 16:31:35 +00:00
parent 33feabb504
commit 8269d8130b
9 changed files with 12 additions and 62 deletions

View File

@@ -348,14 +348,10 @@ struct SILDeclRef {
/// True if the referenced entity is some kind of thunk.
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.
bool isClangImported() const;
/// True if the referenced entity is emitted by Clang on behalf of the Clang
/// importer.
bool isClangGenerated() const;
bool isImplicit() const {
if (hasDecl())
return getDecl()->isImplicit();

View File

@@ -120,13 +120,11 @@ private:
/// The linkage of the function.
unsigned Linkage : NumSILLinkageBits;
/// This flag indicates if a function can be eliminated by dead function
/// elimination. If it is unset, DFE will preserve the function and make
/// it public.
unsigned KeepAsPublic : 1;
/// This flag indicates if a function has a body generated by Clang.
unsigned ForeignBody : 1;
/// This flags indicates if a function can be
/// eliminated by dead function elimination.
/// If it is unset, DFE will preserve the function
/// and make it public.
unsigned KeepAsPublic: 1;
/// This is the number of uses of this SILFunction inside the SIL.
/// It does not include references from debug scopes.
@@ -423,10 +421,6 @@ public:
bool isKeepAsPublic() const { return KeepAsPublic; }
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
/// of the function.
///

View File

@@ -84,18 +84,12 @@ enum {
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 {
IsNotFragile,
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
/// the linkage.
inline SILLinkage stripExternalFromLinkage(SILLinkage linkage) {

View File

@@ -215,9 +215,6 @@ bool SILDeclRef::isClangImported() const {
DeclContext *moduleContext = d->getDeclContext()->getModuleScopeContext();
if (isa<ClangModuleUnit>(moduleContext)) {
if (isClangGenerated())
return true;
if (isa<ConstructorDecl>(d) || isa<EnumElementDecl>(d))
return true;
@@ -229,21 +226,6 @@ bool SILDeclRef::isClangImported() const {
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 {
// Anonymous functions have local linkage.
if (auto closure = getAbstractClosureExpr())

View File

@@ -89,7 +89,6 @@ SILFunction::SILFunction(SILModule &Module, SILLinkage Linkage,
InlineStrategy(inlineStrategy),
Linkage(unsigned(Linkage)),
KeepAsPublic(false),
ForeignBody(false),
EK(E) {
if (InsertBefore)
Module.functions.insert(SILModule::iterator(InsertBefore), this);

View File

@@ -359,14 +359,10 @@ SILFunction *SILModule::getOrCreateFunction(SILLocation loc,
F->setDebugScope(new (*this) SILDebugScope(loc, *F));
F->setGlobalInit(constant.isGlobal());
if (constant.hasDecl()) {
if (constant.isForeign && constant.isClangGenerated())
F->setForeignBody(HasForeignBody);
if (constant.hasDecl())
if (auto SemanticsA =
constant.getDecl()->getAttrs().getAttribute<SemanticsAttr>())
F->setSemanticsAttr(SemanticsA->Value);
}
F->setDeclContext(constant.hasDecl() ? constant.getDecl() : nullptr);

View File

@@ -2947,21 +2947,16 @@ public:
verifySILFunctionType(FTy);
if (F->isExternalDeclaration()) {
if (F->hasForeignBody())
return;
assert(F->isAvailableExternally() &&
"external declaration of internal SILFunction not allowed");
assert(!hasSharedVisibility(F->getLinkage()) &&
"external declarations of SILFunctions with shared visibility is not "
"external declarations of SILFunctions with shared visiblity is not "
"allowed");
// If F is an external declaration, there is nothing further to do,
// return.
return;
}
assert(!F->hasForeignBody());
// Make sure that our SILFunction only has context generic params if our
// SILFunctionType is non-polymorphic.
if (F->getContextGenericParams()) {

View File

@@ -6,7 +6,7 @@ import c_layout
func blackHole<T>(t: T) { }
// 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() {
blackHole(c_layout.staticFloat)

View File

@@ -4,14 +4,8 @@
- (Ansible*)initWithBellsOn:(id)theBells;
@end
static Ansible *NSAnse(Ansible *x) {
return x;
}
Ansible *NSAnseExternal(Ansible *x) {
Ansible *NSAnse(Ansible *x) {
return x;
}
void hasNoPrototype();
static void staticForwardDeclaration(void);