Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 93418ee

Browse files
committed
Fix assertion failure in ARMConstantIslandPass.
The ARMConstantIslandPass didn't have support for handling accesses to constant island objects through ARM::t2LDRBpci instructions. This adds support for that. This fixes PR31997. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295964 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ee4b4ec commit 93418ee

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ initializeFunctionInfo(const std::vector<MachineInstr*> &CPEMIs) {
805805
case ARM::LDRcp:
806806
case ARM::t2LDRpci:
807807
case ARM::t2LDRHpci:
808+
case ARM::t2LDRBpci:
808809
Bits = 12; // +-offset_12
809810
NegOk = true;
810811
break;

test/CodeGen/ARM/constantpool-promote.ll

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
; RUN: llc -relocation-model=static < %s | FileCheck %s
2-
; RUN: llc -relocation-model=pic < %s | FileCheck %s
3-
; RUN: llc -relocation-model=ropi < %s | FileCheck %s
4-
; RUN: llc -relocation-model=rwpi < %s | FileCheck %s
5-
6-
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
7-
target triple = "armv7--linux-gnueabihf"
1+
; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
2+
; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
3+
; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
4+
; RUN: llc -mtriple armv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7ARM
5+
; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
6+
; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
7+
; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
8+
; RUN: llc -mtriple thumbv7--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V7,CHECK-V7THUMB
9+
; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=static < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
10+
; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=pic < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
11+
; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=ropi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
12+
; RUN: llc -mtriple thumbv6m--linux-gnueabihf -relocation-model=rwpi < %s | FileCheck %s --check-prefixes=CHECK,CHECK-V6M
813

914
@.str = private unnamed_addr constant [2 x i8] c"s\00", align 1
1015
@.str1 = private unnamed_addr constant [69 x i8] c"this string is far too long to fit in a literal pool by far and away\00", align 1
@@ -134,18 +139,48 @@ define void @test9() #0 {
134139
ret void
135140
}
136141

142+
; CHECK-LABEL: @test10
143+
; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]]
144+
; CHECK-V6M: [[x]]:
145+
; CHECK-V6M: .asciz "s\000\000"
146+
; CHECK-V7: ldrb{{(.w)?}} r{{[0-9]*}}, [[x:.*]]
147+
; CHECK-V7: [[x]]:
148+
; CHECK-V7: .asciz "s\000\000"
149+
define void @test10(i8* %a) local_unnamed_addr #0 {
150+
call void @llvm.memmove.p0i8.p0i8.i32(i8* %a, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i32 1, i32 1, i1 false)
151+
ret void
152+
}
153+
154+
; CHECK-LABEL: @test11
155+
; CHECK-V6M: adr r{{[0-9]*}}, [[x:.*]]
156+
; CHECK-V6M: [[x]]:
157+
; CHECK-V6M: .short 3
158+
; CHECK-V6M: .short 4
159+
; CHECK-V7THUMB: ldrh{{(.w)?}} r{{[0-9]*}}, [[x:.*]]
160+
; CHECK-V7THUMB: [[x]]:
161+
; CHECK-V7THUMB: .short 3
162+
; CHECK-V7THUMB: .short 4
163+
; CHECK-V7ARM: adr r{{[0-9]*}}, [[x:.*]]
164+
; CHECK-V7ARM: [[x]]:
165+
; CHECK-V7ARM: .short 3
166+
; CHECK-V7ARM: .short 4
167+
define void @test11(i16* %a) local_unnamed_addr #0 {
168+
call void @llvm.memmove.p0i16.p0i16.i32(i16* %a, i16* getelementptr inbounds ([2 x i16], [2 x i16]* @.arr1, i32 0, i32 0), i32 2, i32 2, i1 false)
169+
ret void
170+
}
171+
137172

138173
declare void @b(i8*) #1
139174
declare void @c(i16*) #1
140175
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1)
176+
declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) local_unnamed_addr
177+
declare void @llvm.memmove.p0i16.p0i16.i32(i16*, i16*, i32, i32, i1) local_unnamed_addr
141178

142179
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
143180
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
144181
attributes #2 = { nounwind }
145182

146183
!llvm.module.flags = !{!0, !1}
147-
!llvm.ident = !{!2}
148184

149185
!0 = !{i32 1, !"wchar_size", i32 4}
150186
!1 = !{i32 1, !"min_enum_size", i32 4}
151-
!2 = !{!"Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)"}

0 commit comments

Comments
 (0)