diff options
author | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-10-03 12:52:38 -0500 |
---|---|---|
committer | Noah Goldstein <goldstein.w.n@gmail.com> | 2023-10-03 16:12:19 -0500 |
commit | 2da4960f20f7e5d88a68ce25636a895284dc66d8 (patch) | |
tree | a7482aad1f16862f64501aa85382f41a6fa059b8 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 2d037f5aed34291a078e90afa1c09b9482d9a242 (diff) | |
download | llvm-2da4960f20f7e5d88a68ce25636a895284dc66d8.zip llvm-2da4960f20f7e5d88a68ce25636a895284dc66d8.tar.gz llvm-2da4960f20f7e5d88a68ce25636a895284dc66d8.tar.bz2 |
[Inliner] Also propagate `noundef` and `align` ret attributes during inlining
Both of these can potentially be lost otherwise.
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 0b7b3de..6d5312c 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1358,6 +1358,8 @@ static AttrBuilder IdentifyValidUBGeneratingAttributes(CallBase &CB) { Valid.addDereferenceableOrNullAttr(DerefOrNullBytes); if (CB.hasRetAttr(Attribute::NoAlias)) Valid.addAttribute(Attribute::NoAlias); + if (CB.hasRetAttr(Attribute::NoUndef)) + Valid.addAttribute(Attribute::NoUndef); return Valid; } @@ -1367,6 +1369,8 @@ static AttrBuilder IdentifyValidPoisonGeneratingAttributes(CallBase &CB) { AttrBuilder Valid(CB.getContext()); if (CB.hasRetAttr(Attribute::NonNull)) Valid.addAttribute(Attribute::NonNull); + if (CB.hasRetAttr(Attribute::Alignment)) + Valid.addAlignmentAttr(CB.getRetAlign()); return Valid; } @@ -1455,6 +1459,8 @@ static void AddReturnAttributes(CallBase &CB, ValueToValueMapTy &VMap) { // any new poison at @use will trigger UB anyways. // In case 3, we can never propagate nonnull because it may create UB due to // the noundef on @bar. + if (ValidPG.getAlignment().valueOrOne() < AL.getRetAlignment().valueOrOne()) + ValidPG.removeAttribute(Attribute::Alignment); if (ValidPG.hasAttributes()) { // Three checks. // If the callsite has `noundef`, then a poison due to violating the |