[clang] [lld] [llvm] [Windows] Add support for emitting PGO/LTO magic strings in the Windows PE debug directory (PR #114260)

Mikołaj Piróg via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 06:20:12 PST 2024


================
@@ -0,0 +1,13 @@
+// This test checks if Window PE file compiled with -flto option contains a magic 
+// string "LTCG" to indicate LTO compilation.
+
+// REQUIRES: system-windows
+
+// RUN: %clang --target=x86_64-pc-windows-msvc -flto -fuse-ld=lld %s -o %t.exe
----------------
mikolaj-pirog wrote:


> > llvm-test-suite is the right place for that
> 
> That’s not exactly what I meant - llvm-test-suite has full test applications where it’s more about executing the built code - while for the same style of build-and-inspect lit tests, there is llvm-project/cross-project-tests - which is rather new, and I’m not sure about how much it actually is executed. (As for llvm-test-suite, it’s not completely buildable on windows, as far as I know.)
> 
> Regarding an all-in-one compile-and-link test; one risk (which of course is possible to test and handle) is that the test implicitly requires you to have MSVC/WinSDK files available (if the compiler injects such defaultlib directives) - so even if the test has `REQUIRES: system-windows` or similar, it could break in an mingw environment. So while the isolated stepwise unit tests feel more brittle, they ensure that those tests can run in any environment where we can compile clang and lld, as we exactly control the inputs to each step.
> 
> I.e. I’m not sure that we really do need the end-to-end tests unless you feel very strongly about it - the stepwise isolated unit tests do provide the same coverage. Back when I was new to writing tests within this ecosystem, I also wanted to test things that way, but I’ve come to appreciate the elegance of the split up tests.

I see what you mean, I have separated the tests: the Codegen ones check if magic sections are emitted, and the lld ones check for magic strings from these sections (or from bitcode in case of LTO test)


https://github.com/llvm/llvm-project/pull/114260


More information about the cfe-commits mailing list