Index: lib/Driver/ToolChains/MinGW.cpp =================================================================== --- lib/Driver/ToolChains/MinGW.cpp +++ lib/Driver/ToolChains/MinGW.cpp @@ -270,6 +270,8 @@ CmdArgs.push_back("--no-whole-archive"); } + TC.addProfileRTLibs(Args, CmdArgs); + if (!HasWindowsApp) { // Add system libraries. If linking to libwindowsapp.a, that import // library replaces all these and we shouldn't accidentally try to Index: test/Driver/instrprof-ld.c =================================================================== --- test/Driver/instrprof-ld.c +++ test/Driver/instrprof-ld.c @@ -121,3 +121,11 @@ // // CHECK-WINDOWS-X86-64: "{{.*}}link{{(.exe)?}}" // CHECK-WINDOWS-X86-64: "{{.*}}clang_rt.profile-x86_64.lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 -fuse-ld=lld \ +// RUN: -target x86_64-mingw32 -fprofile-instr-generate \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: | FileCheck --check-prefix=CHECK-MINGW-X86-64 %s +// +// CHECK-MINGW-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}" +// CHECK-MINGW-X86-64: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}windows{{/|\\\\}}libclang_rt.profile-x86_64.a"