[lld] [openmp] [polly] [flang] [clang] [libcxx] [compiler-rt] [llvm] [mlir] [libc] [lldb] [WebAssembly] Correctly consider signext/zext arg flags at function declaration (PR #77281)
@@ -839,9 +839,11 @@ bool WebAssemblyFastISel::selectCall(const Instruction *I) { unsigned Reg; -if (Attrs.hasParamAttr(I, Attribute::SExt)) +if (Attrs.hasParamAttr(I, Attribute::SExt) || +(IsDirect && Func->hasParamAttribute(I, Attribute::SExt))) wingo wrote: I have been too long away from LLVM to LGTM, but I would guess that you would have a similar situation with indirect function calls as well. Perhaps you could test a function that takes a function pointer parameter with sext / zext attributes. But, again, perhaps this comment is off-base. https://github.com/llvm/llvm-project/pull/77281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] eb3af1e - [clang][NFC] Remove dead code
Author: Andy Wingo Date: 2021-09-20T11:33:34+02:00 New Revision: eb3af1e77341e82249993a5a8a50779c48e1cb61 URL: https://github.com/llvm/llvm-project/commit/eb3af1e77341e82249993a5a8a50779c48e1cb61 DIFF: https://github.com/llvm/llvm-project/commit/eb3af1e77341e82249993a5a8a50779c48e1cb61.diff LOG: [clang][NFC] Remove dead code Remove code that has no effect in SemaType.cpp:processTypeAttrs. Differential Revision: https://reviews.llvm.org/D108360 Added: Modified: clang/lib/Sema/SemaType.cpp Removed: diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index df9f203ae4c6..53e41f01f83d 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8310,10 +8310,6 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, attr.getMacroExpansionLoc()); } } - - if (!state.getSema().getLangOpts().OpenCL || - type.getAddressSpace() != LangAS::Default) -return; } void Sema::completeExprArrayBound(Expr *E) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9ae4275 - [clang][NFC] Fix needless double-parenthisation
Author: Andy Wingo Date: 2021-09-21T17:03:23+02:00 New Revision: 9ae4275557ca10f79af91ca99a2aa79d5dfd7ed3 URL: https://github.com/llvm/llvm-project/commit/9ae4275557ca10f79af91ca99a2aa79d5dfd7ed3 DIFF: https://github.com/llvm/llvm-project/commit/9ae4275557ca10f79af91ca99a2aa79d5dfd7ed3.diff LOG: [clang][NFC] Fix needless double-parenthisation Strip a layer of parentheses in TreeTransform::RebuildQualifiedType. Differential Revision: https://reviews.llvm.org/D108359 Added: Modified: clang/lib/Sema/TreeTransform.h Removed: diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 0aee33a51633..9c1236841b30 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -4745,8 +4745,8 @@ QualType TreeTransform::RebuildQualifiedType(QualType T, SourceLocation Loc = TL.getBeginLoc(); Qualifiers Quals = TL.getType().getLocalQualifiers(); - if (((T.getAddressSpace() != LangAS::Default && -Quals.getAddressSpace() != LangAS::Default)) && + if ((T.getAddressSpace() != LangAS::Default && + Quals.getAddressSpace() != LangAS::Default) && T.getAddressSpace() != Quals.getAddressSpace()) { SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst) << TL.getType() << T; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d7086af - [WebAssembly] Support for WebAssembly globals in LLVM IR
Author: Paulo Matos Date: 2021-05-11T11:19:29+02:00 New Revision: d7086af2143d58a6535e0837c4d8789c69c6985f URL: https://github.com/llvm/llvm-project/commit/d7086af2143d58a6535e0837c4d8789c69c6985f DIFF: https://github.com/llvm/llvm-project/commit/d7086af2143d58a6535e0837c4d8789c69c6985f.diff LOG: [WebAssembly] Support for WebAssembly globals in LLVM IR This patch adds support for WebAssembly globals in LLVM IR, representing them as pointers to global values, in a non-default, non-integral address space. Instruction selection legalizes loads and stores to these pointers to new WebAssemblyISD nodes GLOBAL_GET and GLOBAL_SET. Once the lowering creates the new nodes, tablegen pattern matches those and converts them to Wasm global.get/set of the appropriate type. Based on work by Paulo Matos in https://reviews.llvm.org/D95425. Reviewed By: pmatos Differential Revision: https://reviews.llvm.org/D101608 Added: llvm/test/CodeGen/WebAssembly/global-get.ll llvm/test/CodeGen/WebAssembly/global-set.ll Modified: clang/lib/Basic/Targets/WebAssembly.h clang/test/CodeGen/target-data.c llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp llvm/lib/Target/WebAssembly/WebAssemblyISD.def llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp Removed: diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h index be5b66a9580b..70115183e46b 100644 --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -147,7 +147,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo explicit WebAssembly32TargetInfo(const llvm::Triple &T, const TargetOptions &Opts) : WebAssemblyTargetInfo(T, Opts) { -resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128"); +resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:1"); } protected: @@ -166,7 +166,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssembly64TargetInfo SizeType = UnsignedLong; PtrDiffType = SignedLong; IntPtrType = SignedLong; -resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128"); +resetDataLayout("e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"); } protected: diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c index ea6cef484341..1d88984530e5 100644 --- a/clang/test/CodeGen/target-data.c +++ b/clang/test/CodeGen/target-data.c @@ -108,11 +108,11 @@ // RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=WEBASSEMBLY32 -// WEBASSEMBLY32: target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +// WEBASSEMBLY32: target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1" // RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=WEBASSEMBLY64 -// WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" +// WEBASSEMBLY64: target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128-ni:1" // RUN: %clang_cc1 -triple lanai-unknown-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=LANAI diff --git a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h index 0d9c07cbf1f9..1ec1df5d0c3d 100644 --- a/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h +++ b/llvm/lib/Target/WebAssembly/Utils/WebAssemblyUtilities.h @@ -28,6 +28,26 @@ class WebAssemblySubtarget; namespace WebAssembly { +enum WasmAddressSpace : unsigned { + // Default address space, for pointers to linear memory (stack, heap, data). + WASM_ADDRESS_SPACE_DEFAULT = 0, + // A non-integral address space for pointers to named objects outside of + // linear memory: WebAssembly globals or WebAssembly locals. Loads and stores + // to these pointers are lowered to global.get / global.set or local.get / + // local.set, as appropriate. + WASM_ADDRESS_SPACE_WASM_VAR = 1 +}; + +inline bool isDefaultAddressSpace(unsigned AS) { + return AS == WASM_ADDRESS_SPACE_DEFAULT; +} +inline bool isWasmVarAddressSpace(unsigned AS) { + return AS == WASM_ADDRESS_SPACE_WASM_VAR; +} +inline bool isValidAddressSpace(unsigned AS) { + return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS); +} + bool isChild(const MachineInstr &MI, const WebAssemblyFunctionInfo &MFI); bool mayThrow(const MachineInstr &MI); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp index 68e4b9c31b7c..cb0cdf1d8f98 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ b/llvm/lib/Target/WebAssembly/We
[clang] d3d4d98 - [clang][NFC] GetOrCreateLLVMGlobal takes LangAS
Author: Andy Wingo Date: 2021-08-23T14:55:58+02:00 New Revision: d3d4d98576f4f9b21579fa65630f5355dd9d1234 URL: https://github.com/llvm/llvm-project/commit/d3d4d98576f4f9b21579fa65630f5355dd9d1234 DIFF: https://github.com/llvm/llvm-project/commit/d3d4d98576f4f9b21579fa65630f5355dd9d1234.diff LOG: [clang][NFC] GetOrCreateLLVMGlobal takes LangAS Pass a LangAS instead of a target address space to GetOrCreateLLVMGlobal, to remove a place where the frontend assumes that target address space 0 is special. Differential Revision: https://reviews.llvm.org/D108445 Added: Modified: clang/lib/CodeGen/CGBlocks.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h Removed: diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index f39a56f81d41..c8bf47fdc837 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -2910,8 +2910,8 @@ llvm::Constant *CodeGenModule::getNSConcreteGlobalBlock() { if (NSConcreteGlobalBlock) return NSConcreteGlobalBlock; - NSConcreteGlobalBlock = - GetOrCreateLLVMGlobal("_NSConcreteGlobalBlock", Int8PtrTy, 0, nullptr); + NSConcreteGlobalBlock = GetOrCreateLLVMGlobal( + "_NSConcreteGlobalBlock", Int8PtrTy, LangAS::Default, nullptr); configureBlocksRuntimeObject(*this, NSConcreteGlobalBlock); return NSConcreteGlobalBlock; } @@ -2920,8 +2920,8 @@ llvm::Constant *CodeGenModule::getNSConcreteStackBlock() { if (NSConcreteStackBlock) return NSConcreteStackBlock; - NSConcreteStackBlock = - GetOrCreateLLVMGlobal("_NSConcreteStackBlock", Int8PtrTy, 0, nullptr); + NSConcreteStackBlock = GetOrCreateLLVMGlobal( + "_NSConcreteStackBlock", Int8PtrTy, LangAS::Default, nullptr); configureBlocksRuntimeObject(*this, NSConcreteStackBlock); return NSConcreteStackBlock; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 0fdd85cc656a..7723c4e70bbf 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2851,7 +2851,8 @@ ConstantAddress CodeGenModule::GetWeakRefReference(const ValueDecl *VD) { GlobalDecl(cast(VD)), /*ForVTable=*/false); else -Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), DeclTy, 0, nullptr); +Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), DeclTy, LangAS::Default, +nullptr); auto *F = cast(Aliasee); F->setLinkage(llvm::Function::ExternalWeakLinkage); @@ -3824,10 +3825,11 @@ bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) { /// mangled name but some other type. llvm::Constant * CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, - unsigned AddrSpace, const VarDecl *D, + LangAS AddrSpace, const VarDecl *D, ForDefinition_t IsForDefinition) { // Lookup the entry, lazily creating it if necessary. llvm::GlobalValue *Entry = GetGlobalValue(MangledName); + unsigned TargetAS = getContext().getTargetAddressSpace(AddrSpace); if (Entry) { if (WeakRefReferences.erase(Entry)) { if (D && !D->hasAttr()) @@ -3841,7 +3843,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, if (LangOpts.OpenMP && !LangOpts.OpenMPSimd && D) getOpenMPRuntime().registerTargetGlobalVariable(D, Entry); -if (Entry->getValueType() == Ty && Entry->getAddressSpace() == AddrSpace) +if (Entry->getValueType() == Ty && Entry->getAddressSpace() == TargetAS) return Entry; // If there are two attempts to define the same mangled name, issue an @@ -3865,24 +3867,23 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty, } // Make sure the result is of the correct type. -if (Entry->getType()->getAddressSpace() != AddrSpace) { +if (Entry->getType()->getAddressSpace() != TargetAS) { return llvm::ConstantExpr::getAddrSpaceCast(Entry, - Ty->getPointerTo(AddrSpace)); + Ty->getPointerTo(TargetAS)); } // (If global is requested for a definition, we always need to create a new // global, not just return a bitcast.) if (!IsForDefinition) - return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo(AddrSpace)); + return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo(TargetAS)); } auto DAddrSpace = GetGlobalVarAddressSpace(D); - auto TargetAddrSpace = getContext().getTargetAddressSpace(DAddrSpace); auto *GV = new llvm::GlobalVariable( getModule(), Ty, false, llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr, llvm::GlobalVariable:
[clang] 8da70fe - [clang][NFC] Tighten up code for GetGlobalVarAddressSpace
Author: Andy Wingo Date: 2021-08-23T14:55:58+02:00 New Revision: 8da70fed704c15d9656cbf2df190122acb975921 URL: https://github.com/llvm/llvm-project/commit/8da70fed704c15d9656cbf2df190122acb975921 DIFF: https://github.com/llvm/llvm-project/commit/8da70fed704c15d9656cbf2df190122acb975921.diff LOG: [clang][NFC] Tighten up code for GetGlobalVarAddressSpace The LangAS local is only used in the OpenCL case; move its decl inwards. Differential Revision: https://reviews.llvm.org/D108449 Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7723c4e70bbf..13d7cce880e0 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4148,16 +4148,15 @@ CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const { } LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { - LangAS AddrSpace = LangAS::Default; if (LangOpts.OpenCL) { -AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global; -assert(AddrSpace == LangAS::opencl_global || - AddrSpace == LangAS::opencl_global_device || - AddrSpace == LangAS::opencl_global_host || - AddrSpace == LangAS::opencl_constant || - AddrSpace == LangAS::opencl_local || - AddrSpace >= LangAS::FirstTargetAddressSpace); -return AddrSpace; +LangAS AS = D ? D->getType().getAddressSpace() : LangAS::opencl_global; +assert(AS == LangAS::opencl_global || + AS == LangAS::opencl_global_device || + AS == LangAS::opencl_global_host || + AS == LangAS::opencl_constant || + AS == LangAS::opencl_local || + AS >= LangAS::FirstTargetAddressSpace); +return AS; } if (LangOpts.SYCLIsDevice && ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4fb0c08 - [clang][CodeGen] GetDefaultAlignTempAlloca uses preferred alignment
Author: Andy Wingo Date: 2021-08-23T14:55:58+02:00 New Revision: 4fb0c083429ad3119096b3fadf01954952b68a25 URL: https://github.com/llvm/llvm-project/commit/4fb0c083429ad3119096b3fadf01954952b68a25 DIFF: https://github.com/llvm/llvm-project/commit/4fb0c083429ad3119096b3fadf01954952b68a25.diff LOG: [clang][CodeGen] GetDefaultAlignTempAlloca uses preferred alignment This function was defaulting to use the ABI alignment for the LLVM type. Here we change to use the preferred alignment. This will allow unification with GetTempAlloca, which if alignment isn't specified, uses the preferred alignment. Differential Revision: https://reviews.llvm.org/D108450 Added: Modified: clang/lib/CodeGen/CGExpr.cpp Removed: diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 83f5f42431e0..8548a9e75f4b 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -122,7 +122,7 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, Address CodeGenFunction::CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name) { CharUnits Align = -CharUnits::fromQuantity(CGM.getDataLayout().getABITypeAlignment(Ty)); + CharUnits::fromQuantity(CGM.getDataLayout().getPrefTypeAlignment(Ty)); return CreateTempAlloca(Ty, Align, Name); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits