[llvm] 5dcea46 - [AutoUpgrade] Preserve attributes when upgrading named struct return
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 2 03:43:04 PDT 2024
Author: Nikita Popov
Date: 2024-09-02T12:42:52+02:00
New Revision: 5dcea4628d7206d4351101850655356d4a8fc24a
URL: https://github.com/llvm/llvm-project/commit/5dcea4628d7206d4351101850655356d4a8fc24a
DIFF: https://github.com/llvm/llvm-project/commit/5dcea4628d7206d4351101850655356d4a8fc24a.diff
LOG: [AutoUpgrade] Preserve attributes when upgrading named struct return
For example, if the argument has an alignment attribute, preserve it.
Added:
llvm/test/Bitcode/intrinsics-struct-upgrade-attributes.ll
Modified:
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 50fc2e728fcc01..69dae5e32dbbe8 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4330,7 +4330,8 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
"Must have same number of elements");
SmallVector<Value *> Args(CI->args());
- Value *NewCI = Builder.CreateCall(NewFn, Args);
+ CallInst *NewCI = Builder.CreateCall(NewFn, Args);
+ NewCI->setAttributes(CI->getAttributes());
Value *Res = PoisonValue::get(OldST);
for (unsigned Idx = 0; Idx < OldST->getNumElements(); ++Idx) {
Value *Elem = Builder.CreateExtractValue(NewCI, Idx);
diff --git a/llvm/test/Bitcode/intrinsics-struct-upgrade-attributes.ll b/llvm/test/Bitcode/intrinsics-struct-upgrade-attributes.ll
new file mode 100644
index 00000000000000..4962144899ae4b
--- /dev/null
+++ b/llvm/test/Bitcode/intrinsics-struct-upgrade-attributes.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+%struct.__neon_int8x8x2_t = type { <8 x i8>, <8 x i8> }
+
+declare %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8*)
+
+; CHECK-LABEL: define %struct.__neon_int8x8x2_t @test_named_struct_return(ptr %A) {
+; CHECK: %1 = call { <8 x i8>, <8 x i8> } @llvm.aarch64.neon.ld2.v8i8.p0(ptr align 16 %A)
+; CHECK: %2 = extractvalue { <8 x i8>, <8 x i8> } %1, 0
+; CHECK: %3 = insertvalue %struct.__neon_int8x8x2_t poison, <8 x i8> %2, 0
+; CHECK: %4 = extractvalue { <8 x i8>, <8 x i8> } %1, 1
+; CHECK: %5 = insertvalue %struct.__neon_int8x8x2_t %3, <8 x i8> %4, 1
+; CHECK: ret %struct.__neon_int8x8x2_t %5
+
+define %struct.__neon_int8x8x2_t @test_named_struct_return(ptr %A) {
+ %val = call %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(ptr align 16 %A)
+ ret %struct.__neon_int8x8x2_t %val
+}
More information about the llvm-commits
mailing list