[llvm] 16f9c55 - [SimplifyLibCalls] Retain attributes added by Builder.CreateMem*
Alex Richardson via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 06:12:01 PDT 2022
Author: Alex Richardson
Date: 2022-10-04T13:11:34Z
New Revision: 16f9c5577d2f498ba459de1862f8474882ea0690
URL: https://github.com/llvm/llvm-project/commit/16f9c5577d2f498ba459de1862f8474882ea0690
DIFF: https://github.com/llvm/llvm-project/commit/16f9c5577d2f498ba459de1862f8474882ea0690.diff
LOG: [SimplifyLibCalls] Retain attributes added by Builder.CreateMem*
This currently does not make much of a difference (only one tests is
affected), but it is helpful e.g. for the out-of-tree CHERI target where
Builder.CreateMemCpy() can add attributes other than parameter alignment.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D135075
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 0303831dd8fb8..be0912b786009 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -289,7 +289,8 @@ static Value *copyFlags(const CallInst &Old, Value *New) {
}
static Value *mergeAttributesAndFlags(CallInst *NewCI, const CallInst &Old) {
- NewCI->setAttributes(Old.getAttributes());
+ NewCI->setAttributes(AttributeList::get(
+ NewCI->getContext(), {NewCI->getAttributes(), Old.getAttributes()}));
NewCI->removeRetAttrs(AttributeFuncs::typeIncompatible(NewCI->getType()));
return copyFlags(Old, NewCI);
}
diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll b/llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
index cd982f6c3f9d6..3524578508a0e 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
@@ -11,7 +11,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
define void @test_nobuiltin(i8* %dst, i64 %len) {
; CHECK-LABEL: @test_nobuiltin(
-; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[DST:%.*]], i8 0, i64 [[LEN:%.*]], i1 false) #1
+; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[DST:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
; CHECK-NEXT: ret void
;
call i8* @__memset_chk(i8* %dst, i32 0, i64 %len, i64 -1) nobuiltin
More information about the llvm-commits
mailing list