summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2019-08-01 23:44:42 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2019-08-01 23:44:42 +0000
commit1055a11d1bc70f80e78adba816626668941136a4 (patch)
tree1bbc2c7fa1b56490969b364d90635af2c435cbfe /llvm
parentf93d162e335320c5c33f7ae9f6cc94cce2494f6d (diff)
downloadbcm5719-llvm-1055a11d1bc70f80e78adba816626668941136a4.tar.gz
bcm5719-llvm-1055a11d1bc70f80e78adba816626668941136a4.zip
Prevent vregs leaking into the MC layer via TargetRegisterClass::contains()
Summary: The MC layer doesn't expect to deal with vregs but TargetRegisterClass::contains() forwards into MCRegisterClass::contains() and this can cause vregs to turn up in the MC layer APIs. Add guards against this to prevent this becoming a problem as we replace unsigned with a new MCRegister object for improved type safety. Reviewers: arsenm Subscribers: wdng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65554 llvm-svn: 367636
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/CodeGen/TargetRegisterInfo.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
index dd88f250a21..8c98d626b6d 100644
--- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h
@@ -87,11 +87,20 @@ public:
/// Return true if the specified register is included in this register class.
/// This does not include virtual registers.
bool contains(unsigned Reg) const {
+ /// FIXME: Historically this function has returned false when given vregs
+ /// but it should probably only receive physical registers
+ if (!Register::isPhysicalRegister(Reg))
+ return false;
return MC->contains(Reg);
}
/// Return true if both registers are in this class.
bool contains(unsigned Reg1, unsigned Reg2) const {
+ /// FIXME: Historically this function has returned false when given a vregs
+ /// but it should probably only receive physical registers
+ if (!Register::isPhysicalRegister(Reg1) ||
+ !Register::isPhysicalRegister(Reg2))
+ return false;
return MC->contains(Reg1, Reg2);
}
OpenPOWER on IntegriCloud