[OpaquePtr] Mangle intrinsics with opaque pointers arguments

Mangling intrinsics with opaque pointer arguments using "op"+{address space}.

Differential Revision: https://reviews.llvm.org/D104272
This commit is contained in:
Zequan Wu 2021-06-15 14:59:51 -07:00
parent 7b81fdf984
commit ec08f03be3
2 changed files with 19 additions and 5 deletions

View File

@ -775,10 +775,13 @@ void Function::recalculateIntrinsicID() {
/// indicating that extra care must be taken to ensure a unique name.
static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
std::string Result;
if (PointerType* PTyp = dyn_cast<PointerType>(Ty)) {
Result += "p" + utostr(PTyp->getAddressSpace()) +
getMangledTypeStr(PTyp->getElementType(), HasUnnamedType);
} else if (ArrayType* ATyp = dyn_cast<ArrayType>(Ty)) {
if (PointerType *PTyp = dyn_cast<PointerType>(Ty)) {
Result += "p" + utostr(PTyp->getAddressSpace());
// Opaque pointer doesn't have pointee type information, so we just mangle
// address space for opaque pointer.
if (!PTyp->isOpaque())
Result += getMangledTypeStr(PTyp->getElementType(), HasUnnamedType);
} else if (ArrayType *ATyp = dyn_cast<ArrayType>(Ty)) {
Result += "a" + utostr(ATyp->getNumElements()) +
getMangledTypeStr(ATyp->getElementType(), HasUnnamedType);
} else if (StructType *STyp = dyn_cast<StructType>(Ty)) {
@ -803,7 +806,7 @@ static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
Result += "vararg";
// Ensure nested function types are distinguishable.
Result += "f";
} else if (VectorType* VTy = dyn_cast<VectorType>(Ty)) {
} else if (VectorType *VTy = dyn_cast<VectorType>(Ty)) {
ElementCount EC = VTy->getElementCount();
if (EC.isScalable())
Result += "nx";

View File

@ -23,3 +23,14 @@ define void @atomicrmw(ptr %a, i32 %i) {
%b = atomicrmw add ptr %a, i32 %i acquire
ret void
}
define void @opaque_mangle(ptr %a) {
call void @llvm.lifetime.start.p0(i64 8, ptr %a)
call void @llvm.lifetime.end.p0(i64 8, ptr %a)
ret void
}
; CHECK: @llvm.lifetime.start.p0
; CHECK: @llvm.lifetime.end.p0
declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
declare void @llvm.lifetime.end.p0(i64, ptr nocapture)