Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 383081c

Browse files
committed
[x86/SLH] Add an assert to catch if we ever end up trying to harden
post-load a register that isn't valid for use with OR or SHRX. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337078 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 24ec170 commit 383081c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Target/X86/X86SpeculativeLoadHardening.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,14 @@ void X86SpeculativeLoadHardeningPass::hardenPostLoad(
15331533
unsigned OrOpCodes[] = {X86::OR8rr, X86::OR16rr, X86::OR32rr, X86::OR64rr};
15341534
unsigned OrOpCode = OrOpCodes[Log2_32(DefRegBytes)];
15351535

1536+
#ifndef NDEBUG
1537+
const TargetRegisterClass *OrRegClasses[] = {
1538+
&X86::GR8RegClass, &X86::GR16RegClass, &X86::GR32RegClass,
1539+
&X86::GR64RegClass};
1540+
assert(DefRC->hasSuperClassEq(OrRegClasses[Log2_32(DefRegBytes)]) &&
1541+
"Cannot define this register with OR instruction!");
1542+
#endif
1543+
15361544
unsigned SubRegImms[] = {X86::sub_8bit, X86::sub_16bit, X86::sub_32bit};
15371545

15381546
auto GetStateRegInRC = [&](const TargetRegisterClass &RC) {

0 commit comments

Comments
 (0)