[PATCH] D33574: PPC: Verify that branch fixups fit within the range.
Kyle Butt via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 10:21:53 PDT 2017
iteratee updated this revision to Diff 100730.
iteratee added a comment.
Tidy up comparisons.
https://reviews.llvm.org/D33574
Files:
lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
Index: lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
===================================================================
--- lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
+++ lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp
@@ -35,10 +35,22 @@
case PPC::fixup_ppc_nofixup:
return Value;
case PPC::fixup_ppc_brcond14:
+ if (static_cast<int64_t>(Value) >= 0 && Value > 0x7fff)
+ llvm_unreachable("Cond branch target overflow.");
+ else if (static_cast<int64_t>(Value) < 0 && -Value > 0x8000)
+ llvm_unreachable("Cond branch target underflow.");
+ return Value & 0xfffc;
case PPC::fixup_ppc_brcond14abs:
+ assert(Value <= 0xffff && "Cond branch absolute target overflow.");
return Value & 0xfffc;
case PPC::fixup_ppc_br24:
+ if (static_cast<int64_t>(Value) >= 0 && Value > 0x1ffffff)
+ llvm_unreachable("Branch target overflow.");
+ else if (static_cast<int64_t>(Value) < 0 && -Value > 0x2000000)
+ llvm_unreachable("Branch target underflow.");
+ return Value & 0x3fffffc;
case PPC::fixup_ppc_br24abs:
+ assert(Value <= 0x3ffffff && "Branch absolute target overflow.");
return Value & 0x3fffffc;
case PPC::fixup_ppc_half16:
return Value & 0xffff;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33574.100730.patch
Type: text/x-patch
Size: 1235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170530/e17b7023/attachment.bin>
More information about the llvm-commits
mailing list