xref: /llvm-project/llvm/docs/CommandGuide/llvm-diff.rst (revision fa9d232e4389bbd9ca82f8b6b34a1784107835fc)
18f4a8a63SDaniel Dunbarllvm-diff - LLVM structural 'diff'
28f4a8a63SDaniel Dunbar==================================
38f4a8a63SDaniel Dunbar
4*a056684cSJames Henderson.. program:: llvm-diff
58f4a8a63SDaniel Dunbar
68f4a8a63SDaniel DunbarSYNOPSIS
78f4a8a63SDaniel Dunbar--------
88f4a8a63SDaniel Dunbar
98f4a8a63SDaniel Dunbar**llvm-diff** [*options*] *module 1* *module 2* [*global name ...*]
108f4a8a63SDaniel Dunbar
118f4a8a63SDaniel DunbarDESCRIPTION
128f4a8a63SDaniel Dunbar-----------
138f4a8a63SDaniel Dunbar
148f4a8a63SDaniel Dunbar**llvm-diff** compares the structure of two LLVM modules, primarily
158f4a8a63SDaniel Dunbarfocusing on differences in function definitions.  Insignificant
168f4a8a63SDaniel Dunbardifferences, such as changes in the ordering of globals or in the
178f4a8a63SDaniel Dunbarnames of local values, are ignored.
188f4a8a63SDaniel Dunbar
198f4a8a63SDaniel DunbarAn input module will be interpreted as an assembly file if its name
208f4a8a63SDaniel Dunbarends in '.ll';  otherwise it will be read in as a bitcode file.
218f4a8a63SDaniel Dunbar
228f4a8a63SDaniel DunbarIf a list of global names is given, just the values with those names
238f4a8a63SDaniel Dunbarare compared; otherwise, all global values are compared, and
248f4a8a63SDaniel Dunbardiagnostics are produced for globals which only appear in one module
258f4a8a63SDaniel Dunbaror the other.
268f4a8a63SDaniel Dunbar
278f4a8a63SDaniel Dunbar**llvm-diff** compares two functions by comparing their basic blocks,
288f4a8a63SDaniel Dunbarbeginning with the entry blocks.  If the terminators seem to match,
298f4a8a63SDaniel Dunbarthen the corresponding successors are compared; otherwise they are
308f4a8a63SDaniel Dunbarignored.  This algorithm is very sensitive to changes in control flow,
318f4a8a63SDaniel Dunbarwhich tend to stop any downstream changes from being detected.
328f4a8a63SDaniel Dunbar
338f4a8a63SDaniel Dunbar**llvm-diff** is intended as a debugging tool for writers of LLVM
348f4a8a63SDaniel Dunbarpasses and frontends.  It does not have a stable output format.
358f4a8a63SDaniel Dunbar
368f4a8a63SDaniel DunbarEXIT STATUS
378f4a8a63SDaniel Dunbar-----------
388f4a8a63SDaniel Dunbar
398f4a8a63SDaniel DunbarIf **llvm-diff** finds no differences between the modules, it will exit
408f4a8a63SDaniel Dunbarwith 0 and produce no output.  Otherwise it will exit with a non-zero
418f4a8a63SDaniel Dunbarvalue.
428f4a8a63SDaniel Dunbar
438f4a8a63SDaniel DunbarBUGS
448f4a8a63SDaniel Dunbar----
458f4a8a63SDaniel Dunbar
468f4a8a63SDaniel DunbarMany important differences, like changes in linkage or function
478f4a8a63SDaniel Dunbarattributes, are not diagnosed.
488f4a8a63SDaniel Dunbar
498f4a8a63SDaniel DunbarChanges in memory behavior (for example, coalescing loads) can cause
508f4a8a63SDaniel Dunbarmassive detected differences in blocks.
51