[PATCH] D70586: [BPF] Fix a recursion bug in BPF Peephole ZEXT optimization
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 00:34:12 PST 2019
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Commit a0841dfe8594 <https://reviews.llvm.org/rGa0841dfe8594f189d79f3612fec019eda4824474> ("[BPF] Fix a bug in peephole optimization")
fixed a bug in peephole optimization. Recursion is introduced
to handle COPY and PHI instructions.
Unfortunately, multiple PHI instructions may form a cycle
and this will cause infinite recursion, eventual segfault.
For Commit a0841dfe8594 <https://reviews.llvm.org/rGa0841dfe8594f189d79f3612fec019eda4824474>, I indeed tried a few loops to ensure
that I won't see the recursion, but I did not try with
complex control flows, which, as demonstrated with the test case
in this patch, may introduce PHI cycles.
This patch fixed the issue by introducing a set to remember
visited PHI instructions. This way, cycles can be properly
detected and handled.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70586
Files:
llvm/lib/Target/BPF/BPFMIPeephole.cpp
llvm/test/CodeGen/BPF/32-bit-subreg-peephole-phi-3.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70586.230600.patch
Type: text/x-patch
Size: 3191 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191122/3c05d781/attachment.bin>
More information about the llvm-commits
mailing list