[llvm] 4506f61 - OpaquePtr: Reject 'ptr*' again when parsing textual IR
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 15:21:17 PDT 2021
Author: Duncan P. N. Exon Smith
Date: 2021-06-25T15:18:44-07:00
New Revision: 4506f614cb6983a16d117cf77a968608e66d7a5c
URL: https://github.com/llvm/llvm-project/commit/4506f614cb6983a16d117cf77a968608e66d7a5c
DIFF: https://github.com/llvm/llvm-project/commit/4506f614cb6983a16d117cf77a968608e66d7a5c.diff
LOG: OpaquePtr: Reject 'ptr*' again when parsing textual IR
Bring back the testcase dropped in
1e6303e60ca5af4fbe7ca728572fd65666a98271 and get it passing by checking
explicitly for `ptr*` in LLParser. Uses `Type::isOpaquePointerTy()` from
ad4bb8280952c2cacf497e30560ee94c119b36e0.
Differential Revision: https://reviews.llvm.org/D104938
Added:
llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll
llvm/test/Assembler/invalid-opaque-ptr.ll
Modified:
llvm/lib/AsmParser/LLParser.cpp
Removed:
################################################################################
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index bcdf51c47f96..c4fa35ff15ec 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -2597,6 +2597,8 @@ bool LLParser::parseType(Type *&Result, const Twine &Msg, bool AllowVoid) {
return tokError("basic block pointers are invalid");
if (Result->isVoidTy())
return tokError("pointers to void are invalid - use i8* instead");
+ if (Result->isOpaquePointerTy())
+ return tokError("ptr* is invalid - use ptr instead");
if (!PointerType::isValidElementType(Result))
return tokError("pointer to this type is invalid");
Result = PointerType::getUnqual(Result);
diff --git a/llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll b/llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll
new file mode 100644
index 000000000000..f3d7722891cb
--- /dev/null
+++ b/llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: ptr* is invalid - use ptr instead
+define void @f(ptr addrspace(3) %a) {
+ %b = bitcast ptr addrspace(3) %a to ptr addrspace(3)*
+ ret void
+}
diff --git a/llvm/test/Assembler/invalid-opaque-ptr.ll b/llvm/test/Assembler/invalid-opaque-ptr.ll
new file mode 100644
index 000000000000..6e8340b4cae9
--- /dev/null
+++ b/llvm/test/Assembler/invalid-opaque-ptr.ll
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: ptr* is invalid - use ptr instead
+define void @f(ptr %a) {
+ %b = bitcast ptr %a to ptr*
+ ret void
+}
More information about the llvm-commits
mailing list