diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2217,6 +2217,26 @@ // Type ::= 'float' | 'void' (etc) Result = Lex.getTyVal(); Lex.Lex(); + + // Handle (explicit) opaque pointer types (not --force-opaque-pointers). + // + // Type ::= ptr ('addrspace' '(' uint32 ')')? + if (Result->isOpaquePointerTy()) { + unsigned AddrSpace; + if (parseOptionalAddrSpace(AddrSpace)) + return true; + Result = PointerType::get(getContext(), AddrSpace); + + // Give a nice error for 'ptr*'. + if (Lex.getKind() == lltok::star) + return tokError("ptr* is invalid - use ptr instead"); + + // Fall through to parsing the type suffixes only if this 'ptr' is a + // function return. Otherwise, return success, implicitly rejecting other + // suffixes. + if (Lex.getKind() != lltok::lparen) + return false; + } break; case lltok::lbrace: // Type ::= StructType @@ -2270,26 +2290,6 @@ } } - // Handle (explicit) opaque pointer types (not --force-opaque-pointers). - // - // Type ::= ptr ('addrspace' '(' uint32 ')')? - if (Result->isOpaquePointerTy()) { - unsigned AddrSpace; - if (parseOptionalAddrSpace(AddrSpace)) - return true; - Result = PointerType::get(getContext(), AddrSpace); - - // Give a nice error for 'ptr*'. - if (Lex.getKind() == lltok::star) - return tokError("ptr* is invalid - use ptr instead"); - - // Fall through to parsing the type suffixes only if this 'ptr' is a - // function return. Otherwise, return success, implicitly rejecting other - // suffixes. - if (Lex.getKind() != lltok::lparen) - return false; - } - // parse the type suffixes. while (true) { switch (Lex.getKind()) { diff --git a/llvm/test/Other/force-opaque-ptrs.ll b/llvm/test/Other/force-opaque-ptrs.ll --- a/llvm/test/Other/force-opaque-ptrs.ll +++ b/llvm/test/Other/force-opaque-ptrs.ll @@ -3,6 +3,8 @@ ; RUN: llvm-as < %s | llvm-dis --force-opaque-pointers | FileCheck %s ; RUN: opt --force-opaque-pointers < %s -S | FileCheck %s +%ty = type i32* + ; CHECK: @g = external global i16 @g = external global i16 @@ -49,6 +51,14 @@ unreachable } +define void @f4(%ty* %p) { +; CHECK-LABEL: define {{[^@]+}}@f4 +; CHECK-SAME: (ptr [[P:%.*]]) { +; CHECK-NEXT: unreachable +; + unreachable +} + define void @remangle_intrinsic() { ; CHECK-LABEL: define {{[^@]+}}@remangle_intrinsic() { ; CHECK-NEXT: [[A:%.*]] = alloca ptr, align 8