[PATCH] D81558: [NewPM] Introduce PreserveCFG check
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 01:27:11 PDT 2020
yrouban updated this revision to Diff 289100.
yrouban added a comment.
Defined a separate class named //CFG//.
CFG defines the notion //PreserveCFG// for the multigraph of BasicBlocks with unordered successors.
CFG can safely track and print CFG changes. To guard CFG from accessing deleted blocks //PoisoningVH// is used and is extended with one getter.
The cfg diff printing function is rewritten.
Rebased.
Here is an example of an output of a unexpected CFG change detected after SimplifyCFG mistakenly reported PreservedCFG.
$ opt -passes=simplifycfg -S -verify-cfg-preserved --debug-only=stdinstrumentations
before SimplifyCFG
------------------
define i32 @test5(i32 %A) {
switch i32 %A, label %return [
i32 2, label %return
i32 10, label %2
i32 9, label %1
i32 8, label %2
]
ret i32 1
ret i32 2
return:
ret i32 0
}
after SimplifyCFG
-----------------
define i32 @test5(i32 %A) {
switch i32 %A, label %return [
i32 8, label %2
i32 10, label %2
i32 9, label %1
]
1: ; preds = %return, %2, %0
%merge = phi i32 [ 1, %0 ], [ 2, %2 ], [ 0, %return ]
ret i32 %merge
2: ; preds = %0, %0
br label %1
return: ; preds = %0
br label %1
}
Mocked error
------------
Error: SimplifyCFGPass reported it preserved CFG, but changes detected:
In function @test5
Different number of non-leaf basic blocks: before=1, after=3
Non-leaf block return<0x23931c0> is added (1 successors)
Different successors of block entry<0x2393130> (unordered):
- before (3): return<0x23931c0>(2), unnamed_1<0x2393990>, unnamed_2<0x23938d0>(2),
- after (3): return<0x23931c0>, unnamed_1<0x2393990>, unnamed_2<0x23938d0>(2),
Non-leaf block unnamed_2<0x23938d0> is added (1 successors)
LLVM ERROR: Preserved CFG changed by SimplifyCFGPass
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81558/new/
https://reviews.llvm.org/D81558
Files:
llvm/include/llvm/IR/ValueHandle.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/Passes/StandardInstrumentations.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81558.289100.patch
Type: text/x-patch
Size: 8751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200901/9f25d052/attachment.bin>
More information about the llvm-commits
mailing list