]> granicus.if.org Git - llvm/commit
[AVR] Fix codegen bug in 16-bit loads
authorDylan McKay <me@dylanmckay.io>
Fri, 18 Jan 2019 11:27:38 +0000 (11:27 +0000)
committerDylan McKay <me@dylanmckay.io>
Fri, 18 Jan 2019 11:27:38 +0000 (11:27 +0000)
commit912adb1a84aad5b785e5bb2a5ee5b72cad3d26a2
treea073ee8c01c75178d14967d63e5a740ad69172ac
parent4d0c775881900cb8cd242a2ac42b2338c17e2751
[AVR] Fix codegen bug in 16-bit loads

Prior to this patch, the AVR::LDWRdPtr instruction was always lowered to
instructions of this pattern:

    ld  $GPR8, [PTR:XYZ]+
    ld  $GPR8, [PTR]+1

This has a problem; the [PTR] is incremented in-place once, but never
decremented.

Future uses of the same pointer will use the now clobbered value,
leading to the pointer being incorrect by an offset of one.

This patch modifies the expansion code of the LDWRdPtr pseudo
instruction so that the pointer variable is not silently clobbered in
future uses in the same live range.

Patch by Keshav Kini.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351544 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AVR/AVRExpandPseudoInsts.cpp
test/CodeGen/AVR/PR37143.ll [new file with mode: 0644]
test/CodeGen/AVR/atomics/load16.ll
test/CodeGen/AVR/load.ll
test/CodeGen/AVR/pseudo/LDWRdPtr-same-src-dst.mir
test/CodeGen/AVR/pseudo/LDWRdPtr.mir