[llvm] r374498 - [Attributor][FIX] Do not replace musstail calls with constant
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 18:45:32 PDT 2019
Author: jdoerfert
Date: Thu Oct 10 18:45:32 2019
New Revision: 374498
URL: http://llvm.org/viewvc/llvm-project?rev=374498&view=rev
Log:
[Attributor][FIX] Do not replace musstail calls with constant
Modified:
llvm/trunk/lib/Transforms/IPO/Attributor.cpp
llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll
Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=374498&r1=374497&r2=374498&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Thu Oct 10 18:45:32 2019
@@ -997,7 +997,7 @@ ChangeStatus AAReturnedValuesImpl::manif
// Callback to replace the uses of CB with the constant C.
auto ReplaceCallSiteUsersWith = [](CallBase &CB, Constant &C) {
- if (CB.getNumUses() == 0)
+ if (CB.getNumUses() == 0 || CB.isMustTailCall())
return ChangeStatus::UNCHANGED;
CB.replaceAllUsesWith(&C);
return ChangeStatus::CHANGED;
Modified: llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll?rev=374498&r1=374497&r2=374498&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll Thu Oct 10 18:45:32 2019
@@ -830,6 +830,11 @@ define i32* @use_const() #0 {
; CHECK: ret i32* bitcast (i8* @G to i32*)
ret i32* %c
}
+define i32* @dont_use_const() #0 {
+ %c = musttail call i32* @ret_const()
+ ; CHECK: ret i32* %c
+ ret i32* %c
+}
attributes #0 = { noinline nounwind uwtable }
More information about the llvm-commits
mailing list