[PATCH] D104272: [OpaquePtr] Mangle intrinsics with opaque pointers arguments

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 15 16:05:16 PDT 2021


zequanwu updated this revision to Diff 352280.
zequanwu marked an inline comment as done.
zequanwu added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104272/new/

https://reviews.llvm.org/D104272

Files:
  llvm/lib/IR/Function.cpp
  llvm/test/Verifier/opaque-ptr.ll


Index: llvm/test/Verifier/opaque-ptr.ll
===================================================================
--- llvm/test/Verifier/opaque-ptr.ll
+++ llvm/test/Verifier/opaque-ptr.ll
@@ -23,3 +23,14 @@
     %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)
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -775,10 +775,16 @@
 /// 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)) {
+    // Opaque pointer doesn't have pointee type information, so we just mangle
+    // address space for opaque pointer.
+    if (PTyp->isOpaque()) {
+      Result += "p" + utostr(PTyp->getAddressSpace());
+    } else {
+      Result += "p" + utostr(PTyp->getAddressSpace()) +
+                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 +809,7 @@
       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";


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104272.352280.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210615/48781d3a/attachment.bin>


More information about the llvm-commits mailing list