[llvm] r253222 - [ARM] Prevent use of a value pointed by end() iterator when placing a jump table

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 08:58:20 PST 2015


Is this covered by existing tests? (if I replaced the if/continue with
assert (!= end) would it fire on the existing regression suite?)

On Mon, Nov 16, 2015 at 8:41 AM, Petr Pavlu via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: petr.pavlu
> Date: Mon Nov 16 10:41:13 2015
> New Revision: 253222
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253222&view=rev
> Log:
> [ARM] Prevent use of a value pointed by end() iterator when placing a jump
> table
>
> Function ARMConstantIslands::doInitialJumpTablePlacement() iterates over
> all
> basic blocks in a machine function. It calls `MI =
> MBB.getLastNonDebugInstr()`
> to get the last instruction in each block and then uses MI->getOpcode() to
> decide what to do. If getLastNonDebugInstr() returns MBB.end() (for
> example,
> when the block does not contain any instructions) then calling getOpcode()
> on
> this value is incorrect. Avoid this problem by checking the result of
> getLastNonDebugInstr().
>
> Differential Revision: http://reviews.llvm.org/D14694
>
> Modified:
>     llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
>
> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=253222&r1=253221&r2=253222&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Nov 16
> 10:41:13 2015
> @@ -589,6 +589,8 @@ void ARMConstantIslands::doInitialJumpTa
>    MachineBasicBlock *LastCorrectlyNumberedBB = nullptr;
>    for (MachineBasicBlock &MBB : *MF) {
>      auto MI = MBB.getLastNonDebugInstr();
> +    if (MI == MBB.end())
> +      continue;
>
>      unsigned JTOpcode;
>      switch (MI->getOpcode()) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/4549a3b4/attachment-0001.html>


More information about the llvm-commits mailing list