[llvm] [Inliner] Fix bug where attributes are propagated incorrectly (PR #109347)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 17:47:18 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())
----------------
efriedma-quic wrote:
Suppose you inline a function that contains two calls to foo(). The second call gets simplified away, and the simplified value is the first call to foo(). So the vmap lookup finds the first call to foo(), which has completely different arguments/state.
https://github.com/llvm/llvm-project/pull/109347
More information about the llvm-commits
mailing list