Skip to content

Commit 5dcea46

Browse files
committed
[AutoUpgrade] Preserve attributes when upgrading named struct return
For example, if the argument has an alignment attribute, preserve it.
1 parent 7519755 commit 5dcea46

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/IR/AutoUpgrade.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -4330,7 +4330,8 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
43304330
"Must have same number of elements");
43314331

43324332
SmallVector<Value *> Args(CI->args());
4333-
Value *NewCI = Builder.CreateCall(NewFn, Args);
4333+
CallInst *NewCI = Builder.CreateCall(NewFn, Args);
4334+
NewCI->setAttributes(CI->getAttributes());
43344335
Value *Res = PoisonValue::get(OldST);
43354336
for (unsigned Idx = 0; Idx < OldST->getNumElements(); ++Idx) {
43364337
Value *Elem = Builder.CreateExtractValue(NewCI, Idx);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
2+
3+
%struct.__neon_int8x8x2_t = type { <8 x i8>, <8 x i8> }
4+
5+
declare %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8*)
6+
7+
; CHECK-LABEL: define %struct.__neon_int8x8x2_t @test_named_struct_return(ptr %A) {
8+
; CHECK: %1 = call { <8 x i8>, <8 x i8> } @llvm.aarch64.neon.ld2.v8i8.p0(ptr align 16 %A)
9+
; CHECK: %2 = extractvalue { <8 x i8>, <8 x i8> } %1, 0
10+
; CHECK: %3 = insertvalue %struct.__neon_int8x8x2_t poison, <8 x i8> %2, 0
11+
; CHECK: %4 = extractvalue { <8 x i8>, <8 x i8> } %1, 1
12+
; CHECK: %5 = insertvalue %struct.__neon_int8x8x2_t %3, <8 x i8> %4, 1
13+
; CHECK: ret %struct.__neon_int8x8x2_t %5
14+
15+
define %struct.__neon_int8x8x2_t @test_named_struct_return(ptr %A) {
16+
%val = call %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(ptr align 16 %A)
17+
ret %struct.__neon_int8x8x2_t %val
18+
}

0 commit comments

Comments
 (0)