summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp2
-rw-r--r--llvm/test/Transforms/FunctionAttrs/arg_returned.ll5
2 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index c6de94beaf0..4b393539813 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -997,7 +997,7 @@ ChangeStatus AAReturnedValuesImpl::manifest(Attributor &A) {
// 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;
diff --git a/llvm/test/Transforms/FunctionAttrs/arg_returned.ll b/llvm/test/Transforms/FunctionAttrs/arg_returned.ll
index e9cf2d81f11..99b6762a5c8 100644
--- a/llvm/test/Transforms/FunctionAttrs/arg_returned.ll
+++ b/llvm/test/Transforms/FunctionAttrs/arg_returned.ll
@@ -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 }
OpenPOWER on IntegriCloud