Skip to content

Reland "[LLVM] Add IRNormalizer Pass" #113780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 74 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
286728e
Add IRCanonicalizer.cpp
justinfargnoli Aug 12, 2023
b2e1e73
Port IRCanonicalizer to new pass manager
justinfargnoli Aug 12, 2023
c1d9b51
Port doc updates
justinfargnoli Aug 12, 2023
b9e003d
Port tests
justinfargnoli Aug 12, 2023
57b3710
Turn rename-all and -reorder-operands on by default
justinfargnoli Aug 19, 2023
fa1eadf
Add infinite loop regression test
justinfargnoli Aug 19, 2023
a1af028
Add visited set to fix infinite loop bug
justinfargnoli Aug 27, 2023
3b8d999
Expand test to expose reordering bug
justinfargnoli Aug 27, 2023
98281e8
added some documentation
Aug 28, 2023
09d50eb
pushed broken int test
Aug 28, 2023
4eb996f
Reformat `reorderInstruction`
justinfargnoli Sep 11, 2023
f608049
Bug fix: don't reorder PHI nodes
justinfargnoli Sep 11, 2023
ac9230f
Revert "Turn rename-all and -reorder-operands on by default"
justinfargnoli Sep 11, 2023
a32ebe1
Fix naming-args-instr-blocks.ll
justinfargnoli Sep 25, 2023
1ee5e0b
clang format changes
justinfargnoli Oct 4, 2023
ffea116
clang-format changes
justinfargnoli Oct 4, 2023
0dade12
Rename to IRNormalizer
justinfargnoli Oct 14, 2023
50b8686
Removing debugging line
justinfargnoli Oct 14, 2023
5f5473e
clang-format changes
justinfargnoli Oct 16, 2023
8fcac36
Incorporate fixes
justinfargnoli Oct 21, 2023
1f47284
Add LLVM_DEBUG() for reordering code
justinfargnoli Nov 10, 2023
f8764cf
Accepts F not M
justinfargnoli Nov 10, 2023
3ac9b76
Fix nits
justinfargnoli Nov 10, 2023
9b7d155
Spelling fix
justinfargnoli Nov 10, 2023
1619480
Only sort the first two commutative operands
justinfargnoli Nov 10, 2023
a8b688b
Add LLVM_DEBUG for instruction renaming
justinfargnoli Nov 10, 2023
3937f15
Canonical -> Normal
justinfargnoli Nov 11, 2023
6a59b5f
clang-format changes
justinfargnoli Nov 11, 2023
484966a
Prefix cli arguments with "norm"
justinfargnoli Nov 11, 2023
3a945ef
clang-format changes
justinfargnoli Nov 11, 2023
a762631
clang-format changes
justinfargnoli Nov 11, 2023
d1b4e9b
Use const + WIP
justinfargnoli Nov 12, 2023
a6ee6ed
First draft of new reordering
justinfargnoli Nov 15, 2023
3aba164
New reordering
justinfargnoli Nov 20, 2023
cf71b4a
Change the output ordering
justinfargnoli Nov 20, 2023
1057585
Add comments
justinfargnoli Nov 20, 2023
5256745
Revert "Add comments"
justinfargnoli Nov 20, 2023
47989ec
Revert "Change the output ordering"
justinfargnoli Nov 20, 2023
7d8a9ab
clang-format
justinfargnoli Nov 20, 2023
8a69c6d
Don't reorder bitcasts the precede musttail
justinfargnoli Nov 20, 2023
871d69b
Fixup rebase
justinfargnoli Mar 14, 2024
f69de53
Add regression tests
justinfargnoli Mar 15, 2024
f1c89cd
Add TODO for future work
justinfargnoli Mar 15, 2024
a602c25
Stash clang changes
justinfargnoli Mar 15, 2024
24fda63
Condense tests
justinfargnoli May 5, 2024
f858047
Elaborate comment
justinfargnoli May 5, 2024
b589686
Fix naming.ll
justinfargnoli May 5, 2024
9ff2593
Add TODOs
justinfargnoli May 7, 2024
576e5ed
Prefix infinite-loop.ll with regression
justinfargnoli May 7, 2024
f8eb6cd
Add first set of reordering tests
justinfargnoli May 7, 2024
671c47f
clang-format changes
justinfargnoli May 25, 2024
0b9d91e
Save work
justinfargnoli Jun 1, 2024
4644d23
Revert "Stash clang changes"
justinfargnoli Sep 1, 2024
05e0110
[NFC] Change boolean logic for readability
justinfargnoli Sep 1, 2024
8e12f82
Fixup revert - Delete #include
justinfargnoli Sep 1, 2024
75fccb4
Remove unnecessary sortCommutativeOperands | Rename vars
justinfargnoli Sep 1, 2024
717fe44
clang-format
justinfargnoli Sep 1, 2024
6b1f18e
Remove uses of ++
justinfargnoli Sep 1, 2024
e3cd739
Use int for iterators instead of unsigned long
justinfargnoli Sep 1, 2024
a6d8df9
[NFC] Remove newlines
justinfargnoli Sep 1, 2024
aafcbdc
Refactor sortCommutativeOperands
justinfargnoli Sep 1, 2024
aff753b
clang-format
justinfargnoli Sep 1, 2024
291f53f
[NFC] Refactor `if` for readability
justinfargnoli Sep 1, 2024
e9b3d29
Auto generate tests
justinfargnoli Sep 8, 2024
876d6cf
Handle convergence intrinsics
justinfargnoli Sep 8, 2024
5a3c226
clang-format
justinfargnoli Sep 8, 2024
3cac781
Add checks for regression-deoptimize.ll
justinfargnoli Sep 8, 2024
ef6a751
Port PreservedFunctionHashAnalysis and PreservedModuleHashAnalysis to…
justinfargnoli Nov 13, 2024
5dda941
Abandon PreservedFunctionHashAnalysis and PreservedModuleHashAnalysis…
justinfargnoli Nov 13, 2024
3c33b5b
clang-format
justinfargnoli Nov 13, 2024
e909a45
Revert "clang-format"
justinfargnoli Nov 14, 2024
719157a
Revert "Abandon PreservedFunctionHashAnalysis and PreservedModuleHash…
justinfargnoli Nov 14, 2024
825ee28
Revert "Port PreservedFunctionHashAnalysis and PreservedModuleHashAna…
justinfargnoli Nov 14, 2024
cd500d2
Invalidate all analyses besides CFGAnalyses
justinfargnoli Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/docs/Passes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,14 @@ variables with initializers are marked as internal.
An interprocedural variant of :ref:`Sparse Conditional Constant Propagation
<passes-sccp>`.

