Skip to content

Commit b3d88a7

Browse files
committedMar 1, 2018
[CodeGen] fix argument attribute in lowering statepoint/patchpoint
Summary: Use the correct loop index varaible, ArgI, to retrieve attributes. Reviewers: thanm, sanjoy, rnk Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43832 llvm-svn: 326433
1 parent d49e75a commit b3d88a7

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed
 

‎llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ bool FastISel::lowerCallOperands(const CallInst *CI, unsigned ArgIdx,
702702
ArgListEntry Entry;
703703
Entry.Val = V;
704704
Entry.Ty = V->getType();
705-
Entry.setAttributes(&CS, ArgIdx);
705+
Entry.setAttributes(&CS, ArgI);
706706
Args.push_back(Entry);
707707
}
708708

‎llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7700,7 +7700,7 @@ void SelectionDAGBuilder::populateCallLoweringInfo(
77007700
TargetLowering::ArgListEntry Entry;
77017701
Entry.Node = getValue(V);
77027702
Entry.Ty = V->getType();
7703-
Entry.setAttributes(&CS, ArgIdx);
7703+
Entry.setAttributes(&CS, ArgI);
77047704
Args.push_back(Entry);
77057705
}
77067706

‎llvm/test/CodeGen/X86/patchpoint.ll

+15
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ entry:
9898
ret i64 %result
9999
}
100100

101+
declare i64 @consume_attributes(i64, i8* nest, i64)
102+
define i64 @test_patchpoint_with_attributes() {
103+
entry:
104+
; CHECK-LABEL: test_patchpoint_with_attributes:
105+
; CHECK: movl $42, %edi
106+
; CHECK: xorl %r10d, %r10d
107+
; CHECK: movl $17, %esi
108+
; CHECK: movabsq $_consume_attributes, %r11
109+
; CHECK-NEXT: callq *%r11
110+
; CHECK-NEXT: xchgw %ax, %ax
111+
; CHECK: retq
112+
%result = tail call i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 21, i32 15, i8* bitcast (i64 (i64, i8*, i64)* @consume_attributes to i8*), i32 3, i64 42, i8* nest null, i64 17)
113+
ret i64 %result
114+
}
115+
101116
declare void @llvm.experimental.stackmap(i64, i32, ...)
102117
declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...)
103118
declare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...)

‎llvm/test/CodeGen/X86/statepoint-call-lowering.ll

+21
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ right:
139139
ret i1 true
140140
}
141141

142+
%struct2 = type { i64, i64, i64 }
143+
144+
declare void @consume_attributes(i32, i8* nest, i32, %struct2* byval)
145+
146+
define void @test_attributes(%struct2* byval %s) gc "statepoint-example" {
147+
entry:
148+
; CHECK-LABEL: test_attributes
149+
; Check that arguments with attributes are lowered correctly.
150+
; We call a function that has a nest argument and a byval argument.
151+
; CHECK: movl $42, %edi
152+
; CHECK: xorl %r10d, %r10d
153+
; CHECK: movl $17, %esi
154+
; CHECK: pushq
155+
; CHECK: pushq
156+
; CHECK: pushq
157+
; CHECK: callq consume_attributes
158+
%statepoint_token = call token (i64, i32, void (i32, i8*, i32, %struct2*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidi32p0i8i32p0s_struct2sf(i64 0, i32 0, void (i32, i8*, i32, %struct2*)* @consume_attributes, i32 4, i32 0, i32 42, i8* nest null, i32 17, %struct2* byval %s, i32 0, i32 0)
159+
ret void
160+
}
142161

143162
declare token @llvm.experimental.gc.statepoint.p0f_i1f(i64, i32, i1 ()*, i32, i32, ...)
144163
declare i1 @llvm.experimental.gc.result.i1(token)
@@ -157,4 +176,6 @@ declare %struct @llvm.experimental.gc.result.struct(token)
157176

158177
declare token @llvm.experimental.gc.statepoint.p0f_isVoidi32varargf(i64, i32, void (i32, ...)*, i32, i32, ...)
159178

179+
declare token @llvm.experimental.gc.statepoint.p0f_isVoidi32p0i8i32p0s_struct2sf(i64, i32, void (i32, i8*, i32, %struct2*)*, i32, i32, ...)
180+
160181
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32)

0 commit comments

Comments
 (0)
Please sign in to comment.