Index: llvm/lib/IR/Function.cpp =================================================================== --- llvm/lib/IR/Function.cpp +++ llvm/lib/IR/Function.cpp @@ -1783,7 +1783,10 @@ // invalid and we'll get an error. ExistingGV->setName(WantedName + ".renamed"); } - return Intrinsic::getDeclaration(F->getParent(), ID, ArgTys); + return cast( + F->getParent() + ->getOrInsertFunction(WantedName, F->getFunctionType()) + .getCallee()); }(); NewDecl->setCallingConv(F->getCallingConv()); Index: llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll =================================================================== --- llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll +++ llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll @@ -3,6 +3,8 @@ ; Make sure that opaque pointer intrinsic remangling upgrade works. +%struct.__neon_int8x8x2_t = type { <8 x i8>, <8 x i8> } + declare i32* @fake_personality_function() declare void @func() @@ -43,5 +45,15 @@ ret i8* %p2 } +define %struct.__neon_int8x8x2_t @test_named_struct_return(i8* %A) { +; CHECK-LABEL: @test_named_struct_return( +; CHECK-NEXT: [[VAL:%.*]] = call [[STRUCT___NEON_INT8X8X2_T:%.*]] @llvm.aarch64.neon.ld2.v8i8.p0(ptr [[A:%.*]]) +; CHECK-NEXT: ret [[STRUCT___NEON_INT8X8X2_T]] [[VAL]] +; + %val = call %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8* %A) + ret %struct.__neon_int8x8x2_t %val +} + declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*) +declare %struct.__neon_int8x8x2_t @llvm.aarch64.neon.ld2.v8i8.p0i8(i8*)