[llvm-branch-commits] [llvm] 5834fe6 - [AutoUpgrade] Fix remangling when upgrading struct return type

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 24 04:49:48 PDT 2022


Author: Nikita Popov
Date: 2022-10-24T13:49:24+02:00
New Revision: 5834fe66318b55a54024fd93f69ab801a4c61d33

URL: https://github.com/llvm/llvm-project/commit/5834fe66318b55a54024fd93f69ab801a4c61d33
DIFF: https://github.com/llvm/llvm-project/commit/5834fe66318b55a54024fd93f69ab801a4c61d33.diff

LOG: [AutoUpgrade] Fix remangling when upgrading struct return type

This was remangling the old function rather than the new one, and
could result in failures when we were performing both a struct
return upgrade and an opaque pointer upgrade.

(cherry picked from commit c8938809d155682ef5eec170897b8c26b8cbf3ea)

Added: 
    

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp
    llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 75594f90c926b..b9962da1d3026 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1040,7 +1040,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
                                Name, F->getParent());
 
       // The new function may also need remangling.
-      if (auto Result = llvm::Intrinsic::remangleIntrinsicFunction(F))
+      if (auto Result = llvm::Intrinsic::remangleIntrinsicFunction(NewFn))
         NewFn = *Result;
       return true;
     }

diff  --git a/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll b/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
index c885897f31555..04638b0ddac92 100644
--- a/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
+++ b/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
@@ -3,6 +3,8 @@
 
 ; Make sure that opaque pointer intrinsic remangling upgrade works.
 
+%int8x16x2_t = type { <16 x i8>, <16 x i8> }
+
 declare i32* @fake_personality_function()
 declare void @func()
 
@@ -43,5 +45,22 @@ define i8* @test_ptr_annotation(i8* %p) {
   ret i8* %p2
 }
 
+
+define void @test_struct_return(%int8x16x2_t* %res.p, i8* %a) {
+; CHECK-LABEL: @test_struct_return(
+; CHECK-NEXT:    [[TMP1:%.*]] = call { <16 x i8>, <16 x i8> } @llvm.aarch64.neon.ld1x2.v16i8.p0(ptr [[A:%.*]])
+; CHECK-NEXT:    [[TMP2:%.*]] = extractvalue { <16 x i8>, <16 x i8> } [[TMP1]], 0
+; CHECK-NEXT:    [[TMP3:%.*]] = insertvalue [[INT8X16X2_T:%.*]] poison, <16 x i8> [[TMP2]], 0
+; CHECK-NEXT:    [[TMP4:%.*]] = extractvalue { <16 x i8>, <16 x i8> } [[TMP1]], 1
+; CHECK-NEXT:    [[TMP5:%.*]] = insertvalue [[INT8X16X2_T]] [[TMP3]], <16 x i8> [[TMP4]], 1
+; CHECK-NEXT:    store [[INT8X16X2_T]] [[TMP5]], ptr [[RES_P:%.*]], align 16
+; CHECK-NEXT:    ret void
+;
+  %res = call %int8x16x2_t @llvm.aarch64.neon.ld1x2.v16i8.p0i8(i8* %a)
+  store %int8x16x2_t %res, %int8x16x2_t* %res.p
+  ret void
+}
+
 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 %int8x16x2_t @llvm.aarch64.neon.ld1x2.v16i8.p0i8(i8*)


        


More information about the llvm-branch-commits mailing list