[llvm-dev] Why can't we devirtulize this?
Sameer Abu Asal via llvm-dev
llvm-dev at lists.llvm.org
Tue Nov 3 18:12:09 PST 2020
Hi,
I came across this case that shows a bad case for de-virtualizeation
https://godbolt.org/z/e7r6a8
If you have a call to a virtual function inside of a Loop, llvm is unable
to de-virt the call simply with Instr Combine. However, for the case where
we put the virtual call inside a loop.
You can recreate the output for inst-combine with:
clang++ -mllvm -print-after-all -mllvm
-filter-print-funcs=_Z10devirt_badm -S -O3 -emit-llvm
./test_devirt.cpp -mllvm -debug-only=instcombine -o ./test_devi
rt.ll |& tee /tmp/log.bad
clang++ -mllvm -print-after-all -mllvm
-filter-print-funcs=_Z11devirt_goodv -S -O3 -emit-llvm
./test_devirt.cpp -mllvm -debug-only=instcombine -o ./test
_devirt.ll |& tee /tmp/log.good
It seems to me a problem with Inst combine not being able to hoist the call
to get the virtual func pointer outside of the loop, is that right? Can we
possibly do better than this?
Thank you,
--Sameer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201103/99dca625/attachment.html>
More information about the llvm-dev
mailing list