IPRA: Fix RegMask calculation for alias registers
authorMatthias Braun <matze@braunis.de>
Thu, 21 Jul 2016 03:50:39 +0000 (03:50 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 21 Jul 2016 03:50:39 +0000 (03:50 +0000)
commitd9fdad72aefb6e152a1505807e5afad3a6d7e57b
treee2cb1fdc5b6d300e933175dedad172ee57f0c780
parente3fc4d0fdda3762fc0e88bb426274d8fc946e480
IPRA: Fix RegMask calculation for alias registers

This patch fixes a very subtle bug in regmask calculation. Thanks to zan
jyu Wong <zyfwong@gmail.com> for bringing this to notice.
For example if CL is only clobbered than CH should not be marked
clobbered but CX, RCX and ECX should be mark clobbered. Previously for
each modified register all of its aliases are marked clobbered by
markRegClobbred() in RegUsageInfoCollector.cpp but that is wrong because
when CL is clobbered then MRI::isPhysRegModified() will return true for
CL, CX, ECX, RCX which is correct behavior but then for CX, EXC, RCX we
mark CH also clobbered as CH is aliased to CX,ECX,RCX so
markRegClobbred() is not required because isPhysRegModified already take
cares of proper aliasing register. A very simple test case has been
added to verify this change.
Please find relevant bug report here :
http://llvm.org/PR28567

Patch by Vivek Pandya <vivekvpandya@gmail.com>

Differential Revision: https://reviews.llvm.org/D22400

llvm-svn: 276235
llvm/lib/CodeGen/RegUsageInfoCollector.cpp
llvm/test/CodeGen/X86/ipra-reg-alias.ll [new file with mode: 0644]