mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Set "target-cpu" and "target-features" function attributes to jit host except when they are set explicitly by user
This commit is contained in:
parent
2ddc41b02d
commit
a6d788cdb5
6 changed files with 69 additions and 3 deletions
|
@ -292,6 +292,22 @@ void dumpModuleAsm(const Context &context, const llvm::Module &module,
|
|||
}
|
||||
}
|
||||
|
||||
void setFunctionsTarget(llvm::Module &module, llvm::TargetMachine &TM) {
|
||||
// Set function target cpu to host if it wasn't set explicitly
|
||||
for (auto &&func : module.functions()) {
|
||||
if (!func.hasFnAttribute("target-cpu")) {
|
||||
func.addFnAttr("target-cpu", TM.getTargetCPU());
|
||||
}
|
||||
|
||||
if (!func.hasFnAttribute("target-features")) {
|
||||
auto featStr = TM.getTargetFeatureString();
|
||||
if (!featStr.empty()) {
|
||||
func.addFnAttr("target-features", featStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct JitFinaliser final {
|
||||
MyJIT &jit;
|
||||
bool finalized = false;
|
||||
|
@ -334,6 +350,7 @@ void rtCompileProcessImplSoInternal(const RtCompileModuleList *modlist_head,
|
|||
verifyModule(context, module);
|
||||
|
||||
dumpModule(context, module, DumpStage::OriginalIR);
|
||||
setFunctionsTarget(module, myJit.getTargetMachine());
|
||||
|
||||
module.setDataLayout(myJit.getTargetMachine().createDataLayout());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue