[llvm] 48eeefe - [AutoUpgrade] Handle remangling upgrade for ptr.annotation

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 07:52:14 PST 2022


Author: Nikita Popov
Date: 2022-02-08T16:52:05+01:00
New Revision: 48eeefe59f2d2ab44eb771e8ae315cd15f97f57b

URL: https://github.com/llvm/llvm-project/commit/48eeefe59f2d2ab44eb771e8ae315cd15f97f57b
DIFF: https://github.com/llvm/llvm-project/commit/48eeefe59f2d2ab44eb771e8ae315cd15f97f57b.diff

LOG: [AutoUpgrade] Handle remangling upgrade for ptr.annotation

The code assumed that the upgrade would happen due to the argument
count changing from 4 to 5. However, a remangling upgrade is also
possible here.

Added: 
    llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    llvm/test/Assembler/invoke-intrinsic-upgrade.ll


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 8102e176407e..6803fdb5d600 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -3886,8 +3886,11 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
 
   case Intrinsic::ptr_annotation:
     // Upgrade from versions that lacked the annotation attribute argument.
-    assert(CI->arg_size() == 4 &&
-           "Before LLVM 12.0 this intrinsic took four arguments");
+    if (CI->arg_size() != 4) {
+      DefaultCase();
+      return;
+    }
+
     // Create a new call with an added null annotation attribute argument.
     NewCall = Builder.CreateCall(
         NewFn,

diff  --git a/llvm/test/Assembler/invoke-intrinsic-upgrade.ll b/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
similarity index 75%
rename from llvm/test/Assembler/invoke-intrinsic-upgrade.ll
rename to llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
index eb24dfd238ee..c885897f3155 100644
--- a/llvm/test/Assembler/invoke-intrinsic-upgrade.ll
+++ b/llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll
@@ -1,11 +1,12 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -S -opaque-pointers < %s | FileCheck %s
 
-; Make sure that an intrinsic remangling upgrade works for invokes as well.
+; Make sure that opaque pointer intrinsic remangling upgrade works.
 
 declare i32* @fake_personality_function()
 declare void @func()
 
+; Upgrading of invoked intrinsic.
 define void @test_invoke(i32 addrspace(1)* %b) gc "statepoint-example" personality i32* ()* @fake_personality_function {
 ; CHECK-LABEL: @test_invoke(
 ; CHECK-NEXT:  entry:
@@ -33,4 +34,14 @@ unwind_dest:
   ret void
 }
 
+define i8* @test_ptr_annotation(i8* %p) {
+; CHECK-LABEL: @test_ptr_annotation(
+; CHECK-NEXT:    [[P2:%.*]] = call ptr @llvm.ptr.annotation.p0(ptr [[P:%.*]], ptr undef, ptr undef, i32 undef, ptr undef)
+; CHECK-NEXT:    ret ptr [[P2]]
+;
+  %p2 = call i8* @llvm.ptr.annotation.p0i8(i8* %p, i8* undef, i8* undef, i32 undef, i8* undef)
+  ret i8* %p2
+}
+
 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
+declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)


        


More information about the llvm-commits mailing list