diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index ddc8652d7dbd6..e0539eda4f0c0 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -499,7 +499,11 @@ swift::createTargetMachine(IRGenOptions &Opts, ASTContext &Ctx) { // Create a target machine. auto cmodel = CodeModel::Default; - if (Triple.isWindowsCygwinEnvironment()) + + // On Windows 64 bit, dlls are loaded above the max address for 32 bits. + // This means that a default CodeModel causes generated code to segfault + // when run. + if (Triple.isArch64Bit() && Triple.isOSWindows()) cmodel = CodeModel::Large; llvm::TargetMachine *TargetMachine =