mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 02:45:25 +03:00
Add thunks to symbol list
This commit is contained in:
parent
6734cd19f3
commit
e453edcc6a
1 changed files with 24 additions and 13 deletions
|
@ -541,26 +541,37 @@ generateFuncList(IRState *irs, const Types &types) {
|
|||
return getArrayAndSize(irs->module, types.funcListElemType, elements);
|
||||
}
|
||||
|
||||
llvm::Constant *generateSymListElem(llvm::Module &module, const Types &types,
|
||||
llvm::StringRef name,
|
||||
llvm::GlobalValue &val) {
|
||||
|
||||
llvm::Constant *fields[] = {
|
||||
createStringInitializer(module, name),
|
||||
getI8Ptr(&val),
|
||||
};
|
||||
return llvm::ConstantStruct::get(types.symListElemType, fields);
|
||||
}
|
||||
|
||||
std::pair<llvm::Constant *, llvm::Constant *>
|
||||
generateSymList(IRState *irs, const Types &types,
|
||||
const GlobalValsMap &globalVals) {
|
||||
assert(nullptr != irs);
|
||||
std::vector<llvm::Constant *> elements;
|
||||
for (auto &&it : globalVals) {
|
||||
if (it.second == GlobalValVisibility::Declaration) {
|
||||
auto val = it.first;
|
||||
if (auto fun = llvm::dyn_cast<llvm::Function>(val)) {
|
||||
if (fun->isIntrinsic())
|
||||
continue;
|
||||
}
|
||||
auto name = val->getName();
|
||||
llvm::Constant *fields[] = {
|
||||
createStringInitializer(irs->module, name),
|
||||
getI8Ptr(val),
|
||||
};
|
||||
elements.push_back(
|
||||
llvm::ConstantStruct::get(types.symListElemType, fields));
|
||||
auto val = it.first;
|
||||
assert(val != nullptr);
|
||||
if (auto fun = llvm::dyn_cast<llvm::Function>(val)) {
|
||||
if (fun->isIntrinsic())
|
||||
continue;
|
||||
}
|
||||
auto name = val->getName();
|
||||
elements.push_back(generateSymListElem(irs->module, types, name, *val));
|
||||
}
|
||||
for (auto &&it : irs->dynamicCompiledFunctions) {
|
||||
auto name = it.first->getName();
|
||||
auto thunk = it.second.thunkFunc;
|
||||
assert(thunk != nullptr);
|
||||
elements.push_back(generateSymListElem(irs->module, types, name, *thunk));
|
||||
}
|
||||
return getArrayAndSize(irs->module, types.symListElemType, elements);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue