[llvm] [Inliner] Fix bug where attributes are propagated incorrectly (PR #109347)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 21:34:40 PDT 2024


================
@@ -1477,6 +1483,12 @@ static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap) {
     auto *NewRetVal = dyn_cast_or_null<CallBase>(VMap.lookup(RetVal));
     if (!NewRetVal)
       continue;
+
+    // The RetVal might have be simplified during the inlining
+    // process. Only propagate return attributes if we are in fact calling the
+    // same function.
+    if (RetVal->getCalledFunction() != NewRetVal->getCalledFunction())
----------------
goldsteinn wrote:

Personally I'm for just not using simplifyInstruction on callbases in CloneFunction in inliner. Don't see much value in it in a realistic pipeline and unless I'm missing something, I think it solves the bug.
But would like to hear if anyone else has an opinion on how this should be solved.

https://github.com/llvm/llvm-project/pull/109347


More information about the llvm-commits mailing list