diff options
author | Leo Li <aoli@google.com> | 2017-06-29 17:03:34 +0000 |
---|---|---|
committer | Leo Li <aoli@google.com> | 2017-06-29 17:03:34 +0000 |
commit | 20fbad9307c52ca552cf9d71a45792640b06c1af (patch) | |
tree | 3aa31561e8e1b170dcfe8eef94c99fbdefeef1c1 /llvm/test | |
parent | b7df17ec590934471096ea0d25077f144ad33195 (diff) | |
download | bcm5719-llvm-20fbad9307c52ca552cf9d71a45792640b06c1af.tar.gz bcm5719-llvm-20fbad9307c52ca552cf9d71a45792640b06c1af.zip |
[ConstantHoisting] Avoid hoisting constants in GEPs that index into a struct type.
Summary:
Indices for GEPs that index into a struct type should always be
constants. This added more checks in `collectConstantCandidates:` which make
sure constants for GEP pointer type are not hoisted.
This fixed Bug https://bugs.llvm.org/show_bug.cgi?id=33538
Reviewers: ributzka, rnk
Reviewed By: ributzka
Subscribers: efriedma, llvm-commits, srhines, javed.absar, pirama
Differential Revision: https://reviews.llvm.org/D34576
llvm-svn: 306704
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/ConstantHoisting/ARM/gep-struct-index.ll | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/llvm/test/Transforms/ConstantHoisting/ARM/gep-struct-index.ll b/llvm/test/Transforms/ConstantHoisting/ARM/gep-struct-index.ll new file mode 100644 index 00000000000..45f4500b37c --- /dev/null +++ b/llvm/test/Transforms/ConstantHoisting/ARM/gep-struct-index.ll @@ -0,0 +1,37 @@ +; RUN: opt -consthoist -S < %s | FileCheck %s +target triple = "thumbv6m-none-eabi" + +%T = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, +i32, i32, i32, i32, i32, i32 } + +; Indices for GEPs that index into a struct type should not be hoisted. +define i32 @test1(%T* %P) nounwind { +; CHECK-LABEL: @test1 +; CHECK: %const = bitcast i32 256 to i32 +; CHECK: %addr1 = getelementptr %T, %T* %P, i32 %const, i32 256 +; CHECK: %addr2 = getelementptr %T, %T* %P, i32 %const, i32 256 +; The first index into the pointer is hoisted, but the second one into the +; struct isn't. + %addr1 = getelementptr %T, %T* %P, i32 256, i32 256 + %tmp1 = load i32, i32* %addr1 + %addr2 = getelementptr %T, %T* %P, i32 256, i32 256 + %tmp2 = load i32, i32* %addr2 + %tmp4 = add i32 %tmp1, %tmp2 + ret i32 %tmp4 +} + |