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

Commit c4002d7

Browse files
author
Marcin Koscielnicki
committed
[SystemZ] Implement llvm.get.dynamic.area.offset
To be used for AddressSanitizer. Differential Revision: http://reviews.llvm.org/D19817 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268572 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b4420ea commit c4002d7

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

lib/Target/SystemZ/SystemZISelDAGToDAG.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ bool SystemZDAGToDAGISel::selectAddress(SDValue Addr,
554554
expandDisp(AM, true, SDValue(),
555555
cast<ConstantSDNode>(Addr)->getSExtValue()))
556556
;
557+
// Also see if it's a bare ADJDYNALLOC.
558+
else if (Addr.getOpcode() == SystemZISD::ADJDYNALLOC &&
559+
expandAdjDynAlloc(AM, true, SDValue()))
560+
;
557561
else
558562
// Otherwise try expanding each component.
559563
while (expandAddress(AM, true) ||

lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
253253
// We need to handle dynamic allocations specially because of the
254254
// 160-byte area at the bottom of the stack.
255255
setOperationAction(ISD::DYNAMIC_STACKALLOC, PtrVT, Custom);
256+
setOperationAction(ISD::GET_DYNAMIC_AREA_OFFSET, PtrVT, Custom);
256257

257258
// Use custom expanders so that we can force the function to use
258259
// a frame pointer.
@@ -2900,6 +2901,13 @@ lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const {
29002901
return DAG.getMergeValues(Ops, DL);
29012902
}
29022903

2904+
SDValue SystemZTargetLowering::lowerGET_DYNAMIC_AREA_OFFSET(
2905+
SDValue Op, SelectionDAG &DAG) const {
2906+
SDLoc DL(Op);
2907+
2908+
return DAG.getNode(SystemZISD::ADJDYNALLOC, DL, MVT::i64);
2909+
}
2910+
29032911
SDValue SystemZTargetLowering::lowerSMUL_LOHI(SDValue Op,
29042912
SelectionDAG &DAG) const {
29052913
EVT VT = Op.getValueType();
@@ -4487,6 +4495,8 @@ SDValue SystemZTargetLowering::LowerOperation(SDValue Op,
44874495
return lowerVACOPY(Op, DAG);
44884496
case ISD::DYNAMIC_STACKALLOC:
44894497
return lowerDYNAMIC_STACKALLOC(Op, DAG);
4498+
case ISD::GET_DYNAMIC_AREA_OFFSET:
4499+
return lowerGET_DYNAMIC_AREA_OFFSET(Op, DAG);
44904500
case ISD::SMUL_LOHI:
44914501
return lowerSMUL_LOHI(Op, DAG);
44924502
case ISD::UMUL_LOHI:

lib/Target/SystemZ/SystemZISelLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ class SystemZTargetLowering : public TargetLowering {
487487
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
488488
SDValue lowerVACOPY(SDValue Op, SelectionDAG &DAG) const;
489489
SDValue lowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
490+
SDValue lowerGET_DYNAMIC_AREA_OFFSET(SDValue Op, SelectionDAG &DAG) const;
490491
SDValue lowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
491492
SDValue lowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
492493
SDValue lowerSDIVREM(SDValue Op, SelectionDAG &DAG) const;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
2+
3+
declare i64 @llvm.get.dynamic.area.offset.i64()
4+
5+
declare void @use(i64)
6+
7+
define void @f1() {
8+
; CHECK-LABEL: f1
9+
; CHECK: la %r2, 160
10+
; CHECK: brasl %r14, use
11+
; CHECK: br %r14
12+
%tmp = alloca i64, align 32
13+
%dynamic_area_offset = call i64 @llvm.get.dynamic.area.offset.i64()
14+
call void @use(i64 %dynamic_area_offset)
15+
ret void
16+
}
17+
18+
define void @f2(i64 %arg) {
19+
; CHECK-LABEL: f2
20+
; CHECK: la %r2, 160(%r2)
21+
; CHECK: brasl %r14, use
22+
; CHECK: br %r14
23+
%tmp = alloca i64, align 32
24+
%dynamic_area_offset = call i64 @llvm.get.dynamic.area.offset.i64()
25+
%param = add i64 %dynamic_area_offset, %arg
26+
call void @use(i64 %param)
27+
ret void
28+
}
29+
30+
declare void @eatsalot(i64, i64, i64, i64, i64, i64)
31+
32+
define void @f3() {
33+
; CHECK-LABEL: f3
34+
; CHECK: la %r2, 168
35+
; CHECK: brasl %r14, use
36+
; CHECK: br %r14
37+
%tmp = alloca i64, align 32
38+
call void @eatsalot(i64 0, i64 0, i64 0, i64 0, i64 0, i64 0)
39+
%dynamic_area_offset = call i64 @llvm.get.dynamic.area.offset.i64()
40+
call void @use(i64 %dynamic_area_offset)
41+
ret void
42+
}

0 commit comments

Comments
 (0)