[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
Mon Nov 4 12:39:27 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:

> Yes, I understand that you’d want to test the full chain - that would be highly valuable, but that’s unfortunately generally much less portable, and doesn’t work as all these tools are in separate subprojects that are independent.
> 
> In clang you can have a test that runs clang on a C file and produces LLVM IR - you can check that the produced IR contains the relevant key elements. A LLVM test, if necessary (but I guess it isn’t necessary here), can compile the IR to an object file, and you can check that it contains the necessary bits. And in LLD, you can have the LTO test - you’d have LLVM IR that gets built into a bitcode object file (i.e. LTO object file), which you can link and check the output binary properties.
> 
> That kind of holistic tests would need to go in a separate subproject for end-to-end tests - we do have that I think, but I’m not sure how much it is used.

I have changed the pgi test to emit object file and check for magic section. I will try to do something similar to the ltcg/pgu test, but I have to provide them with LTO object file and instrumentation file respectively.

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


More information about the cfe-commits mailing list