``ir-normalizer``: Transforms IR into a normal form that's easier to diff
----------------------------------------------------------------------------

This pass aims to transform LLVM Modules into a normal form by reordering and
renaming instructions while preserving the same semantics. The normalizer makes
it easier to spot semantic differences while diffing two modules which have
undergone two different passes.

``jump-threading``: Jump Threading
----------------------------------

Expand Down
5 changes: 5 additions & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ point (e.g. maybe you would like to give an example of the
functionality, or simply have a lot to talk about), see the comment below
for adding a new subsection. -->

* Added a new IRNormalizer pass which aims to transform LLVM modules into
a normal form by reordering and renaming instructions while preserving the
same semantics. The normalizer makes it easier to spot semantic differences
when diffing two modules which have undergone different passes.

* ...

<!-- If you would like to document a larger change, then you can add a
Expand Down
15 changes: 15 additions & 0 deletions llvm/include/llvm/Transforms/Utils/IRNormalizer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef LLVM_TRANSFORMS_UTILS_IRNORMALIZER_H
#define LLVM_TRANSFORMS_UTILS_IRNORMALIZER_H

#include "llvm/IR/PassManager.h"

namespace llvm {

/// IRNormalizer aims to transform LLVM IR into normal form.
struct IRNormalizerPass : public PassInfoMixin<IRNormalizerPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) const;
};

} // namespace llvm

#endif // LLVM_TRANSFORMS_UTILS_IRNORMALIZER_H
2 changes: 1 addition & 1 deletion llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
#include "llvm/Transforms/Utils/FixIrreducible.h"
#include "llvm/Transforms/Utils/HelloWorld.h"
#include "llvm/Transforms/Utils/IRNormalizer.h"
#include "llvm/Transforms/Utils/InjectTLIMappings.h"
#include "llvm/Transforms/Utils/InstructionNamer.h"
#include "llvm/Transforms/Utils/Instrumentation.h"
#include "llvm/Transforms/Utils/LCSSA.h"
#include "llvm/Transforms/Utils/LibCallsShrinkWrap.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Passes/PassRegistry.def
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ FUNCTION_PASS("move-auto-init", MoveAutoInitPass())
FUNCTION_PASS("nary-reassociate", NaryReassociatePass())
FUNCTION_PASS("newgvn", NewGVNPass())
FUNCTION_PASS("no-op-function", NoOpFunctionPass())
FUNCTION_PASS("normalize", IRNormalizerPass())
FUNCTION_PASS("objc-arc", ObjCARCOptPass())
FUNCTION_PASS("objc-arc-contract", ObjCARCContractPass())
FUNCTION_PASS("objc-arc-expand", ObjCARCExpandPass())
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_llvm_component_library(LLVMTransformUtils
InstructionNamer.cpp
Instrumentation.cpp
IntegerDivision.cpp
IRNormalizer.cpp
LCSSA.cpp
LibCallsShrinkWrap.cpp
Local.cpp
Expand Down
Loading