[llvm] [Inliner] Fix bug where attributes are propagated incorrectly (PR #109347)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 18:06:43 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:
You are worried about something like:
```
declare ptr @foo(ptr) memory(none) willreturn nounwind
define ptr @caller(ptr %p, i1 %c) {
%r = call ptr @callee(ptr %p, i1 %c)
ret ptr %r
}
define ptr @callee(ptr %p, i1 %c) {
%x = call ptr @foo(ptr %p)
br i1 %c, label %T, label %F
T:
ret ptr %x
F:
%r2 = call nonnull ptr @foo(ptr %p)
ret ptr %r2
}
```
?
Where we might prop the `nonnull` from the second call to the first call if it got simplified?
https://github.com/llvm/llvm-project/pull/109347
More information about the llvm-commits
mailing list