|
@@ -119,6 +119,7 @@ public:
|
|
return m_functionNameMap;
|
|
return m_functionNameMap;
|
|
}
|
|
}
|
|
bool IsInitFunc(llvm::Function *F);
|
|
bool IsInitFunc(llvm::Function *F);
|
|
|
|
+ bool IsEntry(llvm::Function *F);
|
|
bool IsResourceGlobal(const llvm::Constant *GV);
|
|
bool IsResourceGlobal(const llvm::Constant *GV);
|
|
DxilResourceBase *GetResource(const llvm::Constant *GV);
|
|
DxilResourceBase *GetResource(const llvm::Constant *GV);
|
|
|
|
|
|
@@ -135,6 +136,7 @@ private:
|
|
DxilModule &m_DM;
|
|
DxilModule &m_DM;
|
|
// Map from name to Link info for extern functions.
|
|
// Map from name to Link info for extern functions.
|
|
llvm::StringMap<std::unique_ptr<DxilFunctionLinkInfo>> m_functionNameMap;
|
|
llvm::StringMap<std::unique_ptr<DxilFunctionLinkInfo>> m_functionNameMap;
|
|
|
|
+ llvm::SmallPtrSet<llvm::Function*,4> m_entrySet;
|
|
// Map from resource link global to resource. MapVector for deterministic iteration.
|
|
// Map from resource link global to resource. MapVector for deterministic iteration.
|
|
llvm::MapVector<const llvm::Constant *, DxilResourceBase *> m_resourceMap;
|
|
llvm::MapVector<const llvm::Constant *, DxilResourceBase *> m_resourceMap;
|
|
// Set of initialize functions for global variable. SetVector for deterministic iteration.
|
|
// Set of initialize functions for global variable. SetVector for deterministic iteration.
|
|
@@ -202,6 +204,8 @@ DxilLib::DxilLib(std::unique_ptr<llvm::Module> pModule)
|
|
}
|
|
}
|
|
m_functionNameMap[F.getName()] =
|
|
m_functionNameMap[F.getName()] =
|
|
llvm::make_unique<DxilFunctionLinkInfo>(&F);
|
|
llvm::make_unique<DxilFunctionLinkInfo>(&F);
|
|
|
|
+ if (m_DM.IsEntry(&F))
|
|
|
|
+ m_entrySet.insert(&F);
|
|
}
|
|
}
|
|
|
|
|
|
// Update internal global name.
|
|
// Update internal global name.
|
|
@@ -211,6 +215,7 @@ DxilLib::DxilLib(std::unique_ptr<llvm::Module> pModule)
|
|
GV.setName(MID + GV.getName());
|
|
GV.setName(MID + GV.getName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
void DxilLib::FixIntrinsicOverloads() {
|
|
void DxilLib::FixIntrinsicOverloads() {
|
|
@@ -327,6 +332,7 @@ bool DxilLib::HasFunction(std::string &name) {
|
|
return m_functionNameMap.count(name);
|
|
return m_functionNameMap.count(name);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool DxilLib::IsEntry(llvm::Function *F) { return m_entrySet.count(F); }
|
|
bool DxilLib::IsInitFunc(llvm::Function *F) { return m_initFuncSet.count(F); }
|
|
bool DxilLib::IsInitFunc(llvm::Function *F) { return m_initFuncSet.count(F); }
|
|
bool DxilLib::IsResourceGlobal(const llvm::Constant *GV) {
|
|
bool DxilLib::IsResourceGlobal(const llvm::Constant *GV) {
|
|
return m_resourceMap.count(GV);
|
|
return m_resourceMap.count(GV);
|
|
@@ -1466,7 +1472,7 @@ DxilLinkerImpl::Link(StringRef entry, StringRef profile, dxilutil::ExportMap &ex
|
|
return nullptr;
|
|
return nullptr;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- if (exportMap.empty()) {
|
|
|
|
|
|
+ if (exportMap.empty() && !exportMap.isExportShadersOnly()) {
|
|
// Add every function for lib profile.
|
|
// Add every function for lib profile.
|
|
for (auto &it : m_functionNameMap) {
|
|
for (auto &it : m_functionNameMap) {
|
|
StringRef name = it.getKey();
|
|
StringRef name = it.getKey();
|
|
@@ -1496,6 +1502,28 @@ DxilLinkerImpl::Link(StringRef entry, StringRef profile, dxilutil::ExportMap &ex
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else if (exportMap.isExportShadersOnly()) {
|
|
|
|
+ SmallVector<StringRef, 4> workList;
|
|
|
|
+ for (auto *pLib : m_attachedLibs) {
|
|
|
|
+ auto &DM = pLib->GetDxilModule();
|
|
|
|
+ auto *pM = DM.GetModule();
|
|
|
|
+ for (Function &F : pM->functions()) {
|
|
|
|
+ if (!pLib->IsEntry(&F)) {
|
|
|
|
+ if (!F.isDeclaration()) {
|
|
|
|
+ // Set none entry to be internal so they could be removed.
|
|
|
|
+ F.setLinkage(GlobalValue::LinkageTypes::InternalLinkage);
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ workList.emplace_back(F.getName());
|
|
|
|
+ }
|
|
|
|
+ libSet.insert(pLib);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!AddFunctions(workList, libSet, addedFunctionSet, linkJob,
|
|
|
|
+ /*bLazyLoadDone*/ false,
|
|
|
|
+ /*bAllowFuncionDecls*/ false))
|
|
|
|
+ return nullptr;
|
|
} else {
|
|
} else {
|
|
SmallVector<StringRef, 4> workList;
|
|
SmallVector<StringRef, 4> workList;
|
|
|
|
|