From 6f1ae3c7db43a312d638cbcde2b431026d211d8d Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 2 Aug 2016 08:56:52 +0000 Subject: [PATCH] AArch64: Assert on branch displacement bits llvm-svn: 277434 --- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 05bc1cb..d359953 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -132,6 +132,13 @@ static unsigned getBranchMaxDisplacementBytes(unsigned Opc) { unsigned Bits = getBranchDisplacementBits(Opc); unsigned MaxOffs = ((1 << (Bits - 1)) - 1) << 2; + + // Verify the displacement bits options have sane values. + // XXX: Is there a better place for this? + assert(MaxOffs >= 8 && + "max branch displacement must be enough to jump" + "over conditional branch expansion"); + return MaxOffs; } -- 2.7.4