Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 36c8f31

Browse files
Dan Gohmanalexcrichton
Dan Gohman
authored andcommitted
[SelectionDAG]: Ignore "returned" in the presence of an implicit sret.
When a function return value can't be directly lowered, such as returning an i128 on WebAssembly, as indicated by the CanLowerReturn target hook, SelectionDAGBuilder can translate it to return the value through a hidden sret-like argument. If such a function has an argument with the "returned" attribute, the attribute can't be automatically lowered, because the function no longer has a normal return value. For now, just discard the "returned" attribute. This fixes PR36128. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323715 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent f8c3edc commit 36c8f31

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8220,8 +8220,10 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
82208220
else if (Args[i].IsZExt)
82218221
ExtendKind = ISD::ZERO_EXTEND;
82228222

8223-
// Conservatively only handle 'returned' on non-vectors for now
8224-
if (Args[i].IsReturned && !Op.getValueType().isVector()) {
8223+
// Conservatively only handle 'returned' on non-vectors that can be lowered,
8224+
// for now.
8225+
if (Args[i].IsReturned && !Op.getValueType().isVector() &&
8226+
CanLowerReturn) {
82258227
assert(CLI.RetTy == Args[i].Ty && RetTys.size() == NumValues &&
82268228
"unexpected use of 'returned'");
82278229
// Before passing 'returned' to the target lowering code, ensure that
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llc < %s -asm-verbose=false | FileCheck %s
2+
3+
; Test that the "returned" attribute works with i128 types.
4+
; PR36128
5+
6+
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7+
target triple = "wasm32-unknown-unknown-wasm"
8+
9+
declare i128 @bar(i128 returned)
10+
11+
define i128 @foo(i128) {
12+
%r = tail call i128 @bar(i128 %0)
13+
ret i128 %r
14+
}
15+
16+
; CHECK-LABEL: foo:
17+
; CHECK-NEXT: .param i32, i64, i64
18+
; CHECK-NOT: .result
19+
20+
; CHECK: .functype bar, void, i32, i64, i64

0 commit comments

Comments
 (0)