authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-06-16 12:14:50+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-20 16:25:22-07:00
log76102ea41f6369b2254b4a281001061e48d81ffb
treeeebbcc27d429384591633e564eb4938c209cb5c5
parent74ca811a663eb5d5e774fbccc4930da722811036

stage1: Store the specified code model in the LLVM module

This is needed for LTO builds to pick up the correct module. Closes #9132

3 files changed, 11 insertions(+), 0 deletions(-)

src/stage1/codegen.cpp+4
...@@ -9289,6 +9289,10 @@ static void init(CodeGen *g) {...@@ -9289,6 +9289,10 @@ static void init(CodeGen *g) {
9289 ZigLLVMSetModulePIELevel(g->module);9289 ZigLLVMSetModulePIELevel(g->module);
9290 }9290 }
92919291
9292 if (g->code_model != CodeModelDefault) {
9293 ZigLLVMSetModuleCodeModel(g->module, to_llvm_code_model(g));
9294 }
9295
9292 const char *target_specific_cpu_args = "";9296 const char *target_specific_cpu_args = "";
9293 const char *target_specific_features = "";9297 const char *target_specific_features = "";
92949298
src/zig_llvm.cpp+6
...@@ -969,6 +969,12 @@ void ZigLLVMSetModulePIELevel(LLVMModuleRef module) {...@@ -969,6 +969,12 @@ void ZigLLVMSetModulePIELevel(LLVMModuleRef module) {
969 unwrap(module)->setPIELevel(PIELevel::Level::Large);969 unwrap(module)->setPIELevel(PIELevel::Level::Large);
970}970}
971971
972void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model) {
973 bool JIT;
974 unwrap(module)->setCodeModel(*unwrap(code_model, JIT));
975 assert(!JIT);
976}
977
972static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {978static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
973 switch (Ordering) {979 switch (Ordering) {
974 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;980 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
src/zig_llvm.h+1
...@@ -208,6 +208,7 @@ ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);...@@ -208,6 +208,7 @@ ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);
208ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);208ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);
209ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module);209ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module);
210ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module);210ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module);
211ZIG_EXTERN_C void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model);
211212
212ZIG_EXTERN_C void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column,213ZIG_EXTERN_C void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column,
213 struct ZigLLVMDIScope *scope);214 struct ZigLLVMDIScope *scope);