[llvm] r362546 - [SelectionDAG][FIX] Allow "returned" arguments to be bit-casted
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 13:34:44 PDT 2019
Author: jdoerfert
Date: Tue Jun 4 13:34:43 2019
New Revision: 362546
URL: http://llvm.org/viewvc/llvm-project?rev=362546&view=rev
Log:
[SelectionDAG][FIX] Allow "returned" arguments to be bit-casted
Summary:
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.
Reviewers: sunfish, stephenwlin, niravd, arsenm
Subscribers: wdng, hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59917
Added:
llvm/trunk/test/CodeGen/X86/arg_returned_bitcast.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=362546&r1=362545&r2=362546&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Jun 4 13:34:43 2019
@@ -9111,8 +9111,11 @@ TargetLowering::LowerCallTo(TargetLoweri
// 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() &&
+ CLI.RetTy->getPointerAddressSpace() ==
+ Args[i].Ty->getPointerAddressSpace())) &&
+ 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
Added: llvm/trunk/test/CodeGen/X86/arg_returned_bitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/arg_returned_bitcast.ll?rev=362546&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/arg_returned_bitcast.ll (added)
+++ llvm/trunk/test/CodeGen/X86/arg_returned_bitcast.ll Tue Jun 4 13:34:43 2019
@@ -0,0 +1,12 @@
+; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s
+
+; Test that the "returned" attribute "works" even if there is a bitcast between
+; the argument and return value.
+
+declare double* @bar(i8* returned)
+
+define double* @foo(i8*) {
+ %r = tail call double* @bar(i8* %0)
+; CHECK: jmp bar
+ ret double* %r
+}
More information about the llvm-commits
mailing list