]> granicus.if.org Git - llvm/commitdiff
[Attributor][FIX] Do not replace musstail calls with constant
authorJohannes Doerfert <jdoerfert@anl.gov>
Fri, 11 Oct 2019 01:45:32 +0000 (01:45 +0000)
committerJohannes Doerfert <jdoerfert@anl.gov>
Fri, 11 Oct 2019 01:45:32 +0000 (01:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374498 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/Attributor.cpp
test/Transforms/FunctionAttrs/arg_returned.ll

index c6de94beaf07b89726de8f5f61aba9689f06f262..4b393539813da514c871d98580059fb0f768b586 100644 (file)
@@ -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;
index e9cf2d81f1169dabd9a9dd26e51930085ec5980f..99b6762a5c8183716884c7f560519a829f712976 100644 (file)
@@ -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 }