Skip to content

[LLVM] Add IRNormalizer Pass #68176

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 69 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
77071b7
Add IRCanonicalizer.cpp
justinfargnoli Aug 12, 2023
03181ee
Port IRCanonicalizer to new pass manager
justinfargnoli Aug 12, 2023
e6bbd5c
Port doc updates
justinfargnoli Aug 12, 2023
22bdc47
Port tests
justinfargnoli Aug 12, 2023
a6c8cdd
Turn rename-all and -reorder-operands on by default
justinfargnoli Aug 19, 2023
f1eece7
Add infinite loop regression test
justinfargnoli Aug 19, 2023
6df03e5
Add visited set to fix infinite loop bug
justinfargnoli Aug 27, 2023
0d45321
Expand test to expose reordering bug
justinfargnoli Aug 27, 2023
cbe5540
added some documentation
Aug 28, 2023
5ea1b1b
pushed broken int test
Aug 28, 2023
85a6d01
Reformat `reorderInstruction`
justinfargnoli Sep 11, 2023
dd5a7b5
Bug fix: don't reorder PHI nodes
justinfargnoli Sep 11, 2023
3c41c79
Revert "Turn rename-all and -reorder-operands on by default"
justinfargnoli Sep 11, 2023
e461ddf
Fix naming-args-instr-blocks.ll
justinfargnoli Sep 25, 2023
d2395f3
clang format changes
justinfargnoli Oct 4, 2023
208fc1c
clang-format changes
justinfargnoli Oct 4, 2023
2741370
Rename to IRNormalizer
justinfargnoli Oct 14, 2023
97885a1
Removing debugging line
justinfargnoli Oct 14, 2023
25f4d54
clang-format changes
justinfargnoli Oct 16, 2023
f37b55e
Incorporate fixes
justinfargnoli Oct 21, 2023
5f0a19e
Add LLVM_DEBUG() for reordering code
justinfargnoli Nov 10, 2023
8d2a090
Accepts F not M
justinfargnoli Nov 10, 2023
d204594
Fix nits
justinfargnoli Nov 10, 2023
73f0bc6
Spelling fix
justinfargnoli Nov 10, 2023
fafd25f
Only sort the first two commutative operands
justinfargnoli Nov 10, 2023
1f88816
Add LLVM_DEBUG for instruction renaming
justinfargnoli Nov 10, 2023
d07b49c
Canonical -> Normal
justinfargnoli Nov 11, 2023
8cb6b34
clang-format changes
justinfargnoli Nov 11, 2023
86bf135
Prefix cli arguments with "norm"
justinfargnoli Nov 11, 2023
e107b65
clang-format changes
justinfargnoli Nov 11, 2023
767fbe5
clang-format changes
justinfargnoli Nov 11, 2023
7b31db7
Use const + WIP
justinfargnoli Nov 12, 2023
6076c36
First draft of new reordering
justinfargnoli Nov 15, 2023
57d9daf
New reordering
justinfargnoli Nov 20, 2023
1862ac1
Change the output ordering
justinfargnoli Nov 20, 2023
170d5a6
Add comments
justinfargnoli Nov 20, 2023
0c7eba6
Revert "Add comments"
justinfargnoli Nov 20, 2023
eee14f6
Revert "Change the output ordering"
justinfargnoli Nov 20, 2023
cc10ec1
clang-format
justinfargnoli Nov 20, 2023
22b1547
Don't reorder bitcasts the precede musttail
justinfargnoli Nov 20, 2023
ca3ce5c
Fixup rebase
justinfargnoli Mar 14, 2024
9346eea
Add regression tests
justinfargnoli Mar 15, 2024
057bf09
Add TODO for future work
justinfargnoli Mar 15, 2024
c39d315
Stash clang changes
justinfargnoli Mar 15, 2024
cfaeb59
Condense tests
justinfargnoli May 5, 2024
0bf0557
Elaborate comment
justinfargnoli May 5, 2024
6a45ffd
Fix naming.ll
justinfargnoli May 5, 2024
2c078de
Add TODOs
justinfargnoli May 7, 2024
aa47fc5
Prefix infinite-loop.ll with regression
justinfargnoli May 7, 2024
af9d03a
Add first set of reordering tests
justinfargnoli May 7, 2024
d6c37c2
clang-format changes
justinfargnoli May 25, 2024
0bc97cc
Save work
justinfargnoli Jun 1, 2024
5ac3cd8
Revert "Stash clang changes"
justinfargnoli Sep 1, 2024
1795475
[NFC] Change boolean logic for readability
justinfargnoli Sep 1, 2024
093ee53
Fixup revert - Delete #include
justinfargnoli Sep 1, 2024
4ca4d95
Remove unnecessary sortCommutativeOperands | Rename vars
justinfargnoli Sep 1, 2024
940119a
clang-format
justinfargnoli Sep 1, 2024
d6e6158
Remove uses of ++
justinfargnoli Sep 1, 2024
62aaf5c
Use int for iterators instead of unsigned long
justinfargnoli Sep 1, 2024
e0a05f0
[NFC] Remove newlines
justinfargnoli Sep 1, 2024
ea990c5
Refactor sortCommutativeOperands
justinfargnoli Sep 1, 2024
21c5491
clang-format
justinfargnoli Sep 1, 2024
e8036f1
[NFC] Refactor `if` for readability
justinfargnoli Sep 1, 2024
a64f342
Auto generate tests
justinfargnoli Sep 8, 2024
d7a532f
Handle convergence intrinsics
justinfargnoli Sep 8, 2024
c58bb60
clang-format
justinfargnoli Sep 8, 2024
19e47e0
Add checks for regression-deoptimize.ll
justinfargnoli Sep 8, 2024
937bcea
Merge branch 'main' of github.com:llvm/llvm-project
justinfargnoli Oct 21, 2024
a4fbfdb
Fixup merge commit
justinfargnoli Oct 21, 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
1 change: 1 addition & 0 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
#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"
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 @@ -412,6 +412,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