From eeb7348dc3fbb0b85a7f45b5972e744085cb632d Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 22 May 2019 13:00:09 +0200 Subject: [PATCH] PGO: Check that pgo-use file actually exists. LLVM seems to only emit an easy-to-overlook warning otherwise. --- src/librustc/session/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 4d47491661e..3d8092f6e00 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1272,6 +1272,15 @@ fn validate_commandline_args_with_session_available(sess: &Session) { sess.err("Linker plugin based LTO is not supported together with \ `-C prefer-dynamic` when targeting MSVC"); } + + // Make sure that any given profiling data actually exists so LLVM can't + // decide to silently skip PGO. + if let Some(ref path) = sess.opts.debugging_opts.pgo_use { + if !path.exists() { + sess.err(&format!("File `{}` passed to `-Zpgo-use` does not exist.", + path.display())); + } + } } /// Hash value constructed out of all the `-C metadata` arguments passed to the