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

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 18:07:36 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:

I guess the other options are either move this to before simplifications in the `cloneFunction` call or track which callbases get simplified and skip them.

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


More information about the llvm-commits mailing list