diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-09-10 18:54:50 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-10-03 16:12:16 -0500 |
commit | 2d037f5aed34291a078e90afa1c09b9482d9a242 (patch) | |
tree | 9e67e9a361eb8597293fe524f8c9566857f21432 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 733f373ebe43b890fd783230caede0aa301b1c9a (diff) | |
download | llvm-2d037f5aed34291a078e90afa1c09b9482d9a242.zip llvm-2d037f5aed34291a078e90afa1c09b9482d9a242.tar.gz llvm-2d037f5aed34291a078e90afa1c09b9482d9a242.tar.bz2 |
[Inliner] Use "best" ret attribute when propagating attributes during inlining
For attributes assosiated with a value (like `dereferenceable(N)`)
instead of always using the attribute from the to-be inlined caller,
it should keep using the value at existing callsites that have the
attribute if the value is higher (provides more information).
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 548f949..0b7b3de 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1417,6 +1417,11 @@ static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap) { // existing attribute value (i.e. attributes such as dereferenceable, // dereferenceable_or_null etc). See AttrBuilder::merge for more details. AttributeList AL = NewRetVal->getAttributes(); + if (ValidUB.getDereferenceableBytes() < AL.getRetDereferenceableBytes()) + ValidUB.removeAttribute(Attribute::Dereferenceable); + if (ValidUB.getDereferenceableOrNullBytes() < + AL.getRetDereferenceableOrNullBytes()) + ValidUB.removeAttribute(Attribute::DereferenceableOrNull); AttributeList NewAL = AL.addRetAttributes(Context, ValidUB); // Attributes that may generate poison returns are a bit tricky. If we // propagate them, other uses of the callsite might have their behavior |