[PATCH] D33719: Add _Float16 as a C/C++ source language type
SjoerdMeijer added a comment. Ping https://reviews.llvm.org/D33719 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36664: [analyzer] Make StmtDataCollector customizable
arphaman added a subscriber: rsmith. arphaman added a comment. In https://reviews.llvm.org/D36664#841758, @teemperor wrote: > Very well done, I really like this patch! I added a few remarks mostly about > the comments that need some small adjusting. > > I'm wondering what would be a nice way of creating a StmtDataCollector that > is faster but only works for single translation units (e.g. it only hashes > the pointer values of decls instead of their qualified name)? The use case > here would be Stmt::Profile and the CloneDetector which could be set to a > single-TU-mode in the CloneChecker. For Stmt::Profile it would ensure we > don't degrade performance from the current version, for the CloneChecker we > probably get a reasonable performance boost (as the hashing is currently the > last remaining bottle neck). > > @arphaman Any suggestions who could review/approve the additions to `AST/`? I guess @rsmith, but he's usually busy. I don't think this patch requires some special approval though. This patch adds support for things like literals and DeclRefExpr and MemberExpr, but they're untested. They should either be added in a follow-up patch or tested with an appropriate unittest in unittests/AST or unittests/Tooling. https://reviews.llvm.org/D36664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33989: [OpenCL] Allow targets to select address space per type
This revision was automatically updated to reflect the committed changes. Closed by commit rL310911: [OpenCL] Allow targets to select address space per type (authored by svenvh). Changed prior to commit: https://reviews.llvm.org/D33989?vs=110947=37#toc Repository: rL LLVM https://reviews.llvm.org/D33989 Files: cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets/AMDGPU.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Index: cfe/trunk/include/clang/Basic/TargetInfo.h === --- cfe/trunk/include/clang/Basic/TargetInfo.h +++ cfe/trunk/include/clang/Basic/TargetInfo.h @@ -46,6 +46,7 @@ class QualType; class SourceLocation; class SourceManager; +class Type; namespace Builtin { struct Info; } @@ -1050,10 +1051,8 @@ return getTargetOpts().SupportedOpenCLOptions; } - /// \brief Get OpenCL image type address space. - virtual LangAS::ID getOpenCLImageAddrSpace() const { -return LangAS::opencl_global; - } + /// \brief Get address space for OpenCL type. + virtual LangAS::ID getOpenCLTypeAddrSpace(const Type *T) const; /// \returns Target specific vtbl ptr address space. virtual unsigned getVtblPtrAddressSpace() const { Index: cfe/trunk/test/CodeGenOpenCL/opencl_types.cl === --- cfe/trunk/test/CodeGenOpenCL/opencl_types.cl +++ cfe/trunk/test/CodeGenOpenCL/opencl_types.cl @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR -// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "spir-unknown-unknown" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-SPIR +// RUN: %clang_cc1 -cl-std=CL2.0 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -O0 | FileCheck %s --check-prefix=CHECK-AMDGCN #define CLK_ADDRESS_CLAMP_TO_EDGE 2 #define CLK_NORMALIZED_COORDS_TRUE 1 @@ -42,13 +42,23 @@ // CHECK-SPIR: alloca %opencl.sampler_t addrspace(2)* event_t evt; // CHECK-SPIR: alloca %opencl.event_t* + clk_event_t clk_evt; + // CHECK-SPIR: alloca %opencl.clk_event_t* + queue_t queue; + // CHECK-SPIR: alloca %opencl.queue_t* + reserve_id_t rid; + // CHECK-SPIR: alloca %opencl.reserve_id_t* // CHECK-SPIR: store %opencl.sampler_t addrspace(2)* fnc4smp(smp); // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* fnc4smp(glb_smp); // CHECK-SPIR: call {{.*}}void @fnc4smp(%opencl.sampler_t addrspace(2)* } +kernel void foo_pipe(read_only pipe int p) {} +// CHECK-SPIR: @foo_pipe(%opencl.pipe_t addrspace(1)* %p) +// CHECK_AMDGCN: @foo_pipe(%opencl.pipe_t addrspace(1)* %p) + void __attribute__((overloadable)) bad1(image1d_t b, image2d_t c, image2d_t d) {} // CHECK-SPIR-LABEL: @{{_Z4bad114ocl_image1d_ro14ocl_image2d_roS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d_ro@@PAUocl_image2d_ro@@1@Z"}} // CHECK-AMDGCN-LABEL: @{{_Z4bad114ocl_image1d_ro14ocl_image2d_roS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d_ro@@PAUocl_image2d_ro@@1@Z"}}(%opencl.image1d_ro_t addrspace(2)*{{.*}}%opencl.image2d_ro_t addrspace(2)*{{.*}}%opencl.image2d_ro_t addrspace(2)*{{.*}}) Index: cfe/trunk/lib/AST/ASTContext.cpp === --- cfe/trunk/lib/AST/ASTContext.cpp +++ cfe/trunk/lib/AST/ASTContext.cpp @@ -1631,6 +1631,7 @@ uint64_t Width = 0; unsigned Align = 8; bool AlignIsRequired = false; + unsigned AS = 0; switch (T->getTypeClass()) { #define TYPE(Class, Base) #define ABSTRACT_TYPE(Class, Base) @@ -1777,53 +1778,41 @@ Width = Target->getPointerWidth(0); Align = Target->getPointerAlign(0); break; -case BuiltinType::OCLSampler: { - auto AS = getTargetAddressSpace(LangAS::opencl_constant); - Width = Target->getPointerWidth(AS); - Align = Target->getPointerAlign(AS); - break; -} +case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: case BuiltinType::OCLClkEvent: case BuiltinType::OCLQueue: case BuiltinType::OCLReserveID: - // Currently these types are pointers to opaque types. - Width = Target->getPointerWidth(0); - Align = Target->getPointerAlign(0); - break; #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ case BuiltinType::Id: #include "clang/Basic/OpenCLImageTypes.def" - { -auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace()); -Width = Target->getPointerWidth(AS); -Align = Target->getPointerAlign(AS); - } + AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(T)); +
r310911 - [OpenCL] Allow targets to select address space per type
Author: svenvh Date: Tue Aug 15 02:38:18 2017 New Revision: 310911 URL: http://llvm.org/viewvc/llvm-project?rev=310911=rev Log: [OpenCL] Allow targets to select address space per type Generalize getOpenCLImageAddrSpace into getOpenCLTypeAddrSpace, such that targets can select the address space per type. No functional changes intended. Initial patch by Simon Perretta. Differential Revision: https://reviews.llvm.org/D33989 Modified: cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Basic/TargetInfo.cpp cfe/trunk/lib/Basic/Targets/AMDGPU.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/test/CodeGenOpenCL/opencl_types.cl Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=310911=310910=310911=diff == --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Aug 15 02:38:18 2017 @@ -46,6 +46,7 @@ class MacroBuilder; class QualType; class SourceLocation; class SourceManager; +class Type; namespace Builtin { struct Info; } @@ -1050,10 +1051,8 @@ public: return getTargetOpts().SupportedOpenCLOptions; } - /// \brief Get OpenCL image type address space. - virtual LangAS::ID getOpenCLImageAddrSpace() const { -return LangAS::opencl_global; - } + /// \brief Get address space for OpenCL type. + virtual LangAS::ID getOpenCLTypeAddrSpace(const Type *T) const; /// \returns Target specific vtbl ptr address space. virtual unsigned getVtblPtrAddressSpace() const { Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=310911=310910=310911=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Aug 15 02:38:18 2017 @@ -1631,6 +1631,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con uint64_t Width = 0; unsigned Align = 8; bool AlignIsRequired = false; + unsigned AS = 0; switch (T->getTypeClass()) { #define TYPE(Class, Base) #define ABSTRACT_TYPE(Class, Base) @@ -1777,28 +1778,18 @@ TypeInfo ASTContext::getTypeInfoImpl(con Width = Target->getPointerWidth(0); Align = Target->getPointerAlign(0); break; -case BuiltinType::OCLSampler: { - auto AS = getTargetAddressSpace(LangAS::opencl_constant); - Width = Target->getPointerWidth(AS); - Align = Target->getPointerAlign(AS); - break; -} +case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: case BuiltinType::OCLClkEvent: case BuiltinType::OCLQueue: case BuiltinType::OCLReserveID: - // Currently these types are pointers to opaque types. - Width = Target->getPointerWidth(0); - Align = Target->getPointerAlign(0); - break; #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ case BuiltinType::Id: #include "clang/Basic/OpenCLImageTypes.def" - { -auto AS = getTargetAddressSpace(Target->getOpenCLImageAddrSpace()); -Width = Target->getPointerWidth(AS); -Align = Target->getPointerAlign(AS); - } + AS = getTargetAddressSpace(Target->getOpenCLTypeAddrSpace(T)); + Width = Target->getPointerWidth(AS); + Align = Target->getPointerAlign(AS); + break; } break; case Type::ObjCObjectPointer: @@ -1806,8 +1797,7 @@ TypeInfo ASTContext::getTypeInfoImpl(con Align = Target->getPointerAlign(0); break; case Type::BlockPointer: { -unsigned AS = getTargetAddressSpace( -cast(T)->getPointeeType()); +AS = getTargetAddressSpace(cast(T)->getPointeeType()); Width = Target->getPointerWidth(AS); Align = Target->getPointerAlign(AS); break; @@ -1816,14 +1806,13 @@ TypeInfo ASTContext::getTypeInfoImpl(con case Type::RValueReference: { // alignof and sizeof should never enter this code path here, so we go // the pointer route. -unsigned AS = getTargetAddressSpace( -cast(T)->getPointeeType()); +AS = getTargetAddressSpace(cast(T)->getPointeeType()); Width = Target->getPointerWidth(AS); Align = Target->getPointerAlign(AS); break; } case Type::Pointer: { -unsigned AS = getTargetAddressSpace(cast(T)->getPointeeType()); +AS = getTargetAddressSpace(cast(T)->getPointeeType()); Width = Target->getPointerWidth(AS); Align = Target->getPointerAlign(AS); break; Modified: cfe/trunk/lib/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=310911=310910=310911=diff == ---
[PATCH] D36664: [analyzer] Make StmtDataCollector customizable
teemperor added a comment. Very well done, I really like this patch! I added a few remarks mostly about the comments that need some small adjusting. I'm wondering what would be a nice way of creating a StmtDataCollector that is faster but only works for single translation units (e.g. it only hashes the pointer values of decls instead of their qualified name)? The use case here would be Stmt::Profile and the CloneDetector which could be set to a single-TU-mode in the CloneChecker. For Stmt::Profile it would ensure we don't degrade performance from the current version, for the CloneChecker we probably get a reasonable performance boost (as the hashing is currently the last remaining bottle neck). @arphaman Any suggestions who could review/approve the additions to `AST/`? Comment at: include/clang/AST/DataCollection.h:19 + +namespace clang { + I think we need another namespace here because I don't like a generic function name like `addDataToConsumer` in the `clang` namespace. Maybe `clang::data_collection::addDataToConsumer` or something like that. Comment at: lib/AST/StmtDataCollectors.inc:5 + addData(S->getStmtClass()); + // This ensures that macro generated code isn't identical to macro-generated + // code. I know this is from my code, but as you're anyway touching this line, could you fix this comment? It should be "that non-macro-generated code` instead of `that macro generated`. Thanks! Comment at: lib/Analysis/CloneDetection.cpp:172 +/// Collects the data of a single Stmt. +/// I think this line can be removed now. Comment at: lib/Analysis/CloneDetection.cpp:174 +/// +/// This class defines what a code clone is: If it collects for two statements +/// the same data, then those two statements are considered to be clones of each `what a code clone is ` -> `what a type II code clone is` Comment at: lib/Analysis/CloneDetection.cpp:210 + +// Override the definition for some visitors. +#define SKIP(CLASS) \ Should be `Type II clones ignore variable names and literals, so let's skip them` https://reviews.llvm.org/D36664 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36686: [clang-diff] Add option to compare files across git revisions
arphaman added a comment. That would be nice. Temporary checkouts are a way to solve the problem. But they might not work for all projects, like when some translation unit includes a file that's not in git using a relative path. Another solution is to use virtual file systems. A custom vfs could load the files that are in a particular git revision. Then, an overlay fs can be used to combine both the git vfs and the real fs. That overlay should be somehow passed into the AST producer. I don't think it's worth doing this right now because of time constraints, so temporary checkouts is probably the better solution for the time being. https://reviews.llvm.org/D36686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36728: Switch to consumeError(), since this can crash otherwise.
arphaman accepted this revision. arphaman added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D36728 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits