14 Commits

Author SHA1 Message Date
Aiden Grossman
09f4c6967f [NFC][IR] Update StructuralHash comment
This patch updates a comment at the top of the structural hash
implementation that was made invalid by
64da0be1fc06ee2199bd27c980736986e0eccd9d. The class is now used for more
than just validating pass return status and is now the sole
implementation rather than being copied from somewhere.
2023-08-29 19:41:14 -07:00
Aiden Grossman
f532d61de0 [IR] Add more details to StructuralHash
This pass extends StructuralHash to include much more information about
the IR under analysis. This is done with a flag (Detailed) to configure
the behavior. The detailed behavior is intended for use in expensive
checks and downstream.

Differential Revision: https://reviews.llvm.org/D158250

Reviewed-By: aeubanks, nikic
2023-08-25 14:32:47 -07:00
Aiden Grossman
64da0be1fc Reland "[NFCi][MergeFunctions] Consolidate Hashing Functions"
This is a reland of 28134a29fdedd8972acdfb39223571ddcc15dc59 which was
reverted due to behavioral differences between 32 and 64 bit builds that
have since been fixed.

Differential Revision: https://reviews.llvm.org/D158217
2023-08-19 17:14:08 -07:00
Aiden Grossman
7ff7df1c62 Revert "[NFCi][MergeFunctions] Consolidate Hashing Functions"
This reverts commit 28134a29fdedd8972acdfb39223571ddcc15dc59.

This patch was causing build failures on multiple buildbots on 32-bit
architectures. Reverting now so I can deboug out-of-trunk and resubmit
later.
2023-08-19 12:23:16 -07:00
Aiden Grossman
28134a29fd [NFCi][MergeFunctions] Consolidate Hashing Functions
A couple years ago, StructuralHash was created, copying the exact
hashing implementation from FunctionComparator (minus a couple small
details/refactorings). Since then, the hashing implementation has not
diverged, but several other areas, like unit testing, have diverged
significantly, with StructuralHash getting more attention in these
areas. This patch aims to consolidate the two hashing functions into
StructuralHash given they do the exact same thing and having less
divergence in areas like unit testing would be beneficial.

The original aim at creating a separate StructuralHash was to make the
implementation divergent and capture additional details like instruction
operands (which neither hashing implementation does currently). The
MergeFunctions pass doesn't need these detaisl, but verification of pass
return values would benefit from this additional data. Setting an option
to calculate these values would allow for divergent behavior where
appropriate while reducing code duplication with little runtime
overhead.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D158217
2023-08-18 13:15:12 -07:00
Paul Kirth
e8e499f5f9 [IR] Ignore globals with the llvm. prefix when calculating module hash
This came up in This came up in
https://reviews.llvm.org/D146776#inline-1489091 and is slightly related
to https://reviews.llvm.org/D153855. In both patches, there is the
observation that some modifications of the module should not invalidate
analysis, such as when adding a declaration or some metadata the won't
be used when compiling the current module.

This patch implements the suggestion that we should ignore globals that have
the `llvm.` prefix when calculating the module hash.

Fixes https://github.com/llvm/llvm-project/issues/63590

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D154019
2023-07-12 15:40:31 +00:00
Mikael Holmen
d2640f596c [StructuralHash] Ignore global variable declarations
Ignore declarations of global variables, just as we do with declarations
of functions.

Done as a follow up to the comments in https://reviews.llvm.org/D149209

Differential Revision: https://reviews.llvm.org/D153855

# Conflicts:
#	llvm/lib/IR/StructuralHash.cpp
2023-06-29 07:51:49 +02:00
Paul Kirth
75a1797044 Reland [llvm] Preliminary fat-lto-objects support
Fat LTO objects contain both LTO compatible IR, as well as generated
object code. This allows users to defer the choice of whether to use LTO
or not to link-time. This is a feature available in GCC for some time,
and makes the existing -ffat-lto-objects flag functional in the same
way as GCC's.

Within LLVM, we add a new EmbedBitcodePass that serializes the module to
the object file, and expose a new pass pipeline for compiling fat
objects. The new pipeline initially clones the module and runs the
selected (Thin)LTOPrelink pipeline, after which it will serialize the
module into a `.llvm.lto` section of an ELF file. When compiling for
(Thin)LTO, this normally the point at which the compiler would emit a
object file containing the bitcode and metadata.

After that point we compile the original module using the
PerModuleDefaultPipeline used for non-LTO compilation. We generate
standard object files at the end of this pipeline, which contain machine
code and the new `.llvm.lto` section containing bitcode.

Since the two pipelines operate on different copies of the module, we
can be sure that the bitcode in the `.llvm.lto` section and object code
in  `.text` are congruent with the existing output produced by the
default and LTO pipelines.

Original RFC: https://discourse.llvm.org/t/rfc-ffat-lto-objects-support/63977

Earlier versions of this patch were missing REQUIRES lines for llc
related tests in Transforms/EmbedBitcode. Those tests are now under
CodeGen/X86, which should avoid running the check on unsupported
platforms.

The EmbedbBitcodePass also returned PreservedAnalyses::all when adding a
metadata section, which failed expensive checks, since it modified the
module. This is now corrected.

Reviewed By: tejohnson, MaskRay, nikic

Differential Revision: https://reviews.llvm.org/D146776
2023-06-28 21:37:50 +00:00
Arthur Eubanks
ce90dfc74b [StructuralHash] Track global variables
Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D149209
2023-05-15 16:57:18 -07:00
Arthur Eubanks
891ce5bdce [NFC][StructuralHash] Use hash_code 2023-04-25 14:12:06 -07:00
Arthur Eubanks
20a7ea49f4 [StandardInstrumentations] Verify function doesn't change if analyses are preserved
Reuse StructuralHash and allow it to be used in non-expensive checks builds.

Move PreservedAnalysisChecker further down StandardInstrumentations so other Instrumentations (e.g. printing) have a chance to run before PreservedAnalysisChecker crashes.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D146003
2023-03-15 13:13:08 -07:00
Arthur Eubanks
b5776f10a3 [StructuralHash][NFC] Use anonymous namespace 2023-03-14 10:48:34 -07:00
Guillaume Chatelet
59b029238a [reland][NFC] Vastly simplifies TypeSize
Simplifies the implementation of `TypeSize` while retaining its interface.
There is no need for abstract concepts like `LinearPolyBase`, `UnivariateLinearPolyBase` or `LinearPolySize`.

Differential Revision: https://reviews.llvm.org/D140263
2023-01-09 08:43:37 +00:00
serge-sans-paille
b1f4e5979b (Expensive) Check for Loop, SCC and Region pass return status
This generalizes the logic introduced in https://reviews.llvm.org/D80916 to
other passes.

It's needed by https://reviews.llvm.org/D86442 to assert passes correctly report
their status.

Differential Revision: https://reviews.llvm.org/D86589
2020-08-28 07:56:35 +02:00