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

Commit 71beb00

Browse files
author
James Molloy
committed
[Thumb] Don't try and emit LDRH/LDRB from the constant pool
This is not a valid encoding - these instructions cannot do PC-relative addressing. The underlying problem here is of whitelist in ARMISelDAGToDAG that unwraps ARMISD::Wrappers during addressing-mode selection. This didn't realise TargetConstantPool was actually possible, so didn't handle it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283323 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 471e290 commit 71beb00

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/Target/ARM/ARMISelDAGToDAG.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ ARMDAGToDAGISel::SelectThumbAddrModeImm5S(SDValue N, unsigned Scale,
11881188
} else if (N.getOpcode() == ARMISD::Wrapper &&
11891189
N.getOperand(0).getOpcode() != ISD::TargetGlobalAddress &&
11901190
N.getOperand(0).getOpcode() != ISD::TargetExternalSymbol &&
1191+
N.getOperand(0).getOpcode() != ISD::TargetConstantPool &&
11911192
N.getOperand(0).getOpcode() != ISD::TargetGlobalTLSAddress) {
11921193
Base = N.getOperand(0);
11931194
} else {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc < %s -O0 -fast-isel=false | FileCheck %s
2+
; RUN: llc < %s -O0 -fast-isel=false -filetype=obj
3+
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4+
target triple = "thumbv6m-arm-linux-gnueabi"
5+
6+
@fn1.a = private unnamed_addr constant [4 x i16] [i16 6, i16 0, i16 0, i16 0], align 2
7+
8+
; We must not try and emit this bad instruction: "ldrh r1, .LCPI0_0"
9+
; CHECK-LABEL: fn1:
10+
; CHECK: adr [[base:r[0-9]+]], .LCPI0_0
11+
; CHECK-NOT: ldrh {{r[0-9]+}}, .LCPI0_0
12+
; FIXME: We want to use [[base]] below instead of "r0", but the preceding square bracket confuses FileCheck.
13+
; CHECK: ldrh r{{[0-9]+}}, [r0]
14+
define hidden i32 @fn1() #0 {
15+
entry:
16+
call void @llvm.memcpy.p0i8.p0i8.i32(i8* undef, i8* bitcast ([4 x i16]* @fn1.a to i8*), i32 8, i32 2, i1 false)
17+
ret i32 undef
18+
}
19+
20+
; Function Attrs: argmemonly nounwind
21+
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1)
22+
attributes #0 = { "target-features"="+strict-align" }

0 commit comments

Comments
 (0)