[llvm] r323715 - [SelectionDAG]: Ignore "returned" in the presence of an implicit sret.

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 16:14:40 PST 2018


Author: djg
Date: Mon Jan 29 16:14:40 2018
New Revision: 323715

URL: http://llvm.org/viewvc/llvm-project?rev=323715&view=rev
Log:
[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.

Added:
    llvm/trunk/test/CodeGen/WebAssembly/i128-returned.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=323715&r1=323714&r2=323715&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Jan 29 16:14:40 2018
@@ -8241,8 +8241,10 @@ TargetLowering::LowerCallTo(TargetLoweri
       else if (Args[i].IsZExt)
         ExtendKind = ISD::ZERO_EXTEND;
 
-      // Conservatively only handle 'returned' on non-vectors for now
-      if (Args[i].IsReturned && !Op.getValueType().isVector()) {
+      // Conservatively only handle 'returned' on non-vectors that can be lowered,
+      // for now.
+      if (Args[i].IsReturned && !Op.getValueType().isVector() &&
+          CanLowerReturn) {
         assert(CLI.RetTy == Args[i].Ty && RetTys.size() == NumValues &&
                "unexpected use of 'returned'");
         // Before passing 'returned' to the target lowering code, ensure that

Added: llvm/trunk/test/CodeGen/WebAssembly/i128-returned.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/i128-returned.ll?rev=323715&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/i128-returned.ll (added)
+++ llvm/trunk/test/CodeGen/WebAssembly/i128-returned.ll Mon Jan 29 16:14:40 2018
@@ -0,0 +1,20 @@
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+
+; Test that the "returned" attribute works with i128 types.
+; PR36128
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown-wasm"
+
+declare i128 @bar(i128 returned)
+
+define i128 @foo(i128) {
+  %r = tail call i128 @bar(i128 %0)
+  ret i128 %r
+}
+
+; CHECK-LABEL: foo:
+; CHECK-NEXT: .param  	i32, i64, i64
+; CHECK-NOT:  .result
+
+; CHECK: .functype	bar, void, i32, i64, i64




More information about the llvm-commits mailing list