Skip to content

Commit 48eeefe

Browse files
committed
[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.
1 parent eabae1b commit 48eeefe

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

llvm/lib/IR/AutoUpgrade.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -3886,8 +3886,11 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
38863886

38873887
case Intrinsic::ptr_annotation:
38883888
// Upgrade from versions that lacked the annotation attribute argument.
3889-
assert(CI->arg_size() == 4 &&
3890-
"Before LLVM 12.0 this intrinsic took four arguments");
3889+
if (CI->arg_size() != 4) {
3890+
DefaultCase();
3891+
return;
3892+
}
3893+
38913894
// Create a new call with an added null annotation attribute argument.
38923895
NewCall = Builder.CreateCall(
38933896
NewFn,

llvm/test/Assembler/invoke-intrinsic-upgrade.ll llvm/test/Assembler/opaque-ptr-intrinsic-remangling.ll

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -opaque-pointers < %s | FileCheck %s
33

4-
; Make sure that an intrinsic remangling upgrade works for invokes as well.
4+
; Make sure that opaque pointer intrinsic remangling upgrade works.
55

66
declare i32* @fake_personality_function()
77
declare void @func()
88

9+
; Upgrading of invoked intrinsic.
910
define void @test_invoke(i32 addrspace(1)* %b) gc "statepoint-example" personality i32* ()* @fake_personality_function {
1011
; CHECK-LABEL: @test_invoke(
1112
; CHECK-NEXT: entry:
@@ -33,4 +34,14 @@ unwind_dest:
3334
ret void
3435
}
3536

37+
define i8* @test_ptr_annotation(i8* %p) {
38+
; CHECK-LABEL: @test_ptr_annotation(
39+
; CHECK-NEXT: [[P2:%.*]] = call ptr @llvm.ptr.annotation.p0(ptr [[P:%.*]], ptr undef, ptr undef, i32 undef, ptr undef)
40+
; CHECK-NEXT: ret ptr [[P2]]
41+
;
42+
%p2 = call i8* @llvm.ptr.annotation.p0i8(i8* %p, i8* undef, i8* undef, i32 undef, i8* undef)
43+
ret i8* %p2
44+
}
45+
3646
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
47+
declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)

0 commit comments

Comments
 (0)