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) {
92899289 ZigLLVMSetModulePIELevel(g->module);
92909290 }
92919291
9292 if (g->code_model != CodeModelDefault) {
9293 ZigLLVMSetModuleCodeModel(g->module, to_llvm_code_model(g));
9294 }
9295
92929296 const char *target_specific_cpu_args = "";
92939297 const char *target_specific_features = "";
92949298
src/zig_llvm.cpp+6
......@@ -969,6 +969,12 @@ void ZigLLVMSetModulePIELevel(LLVMModuleRef module) {
969969 unwrap(module)->setPIELevel(PIELevel::Level::Large);
970970}
971971
972void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model) {
973 bool JIT;
974 unwrap(module)->setCodeModel(*unwrap(code_model, JIT));
975 assert(!JIT);
976}
977
972978static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
973979 switch (Ordering) {
974980 case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
src/zig_llvm.h+1
......@@ -208,6 +208,7 @@ ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);
208208ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);
209209ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module);
210210ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module);
211ZIG_EXTERN_C void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model);
211212
212213ZIG_EXTERN_C void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column,
213214 struct ZigLLVMDIScope *scope);