Index: llvm/include/llvm/AsmParser/LLParser.h =================================================================== --- llvm/include/llvm/AsmParser/LLParser.h +++ llvm/include/llvm/AsmParser/LLParser.h @@ -172,9 +172,8 @@ /// getGlobalVal - Get a value with the specified name or ID, creating a /// forward reference record if needed. This can return null if the value /// exists but does not have the right type. - GlobalValue *getGlobalVal(const std::string &N, Type *Ty, LocTy Loc, - bool IsCall); - GlobalValue *getGlobalVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall); + GlobalValue *getGlobalVal(const std::string &N, Type *Ty, LocTy Loc); + GlobalValue *getGlobalVal(unsigned ID, Type *Ty, LocTy Loc); /// Get a Comdat with the specified name, creating a forward reference /// record if needed. @@ -423,8 +422,8 @@ /// GetVal - Get a value with the specified name or ID, creating a /// forward reference record if needed. This can return null if the value /// exists but does not have the right type. - Value *getVal(const std::string &Name, Type *Ty, LocTy Loc, bool IsCall); - Value *getVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall); + Value *getVal(const std::string &Name, Type *Ty, LocTy Loc); + Value *getVal(unsigned ID, Type *Ty, LocTy Loc); /// setInstName - After an instruction is parsed and inserted into its /// basic block, this installs its name. @@ -446,10 +445,10 @@ }; bool convertValIDToValue(Type *Ty, ValID &ID, Value *&V, - PerFunctionState *PFS, bool IsCall); + PerFunctionState *PFS); Value *checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty, - Value *Val, bool IsCall); + Value *Val); bool parseConstantValue(Type *Ty, Constant *&C); bool parseValue(Type *Ty, Value *&V, PerFunctionState *PFS); Index: llvm/lib/AsmParser/LLLexer.cpp =================================================================== --- llvm/lib/AsmParser/LLLexer.cpp +++ llvm/lib/AsmParser/LLLexer.cpp @@ -849,7 +849,15 @@ TYPEKEYWORD("x86_mmx", Type::getX86_MMXTy(Context)); TYPEKEYWORD("x86_amx", Type::getX86_AMXTy(Context)); TYPEKEYWORD("token", Type::getTokenTy(Context)); - TYPEKEYWORD("ptr", PointerType::getUnqual(Context)); + + if (Keyword == "ptr") { + if (Context.supportsTypedPointers()) { + Warning("ptr type is only supported in -opaque-pointers mode"); + return lltok::Error; + } + TyVal = PointerType::getUnqual(Context); + return lltok::Type; + } #undef TYPEKEYWORD Index: llvm/lib/AsmParser/LLParser.cpp =================================================================== --- llvm/lib/AsmParser/LLParser.cpp +++ llvm/lib/AsmParser/LLParser.cpp @@ -1404,14 +1404,10 @@ } Value *LLParser::checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty, - Value *Val, bool IsCall) { + Value *Val) { Type *ValTy = Val->getType(); if (ValTy == Ty) return Val; - // For calls, we also allow opaque pointers. - if (IsCall && ValTy == PointerType::get(Ty->getContext(), - Ty->getPointerAddressSpace())) - return Val; if (Ty->isLabelTy()) error(Loc, "'" + Name + "' is not a basic block"); else @@ -1425,7 +1421,7 @@ /// forward reference record if needed. This can return null if the value /// exists but does not have the right type. GlobalValue *LLParser::getGlobalVal(const std::string &Name, Type *Ty, - LocTy Loc, bool IsCall) { + LocTy Loc) { PointerType *PTy = dyn_cast(Ty); if (!PTy) { error(Loc, "global variable reference must have pointer type"); @@ -1447,7 +1443,7 @@ // If we have the value in the symbol table or fwd-ref table, return it. if (Val) return cast_or_null( - checkValidVariableType(Loc, "@" + Name, Ty, Val, IsCall)); + checkValidVariableType(Loc, "@" + Name, Ty, Val)); // Otherwise, create a new forward reference for this value and remember it. GlobalValue *FwdVal = createGlobalFwdRef(M, PTy); @@ -1455,8 +1451,7 @@ return FwdVal; } -GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc, - bool IsCall) { +GlobalValue *LLParser::getGlobalVal(unsigned ID, Type *Ty, LocTy Loc) { PointerType *PTy = dyn_cast(Ty); if (!PTy) { error(Loc, "global variable reference must have pointer type"); @@ -1476,7 +1471,7 @@ // If we have the value in the symbol table or fwd-ref table, return it. if (Val) return cast_or_null( - checkValidVariableType(Loc, "@" + Twine(ID), Ty, Val, IsCall)); + checkValidVariableType(Loc, "@" + Twine(ID), Ty, Val)); // Otherwise, create a new forward reference for this value and remember it. GlobalValue *FwdVal = createGlobalFwdRef(M, PTy); @@ -2218,7 +2213,7 @@ Result = Lex.getTyVal(); Lex.Lex(); - // Handle (explicit) opaque pointer types (not --force-opaque-pointers). + // Handle "ptr" opaque pointer type. // // Type ::= ptr ('addrspace' '(' uint32 ')')? if (Result->isOpaquePointerTy()) { @@ -2794,7 +2789,7 @@ /// forward reference record if needed. This can return null if the value /// exists but does not have the right type. Value *LLParser::PerFunctionState::getVal(const std::string &Name, Type *Ty, - LocTy Loc, bool IsCall) { + LocTy Loc) { // Look this name up in the normal function symbol table. Value *Val = F.getValueSymbolTable()->lookup(Name); @@ -2808,7 +2803,7 @@ // If we have the value in the symbol table or fwd-ref table, return it. if (Val) - return P.checkValidVariableType(Loc, "%" + Name, Ty, Val, IsCall); + return P.checkValidVariableType(Loc, "%" + Name, Ty, Val); // Don't make placeholders with invalid type. if (!Ty->isFirstClassType()) { @@ -2828,8 +2823,7 @@ return FwdVal; } -Value *LLParser::PerFunctionState::getVal(unsigned ID, Type *Ty, LocTy Loc, - bool IsCall) { +Value *LLParser::PerFunctionState::getVal(unsigned ID, Type *Ty, LocTy Loc) { // Look this name up in the normal function symbol table. Value *Val = ID < NumberedVals.size() ? NumberedVals[ID] : nullptr; @@ -2843,7 +2837,7 @@ // If we have the value in the symbol table or fwd-ref table, return it. if (Val) - return P.checkValidVariableType(Loc, "%" + Twine(ID), Ty, Val, IsCall); + return P.checkValidVariableType(Loc, "%" + Twine(ID), Ty, Val); if (!Ty->isFirstClassType()) { P.error(Loc, "invalid use of a non-first-class type"); @@ -2930,12 +2924,12 @@ BasicBlock *LLParser::PerFunctionState::getBB(const std::string &Name, LocTy Loc) { return dyn_cast_or_null( - getVal(Name, Type::getLabelTy(F.getContext()), Loc, /*IsCall=*/false)); + getVal(Name, Type::getLabelTy(F.getContext()), Loc)); } BasicBlock *LLParser::PerFunctionState::getBB(unsigned ID, LocTy Loc) { return dyn_cast_or_null( - getVal(ID, Type::getLabelTy(F.getContext()), Loc, /*IsCall=*/false)); + getVal(ID, Type::getLabelTy(F.getContext()), Loc)); } /// defineBB - Define the specified basic block, which is either named or @@ -3648,7 +3642,7 @@ ValID ID; Value *V = nullptr; bool Parsed = parseValID(ID, /*PFS=*/nullptr, Ty) || - convertValIDToValue(Ty, ID, V, nullptr, /*IsCall=*/false); + convertValIDToValue(Ty, ID, V, nullptr); if (V && !(C = dyn_cast(V))) return error(ID.Loc, "global values must be constants"); return Parsed; @@ -5238,7 +5232,7 @@ //===----------------------------------------------------------------------===// bool LLParser::convertValIDToValue(Type *Ty, ValID &ID, Value *&V, - PerFunctionState *PFS, bool IsCall) { + PerFunctionState *PFS) { if (Ty->isFunctionTy()) return error(ID.Loc, "functions are not values, refer to them as pointers"); @@ -5246,12 +5240,12 @@ case ValID::t_LocalID: if (!PFS) return error(ID.Loc, "invalid use of function-local name"); - V = PFS->getVal(ID.UIntVal, Ty, ID.Loc, IsCall); + V = PFS->getVal(ID.UIntVal, Ty, ID.Loc); return V == nullptr; case ValID::t_LocalName: if (!PFS) return error(ID.Loc, "invalid use of function-local name"); - V = PFS->getVal(ID.StrVal, Ty, ID.Loc, IsCall); + V = PFS->getVal(ID.StrVal, Ty, ID.Loc); return V == nullptr; case ValID::t_InlineAsm: { if (!ID.FTy || !InlineAsm::Verify(ID.FTy, ID.StrVal2)) @@ -5262,10 +5256,10 @@ return false; } case ValID::t_GlobalName: - V = getGlobalVal(ID.StrVal, Ty, ID.Loc, IsCall); + V = getGlobalVal(ID.StrVal, Ty, ID.Loc); return V == nullptr; case ValID::t_GlobalID: - V = getGlobalVal(ID.UIntVal, Ty, ID.Loc, IsCall); + V = getGlobalVal(ID.UIntVal, Ty, ID.Loc); return V == nullptr; case ValID::t_APSInt: if (!Ty->isIntegerTy()) @@ -5389,7 +5383,7 @@ case ValID::t_ConstantStruct: case ValID::t_PackedConstantStruct: { Value *V; - if (convertValIDToValue(Ty, ID, V, /*PFS=*/nullptr, /*IsCall=*/false)) + if (convertValIDToValue(Ty, ID, V, /*PFS=*/nullptr)) return true; assert(isa(V) && "Expected a constant value"); C = cast(V); @@ -5407,7 +5401,7 @@ V = nullptr; ValID ID; return parseValID(ID, PFS, Ty) || - convertValIDToValue(Ty, ID, V, PFS, /*IsCall=*/false); + convertValIDToValue(Ty, ID, V, PFS); } bool LLParser::parseTypeAndValue(Value *&V, PerFunctionState *PFS) { @@ -5702,7 +5696,7 @@ Value *ResolvedVal = BlockAddress::get(&F, BB); ResolvedVal = P.checkValidVariableType(BBID.Loc, BBID.StrVal, GV->getType(), - ResolvedVal, false); + ResolvedVal); if (!ResolvedVal) return true; GV->replaceAllUsesWith(ResolvedVal); @@ -6271,7 +6265,7 @@ // Look up the callee. Value *Callee; if (convertValIDToValue(PointerType::get(Ty, InvokeAddrSpace), CalleeID, - Callee, &PFS, /*IsCall=*/true)) + Callee, &PFS)) return true; // Set up the Attribute for the function. @@ -6596,8 +6590,7 @@ // Look up the callee. Value *Callee; - if (convertValIDToValue(PointerType::getUnqual(Ty), CalleeID, Callee, &PFS, - /*IsCall=*/true)) + if (convertValIDToValue(PointerType::getUnqual(Ty), CalleeID, Callee, &PFS)) return true; // Set up the Attribute for the function. @@ -7003,7 +6996,7 @@ // Look up the callee. Value *Callee; if (convertValIDToValue(PointerType::get(Ty, CallAddrSpace), CalleeID, Callee, - &PFS, /*IsCall=*/true)) + &PFS)) return true; // Set up the Attribute for the function. Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1792,6 +1792,9 @@ case bitc::TYPE_CODE_OPAQUE_POINTER: { // OPAQUE_POINTER: [addrspace] if (Record.size() != 1) return error("Invalid record"); + if (Context.supportsTypedPointers()) + return error( + "Opaque pointers are only supported in -opaque-pointers mode"); unsigned AddressSpace = Record[0]; ResultTy = PointerType::get(Context, AddressSpace); break; Index: llvm/lib/IR/Function.cpp =================================================================== --- llvm/lib/IR/Function.cpp +++ llvm/lib/IR/Function.cpp @@ -1438,11 +1438,6 @@ if (!PT->isOpaque()) return matchIntrinsicType(PT->getElementType(), Infos, ArgTys, DeferredChecks, IsDeferredCheck); - // If typed pointers are supported, do not allow using opaque pointer in - // place of fixed pointer type. This would make the intrinsic signature - // non-unique. - if (Ty->getContext().supportsTypedPointers()) - return true; // Consume IIT descriptors relating to the pointer element type. while (Infos.front().Kind == IITDescriptor::Pointer) Infos = Infos.slice(1); @@ -1560,11 +1555,8 @@ if (!ThisArgType || !ReferenceType) return true; - if (!ThisArgType->isOpaque()) - return ThisArgType->getElementType() != ReferenceType->getElementType(); - // If typed pointers are supported, do not allow opaque pointer to ensure - // uniqueness. - return Ty->getContext().supportsTypedPointers(); + return !ThisArgType->isOpaqueOrPointeeTypeMatches( + ReferenceType->getElementType()); } case IITDescriptor::VecOfAnyPtrsToElt: { unsigned RefArgNumber = D.getRefArgNumber(); Index: llvm/lib/IR/LLVMContext.cpp =================================================================== --- llvm/lib/IR/LLVMContext.cpp +++ llvm/lib/IR/LLVMContext.cpp @@ -349,5 +349,5 @@ } bool LLVMContext::supportsTypedPointers() const { - return !pImpl->ForceOpaquePointers; + return !pImpl->OpaquePointers; } Index: llvm/lib/IR/LLVMContextImpl.h =================================================================== --- llvm/lib/IR/LLVMContextImpl.h +++ llvm/lib/IR/LLVMContextImpl.h @@ -1461,7 +1461,7 @@ DenseMap, VectorType*> VectorTypes; // TODO: clean up the following after we no longer support non-opaque pointer // types. - bool ForceOpaquePointers; + bool OpaquePointers; DenseMap PointerTypes; // Pointers in AddrSpace = 0 DenseMap, PointerType*> ASPointerTypes; Index: llvm/lib/IR/LLVMContextImpl.cpp =================================================================== --- llvm/lib/IR/LLVMContextImpl.cpp +++ llvm/lib/IR/LLVMContextImpl.cpp @@ -23,9 +23,8 @@ using namespace llvm; static cl::opt - ForceOpaquePointersCL("force-opaque-pointers", - cl::desc("Force all pointers to be opaque pointers"), - cl::init(false)); + OpaquePointersCL("opaque-pointers", cl::desc("Use opaque pointers"), + cl::init(false)); LLVMContextImpl::LLVMContextImpl(LLVMContext &C) : DiagHandler(std::make_unique()), @@ -37,7 +36,7 @@ PPC_FP128Ty(C, Type::PPC_FP128TyID), X86_MMXTy(C, Type::X86_MMXTyID), X86_AMXTy(C, Type::X86_AMXTyID), Int1Ty(C, 1), Int8Ty(C, 8), Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128), - ForceOpaquePointers(ForceOpaquePointersCL) {} + OpaquePointers(OpaquePointersCL) {} LLVMContextImpl::~LLVMContextImpl() { // NOTE: We need to delete the contents of OwnedModules, but Module's dtor Index: llvm/lib/IR/Type.cpp =================================================================== --- llvm/lib/IR/Type.cpp +++ llvm/lib/IR/Type.cpp @@ -696,8 +696,8 @@ LLVMContextImpl *CImpl = EltTy->getContext().pImpl; - // Create opaque pointer for pointer to opaque pointer. - if (CImpl->ForceOpaquePointers || EltTy->isOpaquePointerTy()) + // Automatically convert typed pointers to opaque pointers. + if (CImpl->OpaquePointers) return get(EltTy->getContext(), AddressSpace); // Since AddressSpace #0 is the common case, we special case it. @@ -711,6 +711,8 @@ PointerType *PointerType::get(LLVMContext &C, unsigned AddressSpace) { LLVMContextImpl *CImpl = C.pImpl; + assert(CImpl->OpaquePointers && + "Can only create opaque pointers in opaque pointer mode"); // Since AddressSpace #0 is the common case, we special case it. PointerType *&Entry = Index: llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll =================================================================== --- llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll +++ llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll @@ -1,4 +1,4 @@ -; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s +; RUN: not llvm-as < %s -opaque-pointers -disable-output 2>&1 | FileCheck %s ; CHECK: ptr* is invalid - use ptr instead define void @f(ptr addrspace(3) %a) { Index: llvm/test/Assembler/invalid-opaque-ptr-double-addrspace.ll =================================================================== --- llvm/test/Assembler/invalid-opaque-ptr-double-addrspace.ll +++ llvm/test/Assembler/invalid-opaque-ptr-double-addrspace.ll @@ -1,4 +1,4 @@ -; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s +; RUN: not llvm-as < %s -opaque-pointers -disable-output 2>&1 | FileCheck %s ; CHECK: expected top-level entity @g1 = external global ptr addrspace(3) addrspace(4) Index: llvm/test/Assembler/invalid-opaque-ptr.ll =================================================================== --- llvm/test/Assembler/invalid-opaque-ptr.ll +++ llvm/test/Assembler/invalid-opaque-ptr.ll @@ -1,4 +1,4 @@ -; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s +; RUN: not llvm-as < %s -opaque-pointers -disable-output 2>&1 | FileCheck %s ; CHECK: ptr* is invalid - use ptr instead define void @f(ptr %a) { Index: llvm/test/Assembler/opaque-ptr-cmpxchg.ll =================================================================== --- llvm/test/Assembler/opaque-ptr-cmpxchg.ll +++ llvm/test/Assembler/opaque-ptr-cmpxchg.ll @@ -1,4 +1,4 @@ -; RUN: not llvm-as < %s 2>&1 | FileCheck %s +; RUN: not llvm-as -opaque-pointers < %s 2>&1 | FileCheck %s ; CHECK: compare value and new value type do not match define void @cmpxchg(ptr %p, i32 %a, i64 %b) { Index: llvm/test/Assembler/opaque-ptr.ll =================================================================== --- llvm/test/Assembler/opaque-ptr.ll +++ llvm/test/Assembler/opaque-ptr.ll @@ -1,12 +1,12 @@ -; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s -; RUN: verify-uselistorder %s +; RUN: llvm-as -opaque-pointers < %s | llvm-dis -opaque-pointers | llvm-as -opaque-pointers | llvm-dis -opaque-pointers | FileCheck %s +; RUN: verify-uselistorder -opaque-pointers %s ; CHECK: @global = external global ptr @global = external global ptr -; CHECK: @fptr1 = external global ptr ()* -; CHECK: @fptr2 = external global ptr () addrspace(1)* -; CHECK: @fptr3 = external global ptr () addrspace(1)* addrspace(2)* +; CHECK: @fptr1 = external global ptr +; CHECK: @fptr2 = external global ptr addrspace(1) +; CHECK: @fptr3 = external global ptr addrspace(2) @fptr1 = external global ptr ()* @fptr2 = external global ptr () addrspace(1)* @fptr3 = external global ptr () addrspace(1)* addrspace(2)* @@ -125,7 +125,7 @@ ret void } -; CHECK: define void @invoke(ptr %p) personality void ()* @personality { +; CHECK: define void @invoke(ptr %p) personality ptr @personality { ; CHECK: invoke void %p() ; CHECK: to label %continue unwind label %cleanup declare void @personality() Index: llvm/test/Assembler/ptr-outside-opaque-pointers-mode.ll =================================================================== --- /dev/null +++ llvm/test/Assembler/ptr-outside-opaque-pointers-mode.ll @@ -0,0 +1,7 @@ +; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s + +; CHECK: warning: ptr type is only supported in -opaque-pointers mode +; CHECK: error: expected type +define void @f(ptr %a) { + ret void +} Index: llvm/test/Assembler/remangle-intrinsic-opaque-ptr.ll =================================================================== --- llvm/test/Assembler/remangle-intrinsic-opaque-ptr.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s --check-prefix=TYPED -; RUN: llvm-as --force-opaque-pointers < %s | llvm-dis --force-opaque-pointers | FileCheck %s --check-prefix=OPAQUE - -; An opaque pointer type should not be accepted for an intrinsic that -; specifies a fixed pointer type, outside of --force-opaque-pointers mode. - -define void @test() { -; TYPED: Intrinsic has incorrect return type! -; OPAQUE: call ptr @llvm.stacksave() - call ptr @llvm.stacksave() - -; TYPED: Intrinsic has incorrect argument type! -; OPAQUE: call <2 x i64> @llvm.masked.expandload.v2i64(ptr null, <2 x i1> zeroinitializer, <2 x i64> zeroinitializer) - call <2 x i64> @llvm.masked.expandload.v2i64(ptr null, <2 x i1> zeroinitializer, <2 x i64> zeroinitializer) - - ret void -} - -declare ptr @llvm.stacksave() -declare <2 x i64> @llvm.masked.expandload.v2i64(ptr, <2 x i1>, <2 x i64>) Index: llvm/test/CodeGen/BPF/CORE/intrinsic-array.ll =================================================================== --- llvm/test/CodeGen/BPF/CORE/intrinsic-array.ll +++ llvm/test/CodeGen/BPF/CORE/intrinsic-array.ll @@ -1,8 +1,8 @@ ; RUN: opt -O2 %s | llvm-dis > %t1 ; RUN: llc -filetype=asm -o - %t1 | FileCheck %s ; RUN: llc -mattr=+alu32 -filetype=asm -o - %t1 | FileCheck %s -; RUN: llc -filetype=asm -force-opaque-pointers -o - %t1 | FileCheck %s -; RUN: llc -mattr=+alu32 -filetype=asm -force-opaque-pointers -o - %t1 | FileCheck %s +; RUN: llc -filetype=asm -opaque-pointers -o - %t1 | FileCheck %s +; RUN: llc -mattr=+alu32 -filetype=asm -opaque-pointers -o - %t1 | FileCheck %s ; ; Source code: ; #define _(x) (__builtin_preserve_access_index(x)) Index: llvm/test/CodeGen/Hexagon/atomic-opaque-basic.ll =================================================================== --- llvm/test/CodeGen/Hexagon/atomic-opaque-basic.ll +++ llvm/test/CodeGen/Hexagon/atomic-opaque-basic.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -march=hexagon -force-opaque-pointers < %s | FileCheck %s +; RUN: llc -march=hexagon -opaque-pointers < %s | FileCheck %s %s.0 = type { i8 } @g0 = internal global i8 0, align 1 Index: llvm/test/CodeGen/WebAssembly/add-prototypes-opaque-ptrs.ll =================================================================== --- llvm/test/CodeGen/WebAssembly/add-prototypes-opaque-ptrs.ll +++ llvm/test/CodeGen/WebAssembly/add-prototypes-opaque-ptrs.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -wasm-add-missing-prototypes -force-opaque-pointers %s | FileCheck %s +; RUN: opt -S -wasm-add-missing-prototypes -opaque-pointers %s | FileCheck %s target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" target triple = "wasm32-unknown-unknown" Index: llvm/test/CodeGen/WebAssembly/function-bitcasts.ll =================================================================== --- llvm/test/CodeGen/WebAssembly/function-bitcasts.ll +++ llvm/test/CodeGen/WebAssembly/function-bitcasts.ll @@ -1,5 +1,5 @@ ; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions | FileCheck %s --check-prefixes=CHECK,TYPED -; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions -force-opaque-pointers | FileCheck %s --check-prefixes=CHECK,OPAQUE +; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions -opaque-pointers | FileCheck %s --check-prefixes=CHECK,OPAQUE ; Test that function pointer casts are replaced with wrappers. Index: llvm/test/CodeGen/WebAssembly/main-declaration.ll =================================================================== --- llvm/test/CodeGen/WebAssembly/main-declaration.ll +++ llvm/test/CodeGen/WebAssembly/main-declaration.ll @@ -1,5 +1,5 @@ ; RUN: llc < %s -asm-verbose=false | FileCheck %s -; RUN: llc < %s -asm-verbose=false -force-opaque-pointers | FileCheck %s +; RUN: llc < %s -asm-verbose=false -opaque-pointers | FileCheck %s ; Test main functions with alternate signatures. Index: llvm/test/Instrumentation/SanitizerCoverage/opaque-ptr.ll =================================================================== --- llvm/test/Instrumentation/SanitizerCoverage/opaque-ptr.ll +++ llvm/test/Instrumentation/SanitizerCoverage/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals -; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -force-opaque-pointers -S | FileCheck %s +; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -opaque-pointers -S | FileCheck %s ;. ; CHECK: @[[__SANCOV_LOWEST_STACK:[a-zA-Z0-9_$"\\.-]+]] = external thread_local(initialexec) global i64 Index: llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll =================================================================== --- llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll +++ llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll @@ -5,7 +5,7 @@ ; RUN: not opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 \ ; RUN: -sanitizer-coverage-stack-depth -S 2>&1 | FileCheck %s ; RUN: not opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 \ -; RUN: -sanitizer-coverage-stack-depth -force-opaque-pointers -S 2>&1 | FileCheck %s +; RUN: -sanitizer-coverage-stack-depth -opaque-pointers -S 2>&1 | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" Index: llvm/test/Other/force-opaque-ptrs-typed-dis.ll =================================================================== --- llvm/test/Other/force-opaque-ptrs-typed-dis.ll +++ llvm/test/Other/force-opaque-ptrs-typed-dis.ll @@ -1,13 +1,10 @@ -; RUN: llvm-as --force-opaque-pointers < %s | llvm-dis | FileCheck %s +; RUN: llvm-as --opaque-pointers < %s | not llvm-dis 2>&1 | FileCheck %s + +; CHECK: error: Opaque pointers are only supported in -opaque-pointers mode -; CHECK: @g = external global i16 @g = external global i16 define void @f(i32* %p) { -; CHECK-LABEL: @f( -; CHECK-NEXT: [[A:%.*]] = alloca i17, align 4 -; CHECK-NEXT: ret void -; %a = alloca i17 ret void } Index: llvm/test/Other/force-opaque-ptrs.ll =================================================================== --- llvm/test/Other/force-opaque-ptrs.ll +++ llvm/test/Other/force-opaque-ptrs.ll @@ -1,8 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature -; RUN: llvm-as --force-opaque-pointers < %s | llvm-dis --force-opaque-pointers | FileCheck %s -; RUN: llvm-as < %s | llvm-dis --force-opaque-pointers | FileCheck %s -; RUN: opt --force-opaque-pointers < %s -S | FileCheck %s -; RUN: verify-uselistorder --force-opaque-pointers < %s +; RUN: llvm-as --opaque-pointers < %s | llvm-dis --opaque-pointers | FileCheck %s +; RUN: llvm-as < %s | llvm-dis --opaque-pointers | FileCheck %s +; RUN: opt --opaque-pointers < %s -S | FileCheck %s +; RUN: verify-uselistorder --opaque-pointers < %s %ty = type i32* Index: llvm/test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll =================================================================== --- llvm/test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll +++ llvm/test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll @@ -21,26 +21,6 @@ ret void } -define void @write4to7_opaque_ptr(ptr nocapture %p) { -; CHECK-LABEL: @write4to7_opaque_ptr( -; CHECK-NEXT: entry: -; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 1 -; CHECK-NEXT: [[TMP0:%.*]] = bitcast ptr [[ARRAYIDX0]] to i8* -; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, i8* [[TMP0]], i64 4 -; CHECK-NEXT: [[TMP2:%.*]] = bitcast i8* [[TMP1]] to ptr -; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[TMP2]], i8 0, i64 24, i1 false) -; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1 -; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX1]], align 4 -; CHECK-NEXT: ret void -; -entry: - %arrayidx0 = getelementptr inbounds i32, ptr %p, i64 1 - call void @llvm.memset.p0.i64(ptr align 4 %arrayidx0, i8 0, i64 28, i1 false) - %arrayidx1 = getelementptr inbounds i32, ptr %p, i64 1 - store i32 1, ptr %arrayidx1, align 4 - ret void -} - define void @write4to7_weird_element_type(i32* nocapture %p) { ; CHECK-LABEL: @write4to7_weird_element_type( ; CHECK-NEXT: entry: @@ -452,7 +432,6 @@ declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind declare void @llvm.memset.p0i32.i64(i32* nocapture, i8, i64, i1) nounwind -declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind declare void @llvm.memset.p1i8.i64(i8 addrspace(1)* nocapture, i8, i64, i1) nounwind declare void @llvm.memset.element.unordered.atomic.p0i8.i64(i8* nocapture, i8, i64, i32) nounwind Index: llvm/test/Transforms/DeadStoreElimination/opaque-ptr.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/DeadStoreElimination/opaque-ptr.ll @@ -0,0 +1,22 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -dse -opaque-pointers -S | FileCheck %s + +define void @write4to7_opaque_ptr(ptr nocapture %p) { +; CHECK-LABEL: @write4to7_opaque_ptr( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 1 +; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[ARRAYIDX0]], i64 4 +; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 4 [[TMP0]], i8 0, i64 24, i1 false) +; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 1 +; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX1]], align 4 +; CHECK-NEXT: ret void +; +entry: + %arrayidx0 = getelementptr inbounds i32, ptr %p, i64 1 + call void @llvm.memset.p0.i64(ptr align 4 %arrayidx0, i8 0, i64 28, i1 false) + %arrayidx1 = getelementptr inbounds i32, ptr %p, i64 1 + store i32 1, ptr %arrayidx1, align 4 + ret void +} + +declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind Index: llvm/test/Transforms/InstCombine/opaque-ptr.ll =================================================================== --- llvm/test/Transforms/InstCombine/opaque-ptr.ll +++ llvm/test/Transforms/InstCombine/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -instcombine < %s | FileCheck %s +; RUN: opt -S -instcombine -opaque-pointers < %s | FileCheck %s define ptr @bitcast_opaque_to_opaque(ptr %a) { ; CHECK-LABEL: @bitcast_opaque_to_opaque( Index: llvm/test/Transforms/LoadStoreVectorizer/X86/opaque-ptr.ll =================================================================== --- llvm/test/Transforms/LoadStoreVectorizer/X86/opaque-ptr.ll +++ llvm/test/Transforms/LoadStoreVectorizer/X86/opaque-ptr.ll @@ -1,14 +1,12 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -S < %s | FileCheck %s +; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -opaque-pointers -S < %s | FileCheck %s define void @test(ptr %ptr) { ; CHECK-LABEL: @test( -; CHECK-NEXT: [[TMP1:%.*]] = bitcast ptr [[PTR:%.*]] to <2 x i32>* -; CHECK-NEXT: [[TMP2:%.*]] = load <2 x i32>, <2 x i32>* [[TMP1]], align 4 -; CHECK-NEXT: [[L11:%.*]] = extractelement <2 x i32> [[TMP2]], i32 0 -; CHECK-NEXT: [[L22:%.*]] = extractelement <2 x i32> [[TMP2]], i32 1 -; CHECK-NEXT: [[TMP3:%.*]] = bitcast ptr [[PTR]] to <2 x i32>* -; CHECK-NEXT: store <2 x i32> zeroinitializer, <2 x i32>* [[TMP3]], align 4 +; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i32>, ptr [[PTR:%.*]], align 4 +; CHECK-NEXT: [[L11:%.*]] = extractelement <2 x i32> [[TMP1]], i32 0 +; CHECK-NEXT: [[L22:%.*]] = extractelement <2 x i32> [[TMP1]], i32 1 +; CHECK-NEXT: store <2 x i32> zeroinitializer, ptr [[PTR]], align 4 ; CHECK-NEXT: ret void ; %ptr2 = getelementptr i32, ptr %ptr, i64 1 Index: llvm/test/Transforms/LoopStrengthReduce/opaque-ptr.ll =================================================================== --- llvm/test/Transforms/LoopStrengthReduce/opaque-ptr.ll +++ llvm/test/Transforms/LoopStrengthReduce/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -loop-reduce < %s | FileCheck %s +; RUN: opt -S -loop-reduce -opaque-pointers < %s | FileCheck %s target datalayout = "e-p:64:64:64-n32:64" Index: llvm/test/Transforms/LoopVectorize/opaque-ptr.ll =================================================================== --- llvm/test/Transforms/LoopVectorize/opaque-ptr.ll +++ llvm/test/Transforms/LoopVectorize/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -loop-vectorize -force-vector-width=2 < %s | FileCheck %s +; RUN: opt -S -loop-vectorize -force-vector-width=2 -opaque-pointers < %s | FileCheck %s ; TODO: This still crashes with inbounds on the GEPs. define void @test(ptr %p1.start, ptr %p2.start, ptr %p1.end) { Index: llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll =================================================================== --- llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll +++ llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll @@ -309,22 +309,6 @@ ret void } -define void @test_opaque_ptrs(ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) { -; CHECK-LABEL: @test_opaque_ptrs( -; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i64 [[DST_SIZE:%.*]], [[SRC_SIZE:%.*]] -; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[DST_SIZE]], [[SRC_SIZE]] -; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i64 0, i64 [[TMP2]] -; CHECK-NEXT: [[TMP4:%.*]] = bitcast ptr [[DST:%.*]] to i8* -; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i8, i8* [[TMP4]], i64 [[SRC_SIZE]] -; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[TMP5]], i8 [[C:%.*]], i64 [[TMP3]], i1 false) -; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[SRC_SIZE]], i1 false) -; CHECK-NEXT: ret void -; - call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false) - call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false) - ret void -} - define void @test_weird_element_type(i16* %src, i64 %src_size, i16* noalias %dst, i64 %dst_size, i8 %c) { ; CHECK-LABEL: @test_weird_element_type( ; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i64 [[DST_SIZE:%.*]], [[SRC_SIZE:%.*]] @@ -362,8 +346,6 @@ declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) declare void @llvm.memset.p0i8.i128(i8* nocapture, i8, i128, i1) declare void @llvm.memcpy.p0i8.p0i8.i128(i8* nocapture, i8* nocapture readonly, i128, i1) -declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) -declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1) declare void @llvm.memset.p0i16.i64(i16* nocapture, i8, i64, i1) declare void @llvm.memcpy.p0i16.p0i16.i64(i16* nocapture, i16* nocapture readonly, i64, i1) declare void @llvm.memset.p1i8.i64(i8 addrspace(1)* nocapture, i8, i64, i1) Index: llvm/test/Transforms/MemCpyOpt/no-libcalls.ll =================================================================== --- llvm/test/Transforms/MemCpyOpt/no-libcalls.ll +++ llvm/test/Transforms/MemCpyOpt/no-libcalls.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -memcpyopt < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS -; RUN: opt -S -memcpyopt -mtriple=amdgcn-- < %s | FileCheck %s --check-prefixes=CHECK,NO-LIBCALLS -; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls < %s \ +; RUN: opt -S -memcpyopt -opaque-pointers < %s | FileCheck %s --check-prefixes=CHECK,LIBCALLS +; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -opaque-pointers < %s | FileCheck %s --check-prefixes=CHECK,NO-LIBCALLS +; RUN: opt -S -memcpyopt -mtriple=amdgcn-- -enable-memcpyopt-without-libcalls -opaque-pointers < %s \ ; RUN: | FileCheck %s --check-prefixes=CHECK,LIBCALLS ; REQUIRES: amdgpu-registered-target Index: llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll @@ -0,0 +1,20 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -basic-aa -memcpyopt -S %s -verify-memoryssa -opaque-pointers | FileCheck %s + +define void @test_memset_memcpy(ptr %src, i64 %src_size, ptr noalias %dst, i64 %dst_size, i8 %c) { +; CHECK-LABEL: @test_memset_memcpy( +; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i64 [[DST_SIZE:%.*]], [[SRC_SIZE:%.*]] +; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[DST_SIZE]], [[SRC_SIZE]] +; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i64 0, i64 [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i8, ptr [[DST:%.*]], i64 [[SRC_SIZE]] +; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[TMP4]], i8 [[C:%.*]], i64 [[TMP3]], i1 false) +; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[SRC_SIZE]], i1 false) +; CHECK-NEXT: ret void +; + call void @llvm.memset.p0.i64(ptr %dst, i8 %c, i64 %dst_size, i1 false) + call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %src_size, i1 false) + ret void +} + +declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) +declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1) Index: llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr.ll =================================================================== --- llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr.ll +++ llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S -slp-vectorizer -mtriple=x86_64-apple-macosx -mcpu=haswell < %s | FileCheck %s +; RUN: opt -S -slp-vectorizer -mtriple=x86_64-apple-macosx -mcpu=haswell -opaque-pointers < %s | FileCheck %s define void @test(ptr %r, ptr %p, ptr %q) #0 { ; CHECK-LABEL: @test( @@ -11,19 +11,17 @@ ; CHECK-NEXT: [[Q1:%.*]] = getelementptr inbounds i64, ptr [[Q]], i64 1 ; CHECK-NEXT: [[Q2:%.*]] = getelementptr inbounds i64, ptr [[Q]], i64 2 ; CHECK-NEXT: [[Q3:%.*]] = getelementptr inbounds i64, ptr [[Q]], i64 3 -; CHECK-NEXT: [[TMP1:%.*]] = bitcast ptr [[P0]] to <4 x i64>* -; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i64>, <4 x i64>* [[TMP1]], align 2 -; CHECK-NEXT: [[TMP3:%.*]] = bitcast ptr [[Q0]] to <4 x i64>* -; CHECK-NEXT: [[TMP4:%.*]] = load <4 x i64>, <4 x i64>* [[TMP3]], align 2 -; CHECK-NEXT: [[TMP5:%.*]] = sub nsw <4 x i64> [[TMP2]], [[TMP4]] -; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i64> [[TMP5]], i32 0 -; CHECK-NEXT: [[G0:%.*]] = getelementptr inbounds i32, ptr [[R:%.*]], i64 [[TMP6]] -; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[TMP5]], i32 1 -; CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP7]] -; CHECK-NEXT: [[TMP8:%.*]] = extractelement <4 x i64> [[TMP5]], i32 2 -; CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP8]] -; CHECK-NEXT: [[TMP9:%.*]] = extractelement <4 x i64> [[TMP5]], i32 3 -; CHECK-NEXT: [[G3:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP9]] +; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i64>, ptr [[P0]], align 2 +; CHECK-NEXT: [[TMP2:%.*]] = load <4 x i64>, ptr [[Q0]], align 2 +; CHECK-NEXT: [[TMP3:%.*]] = sub nsw <4 x i64> [[TMP1]], [[TMP2]] +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i64> [[TMP3]], i32 0 +; CHECK-NEXT: [[G0:%.*]] = getelementptr inbounds i32, ptr [[R:%.*]], i64 [[TMP4]] +; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i64> [[TMP3]], i32 1 +; CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP5]] +; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x i64> [[TMP3]], i32 2 +; CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP6]] +; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[TMP3]], i32 3 +; CHECK-NEXT: [[G3:%.*]] = getelementptr inbounds i32, ptr [[R]], i64 [[TMP7]] ; CHECK-NEXT: ret void ; %p0 = getelementptr inbounds i64, ptr %p, i64 0 Index: llvm/test/Transforms/SimplifyCFG/speculate-store-opaque-pointer.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/SimplifyCFG/speculate-store-opaque-pointer.ll @@ -0,0 +1,67 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -opaque-pointers -S < %s | FileCheck %s + +declare void @unknown_fun() + +define void @different_type(ptr %ptr, i1 %cmp) { +; CHECK-LABEL: @different_type( +; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4 +; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[RET_END:%.*]] +; CHECK: if.then: +; CHECK-NEXT: store i64 1, ptr [[PTR]], align 4 +; CHECK-NEXT: br label [[RET_END]] +; CHECK: ret.end: +; CHECK-NEXT: ret void +; + store i32 0, ptr %ptr + br i1 %cmp, label %if.then, label %ret.end + +if.then: + store i64 1, ptr %ptr + br label %ret.end + +ret.end: + ret void +} + +define void @readonly_call(ptr %ptr, i1 %cmp) { +; CHECK-LABEL: @readonly_call( +; CHECK-NEXT: ret.end: +; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4 +; CHECK-NEXT: call void @unknown_fun() #[[ATTR0:[0-9]+]] +; CHECK-NEXT: [[SPEC_STORE_SELECT:%.*]] = select i1 [[CMP:%.*]], i32 1, i32 0 +; CHECK-NEXT: store i32 [[SPEC_STORE_SELECT]], ptr [[PTR]], align 4 +; CHECK-NEXT: ret void +; + store i32 0, ptr %ptr + call void @unknown_fun() readonly + br i1 %cmp, label %if.then, label %ret.end + +if.then: + store i32 1, ptr %ptr + br label %ret.end + +ret.end: + ret void +} + +define void @atomic_and_simple(ptr %ptr, i1 %cmp) { +; CHECK-LABEL: @atomic_and_simple( +; CHECK-NEXT: store atomic i32 0, ptr [[PTR:%.*]] seq_cst, align 4 +; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[RET_END:%.*]] +; CHECK: if.then: +; CHECK-NEXT: store i32 1, ptr [[PTR]], align 4 +; CHECK-NEXT: br label [[RET_END]] +; CHECK: ret.end: +; CHECK-NEXT: ret void +; + store atomic i32 0, ptr %ptr seq_cst, align 4 + br i1 %cmp, label %if.then, label %ret.end + +if.then: + store i32 1, ptr %ptr + br label %ret.end + +ret.end: + ret void +} Index: llvm/test/Transforms/SimplifyCFG/speculate-store.ll =================================================================== --- llvm/test/Transforms/SimplifyCFG/speculate-store.ll +++ llvm/test/Transforms/SimplifyCFG/speculate-store.ll @@ -112,68 +112,6 @@ ret void } -define void @different_type(ptr %ptr, i1 %cmp) { -; CHECK-LABEL: @different_type( -; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4 -; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[RET_END:%.*]] -; CHECK: if.then: -; CHECK-NEXT: store i64 1, ptr [[PTR]], align 4 -; CHECK-NEXT: br label [[RET_END]] -; CHECK: ret.end: -; CHECK-NEXT: ret void -; - store i32 0, ptr %ptr - br i1 %cmp, label %if.then, label %ret.end - -if.then: - store i64 1, ptr %ptr - br label %ret.end - -ret.end: - ret void -} - -define void @readonly_call(ptr %ptr, i1 %cmp) { -; CHECK-LABEL: @readonly_call( -; CHECK-NEXT: ret.end: -; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4 -; CHECK-NEXT: call void @unknown_fun() #[[ATTR0:[0-9]+]] -; CHECK-NEXT: [[SPEC_STORE_SELECT:%.*]] = select i1 [[CMP:%.*]], i32 1, i32 0 -; CHECK-NEXT: store i32 [[SPEC_STORE_SELECT]], ptr [[PTR]], align 4 -; CHECK-NEXT: ret void -; - store i32 0, ptr %ptr - call void @unknown_fun() readonly - br i1 %cmp, label %if.then, label %ret.end - -if.then: - store i32 1, ptr %ptr - br label %ret.end - -ret.end: - ret void -} - -define void @atomic_and_simple(ptr %ptr, i1 %cmp) { -; CHECK-LABEL: @atomic_and_simple( -; CHECK-NEXT: store atomic i32 0, ptr [[PTR:%.*]] seq_cst, align 4 -; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[RET_END:%.*]] -; CHECK: if.then: -; CHECK-NEXT: store i32 1, ptr [[PTR]], align 4 -; CHECK-NEXT: br label [[RET_END]] -; CHECK: ret.end: -; CHECK-NEXT: ret void -; - store atomic i32 0, ptr %ptr seq_cst, align 4 - br i1 %cmp, label %if.then, label %ret.end - -if.then: - store i32 1, ptr %ptr - br label %ret.end - -ret.end: - ret void -} ;; Speculate a store, preceded by a local, non-escaping load define i32 @load_before_store_noescape(i64 %i, i32 %b) { Index: llvm/test/Verifier/force-opaque-ptr.ll =================================================================== --- llvm/test/Verifier/force-opaque-ptr.ll +++ llvm/test/Verifier/force-opaque-ptr.ll @@ -1,4 +1,4 @@ -; RUN: not opt -passes=verify -force-opaque-pointers -S < %s 2>&1 | FileCheck %s +; RUN: not opt -passes=verify -opaque-pointers -S < %s 2>&1 | FileCheck %s declare i32 @llvm.umax.i32(i32, i32) Index: llvm/test/Verifier/musttail-invalid.ll =================================================================== --- llvm/test/Verifier/musttail-invalid.ll +++ llvm/test/Verifier/musttail-invalid.ll @@ -1,4 +1,5 @@ ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s +; RUN: not llvm-as %s -opaque-pointers -o /dev/null 2>&1 | FileCheck %s ; Each musttail call should fail to validate. @@ -46,13 +47,6 @@ ret void } -declare void @mismatched_byval_callee2(ptr byval(i32)) -define void @mismatched_byval2(ptr byval(i64) %a) { -; CHECK: mismatched ABI impacting function attributes - musttail call void @mismatched_byval_callee2(ptr byval(i32) %a) - ret void -} - declare void @mismatched_inreg_callee(i32 inreg) define void @mismatched_inreg(i32 %a) { ; CHECK: mismatched ABI impacting function attributes Index: llvm/test/Verifier/opaque-ptr-invalid.ll =================================================================== --- llvm/test/Verifier/opaque-ptr-invalid.ll +++ llvm/test/Verifier/opaque-ptr-invalid.ll @@ -1,7 +1,7 @@ -; RUN: not opt -verify < %s 2>&1 | FileCheck %s +; RUN: not opt -verify -opaque-pointers < %s 2>&1 | FileCheck %s ; CHECK: Attribute 'inalloca' does not support unsized types! -; CHECK-NEXT: void (ptr)* @f +; CHECK-NEXT: ptr @f define void @f(ptr inalloca(token)) { ret void } Index: llvm/test/Verifier/opaque-ptr.ll =================================================================== --- llvm/test/Verifier/opaque-ptr.ll +++ llvm/test/Verifier/opaque-ptr.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -passes=verify -S < %s | FileCheck %s +; RUN: opt -passes=verify -opaque-pointers -S < %s | FileCheck %s define i32 @load(ptr %a) { ; CHECK-LABEL: @load(