[all-commits] [llvm/llvm-project] 39dcb0: Reland "Compute GUIDs once and store in metadata" ...

Mircea Trofin via All-commits all-commits at lists.llvm.org
Tue Jul 7 16:04:46 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 39dcb0ff91b312bb269334168d5e32be78b60417
      https://github.com/llvm/llvm-project/commit/39dcb0ff91b312bb269334168d5e32be78b60417
  Author: Mircea Trofin <mtrofin at google.com>
  Date:   2026-07-07 (Tue, 07 Jul 2026)

  Changed paths:
    M clang/lib/CodeGen/BackendUtil.cpp
    M clang/lib/CodeGen/CGCUDANV.cpp
    M clang/test/CodeGen/cfi-icall-trap-recover-runtime.c
    M clang/test/CodeGen/lto-newpm-pipeline.c
    M clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp
    M lld/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll
    M lld/test/ELF/lto/devirt_vcall_vis_public.ll
    M lld/test/ELF/lto/devirt_vcall_vis_shared_def.ll
    M llvm/include/llvm/Analysis/CtxProfAnalysis.h
    M llvm/include/llvm/Bitcode/BitcodeReader.h
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/GlobalObject.h
    M llvm/include/llvm/IR/GlobalValue.h
    M llvm/include/llvm/IR/Module.h
    M llvm/include/llvm/IR/ModuleSummaryIndex.h
    M llvm/include/llvm/LTO/LTO.h
    M llvm/include/llvm/Passes/PassBuilder.h
    A llvm/include/llvm/Transforms/Utils/AssignGUID.h
    M llvm/lib/Analysis/CtxProfAnalysis.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/GlobalMerge.cpp
    M llvm/lib/IR/Globals.cpp
    M llvm/lib/LTO/LTO.cpp
    M llvm/lib/LTO/LTOBackend.cpp
    M llvm/lib/Passes/PassBuilder.cpp
    M llvm/lib/Passes/PassBuilderPipelines.cpp
    M llvm/lib/Transforms/IPO/ConstantMerge.cpp
    M llvm/lib/Transforms/IPO/FunctionImport.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
    M llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
    M llvm/lib/Transforms/Instrumentation/PGOCtxProfFlattening.cpp
    M llvm/lib/Transforms/Instrumentation/PGOCtxProfLowering.cpp
    M llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
    A llvm/lib/Transforms/Utils/AssignGUID.cpp
    M llvm/lib/Transforms/Utils/CMakeLists.txt
    M llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
    M llvm/lib/Transforms/Utils/CloneModule.cpp
    M llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
    M llvm/lib/Transforms/Utils/InlineFunction.cpp
    R llvm/test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-guid-metadata.ll
    M llvm/test/Assembler/index-value-order.ll
    M llvm/test/Bitcode/thinlto-alias.ll
    M llvm/test/Bitcode/thinlto-function-summary-callgraph-partial-sample-profile-summary.ll
    M llvm/test/Bitcode/thinlto-function-summary-callgraph-pgo.ll
    M llvm/test/Bitcode/thinlto-function-summary-callgraph-profile-summary.ll
    M llvm/test/Bitcode/thinlto-function-summary-callgraph-sample-profile-summary.ll
    M llvm/test/Bitcode/thinlto-function-summary-callgraph.ll
    M llvm/test/Bitcode/thinlto-function-summary-refgraph.ll
    M llvm/test/Bitcode/thinlto-function-summary.ll
    M llvm/test/CodeGen/X86/fat-lto-section.ll
    M llvm/test/LTO/Resolution/X86/not-prevailing-alias.ll
    M llvm/test/LTO/Resolution/X86/not-prevailing-weak-aliasee.ll
    M llvm/test/Linker/funcimport2.ll
    M llvm/test/Other/new-pm-O0-defaults.ll
    M llvm/test/Other/new-pm-defaults.ll
    M llvm/test/Other/new-pm-thinlto-prelink-defaults.ll
    M llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
    M llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
    M llvm/test/ThinLTO/AArch64/aarch64_inline.ll
    M llvm/test/ThinLTO/X86/Inputs/cache-typeid-resolutions1.ll
    M llvm/test/ThinLTO/X86/Inputs/cache-typeid-resolutions2.ll
    M llvm/test/ThinLTO/X86/Inputs/cache-typeid-resolutions3.ll
    M llvm/test/ThinLTO/X86/ctor-dtor-alias.ll
    M llvm/test/ThinLTO/X86/ctor-dtor-alias2.ll
    M llvm/test/ThinLTO/X86/deadstrip.ll
    M llvm/test/ThinLTO/X86/devirt_function_alias.ll
    M llvm/test/ThinLTO/X86/devirt_function_alias2.ll
    M llvm/test/ThinLTO/X86/devirt_pure_virtual_base.ll
    M llvm/test/ThinLTO/X86/devirt_vcall_vis_public.ll
    M llvm/test/ThinLTO/X86/distributed_import.ll
    M llvm/test/ThinLTO/X86/funcattrs-prop-exported-internal.ll
    M llvm/test/ThinLTO/X86/funcattrs-prop-unknown.ll
    M llvm/test/ThinLTO/X86/funcattrs-prop-weak.ll
    M llvm/test/ThinLTO/X86/globals-import.ll
    M llvm/test/ThinLTO/X86/hidden-escaped-symbols-alt.ll
    M llvm/test/ThinLTO/X86/hidden-escaped-symbols.ll
    M llvm/test/ThinLTO/X86/import-ro-constant.ll
    M llvm/test/ThinLTO/X86/index-const-prop-alias.ll
    M llvm/test/ThinLTO/X86/index-const-prop.ll
    M llvm/test/ThinLTO/X86/linkonce_resolution_comdat.ll
    M llvm/test/ThinLTO/X86/memprof-dups.ll
    M llvm/test/ThinLTO/X86/memprof_callee_type_mismatch.ll
    M llvm/test/ThinLTO/X86/memprof_imported_internal.ll
    M llvm/test/ThinLTO/X86/memprof_imported_internal2.ll
    M llvm/test/ThinLTO/X86/prevailing_weak_globals_import.ll
    M llvm/test/ThinLTO/X86/visibility-elf.ll
    M llvm/test/ThinLTO/X86/visibility-macho.ll
    M llvm/test/ThinLTO/X86/weak_resolution.ll
    M llvm/test/ThinLTO/X86/windows-vftable.ll
    M llvm/test/ThinLTO/X86/writeonly.ll
    A llvm/test/Transforms/AssignGUID/assign_guid.ll
    M llvm/test/Transforms/ConstantMerge/merge-dbg.ll
    M llvm/test/Transforms/EmbedBitcode/embed-wpd.ll
    M llvm/test/Transforms/EmbedBitcode/embed.ll
    M llvm/test/Transforms/FunctionImport/funcimport-debug-retained-nodes.ll
    M llvm/test/Transforms/FunctionImport/funcimport.ll
    A llvm/test/Transforms/GlobalMerge/guid.ll
    M llvm/test/Transforms/LowerTypeTests/cfi-icall-alias.ll
    M llvm/test/Transforms/LowerTypeTests/export-icall.ll
    M llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll
    M llvm/test/Transforms/PhaseOrdering/speculative-devirt-then-inliner.ll
    M llvm/test/Transforms/SampleProfile/ctxsplit.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/split.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
    M llvm/test/Transforms/WholeProgramDevirt/branch-funnel-profile.ll
    M llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
    M llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
    M llvm/test/Transforms/WholeProgramDevirt/virtual-const-prop-interposable.ll
    M llvm/test/tools/gold/X86/devirt_vcall_vis_export_dynamic.ll
    M llvm/test/tools/gold/X86/devirt_vcall_vis_public.ll
    M llvm/test/tools/gold/X86/devirt_vcall_vis_shared_def.ll
    M llvm/test/tools/gold/X86/thinlto_weak_library.ll
    M llvm/test/tools/gold/X86/thinlto_weak_resolution.ll
    M llvm/test/tools/gold/X86/v1.16/devirt_vcall_vis_export_dynamic.ll
    M llvm/tools/llvm-link/llvm-link.cpp
    M llvm/tools/opt/NewPMDriver.cpp
    M llvm/tools/opt/optdriver.cpp

  Log Message:
  -----------
  Reland "Compute GUIDs once and store in metadata" (#184065)  (#201849)

This reverts #201194, thus relanding @orodley's PR #184065 (and
#200323):

> This allows us to keep GUIDs consistent across compilation phases
which may change the name or linkage type.
> See
https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801

The CFI issues that triggered the original revert are fixed by #201370,
together with the addressing of the TODOs in `LowerTypeTests.cpp` left
in the latter. The [graphite
diff](https://app.graphite.com/github/pr/llvm/llvm-project/201849/Reland-%23184065)
between this change's V1 and V2 shows what's been added:

- the `TODO`s from #201370 are done
- in LowerTypeTests.cpp, passing `!guid` when creating a new declaration
and when converting a definition to a declaration.
- `llvm/test/Transforms/LowerTypeTests/export-icall.ll` tests also the
above def->decl conversion
- removed
`test/Analysis/CtxProfAnalysis/flatten-prethinlink-requires-guid-metadata.ll`
introduced in #194383 (this was between the revert and this PR), as now
the general expectation is that GUID assignment happens appropriately
and all passes use `getGUID`, so there's no reason for `CtxProfAnalysis`
to do something different.

Currently, we reassign GUIDs when CFI promotes internal linkage symbols,
which is counter to the goal of the RFC. This is addressed in PR
#203171. The reason for this split fix can be explained on
`compiler-rt/test/cfi/icall/wrong-signature-mixed-lto.c`. Here, a module
with the exact same source path is compiled twice, under different
conditional compilation, to produce 2 objects. Each object defines an
internal linkage symbol with the same name (this is
`install_trap_loop_detection` from
`compiler-rt/test/cfi/trap_loop_signal_handler.inc` which is
`-include`\-d by both - see how `%clang_cfi` is defined). The ThinLTO
GUID of this symbol will be the same. Its name won't be - because CFI
promotes it and renames it using a hash that is based on the IR Module
content (rather than the source path). During thinlink,
`LTO::addThinLTO`will mark each of the 2 exported symbols as prevailing
in their corresponding modules. But that is done by associating their
GUID to the module. So whichever comes last wins. The other symbol will
be marked available externally and its body DCEd later in backend. But
each module will refer to its copy of `install_trap_loop_detection`, and
so we end up with a linker error.

As mentioned, the fix is in PR #203171, and this relanding PR just
maintains the existing ThinLTO behavior by rewriting the GUIDs. Since we
haven't yet leveraged the GUID mechanics for e.g. simplifying PGO, this
aspect of this change is essentially NFC.

Co-authored-by: Owen Rodley <orodley at google.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list