Replace nominal type descriptors with a hierarchy of context descriptors.

This new format more efficiently represents existing information, while
more accurately encoding important information about nested generic
contexts with same-type and layout constraints that need to be evaluated
at runtime. It's also designed with an eye to forward- and
backward-compatible expansion for ABI stability with future Swift
versions.
This commit is contained in:
Joe Groff
2017-12-12 09:57:36 -08:00
parent 9ac1dc80b0
commit a7a3b17597
58 changed files with 3418 additions and 1291 deletions

View File

@@ -29,6 +29,7 @@
#include "swift/SILOptimizer/PassManager/Passes.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Constants.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/ConvertUTF.h"
@@ -782,11 +783,46 @@ private:
if (!global.hasAvailableExternallyLinkage() &&
!global.hasAppendingLinkage() &&
!global.hasCommonLinkage()) {
global.setLinkage(llvm::GlobalValue::ExternalLinkage);
if (GlobalsAlreadyEmitted.count(global.getName()))
global.setInitializer(nullptr);
else
if (GlobalsAlreadyEmitted.count(global.getName())) {
// Some targets don't support relative references to undefined
// symbols. Keep the local copy of an ODR symbol if it's used in
// a relative reference expression.
bool usedInRelativeReference = false;
if (global.hasLinkOnceODRLinkage()) {
for (auto user : global.users()) {
// A relative reference will look like sub (ptrtoint @Global, _)
auto expr = dyn_cast<llvm::ConstantExpr>(user);
if (!expr)
continue;
if (expr->getOpcode() != llvm::Instruction::PtrToInt)
continue;
for (auto exprUser : expr->users()) {
auto exprExpr = dyn_cast<llvm::ConstantExpr>(exprUser);
if (!exprExpr)
continue;
if (exprExpr->getOpcode() != llvm::Instruction::Sub)
continue;
if (exprExpr->getOperand(0) != expr)
continue;
usedInRelativeReference = true;
goto done;
}
}
}
done:
if (!usedInRelativeReference)
global.setInitializer(nullptr);
} else
GlobalsAlreadyEmitted.insert(global.getName());
global.setLinkage(llvm::GlobalValue::ExternalLinkage);
}
}