mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
Add auto-upgrade support for annotation intrinsics
The llvm.ptr.annotation and llvm.var.annotation intrinsics were changed since the 11.0 release to add an additional parameter. This patch auto-upgrades IR containing the four-parameter versions of these intrinsics, adding a null pointer as the fifth argument. Differential Revision: https://reviews.llvm.org/D95993
This commit is contained in:
parent
89173fba7a
commit
771be1b79d
@ -937,6 +937,12 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::prefetch, Tys);
|
||||
return true;
|
||||
}
|
||||
} else if (Name.startswith("ptr.annotation.") && F->arg_size() == 4) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::ptr_annotation,
|
||||
F->arg_begin()->getType());
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -947,6 +953,16 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v': {
|
||||
if (Name == "var.annotation" && F->arg_size() == 4) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::var_annotation);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'x':
|
||||
if (UpgradeX86IntrinsicFunction(F, Name, NewFn))
|
||||
return true;
|
||||
@ -3730,6 +3746,32 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
|
||||
case Intrinsic::ptr_annotation:
|
||||
// Upgrade from versions that lacked the annotation attribute argument.
|
||||
assert(CI->getNumArgOperands() == 4 &&
|
||||
"Before LLVM 12.0 this intrinsic took four arguments");
|
||||
// Create a new call with an added null annotation attribute argument.
|
||||
NewCall = Builder.CreateCall(
|
||||
NewFn,
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
|
||||
CI->getArgOperand(3), Constant::getNullValue(Builder.getInt8PtrTy())});
|
||||
NewCall->takeName(CI);
|
||||
CI->replaceAllUsesWith(NewCall);
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
|
||||
case Intrinsic::var_annotation:
|
||||
// Upgrade from versions that lacked the annotation attribute argument.
|
||||
assert(CI->getNumArgOperands() == 4 &&
|
||||
"Before LLVM 12.0 this intrinsic took four arguments");
|
||||
// Create a new call with an added null annotation attribute argument.
|
||||
NewCall = Builder.CreateCall(
|
||||
NewFn,
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
|
||||
CI->getArgOperand(3), Constant::getNullValue(Builder.getInt8PtrTy())});
|
||||
CI->eraseFromParent();
|
||||
return;
|
||||
|
||||
case Intrinsic::x86_xop_vfrcz_ss:
|
||||
case Intrinsic::x86_xop_vfrcz_sd:
|
||||
NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(1)});
|
||||
|
45
test/Bitcode/upgrade-ptr-annotation.ll
Normal file
45
test/Bitcode/upgrade-ptr-annotation.ll
Normal file
@ -0,0 +1,45 @@
|
||||
; Test upgrade of ptr.annotation intrinsics.
|
||||
;
|
||||
; RUN: llvm-dis < %s.bc | FileCheck %s
|
||||
|
||||
; Unused return values
|
||||
; The arguments passed to the intrinisic wouldn't normally be arguments to
|
||||
; the function, but that makes it easier to test that they are handled
|
||||
; correctly.
|
||||
define void @f1(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3) {
|
||||
;CHECK: @f1(i8* [[ARG0:%.*]], i8* [[ARG1:%.*]], i8* [[ARG2:%.*]], i32 [[ARG3:%.*]])
|
||||
%t0 = call i8* @llvm.ptr.annotation.p0i8(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3)
|
||||
;CHECK: call i8* @llvm.ptr.annotation.p0i8(i8* [[ARG0]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
|
||||
|
||||
%arg0_p16 = bitcast i8* %arg0 to i16*
|
||||
%t1 = call i16* @llvm.ptr.annotation.p0i16(i16* %arg0_p16, i8* %arg1, i8* %arg2, i32 %arg3)
|
||||
;CHECK: [[ARG0_P16:%.*]] = bitcast
|
||||
;CHECK: call i16* @llvm.ptr.annotation.p0i16(i16* [[ARG0_P16]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
|
||||
|
||||
%arg0_p256 = bitcast i8* %arg0 to i256*
|
||||
%t2 = call i256* @llvm.ptr.annotation.p0i256(i256* %arg0_p256, i8* %arg1, i8* %arg2, i32 %arg3)
|
||||
;CHECK: [[ARG0_P256:%.*]] = bitcast
|
||||
;CHECK: call i256* @llvm.ptr.annotation.p0i256(i256* [[ARG0_P256]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Used return values
|
||||
define i16* @f2(i16* %x, i16* %y) {
|
||||
%t0 = call i16* @llvm.ptr.annotation.p0i16(i16* %x, i8* undef, i8* undef, i32 undef)
|
||||
%t1 = call i16* @llvm.ptr.annotation.p0i16(i16* %y, i8* undef, i8* undef, i32 undef)
|
||||
%cmp = icmp ugt i16* %t0, %t1
|
||||
%sel = select i1 %cmp, i16* %t0, i16* %t1
|
||||
ret i16* %sel
|
||||
; CHECK: [[T0:%.*]] = call i16* @llvm.ptr.annotation.p0i16(i16* %x, i8* undef, i8* undef, i32 undef, i8* null)
|
||||
; CHECK: [[T1:%.*]] = call i16* @llvm.ptr.annotation.p0i16(i16* %y, i8* undef, i8* undef, i32 undef, i8* null)
|
||||
; CHECK: %cmp = icmp ugt i16* [[T0]], [[T1]]
|
||||
; CHECK: %sel = select i1 %cmp, i16* [[T0]], i16* [[T1]]
|
||||
; CHECK: ret i16* %sel
|
||||
}
|
||||
|
||||
declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32)
|
||||
; CHECK: declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)
|
||||
declare i16* @llvm.ptr.annotation.p0i16(i16*, i8*, i8*, i32)
|
||||
; CHECK: declare i16* @llvm.ptr.annotation.p0i16(i16*, i8*, i8*, i32, i8*)
|
||||
declare i256* @llvm.ptr.annotation.p0i256(i256*, i8*, i8*, i32)
|
||||
; CHECK: declare i256* @llvm.ptr.annotation.p0i256(i256*, i8*, i8*, i32, i8*)
|
BIN
test/Bitcode/upgrade-ptr-annotation.ll.bc
Normal file
BIN
test/Bitcode/upgrade-ptr-annotation.ll.bc
Normal file
Binary file not shown.
15
test/Bitcode/upgrade-var-annotation.ll
Normal file
15
test/Bitcode/upgrade-var-annotation.ll
Normal file
@ -0,0 +1,15 @@
|
||||
; Test upgrade of var.annotation intrinsics.
|
||||
;
|
||||
; RUN: llvm-dis < %s.bc | FileCheck %s
|
||||
|
||||
|
||||
define void @f(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3) {
|
||||
;CHECK: @f(i8* [[ARG0:%.*]], i8* [[ARG1:%.*]], i8* [[ARG2:%.*]], i32 [[ARG3:%.*]])
|
||||
call void @llvm.var.annotation(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3)
|
||||
;CHECK: call void @llvm.var.annotation(i8* [[ARG0]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nofree nosync nounwind willreturn
|
||||
declare void @llvm.var.annotation(i8*, i8*, i8*, i32)
|
||||
; CHECK: declare void @llvm.var.annotation(i8*, i8*, i8*, i32, i8*)
|
BIN
test/Bitcode/upgrade-var-annotation.ll.bc
Normal file
BIN
test/Bitcode/upgrade-var-annotation.ll.bc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user