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

Commit b143180

Browse files
authored
Merge pull request #118 from compnerd/arm-unbounded
ARM: handle checking aliases with out-of-bounds GEPs
2 parents 6f24b42 + 3a2a1ee commit b143180

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,9 +3184,11 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG,
31843184

31853185
bool ARMTargetLowering::isReadOnly(const GlobalValue *GV) const {
31863186
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
3187-
GV = GA->getBaseObject();
3188-
return (isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
3189-
isa<Function>(GV);
3187+
if (!(GV = GA->getBaseObject()))
3188+
return false;
3189+
if (const auto *V = dyn_cast<GlobalVariable>(GV))
3190+
return V->isConstant();
3191+
return isa<Function>(GV);
31903192
}
31913193

31923194
SDValue ARMTargetLowering::LowerGlobalAddress(SDValue Op,

test/CodeGen/ARM/readonly-aliases.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: llc -mtriple thumbv7-unknown-linux-android -filetype asm -o - %s | FileCheck %s
2+
3+
@a = protected constant <{ i32, i32 }> <{ i32 0, i32 0 }>
4+
@b = protected alias i32, getelementptr(i32, i32* getelementptr inbounds (<{ i32, i32 }>, <{ i32, i32 }>* @a, i32 0, i32 1), i32 -1)
5+
6+
declare void @f(i32*)
7+
8+
define void @g() {
9+
entry:
10+
call void @f(i32* @b)
11+
ret void
12+
}
13+
14+
; CHECK-LABEL: g:
15+
; CHECK: movw [[REGISTER:r[0-9]+]], :lower16:b
16+
; CHECK: movt [[REGISTER]], :upper16:b
17+

0 commit comments

Comments
 (0)