[PATCH] D59917: [SelectionDAG][FIX] Allow "returned" arguments to be bit-casted
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 23:47:05 PDT 2019
jdoerfert created this revision.
jdoerfert added reviewers: sunfish, stephenwlin, niravd, arsenm.
Herald added subscribers: bollu, hiraditya, wdng.
Herald added a project: LLVM.
An argument that is return by a function but bit-casted before can still
be annotated as "returned". Make sure we do not crash for this case.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59917
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/Generic/arg_returned_bitcast.ll
Index: llvm/test/CodeGen/Generic/arg_returned_bitcast.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/arg_returned_bitcast.ll
@@ -0,0 +1,13 @@
+; RUN: llc < %s -asm-verbose=false
+
+; Test that the "returned" attribute "works" even if there is a bitcast between
+; the argument and return value.
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+
+declare double* @bar(i8* returned)
+
+define double* @foo(i8*) {
+ %r = tail call double* @bar(i8* %0)
+ ret double* %r
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8944,8 +8944,9 @@
// for now.
if (Args[i].IsReturned && !Op.getValueType().isVector() &&
CanLowerReturn) {
- assert(CLI.RetTy == Args[i].Ty && RetTys.size() == NumValues &&
- "unexpected use of 'returned'");
+ assert((CLI.RetTy == Args[i].Ty ||
+ CLI.RetTy->isPointerTy() && Args[i].Ty->isPointerTy()) &&
+ RetTys.size() == NumValues && "unexpected use of 'returned'");
// Before passing 'returned' to the target lowering code, ensure that
// either the register MVT and the actual EVT are the same size or that
// the return value and argument are extended in the same way; in these
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59917.192566.patch
Type: text/x-patch
Size: 1491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190328/01701892/attachment.bin>
More information about the llvm-commits
mailing list