mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user