Skip to content

Commit 14d3585

Browse files
Added a new IRCanonicalizer pass.
Summary: Added a new IRCanonicalizer pass which aims to transform LLVM modules into a canonical form by reordering and renaming instructions while preserving the same semantics. The canonicalizer makes it easier to spot semantic differences when diffing two modules which have undergone different passes. Presentation: https://www.youtube.com/watch?v=c9WMijSOEUg Reviewed by: plotfi Differential Revision: https://reviews.llvm.org/D66029
1 parent 0591329 commit 14d3585

13 files changed

+722
-1
lines changed

llvm/docs/Passes.rst

+8
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,14 @@ the mess.
691691
An interprocedural variant of :ref:`Sparse Conditional Constant Propagation
692692
<passes-sccp>`.
693693

694+
``-ir-canonicalizer``: Transforms IR into canonical form
695+
--------------------------------------------------------
696+
697+
This pass aims to transform LLVM Modules into a canonical form by reordering and
698+
renaming instructions while preserving the same semantics. The canonicalizer makes
699+
it easier to spot semantic differences while diffing two modules which have undergone
700+
two different passes.
701+
694702
``-jump-threading``: Jump Threading
695703
-----------------------------------
696704

llvm/docs/ReleaseNotes.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ Non-comprehensive list of changes in this release
4141
for adding a new subsection.
4242
4343
* ...
44-
44+
* Added a new IRCanonicalizer pass which aims to transform LLVM modules into
45+
a canonical form by reordering and renaming instructions while preserving the
46+
same semantics. The canonicalizer makes it easier to spot semantic differences
47+
when diffing two modules which have undergone different passes.
4548

4649
.. NOTE
4750
If you would like to document a larger change, then you can add a

llvm/include/llvm/InitializePasses.h

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ void initializeHotColdSplittingLegacyPassPass(PassRegistry&);
179179
void initializeHWAddressSanitizerLegacyPassPass(PassRegistry &);
180180
void initializeIPCPPass(PassRegistry&);
181181
void initializeIPSCCPLegacyPassPass(PassRegistry&);
182+
void initializeIRCanonicalizerPass(PassRegistry&);
182183
void initializeIRCELegacyPassPass(PassRegistry&);
183184
void initializeIRTranslatorPass(PassRegistry&);
184185
void initializeIVUsersWrapperPassPass(PassRegistry&);

llvm/include/llvm/LinkAllPasses.h

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ namespace {
118118
(void) llvm::createLoopGuardWideningPass();
119119
(void) llvm::createIPConstantPropagationPass();
120120
(void) llvm::createIPSCCPPass();
121+
(void) llvm::createIRCanonicalizerPass();
121122
(void) llvm::createInductiveRangeCheckEliminationPass();
122123
(void) llvm::createIndVarSimplifyPass();
123124
(void) llvm::createInstSimplifyLegacyPass();

llvm/include/llvm/Transforms/Utils.h

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ extern char &LowerInvokePassID;
4646
FunctionPass *createInstructionNamerPass();
4747
extern char &InstructionNamerID;
4848

49+
//===----------------------------------------------------------------------===//
50+
//
51+
// IRCanonicalizer - Transforms LLVM Modules into canonical form.
52+
//
53+
Pass *createIRCanonicalizerPass();
54+
4955
//===----------------------------------------------------------------------===//
5056
//
5157
// LowerSwitch - This pass converts SwitchInst instructions into a sequence of

llvm/lib/Transforms/Utils/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_llvm_component_library(LLVMTransformUtils
3232
InjectTLIMappings.cpp
3333
InstructionNamer.cpp
3434
IntegerDivision.cpp
35+
IRCanonicalizer.cpp
3536
LCSSA.cpp
3637
LibCallsShrinkWrap.cpp
3738
Local.cpp

0 commit comments

Comments
 (0)