@@ -436,4 +436,34 @@ TEST(ValueMapperTest, mapValueConstantTargetNoneToLayoutTypeNullValue) {
436436 EXPECT_EQ (NewConstant, Mapper.mapValue (*OldConstant));
437437}
438438
439+ TEST (ValueMapperTest, mapValuePtrAuth) {
440+ LLVMContext C;
441+ Type *PtrTy = PointerType::get (C, 0 );
442+ IntegerType *Int32Ty = Type::getInt32Ty (C);
443+ IntegerType *Int64Ty = Type::getInt64Ty (C);
444+
445+ std::unique_ptr<GlobalVariable> Var0 = std::make_unique<GlobalVariable>(
446+ PtrTy, false , GlobalValue::ExternalLinkage, nullptr , " Var0" );
447+ std::unique_ptr<GlobalVariable> Var1 = std::make_unique<GlobalVariable>(
448+ PtrTy, false , GlobalValue::ExternalLinkage, nullptr , " Var1" );
449+ std::unique_ptr<GlobalVariable> Storage0 = std::make_unique<GlobalVariable>(
450+ PtrTy, false , GlobalValue::ExternalLinkage, nullptr , " Storage0" );
451+ std::unique_ptr<GlobalVariable> Storage1 = std::make_unique<GlobalVariable>(
452+ PtrTy, false , GlobalValue::ExternalLinkage, nullptr , " Storage1" );
453+
454+ ConstantInt *ConstKey = ConstantInt::get (Int32Ty, 1 );
455+ ConstantInt *ConstDisc = ConstantInt::get (Int64Ty, 1234 );
456+
457+ ValueToValueMapTy VM;
458+ VM[Var0.get ()] = Var1.get ();
459+ VM[Storage0.get ()] = Storage1.get ();
460+
461+ ConstantPtrAuth *Value =
462+ ConstantPtrAuth::get (Var0.get (), ConstKey, ConstDisc, Storage0.get ());
463+ ConstantPtrAuth *MappedValue =
464+ ConstantPtrAuth::get (Var1.get (), ConstKey, ConstDisc, Storage1.get ());
465+
466+ EXPECT_EQ (ValueMapper (VM).mapValue (*Value), MappedValue);
467+ }
468+
439469} // end namespace
0 commit comments