From: Justin Bogner Date: Wed, 24 Jun 2015 07:03:07 +0000 (+0000) Subject: Hexagon: Paper over the undefined behaviour introduced by r238692 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0b48c1e633a249b150f059b18cc478f6307a01f7;p=oota-llvm.git Hexagon: Paper over the undefined behaviour introduced by r238692 This stops shifting a 32-bit value by such absurd amounts as 96 and 120. We do this by dropping a call to the function that was doing this entirely, which rather surprisingly doesn't break *any* tests. I've also added an assert in the misbehaving function to prove that it's no longer being called with completely invalid arguments. This change looks pretty bogus and we should probably be reverting r238692 instead, but this is hard to do with the number of follow ups that have happened since. It can't be any worse than the undefined behaviour that was happening before though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240526 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp b/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp index feaaa4f780d..41112ac0b46 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.cpp @@ -81,6 +81,9 @@ unsigned HexagonResource::setWeight(unsigned s) { const unsigned MaskWeight = SlotWeight - 1; bool Key = (1 << s) & getUnits(); + // TODO: Improve this API so that we can prevent misuse statically. + assert(SlotWeight * s < 32 && "Argument to setWeight too large."); + // Calculate relative weight of the insn for the given slot, weighing it the // heavier the more restrictive the insn is and the lowest the slots that the // insn may be executed in. diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h b/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h index 949ad8cebdc..8b6c72ee25e 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonShuffler.h @@ -35,7 +35,6 @@ public: void setUnits(unsigned s) { Slots = s & ~(~0U << HEXAGON_PACKET_SIZE); - setWeight(s); }; unsigned setWeight(unsigned s);