[all-commits] [llvm/llvm-project] bf8d03: [Inliner] Add some additional tests for progagatin...
goldsteinn via All-commits
all-commits at lists.llvm.org
Thu Sep 28 15:28:04 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bf8d03921d3cb599eebcd77e1c0f7d7dd59d42d5
https://github.com/llvm/llvm-project/commit/bf8d03921d3cb599eebcd77e1c0f7d7dd59d42d5
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-09-28 (Thu, 28 Sep 2023)
Changed paths:
A llvm/test/Transforms/Inline/access-attributes-prop.ll
A llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll
Log Message:
-----------
[Inliner] Add some additional tests for progagating attributes before inlining; NFC
Commit: 2f3b7d33f421b723728262a6978041d93f1f8c5c
https://github.com/llvm/llvm-project/commit/2f3b7d33f421b723728262a6978041d93f1f8c5c
Author: Noah Goldstein <goldstein.w.n at gmail.com>
Date: 2023-09-28 (Thu, 28 Sep 2023)
Changed paths:
M llvm/lib/Transforms/Utils/InlineFunction.cpp
M llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll
Log Message:
-----------
[Inliner] Fix bug when propagating poison generating return attributes
Poison generating return attributes can't be propagated the same as
others, as they can change the behavior of other uses and/or create UB
where it otherwise wouldn't have occurred.
For example:
```
define nonnull ptr @foo() {
%p = call ptr @bar()
call void @use(ptr %p)
ret ptr %p
}
```
If we inline `@foo` and propagate `nonnull` to `@bar`, it could change
the behavior of `@use` as instead of taking `null`, `@use` will
now be passed `poison`.
This can be even worth in a case like:
```
define nonnull ptr @foo() {
%p = call noundef ptr @bar()
ret ptr %p
}
```
Where propagating `nonnull` to `@bar` will cause UB on `null` return
of `@bar` (`noundef` + `poison`) where it previously wouldn't
have occurred.
To fix this, we only propagate poison generating return attributes if
either 1) The only use of the callsite to propagate too is return and
the callsite to propagate too doesn't have `noundef`. Or 2) the
callsite to be be inlined has `noundef`.
The former case ensures no new UB or `poison` values will be
added. The latter is UB anyways if the value is `poison` so we can go
ahead without worrying about behavior changes.
Compare: https://github.com/llvm/llvm-project/compare/3e9c36303ca7...2f3b7d33f421
More information about the All-commits
mailing list