[PATCH] D104272: [OpaquePtr] Mangle intrinsics with opaque pointers arguments
Zequan Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 14 15:59:10 PDT 2021
zequanwu updated this revision to Diff 352012.
zequanwu added a comment.
Add a test case.
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/lib/IR/Verifier.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,13 @@
%b = atomicrmw add ptr %a, i32 %i acquire
ret void
}
+
+; CHECK: @opaque_mangle
+define void @opaque_mangle(ptr %a) {
+ call void @llvm.lifetime.start.op(i64 8, ptr %a)
+ call void @llvm.lifetime.end.op(i64 8, ptr %a)
+ ret void
+}
+
+declare void @llvm.lifetime.start.op(i64, ptr nocapture)
+declare void @llvm.lifetime.end.op(i64, ptr nocapture)
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1839,6 +1839,9 @@
V);
if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
+ // Skip opaque pointer.
+ if (PTy->isOpaque())
+ return;
SmallPtrSet<Type*, 4> Visited;
if (!PTy->getElementType()->isSized(&Visited)) {
Assert(!Attrs.hasAttribute(Attribute::ByVal) &&
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -781,10 +781,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 += "op" + 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)) {
@@ -809,7 +815,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.352012.patch
Type: text/x-patch
Size: 2632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210614/9212a6f5/attachment.bin>
More information about the llvm-commits
mailing list