r354909 - [AMDGPU] Allow using integral non-type template parameters
Author: hliao Date: Tue Feb 26 10:49:36 2019 New Revision: 354909 URL: http://llvm.org/viewvc/llvm-project?rev=354909&view=rev Log: [AMDGPU] Allow using integral non-type template parameters Summary: - Allow using integral non-type template parameters in the following attributes __attribute__((amdgpu_flat_work_group_size(, ))) __attribute__((amdgpu_waves_per_eu([, ]))) Reviewers: kzhuravl, yaxunl Subscribers: jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58623 Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp cfe/trunk/test/SemaCUDA/amdgpu-attrs.cu cfe/trunk/test/SemaOpenCL/amdgpu-attrs.cl Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354909&r1=354908&r2=354909&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Tue Feb 26 10:49:36 2019 @@ -1484,14 +1484,14 @@ def RISCVInterrupt : InheritableAttr, Ta def AMDGPUFlatWorkGroupSize : InheritableAttr { let Spellings = [Clang<"amdgpu_flat_work_group_size", 0>]; - let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max">]; + let Args = [ExprArgument<"Min">, ExprArgument<"Max">]; let Documentation = [AMDGPUFlatWorkGroupSizeDocs]; let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; } def AMDGPUWavesPerEU : InheritableAttr { let Spellings = [Clang<"amdgpu_waves_per_eu", 0>]; - let Args = [UnsignedArgument<"Min">, UnsignedArgument<"Max", 1>]; + let Args = [ExprArgument<"Min">, ExprArgument<"Max", 1>]; let Documentation = [AMDGPUWavesPerEUDocs]; let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; } Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354909&r1=354908&r2=354909&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 26 10:49:36 2019 @@ -8674,6 +8674,16 @@ public: void AddXConsumedAttr(Decl *D, SourceRange SR, unsigned SpellingIndex, RetainOwnershipKind K, bool IsTemplateInstantiation); + /// addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size + /// attribute to a particular declaration. + void addAMDGPUFlatWorkGroupSizeAttr(SourceRange AttrRange, Decl *D, Expr *Min, + Expr *Max, unsigned SpellingListIndex); + + /// addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a + /// particular declaration. + void addAMDGPUWavesPerEUAttr(SourceRange AttrRange, Decl *D, Expr *Min, + Expr *Max, unsigned SpellingListIndex); + bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type); //======// Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=354909&r1=354908&r2=354909&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Feb 26 10:49:36 2019 @@ -7797,8 +7797,16 @@ void AMDGPUTargetCodeGenInfo::setTargetA const auto *FlatWGS = FD->getAttr(); if (ReqdWGS || FlatWGS) { -unsigned Min = FlatWGS ? FlatWGS->getMin() : 0; -unsigned Max = FlatWGS ? FlatWGS->getMax() : 0; +unsigned Min = 0; +unsigned Max = 0; +if (FlatWGS) { + Min = FlatWGS->getMin() +->EvaluateKnownConstInt(M.getContext()) +.getExtValue(); + Max = FlatWGS->getMax() +->EvaluateKnownConstInt(M.getContext()) +.getExtValue(); +} if (ReqdWGS && Min == 0 && Max == 0) Min = Max = ReqdWGS->getXDim() * ReqdWGS->getYDim() * ReqdWGS->getZDim(); @@ -7812,8 +7820,12 @@ void AMDGPUTargetCodeGenInfo::setTargetA } if (const auto *Attr = FD->getAttr()) { -unsigned Min = Attr->getMin(); -unsigned Max = Attr->getMax(); +unsigned Min = +Attr->getMin()->EvaluateKnownConstInt(M.getContext()).getExtValue(); +unsigned Max = Attr->getMax() ? Attr->getMax() +->EvaluateKnownConstInt(M.getContext()) +.getExtValue() + : 0; if (Min != 0) { assert((Max == 0 || Min <= Max) && "Min must be less than or equal Max"); Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
r355551 - [CUDA][HIP][DebugInfo] Skip reference device function
Author: hliao Date: Wed Mar 6 13:16:27 2019 New Revision: 31 URL: http://llvm.org/viewvc/llvm-project?rev=31&view=rev Log: [CUDA][HIP][DebugInfo] Skip reference device function Summary: - A device functions could be used as a non-type template parameter in a global/host function template. However, we should not try to retrieve that device function and reference it in the host-side debug info as it's only valid at device side. Subscribers: aprantl, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58992 Added: cfe/trunk/test/CodeGenCUDA/debug-info-template.cu Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=31&r1=30&r2=31&view=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Mar 6 13:16:27 2019 @@ -1725,31 +1725,37 @@ CGDebugInfo::CollectTemplateParams(const QualType T = TA.getParamTypeForDecl().getDesugaredType(CGM.getContext()); llvm::DIType *TTy = getOrCreateType(T, Unit); llvm::Constant *V = nullptr; - const CXXMethodDecl *MD; - // Variable pointer template parameters have a value that is the address - // of the variable. - if (const auto *VD = dyn_cast(D)) -V = CGM.GetAddrOfGlobalVar(VD); - // Member function pointers have special support for building them, though - // this is currently unsupported in LLVM CodeGen. - else if ((MD = dyn_cast(D)) && MD->isInstance()) -V = CGM.getCXXABI().EmitMemberFunctionPointer(MD); - else if (const auto *FD = dyn_cast(D)) -V = CGM.GetAddrOfFunction(FD); - // Member data pointers have special handling too to compute the fixed - // offset within the object. - else if (const auto *MPT = dyn_cast(T.getTypePtr())) { -// These five lines (& possibly the above member function pointer -// handling) might be able to be refactored to use similar code in -// CodeGenModule::getMemberPointerConstant -uint64_t fieldOffset = CGM.getContext().getFieldOffset(D); -CharUnits chars = -CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset); -V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); + // Skip retrieve the value if that template parameter has cuda device + // attribute, i.e. that value is not available at the host side. + if (!CGM.getLangOpts().CUDA || CGM.getLangOpts().CUDAIsDevice || + !D->hasAttr()) { +const CXXMethodDecl *MD; +// Variable pointer template parameters have a value that is the address +// of the variable. +if (const auto *VD = dyn_cast(D)) + V = CGM.GetAddrOfGlobalVar(VD); +// Member function pointers have special support for building them, +// though this is currently unsupported in LLVM CodeGen. +else if ((MD = dyn_cast(D)) && MD->isInstance()) + V = CGM.getCXXABI().EmitMemberFunctionPointer(MD); +else if (const auto *FD = dyn_cast(D)) + V = CGM.GetAddrOfFunction(FD); +// Member data pointers have special handling too to compute the fixed +// offset within the object. +else if (const auto *MPT = + dyn_cast(T.getTypePtr())) { + // These five lines (& possibly the above member function pointer + // handling) might be able to be refactored to use similar code in + // CodeGenModule::getMemberPointerConstant + uint64_t fieldOffset = CGM.getContext().getFieldOffset(D); + CharUnits chars = + CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset); + V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); +} +V = V->stripPointerCasts(); } TemplateParams.push_back(DBuilder.createTemplateValueParameter( - TheCU, Name, TTy, - cast_or_null(V->stripPointerCasts(; + TheCU, Name, TTy, cast_or_null(V))); } break; case TemplateArgument::NullPtr: { QualType T = TA.getNullPtrType(); Added: cfe/trunk/test/CodeGenCUDA/debug-info-template.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/debug-info-template.cu?rev=31&view=auto == --- cfe/trunk/test/CodeGenCUDA/debug-info-template.cu (added) +++ cfe/trunk/test/CodeGenCUDA/debug-info-template.cu Wed Mar 6 13:16:27 2019 @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - -debug-info-kind=limited -dwarf-version=2 -debugger-tuning=gdb | FileCheck %s + +#include "Inputs/cuda.h" + +__device__ void f(); +template __global__ void t() { F(); } +__host__ void g() { t<<<1,1>>>(); } + +// Ensure
r356385 - [AMDGPU] Add the missing clang change of the experimental buffer fat pointer
Author: hliao Date: Mon Mar 18 11:11:37 2019 New Revision: 356385 URL: http://llvm.org/viewvc/llvm-project?rev=356385&view=rev Log: [AMDGPU] Add the missing clang change of the experimental buffer fat pointer Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp cfe/trunk/test/CodeGen/target-data.c cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=356385&r1=356384&r2=356385&view=diff == --- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original) +++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Mon Mar 18 11:11:37 2019 @@ -34,7 +34,8 @@ static const char *const DataLayoutStrin static const char *const DataLayoutStringAMDGCN = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32" "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128" -"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"; +"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" +"-ni:7"; const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = { Generic, // Default Modified: cfe/trunk/test/CodeGen/target-data.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-data.c?rev=356385&r1=356384&r2=356385&view=diff == --- cfe/trunk/test/CodeGen/target-data.c (original) +++ cfe/trunk/test/CodeGen/target-data.c Mon Mar 18 11:11:37 2019 @@ -152,12 +152,12 @@ // RUN: %clang_cc1 -triple amdgcn-unknown -target-cpu hawaii -o - -emit-llvm %s \ // RUN: | FileCheck %s -check-prefix=R600SI -// R600SI: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" +// R600SI: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7" // Test default -target-cpu // RUN: %clang_cc1 -triple amdgcn-unknown -o - -emit-llvm %s \ // RUN: | FileCheck %s -check-prefix=R600SIDefault -// R600SIDefault: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" +// R600SIDefault: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7" // RUN: %clang_cc1 -triple arm64-unknown -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=AARCH64 Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl?rev=356385&r1=356384&r2=356385&view=diff == --- cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl Mon Mar 18 11:11:37 2019 @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s // RUN: %clang_cc1 %s -O0 -triple amdgcn---opencl -emit-llvm -o - | FileCheck %s -// CHECK: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" +// CHECK: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7" void foo(void) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r357236 - [Sema] Fix a crash when nonnull checking
Author: hliao Date: Thu Mar 28 20:55:52 2019 New Revision: 357236 URL: http://llvm.org/viewvc/llvm-project?rev=357236&view=rev Log: [Sema] Fix a crash when nonnull checking Summary: - If a parameter is used, nonnull checking needs function prototype to retrieve the corresponding parameter's attributes. However, at the prototype substitution phase when a template is being instantiated, expression may be created and checked without a fully specialized prototype. Under such a scenario, skip nonnull checking on that argument. Reviewers: rjmccall, tra, yaxunl Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59900 Added: cfe/trunk/test/SemaCXX/pr30559.cpp Modified: cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=357236&r1=357235&r2=357236&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Mar 28 20:55:52 2019 @@ -11592,6 +11592,9 @@ void Sema::DiagnoseAlwaysNonNullPointer( } if (const auto *FD = dyn_cast(PV->getDeclContext())) { +// Skip function template not specialized yet. +if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate) + return; auto ParamIter = llvm::find(FD->parameters(), PV); assert(ParamIter != FD->param_end()); unsigned ParamNo = std::distance(FD->param_begin(), ParamIter); Added: cfe/trunk/test/SemaCXX/pr30559.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr30559.cpp?rev=357236&view=auto == --- cfe/trunk/test/SemaCXX/pr30559.cpp (added) +++ cfe/trunk/test/SemaCXX/pr30559.cpp Thu Mar 28 20:55:52 2019 @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s + +template < bool, class > struct A {}; +template < class, int > void f () {}; +template < class T, int > +decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {}; + +struct B {}; + +int main () +{ + f < B, 0 >; + return 0; +} + +template +auto foo(T x) -> decltype((x == nullptr), *x) { + return *x; +} + +void bar() { + foo(new int); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r359344 - [HIP] Fix visibility of `__constant__` variables.
Author: hliao Date: Fri Apr 26 12:31:48 2019 New Revision: 359344 URL: http://llvm.org/viewvc/llvm-project?rev=359344&view=rev Log: [HIP] Fix visibility of `__constant__` variables. Summary: - `__constant__` variables should not be `hidden` as the linker may turn them into `LOCAL` symbols. Reviewers: yaxunl Subscribers: jvesely, nhaehnle, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61194 Added: cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=359344&r1=359343&r2=359344&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Apr 26 12:31:48 2019 @@ -7847,7 +7847,8 @@ static bool requiresAMDGPUProtectedVisib return D->hasAttr() || (isa(D) && D->hasAttr()) || - (isa(D) && D->hasAttr()); + (isa(D) && + (D->hasAttr() || D->hasAttr())); } void AMDGPUTargetCodeGenInfo::setTargetAttributes( Added: cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu?rev=359344&view=auto == --- cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu (added) +++ cfe/trunk/test/CodeGenCUDA/amdgpu-visibility.cu Fri Apr 26 12:31:48 2019 @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility default -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-DEFAULT %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility protected -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-PROTECTED %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -fapply-global-visibility-to-externs -fvisibility hidden -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-HIDDEN %s + +#include "Inputs/cuda.h" + +// CHECK-DEFAULT: @c = addrspace(4) externally_initialized global +// CHECK-DEFAULT: @g = addrspace(1) externally_initialized global +// CHECK-PROTECTED: @c = protected addrspace(4) externally_initialized global +// CHECK-PROTECTED: @g = protected addrspace(1) externally_initialized global +// CHECK-HIDDEN: @c = protected addrspace(4) externally_initialized global +// CHECK-HIDDEN: @g = protected addrspace(1) externally_initialized global +__constant__ int c; +__device__ int g; + +// CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov() +// CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov() +// CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov() +__global__ void foo() { + g = c; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r360214 - [hip] Fix ambiguity from `>>>` of CUDA.
Author: hliao Date: Tue May 7 17:52:33 2019 New Revision: 360214 URL: http://llvm.org/viewvc/llvm-project?rev=360214&view=rev Log: [hip] Fix ambiguity from `>>>` of CUDA. Summary: - For template arguments ending with `>>>`, we should cease lookahead and treat it as type-id firstly, so that deduction could work properly. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61396 Modified: cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu Modified: cfe/trunk/lib/Parse/ParseTentative.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=360214&r1=360213&r2=360214&view=diff == --- cfe/trunk/lib/Parse/ParseTentative.cpp (original) +++ cfe/trunk/lib/Parse/ParseTentative.cpp Tue May 7 17:52:33 2019 @@ -590,9 +590,11 @@ bool Parser::isCXXTypeId(TentativeCXXTyp } else if (Context == TypeIdAsTemplateArgument && (Tok.isOneOf(tok::greater, tok::comma) || (getLangOpts().CPlusPlus11 && - (Tok.is(tok::greatergreater) || + (Tok.isOneOf(tok::greatergreater, + tok::greatergreatergreater) || (Tok.is(tok::ellipsis) && NextToken().isOneOf(tok::greater, tok::greatergreater, + tok::greatergreatergreater, tok::comma)) { TPR = TPResult::True; isAmbiguous = true; Modified: cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cuda-kernel-call-c%2B%2B11.cu?rev=360214&r1=360213&r2=360214&view=diff == --- cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu (original) +++ cfe/trunk/test/Parser/cuda-kernel-call-c++11.cu Tue May 7 17:52:33 2019 @@ -3,6 +3,10 @@ template struct S {}; template void f(); +template struct S {}; + +template struct V {}; +template struct V {}; void foo(void) { // In C++11 mode, all of these are expected to parse correctly, and the CUDA @@ -21,4 +25,11 @@ void foo(void) { (void)(&f>>==0); (void)(&f>>==0); + + S>> s6; +} + +template +void bar(T... args) { + S>> s7; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354610 - [CodeGen] Fix string literal address space casting.
Author: hliao Date: Thu Feb 21 11:40:20 2019 New Revision: 354610 URL: http://llvm.org/viewvc/llvm-project?rev=354610&view=rev Log: [CodeGen] Fix string literal address space casting. Summary: - If a string literal is reused directly, need to add necessary address space casting if the target requires that. Reviewers: yaxunl Subscribers: jvesely, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58509 Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGenCXX/amdgcn-string-literal.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=354610&r1=354609&r2=354610&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Feb 21 11:40:20 2019 @@ -4522,7 +4522,8 @@ CodeGenModule::GetAddrOfConstantStringFr if (auto GV = *Entry) { if (Alignment.getQuantity() > GV->getAlignment()) GV->setAlignment(Alignment.getQuantity()); - return ConstantAddress(GV, Alignment); + return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV), + Alignment); } } @@ -4584,7 +4585,8 @@ ConstantAddress CodeGenModule::GetAddrOf if (auto GV = *Entry) { if (Alignment.getQuantity() > GV->getAlignment()) GV->setAlignment(Alignment.getQuantity()); - return ConstantAddress(GV, Alignment); + return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV), + Alignment); } } Modified: cfe/trunk/test/CodeGenCXX/amdgcn-string-literal.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/amdgcn-string-literal.cpp?rev=354610&r1=354609&r2=354610&view=diff == --- cfe/trunk/test/CodeGenCXX/amdgcn-string-literal.cpp (original) +++ cfe/trunk/test/CodeGenCXX/amdgcn-string-literal.cpp Thu Feb 21 11:40:20 2019 @@ -14,7 +14,7 @@ void g(const char* p); // CHECK-LABEL: define void @_Z1fv() void f() { const char* l_str = "l_str"; - + // CHECK: call void @llvm.memcpy.p0i8.p4i8.i64 char l_array[] = "l_array"; @@ -26,3 +26,9 @@ void f() { const char* p = g_str; g(p); } + +// CHECK-LABEL: define void @_Z1ev +void e() { + g("string literal"); + g("string literal"); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354741 - [NFC] Minor coding style (indent) fix.
Author: hliao Date: Sat Feb 23 19:07:32 2019 New Revision: 354741 URL: http://llvm.org/viewvc/llvm-project?rev=354741&view=rev Log: [NFC] Minor coding style (indent) fix. Modified: cfe/trunk/lib/AST/Type.cpp Modified: cfe/trunk/lib/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354741&r1=354740&r2=354741&view=diff == --- cfe/trunk/lib/AST/Type.cpp (original) +++ cfe/trunk/lib/AST/Type.cpp Sat Feb 23 19:07:32 2019 @@ -1182,7 +1182,7 @@ struct SubstObjCTypeArgsVisitor // Rebuild object pointer type. return Ctx.getObjCObjectPointerType(resultTy); - } +} } llvm_unreachable("Unexpected ObjCSubstitutionContext!"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r354742 - Typo: s/CHCCK/CHECK
Author: hliao Date: Sat Feb 23 19:10:14 2019 New Revision: 354742 URL: http://llvm.org/viewvc/llvm-project?rev=354742&view=rev Log: Typo: s/CHCCK/CHECK Modified: cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp Modified: cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp?rev=354742&r1=354741&r2=354742&view=diff == --- cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp (original) +++ cfe/trunk/test/CodeGenCXX/pragma-loop-safety.cpp Sat Feb 23 19:10:14 2019 @@ -49,7 +49,7 @@ void interleave_test(int *List, int Leng // CHECK: ![[ACCESS_GROUP_2]] = distinct !{} // CHECK: ![[LOOP1_HINTS]] = distinct !{![[LOOP1_HINTS]], ![[INTERLEAVE_1:[0-9]+]], ![[INTENABLE_1:[0-9]+]], ![[UNROLL_DISABLE:[0-9]+]], ![[PARALLEL_ACCESSES_7:[0-9]+]]} // CHECK: ![[INTERLEAVE_1]] = !{!"llvm.loop.interleave.count", i32 1} -// CHCCK: ![[INTENABLE_1]] = !{!"llvm.loop.vectorize.enable", i1 true} +// CHECK: ![[INTENABLE_1]] = !{!"llvm.loop.vectorize.enable", i1 true} // CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"} // CHECK: ![[PARALLEL_ACCESSES_7]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_2]]} // CHECK: ![[ACCESS_GROUP_8]] = distinct !{} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r362232 - Revise test case due to the change from CUDA 10+.
Author: hliao Date: Fri May 31 08:29:55 2019 New Revision: 362232 URL: http://llvm.org/viewvc/llvm-project?rev=362232&view=rev Log: Revise test case due to the change from CUDA 10+. Modified: cfe/trunk/test/Driver/offloading-interoperability.c Modified: cfe/trunk/test/Driver/offloading-interoperability.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/offloading-interoperability.c?rev=362232&r1=362231&r2=362232&view=diff == --- cfe/trunk/test/Driver/offloading-interoperability.c (original) +++ cfe/trunk/test/Driver/offloading-interoperability.c Fri May 31 08:29:55 2019 @@ -11,7 +11,7 @@ // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64" -// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64" +// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary"{{( "--cuda")?}} "-64" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux-gnu" // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE: -fopenmp // NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r363553 - [HIP] Add the interface deriving the stub name of device kernels.
Author: hliao Date: Mon Jun 17 05:51:36 2019 New Revision: 363553 URL: http://llvm.org/viewvc/llvm-project?rev=363553&view=rev Log: [HIP] Add the interface deriving the stub name of device kernels. Summary: - Revise the interface to derive the stub name and simplify the assertion of it. Reviewers: yaxunl, tra Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63335 Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp cfe/trunk/lib/CodeGen/CGCUDARuntime.h cfe/trunk/lib/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=363553&r1=363552&r2=363553&view=diff == --- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Mon Jun 17 05:51:36 2019 @@ -132,6 +132,8 @@ public: llvm::Function *makeModuleCtorFunction() override; /// Creates module destructor function llvm::Function *makeModuleDtorFunction() override; + /// Construct and return the stub name of a kernel. + std::string getDeviceStubName(llvm::StringRef Name) const override; }; } @@ -217,10 +219,20 @@ std::string CGNVCUDARuntime::getDeviceSi void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args) { - assert(getDeviceSideName(CGF.CurFuncDecl) == CGF.CurFn->getName() || - getDeviceSideName(CGF.CurFuncDecl) + ".stub" == CGF.CurFn->getName() || - CGF.CGM.getContext().getTargetInfo().getCXXABI() != - CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI()); + // Ensure either we have different ABIs between host and device compilations, + // says host compilation following MSVC ABI but device compilation follows + // Itanium C++ ABI or, if they follow the same ABI, kernel names after + // mangling should be the same after name stubbing. The later checking is + // very important as the device kernel name being mangled in host-compilation + // is used to resolve the device binaries to be executed. Inconsistent naming + // result in undefined behavior. Even though we cannot check that naming + // directly between host- and device-compilations, the host- and + // device-mangling in host compilation could help catching certain ones. + assert((CGF.CGM.getContext().getAuxTargetInfo() && + (CGF.CGM.getContext().getAuxTargetInfo()->getCXXABI() != + CGF.CGM.getContext().getTargetInfo().getCXXABI())) || + getDeviceStubName(getDeviceSideName(CGF.CurFuncDecl)) == + CGF.CurFn->getName()); EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl}); if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(), @@ -780,6 +792,12 @@ llvm::Function *CGNVCUDARuntime::makeMod return ModuleDtorFunc; } +std::string CGNVCUDARuntime::getDeviceStubName(llvm::StringRef Name) const { + if (!CGM.getLangOpts().HIP) +return Name; + return std::move((Name + ".stub").str()); +} + CGCUDARuntime *CodeGen::CreateNVCUDARuntime(CodeGenModule &CGM) { return new CGNVCUDARuntime(CGM); } Modified: cfe/trunk/lib/CodeGen/CGCUDARuntime.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDARuntime.h?rev=363553&r1=363552&r2=363553&view=diff == --- cfe/trunk/lib/CodeGen/CGCUDARuntime.h (original) +++ cfe/trunk/lib/CodeGen/CGCUDARuntime.h Mon Jun 17 05:51:36 2019 @@ -15,6 +15,8 @@ #ifndef LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H #define LLVM_CLANG_LIB_CODEGEN_CGCUDARUNTIME_H +#include "llvm/ADT/StringRef.h" + namespace llvm { class Function; class GlobalVariable; @@ -63,6 +65,9 @@ public: /// Returns a module cleanup function or nullptr if it's not needed. /// Must be called after ModuleCtorFunction virtual llvm::Function *makeModuleDtorFunction() = 0; + + /// Construct and return the stub name of a kernel. + virtual std::string getDeviceStubName(llvm::StringRef Name) const = 0; }; /// Creates an instance of a CUDA runtime class. Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=363553&r1=363552&r2=363553&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jun 17 05:51:36 2019 @@ -1088,13 +1088,11 @@ StringRef CodeGenModule::getMangledName( const auto *ND = cast(GD.getDecl()); std::string MangledName = getMangledNameImpl(*this, GD, ND); - // Postfix kernel stub names with .stub to differentiate them from kernel - // names in device binaries. This is to facilitate the debugger to find - // the correct symbols for kernels in the device binary. + // Adjust kernel stub mangling as we may need to be able to differentiate + // them from the ker
r363585 - [clang][AST] Remove unnecessary 'const'.
Author: hliao Date: Mon Jun 17 10:47:03 2019 New Revision: 363585 URL: http://llvm.org/viewvc/llvm-project?rev=363585&view=rev Log: [clang][AST] Remove unnecessary 'const'. Modified: cfe/trunk/include/clang/AST/Expr.h Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=363585&r1=363584&r2=363585&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Mon Jun 17 10:47:03 2019 @@ -1024,7 +1024,7 @@ public: llvm_unreachable("invalid ResultKind"); } ResultStorageKind getResultStorageKind() const { -return static_cast(ConstantExprBits.ResultKind); +return static_cast(ConstantExprBits.ResultKind); } APValue getAPValueResult() const; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r366010 - Remove extra ';' to silent compiler warning.
Author: hliao Date: Sat Jul 13 12:49:39 2019 New Revision: 366010 URL: http://llvm.org/viewvc/llvm-project?rev=366010&view=rev Log: Remove extra ';' to silent compiler warning. - Plus extra style formatting. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=366010&r1=366009&r2=366010&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jul 13 12:49:39 2019 @@ -11082,7 +11082,8 @@ bool Sema::DeduceVariableDeclarationType return VDecl->isInvalidDecl(); } -void Sema::checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc) { +void Sema::checkNonTrivialCUnionInInitializer(const Expr *Init, + SourceLocation Loc) { if (auto *CE = dyn_cast(Init)) Init = CE->getSubExpr(); @@ -3,7 +4,7 @@ void Sema::checkNonTrivialCUnionInInitia if (InitType.hasNonTrivialToPrimitiveCopyCUnion()) checkNonTrivialCUnion(InitType, Loc, NTCUC_CopyInit, NTCUK_Copy); } -}; +} namespace { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r368748 - Remove the extra `;`.
Author: hliao Date: Tue Aug 13 14:26:42 2019 New Revision: 368748 URL: http://llvm.org/viewvc/llvm-project?rev=368748&view=rev Log: Remove the extra `;`. Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=368748&r1=368747&r2=368748&view=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Tue Aug 13 14:26:42 2019 @@ -515,7 +515,7 @@ public: GRBugReporter(BugReporterData& d, ExprEngine& eng) : BugReporter(d, GRBugReporterKind), Eng(eng) {} - ~GRBugReporter() override = default;; + ~GRBugReporter() override = default; /// getGraph - Get the exploded graph created by the analysis engine /// for the analyzed method or function. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r364428 - Make CodeGen depend on ASTMatchers
Author: hliao Date: Wed Jun 26 07:13:43 2019 New Revision: 364428 URL: http://llvm.org/viewvc/llvm-project?rev=364428&view=rev Log: Make CodeGen depend on ASTMatchers - Shared library builds are broken due to the missing dependency. Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=364428&r1=364427&r2=364428&view=diff == --- cfe/trunk/lib/CodeGen/CMakeLists.txt (original) +++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Jun 26 07:13:43 2019 @@ -101,6 +101,7 @@ add_clang_library(clangCodeGen LINK_LIBS clangAnalysis clangAST + clangASTMatchers clangBasic clangFrontend clangLex ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r361994 - [CUDA][HIP] Skip setting `externally_initialized` for static device variables.
Author: hliao Date: Wed May 29 10:23:27 2019 New Revision: 361994 URL: http://llvm.org/viewvc/llvm-project?rev=361994&view=rev Log: [CUDA][HIP] Skip setting `externally_initialized` for static device variables. Summary: - By declaring device variables as `static`, we assume they won't be addressable from the host side. Thus, no `externally_initialized` is required. Reviewers: yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62603 Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/test/CodeGenCUDA/device-var-init.cu Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=361994&r1=361993&r2=361994&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed May 29 10:23:27 2019 @@ -3869,7 +3869,8 @@ void CodeGenModule::EmitGlobalVarDefinit // / cudaMemcpyToSymbol() / cudaMemcpyFromSymbol())." if (GV && LangOpts.CUDA) { if (LangOpts.CUDAIsDevice) { - if (D->hasAttr() || D->hasAttr()) + if (Linkage != llvm::GlobalValue::InternalLinkage && + (D->hasAttr() || D->hasAttr())) GV->setExternallyInitialized(true); } else { // Host-side shadows of external declarations of device-side Modified: cfe/trunk/test/CodeGenCUDA/device-var-init.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/device-var-init.cu?rev=361994&r1=361993&r2=361994&view=diff == --- cfe/trunk/test/CodeGenCUDA/device-var-init.cu (original) +++ cfe/trunk/test/CodeGenCUDA/device-var-init.cu Wed May 29 10:23:27 2019 @@ -33,6 +33,16 @@ __device__ int d_v_i = 1; // DEVICE: @d_v_i = addrspace(1) externally_initialized global i32 1, // HOST: @d_v_i = internal global i32 undef, +// For `static` device variables, assume they won't be addressed from the host +// side. +static __device__ int d_s_v_i = 1; +// DEVICE: @_ZL7d_s_v_i = internal addrspace(1) global i32 1, + +// Dummy function to keep static variables referenced. +__device__ int foo() { + return d_s_v_i; +} + // trivial constructor -- allowed __device__ T d_t; // DEVICE: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r372318 - [CUDA][HIP] Fix typo in `BestViableFunction`
Author: hliao Date: Thu Sep 19 06:14:03 2019 New Revision: 372318 URL: http://llvm.org/viewvc/llvm-project?rev=372318&view=rev Log: [CUDA][HIP] Fix typo in `BestViableFunction` Summary: - Should consider viable ones only when checking SameSide candidates. - Replace erasing with clearing viable flag to reduce data moving/copying. - Add one and revise another one as the diagnostic message are more relevant compared to previous one. Reviewers: tra Subscribers: cfe-commits, yaxunl Tags: #clang Differential Revision: https://reviews.llvm.org/D67730 Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCUDA/function-overload.cu cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=372318&r1=372317&r2=372318&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Sep 19 06:14:03 2019 @@ -9422,17 +9422,19 @@ OverloadCandidateSet::BestViableFunction const FunctionDecl *Caller = dyn_cast(S.CurContext); bool ContainsSameSideCandidate = llvm::any_of(Candidates, [&](OverloadCandidate *Cand) { - return Cand->Function && + // Consider viable function only. + return Cand->Viable && Cand->Function && S.IdentifyCUDAPreference(Caller, Cand->Function) == Sema::CFP_SameSide; }); if (ContainsSameSideCandidate) { - auto IsWrongSideCandidate = [&](OverloadCandidate *Cand) { -return Cand->Function && - S.IdentifyCUDAPreference(Caller, Cand->Function) == - Sema::CFP_WrongSide; - }; - llvm::erase_if(Candidates, IsWrongSideCandidate); + // Clear viable flag for WrongSide varible candidates. + llvm::for_each(Candidates, [&](OverloadCandidate *Cand) { +if (Cand->Viable && Cand->Function && +S.IdentifyCUDAPreference(Caller, Cand->Function) == +Sema::CFP_WrongSide) + Cand->Viable = false; + }); } } Modified: cfe/trunk/test/SemaCUDA/function-overload.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=372318&r1=372317&r2=372318&view=diff == --- cfe/trunk/test/SemaCUDA/function-overload.cu (original) +++ cfe/trunk/test/SemaCUDA/function-overload.cu Thu Sep 19 06:14:03 2019 @@ -402,3 +402,20 @@ __host__ void test_host_template_overloa __device__ void test_device_template_overload() { template_overload(1); // OK. Attribute-based overloading picks __device__ variant. } + +// Two classes with `operator-` defined. One of them is device only. +struct C1; +struct C2; +__device__ +int operator-(const C1 &x, const C1 &y); +int operator-(const C2 &x, const C2 &y); + +template +__host__ __device__ int constexpr_overload(const T &x, const T &y) { + return x - y; +} + +// Verify that function overloading doesn't prune candidate wrongly. +int test_constexpr_overload(C2 &x, C2 &y) { + return constexpr_overload(x, y); +} Modified: cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu?rev=372318&r1=372317&r2=372318&view=diff == --- cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu (original) +++ cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu Thu Sep 19 06:14:03 2019 @@ -74,11 +74,13 @@ struct B4_with_device_copy_ctor { struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor { }; -// expected-note@-3 {{copy constructor of 'C4_with_collision' is implicitly deleted because base class 'B4_with_device_copy_ctor' has no copy constructor}} +// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable: call to invalid function from __host__ function}} +// expected-note@-4 {{implicit copy constructor inferred target collision: call to both __host__ and __device__ members}} +// expected-note@-5 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} void hostfoo4() { C4_with_collision c; - C4_with_collision c2 = c; // expected-error {{call to implicitly-deleted copy constructor of 'C4_with_collision'}} + C4_with_collision c2 = c; // expected-error {{no matching constructor for initialization of 'C4_with_collision'}} } //-- ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r372356 - [CUDA][HIP] Re-apply part of r372318.
Author: hliao Date: Thu Sep 19 14:26:18 2019 New Revision: 372356 URL: http://llvm.org/viewvc/llvm-project?rev=372356&view=rev Log: [CUDA][HIP] Re-apply part of r372318. - r372318 causes violation of `use-of-uninitialized-value` detected by MemorySanitizer. Once `Viable` field is set to false, `FailureKind` needs setting as well as it will be checked during destruction if `Viable` is not true. - Revert the part trying to skip `std::vector` erasing. Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCUDA/function-overload.cu cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=372356&r1=372355&r2=372356&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Sep 19 14:26:18 2019 @@ -9422,13 +9422,15 @@ OverloadCandidateSet::BestViableFunction const FunctionDecl *Caller = dyn_cast(S.CurContext); bool ContainsSameSideCandidate = llvm::any_of(Candidates, [&](OverloadCandidate *Cand) { - return Cand->Function && + // Check viable function only. + return Cand->Viable && Cand->Function && S.IdentifyCUDAPreference(Caller, Cand->Function) == Sema::CFP_SameSide; }); if (ContainsSameSideCandidate) { auto IsWrongSideCandidate = [&](OverloadCandidate *Cand) { -return Cand->Function && +// Check viable function only to avoid unnecessary data copying/moving. +return Cand->Viable && Cand->Function && S.IdentifyCUDAPreference(Caller, Cand->Function) == Sema::CFP_WrongSide; }; Modified: cfe/trunk/test/SemaCUDA/function-overload.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/function-overload.cu?rev=372356&r1=372355&r2=372356&view=diff == --- cfe/trunk/test/SemaCUDA/function-overload.cu (original) +++ cfe/trunk/test/SemaCUDA/function-overload.cu Thu Sep 19 14:26:18 2019 @@ -402,3 +402,20 @@ __host__ void test_host_template_overloa __device__ void test_device_template_overload() { template_overload(1); // OK. Attribute-based overloading picks __device__ variant. } + +// Two classes with `operator-` defined. One of them is device only. +struct C1; +struct C2; +__device__ +int operator-(const C1 &x, const C1 &y); +int operator-(const C2 &x, const C2 &y); + +template +__host__ __device__ int constexpr_overload(const T &x, const T &y) { + return x - y; +} + +// Verify that function overloading doesn't prune candidate wrongly. +int test_constexpr_overload(C2 &x, C2 &y) { + return constexpr_overload(x, y); +} Modified: cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu?rev=372356&r1=372355&r2=372356&view=diff == --- cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu (original) +++ cfe/trunk/test/SemaCUDA/implicit-member-target-collision-cxx11.cu Thu Sep 19 14:26:18 2019 @@ -74,11 +74,13 @@ struct B4_with_device_copy_ctor { struct C4_with_collision : A4_with_host_copy_ctor, B4_with_device_copy_ctor { }; -// expected-note@-3 {{copy constructor of 'C4_with_collision' is implicitly deleted because base class 'B4_with_device_copy_ctor' has no copy constructor}} +// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable: call to invalid function from __host__ function}} +// expected-note@-4 {{implicit copy constructor inferred target collision: call to both __host__ and __device__ members}} +// expected-note@-5 {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} void hostfoo4() { C4_with_collision c; - C4_with_collision c2 = c; // expected-error {{call to implicitly-deleted copy constructor of 'C4_with_collision'}} + C4_with_collision c2 = c; // expected-error {{no matching constructor for initialization of 'C4_with_collision'}} } //-- ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r372640 - [Sema] Fix the atomic expr rebuilding order.
Author: hliao Date: Mon Sep 23 11:48:06 2019 New Revision: 372640 URL: http://llvm.org/viewvc/llvm-project?rev=372640&view=rev Log: [Sema] Fix the atomic expr rebuilding order. Summary: - Rearrange the atomic expr order to the API order when rebuilding atomic expr during template instantiation. Reviewers: erichkeane Subscribers: jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67924 Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/test/AST/atomic-expr.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=372640&r1=372639&r2=372640&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Mon Sep 23 11:48:06 2019 @@ -4637,9 +4637,12 @@ public: MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig = nullptr, bool IsExecConfig = false); - ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, - SourceLocation RParenLoc, MultiExprArg Args, - AtomicExpr::AtomicOp Op); + enum class AtomicArgumentOrder { API, AST }; + ExprResult + BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, + SourceLocation RParenLoc, MultiExprArg Args, + AtomicExpr::AtomicOp Op, + AtomicArgumentOrder ArgOrder = AtomicArgumentOrder::API); ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef Arg, SourceLocation RParenLoc, Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=372640&r1=372639&r2=372640&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Sep 23 11:48:06 2019 @@ -4473,7 +4473,8 @@ ExprResult Sema::SemaAtomicOpsOverloaded ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, - AtomicExpr::AtomicOp Op) { + AtomicExpr::AtomicOp Op, + AtomicArgumentOrder ArgOrder) { // All the non-OpenCL operations take one of the following forms. // The OpenCL operations take the __c11 forms with one extra argument for // synchronization scope. @@ -4754,19 +4755,56 @@ ExprResult Sema::BuildAtomicExpr(SourceR IsPassedByAddress = true; } + SmallVector APIOrderedArgs; + if (ArgOrder == Sema::AtomicArgumentOrder::AST) { +APIOrderedArgs.push_back(Args[0]); +switch (Form) { +case Init: +case Load: + APIOrderedArgs.push_back(Args[1]); // Val1/Order + break; +case LoadCopy: +case Copy: +case Arithmetic: +case Xchg: + APIOrderedArgs.push_back(Args[2]); // Val1 + APIOrderedArgs.push_back(Args[1]); // Order + break; +case GNUXchg: + APIOrderedArgs.push_back(Args[2]); // Val1 + APIOrderedArgs.push_back(Args[3]); // Val2 + APIOrderedArgs.push_back(Args[1]); // Order + break; +case C11CmpXchg: + APIOrderedArgs.push_back(Args[2]); // Val1 + APIOrderedArgs.push_back(Args[4]); // Val2 + APIOrderedArgs.push_back(Args[1]); // Order + APIOrderedArgs.push_back(Args[3]); // OrderFail + break; +case GNUCmpXchg: + APIOrderedArgs.push_back(Args[2]); // Val1 + APIOrderedArgs.push_back(Args[4]); // Val2 + APIOrderedArgs.push_back(Args[5]); // Weak + APIOrderedArgs.push_back(Args[1]); // Order + APIOrderedArgs.push_back(Args[3]); // OrderFail + break; +} + } else +APIOrderedArgs.append(Args.begin(), Args.end()); + // The first argument's non-CV pointer type is used to deduce the type of // subsequent arguments, except for: // - weak flag (always converted to bool) // - memory order (always converted to int) // - scope (always converted to int) - for (unsigned i = 0; i != Args.size(); ++i) { + for (unsigned i = 0; i != APIOrderedArgs.size(); ++i) { QualType Ty; if (i < NumVals[Form] + 1) { switch (i) { case 0: // The first argument is always a pointer. It has a fixed type. // It is always dereferenced, a nullptr is undefined. -CheckNonNullArgument(*this, Args[i], ExprRange.getBegin()); +CheckNonNullArgument(*this, APIOrderedArgs[i], ExprRange.getBegin()); // Nothing else to do: we already know all we want about this pointer. continue; case 1: @@ -4778,14 +4816,16 @@ Ex
r372898 - [CUDA][HIP] Enable kernel function return type deduction.
Author: hliao Date: Wed Sep 25 09:51:45 2019 New Revision: 372898 URL: http://llvm.org/viewvc/llvm-project?rev=372898&view=rev Log: [CUDA][HIP] Enable kernel function return type deduction. Summary: - Even though only `void` is still accepted as the deduced return type, enabling deduction/instantiation on the return type allows more consistent coding. Reviewers: tra, jlebar Subscribers: cfe-commits, yaxunl Tags: #clang Differential Revision: https://reviews.llvm.org/D68031 Added: cfe/trunk/test/SemaCUDA/autoret-global.cu Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaStmt.cpp cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=372898&r1=372897&r2=372898&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Sep 25 09:51:45 2019 @@ -4223,7 +4223,9 @@ static void handleGlobalAttr(Sema &S, De return; } const auto *FD = cast(D); - if (!FD->getReturnType()->isVoidType()) { + if (!FD->getReturnType()->isVoidType() && + !FD->getReturnType()->getAs() && + !FD->getReturnType()->isInstantiationDependentType()) { SourceRange RTRange = FD->getReturnTypeSourceRange(); S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return) << FD->getType() Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=372898&r1=372897&r2=372898&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep 25 09:51:45 2019 @@ -5891,7 +5891,9 @@ ExprResult Sema::BuildResolvedCallExpr(E << FDecl << Fn->getSourceRange()); // CUDA: Kernel function must have 'void' return type - if (!FuncT->getReturnType()->isVoidType()) + if (!FuncT->getReturnType()->isVoidType() && + !FuncT->getReturnType()->getAs() && + !FuncT->getReturnType()->isInstantiationDependentType()) return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return) << Fn->getType() << Fn->getSourceRange()); } else { Modified: cfe/trunk/lib/Sema/SemaStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=372898&r1=372897&r2=372898&view=diff == --- cfe/trunk/lib/Sema/SemaStmt.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Sep 25 09:51:45 2019 @@ -3500,6 +3500,14 @@ bool Sema::DeduceFunctionTypeFromReturnE return true; } + // CUDA: Kernel function must have 'void' return type. + if (getLangOpts().CUDA) +if (FD->hasAttr() && !Deduced->isVoidType()) { + Diag(FD->getLocation(), diag::err_kern_type_not_void_return) + << FD->getType() << FD->getSourceRange(); + return true; +} + // If a function with a declared return type that contains a placeholder type // has multiple return statements, the return type is deduced for each return // statement. [...] if the type deduced is not the same in each deduction, Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=372898&r1=372897&r2=372898&view=diff == --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Sep 25 09:51:45 2019 @@ -3093,6 +3093,13 @@ Sema::SubstituteExplicitTemplateArgument Function->getTypeSpecStartLoc(), Function->getDeclName()); if (ResultType.isNull() || Trap.hasErrorOccurred()) return TDK_SubstitutionFailure; +// CUDA: Kernel function must have 'void' return type. +if (getLangOpts().CUDA) + if (Function->hasAttr() && !ResultType->isVoidType()) { +Diag(Function->getLocation(), diag::err_kern_type_not_void_return) +<< Function->getType() << Function->getSourceRange(); +return TDK_SubstitutionFailure; + } } // Instantiate the types of each of the function parameters given the Added: cfe/trunk/test/SemaCUDA/autoret-global.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/autoret-global.cu?rev=372898&view=auto == --- cfe/trunk/test/SemaCUDA/autoret-global.cu (added) +++ cfe/trunk/test/SemaCUDA/autoret-global.cu Wed Sep 25 09:51:45 2019 @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s + +#include "Inputs/cuda.h" + +template +__global__ T foo() { + // expected-note@-1 {{kernel function type 'T ()'
r373410 - Fix unused variable warning. NFCI.
Author: hliao Date: Tue Oct 1 17:22:45 2019 New Revision: 373410 URL: http://llvm.org/viewvc/llvm-project?rev=373410&view=rev Log: Fix unused variable warning. NFCI. Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=373410&r1=373409&r2=373410&view=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue Oct 1 17:22:45 2019 @@ -7324,10 +7324,10 @@ private: return ElemSize; if (const Expr *LenExpr = OAE->getLength()) { -llvm::Value *LengthVal = CGF.EmitScalarExpr(OAE->getLength()); -LengthVal = CGF.EmitScalarConversion( -LengthVal, OAE->getLength()->getType(), -CGF.getContext().getSizeType(), OAE->getLength()->getExprLoc()); +llvm::Value *LengthVal = CGF.EmitScalarExpr(LenExpr); +LengthVal = CGF.EmitScalarConversion(LengthVal, LenExpr->getType(), + CGF.getContext().getSizeType(), + LenExpr->getExprLoc()); return CGF.Builder.CreateNUWMul(LengthVal, ElemSize); } assert(!OAE->getLength() && OAE->getColonLoc().isValid() && ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373634 - [HIP] Enable specifying different default gpu arch for HIP/CUDA.
Author: hliao Date: Thu Oct 3 10:49:20 2019 New Revision: 373634 URL: http://llvm.org/viewvc/llvm-project?rev=373634&view=rev Log: [HIP] Enable specifying different default gpu arch for HIP/CUDA. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68394 Added: cfe/trunk/test/Driver/hip-default-gpu-arch.hip Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=373634&r1=373633&r2=373634&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Thu Oct 3 10:49:20 2019 @@ -2329,6 +2329,10 @@ class OffloadingActionBuilder final { /// Flag for -fgpu-rdc. bool Relocatable = false; + +/// Default GPU architecture if there's no one specified. +CudaArch DefaultCudaArch = CudaArch::UNKNOWN; + public: CudaActionBuilderBase(Compilation &C, DerivedArgList &Args, const Driver::InputList &Inputs, @@ -2518,7 +2522,7 @@ class OffloadingActionBuilder final { // supported GPUs. sm_20 code should work correctly, if // suboptimally, on all newer GPUs. if (GpuArchList.empty()) -GpuArchList.push_back(CudaArch::SM_20); +GpuArchList.push_back(DefaultCudaArch); return Error; } @@ -2530,7 +2534,9 @@ class OffloadingActionBuilder final { public: CudaActionBuilder(Compilation &C, DerivedArgList &Args, const Driver::InputList &Inputs) -: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) {} +: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_Cuda) { + DefaultCudaArch = CudaArch::SM_20; +} ActionBuilderReturnCode getDeviceDependences(OffloadAction::DeviceDependences &DA, @@ -2645,7 +2651,9 @@ class OffloadingActionBuilder final { public: HIPActionBuilder(Compilation &C, DerivedArgList &Args, const Driver::InputList &Inputs) -: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) {} +: CudaActionBuilderBase(C, Args, Inputs, Action::OFK_HIP) { + DefaultCudaArch = CudaArch::GFX803; +} bool canUseBundlerUnbundler() const override { return true; } Added: cfe/trunk/test/Driver/hip-default-gpu-arch.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-default-gpu-arch.hip?rev=373634&view=auto == --- cfe/trunk/test/Driver/hip-default-gpu-arch.hip (added) +++ cfe/trunk/test/Driver/hip-default-gpu-arch.hip Thu Oct 3 10:49:20 2019 @@ -0,0 +1,7 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -### -x hip -c %s 2>&1 | FileCheck %s + +// CHECK: {{.*}}clang{{.*}}"-target-cpu" "gfx803" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374097 - [driver][hip] Skip bundler if host action is nothing.
Author: hliao Date: Tue Oct 8 11:06:51 2019 New Revision: 374097 URL: http://llvm.org/viewvc/llvm-project?rev=374097&view=rev Log: [driver][hip] Skip bundler if host action is nothing. Reviewers: sfantao, tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68652 Added: cfe/trunk/test/Driver/hip-syntax-only.hip Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=374097&r1=374096&r2=374097&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Oct 8 11:06:51 2019 @@ -3108,7 +3108,8 @@ public: // the resulting list. Otherwise, just append the device actions. For // device only compilation, HostAction is a null pointer, therefore only do // this when HostAction is not a null pointer. -if (CanUseBundler && HostAction && !OffloadAL.empty()) { +if (CanUseBundler && HostAction && +HostAction->getType() != types::TY_Nothing && !OffloadAL.empty()) { // Add the host action to the list in order to create the bundling action. OffloadAL.push_back(HostAction); Added: cfe/trunk/test/Driver/hip-syntax-only.hip URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-syntax-only.hip?rev=374097&view=auto == --- cfe/trunk/test/Driver/hip-syntax-only.hip (added) +++ cfe/trunk/test/Driver/hip-syntax-only.hip Tue Oct 8 11:06:51 2019 @@ -0,0 +1,11 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -### -x hip -nogpulib -target x86_64 -fsyntax-only %s 2>&1 | FileCheck %s + +// Check that there are commands for both host- and device-side compilations. +// +// CHECK-DAG: clang{{.*}}" "-cc1" {{.*}} "-fcuda-is-device" +// CHECK-DAG: clang{{.*}}" "-cc1" "-triple" "x86_64" +// CHECK-NOT: clang-offload-bundler" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374167 - [clang-offload-bundler] Support `.cui` and `.d`.
Author: hliao Date: Wed Oct 9 06:53:37 2019 New Revision: 374167 URL: http://llvm.org/viewvc/llvm-project?rev=374167&view=rev Log: [clang-offload-bundler] Support `.cui` and `.d`. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68663 Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Modified: cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp?rev=374167&r1=374166&r2=374167&view=diff == --- cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp (original) +++ cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp Wed Oct 9 06:53:37 2019 @@ -71,6 +71,8 @@ static cl::opt "Current supported types are:\n" " i - cpp-output\n" " ii - c++-cpp-output\n" + " cui - cuda/hip-output\n" + " d - dependency\n" " ll - llvm\n" " bc - llvm-bc\n" " s - assembler\n" @@ -628,6 +630,12 @@ static FileHandler *CreateFileHandler(Me return new TextFileHandler(/*Comment=*/"//"); if (FilesType == "ii") return new TextFileHandler(/*Comment=*/"//"); + if (FilesType == "cui") +return new TextFileHandler(/*Comment=*/"//"); + // TODO: `.d` should be eventually removed once `-M` and its variants are + // handled properly in offload compilation. + if (FilesType == "d") +return new TextFileHandler(/*Comment=*/"#"); if (FilesType == "ll") return new TextFileHandler(/*Comment=*/";"); if (FilesType == "bc") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374200 - [mangle] Fix mangling where an extra mangle context is required.
Author: hliao Date: Wed Oct 9 12:08:52 2019 New Revision: 374200 URL: http://llvm.org/viewvc/llvm-project?rev=374200&view=rev Log: [mangle] Fix mangling where an extra mangle context is required. Summary: - [Itanium C++ ABI][1], for certain contexts like default parameter and etc., mangling numbering will be local to the particular argument in which it appears. - However, for these cases, the mangle numbering context is allocated per expression evaluation stack entry. That causes, for example, two lambdas defined/used understand the same default parameter are numbered as the same value and, in turn, one of them is not generated at all. - In this patch, an extra mangle numbering context map is maintained in the AST context to map taht extra declaration context to its numbering context. So that, 2 different lambdas defined/used in the same default parameter are numbered differently. [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html Reviewers: rsmith, eli.friedman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68715 Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/test/CodeGenCXX/mangle-lambdas.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=374200&r1=374199&r2=374200&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Oct 9 12:08:52 2019 @@ -514,6 +514,8 @@ private: /// need to be consistently numbered for the mangler). llvm::DenseMap> MangleNumberingContexts; + llvm::DenseMap> + ExtraMangleNumberingContexts; /// Side-table of mangling numbers for declarations which rarely /// need them (like static local vars). @@ -2812,6 +2814,9 @@ public: /// Retrieve the context for computing mangling numbers in the given /// DeclContext. MangleNumberingContext &getManglingNumberContext(const DeclContext *DC); + enum NeedExtraManglingDecl_t { NeedExtraManglingDecl }; + MangleNumberingContext &getManglingNumberContext(NeedExtraManglingDecl_t, + const Decl *D); std::unique_ptr createMangleNumberingContext() const; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=374200&r1=374199&r2=374200&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 9 12:08:52 2019 @@ -1045,13 +1045,6 @@ public: /// suffice, e.g., in a default function argument. Decl *ManglingContextDecl; -/// The context information used to mangle lambda expressions -/// and block literals within this context. -/// -/// This mangling information is allocated lazily, since most contexts -/// do not have lambda expressions or block literals. -std::unique_ptr MangleNumbering; - /// If we are processing a decltype type, a set of call expressions /// for which we have deferred checking the completeness of the return type. SmallVector DelayedDecltypeCalls; @@ -1080,12 +1073,7 @@ public: ExpressionKind ExprContext) : Context(Context), ParentCleanup(ParentCleanup), NumCleanupObjects(NumCleanupObjects), NumTypos(0), - ManglingContextDecl(ManglingContextDecl), MangleNumbering(), - ExprContext(ExprContext) {} - -/// Retrieve the mangling numbering context, used to consistently -/// number constructs like lambdas for mangling. -MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx); + ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext) {} bool isUnevaluated() const { return Context == ExpressionEvaluationContext::Unevaluated || Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=374200&r1=374199&r2=374200&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Wed Oct 9 12:08:52 2019 @@ -10261,6 +10261,16 @@ ASTContext::getManglingNumberContext(con return *MCtx; } +MangleNumberingContext & +ASTContext::getManglingNumberContext(NeedExtraManglingDecl_t, const Decl *D) { + assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C. + std::unique_ptr &MCtx = + ExtraMangleNumberingContexts[D]; + if (!MCtx) +MCtx = createMangleNumberingContext(); + return *MCtx; +} + std::unique_ptr ASTContext::createMangleNumberingContext() const
r374274 - [sema] Revise `getCurrentMangleNumberContext` interface. NFC.
Author: hliao Date: Wed Oct 9 20:14:51 2019 New Revision: 374274 URL: http://llvm.org/viewvc/llvm-project?rev=374274&view=rev Log: [sema] Revise `getCurrentMangleNumberContext` interface. NFC. - Prefer returning mulitple values using a tuple instead of additional pointers/references. Modified: cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaLambda.cpp Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=374274&r1=374273&r2=374274&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 9 20:14:51 2019 @@ -57,6 +57,7 @@ #include #include #include +#include #include namespace llvm { @@ -1092,15 +1093,12 @@ public: void WarnOnPendingNoDerefs(ExpressionEvaluationContextRecord &Rec); /// Compute the mangling number context for a lambda expression or - /// block literal. + /// block literal. Also return the extra mangling decl if any. /// /// \param DC - The DeclContext containing the lambda expression or /// block literal. - /// \param[out] ManglingContextDecl - Returns the ManglingContextDecl - /// associated with the context, if relevant. - MangleNumberingContext *getCurrentMangleNumberContext( -const DeclContext *DC, -Decl *&ManglingContextDecl); + std::tuple + getCurrentMangleNumberContext(const DeclContext *DC); /// SpecialMemberOverloadResult - The overloading result for a special member Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=374274&r1=374273&r2=374274&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 9 20:14:51 2019 @@ -4284,9 +4284,11 @@ void Sema::handleTagNumbering(const TagD } // If this tag isn't a direct child of a class, number it if it is local. + MangleNumberingContext *MCtx; Decl *ManglingContextDecl; - if (MangleNumberingContext *MCtx = getCurrentMangleNumberContext( - Tag->getDeclContext(), ManglingContextDecl)) { + std::tie(MCtx, ManglingContextDecl) = + getCurrentMangleNumberContext(Tag->getDeclContext()); + if (MCtx) { Context.setManglingNumber( Tag, MCtx->getManglingNumber( Tag, getMSManglingNumber(getLangOpts(), TagScope))); @@ -5022,9 +5024,11 @@ Decl *Sema::BuildAnonymousStructOrUnion( if (VarDecl *NewVD = dyn_cast(Anon)) { if (getLangOpts().CPlusPlus && NewVD->isStaticLocal()) { + MangleNumberingContext *MCtx; Decl *ManglingContextDecl; - if (MangleNumberingContext *MCtx = getCurrentMangleNumberContext( - NewVD->getDeclContext(), ManglingContextDecl)) { + std::tie(MCtx, ManglingContextDecl) = + getCurrentMangleNumberContext(NewVD->getDeclContext()); + if (MCtx) { Context.setManglingNumber( NewVD, MCtx->getManglingNumber( NewVD, getMSManglingNumber(getLangOpts(), S))); @@ -7090,9 +7094,11 @@ NamedDecl *Sema::ActOnVariableDeclarator RegisterLocallyScopedExternCDecl(NewVD, S); if (getLangOpts().CPlusPlus && NewVD->isStaticLocal()) { +MangleNumberingContext *MCtx; Decl *ManglingContextDecl; -if (MangleNumberingContext *MCtx = getCurrentMangleNumberContext( -NewVD->getDeclContext(), ManglingContextDecl)) { +std::tie(MCtx, ManglingContextDecl) = +getCurrentMangleNumberContext(NewVD->getDeclContext()); +if (MCtx) { Context.setManglingNumber( NewVD, MCtx->getManglingNumber( NewVD, getMSManglingNumber(getLangOpts(), S))); Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=374274&r1=374273&r2=374274&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 9 20:14:51 2019 @@ -14043,10 +14043,11 @@ void Sema::ActOnBlockStart(SourceLocatio BlockDecl *Block = BlockDecl::Create(Context, CurContext, CaretLoc); if (LangOpts.CPlusPlus) { +MangleNumberingContext *MCtx; Decl *ManglingContextDecl; -if (MangleNumberingContext *MCtx = -getCurrentMangleNumberContext(Block->getDeclContext(), - ManglingContextDecl)) { +std::tie(MCtx, ManglingContextDecl) = +getCurrentMangleNumberContext(Block->getDeclContext()); +if (MCtx) { unsigned ManglingNumber = MCtx->getManglingNumber(Block); Block->setBlockMangling(ManglingNumber, ManglingContextDecl); } Modified: cfe/trunk/lib/Sema/SemaLambda.cpp URL: http://l
r374276 - [ast] Fix indentation. NFC.
Author: hliao Date: Wed Oct 9 21:16:52 2019 New Revision: 374276 URL: http://llvm.org/viewvc/llvm-project?rev=374276&view=rev Log: [ast] Fix indentation. NFC. Modified: cfe/trunk/include/clang/AST/Decl.h Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=374276&r1=374275&r2=374276&view=diff == --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Wed Oct 9 21:16:52 2019 @@ -4114,13 +4114,9 @@ public: void setCaptures(ASTContext &Context, ArrayRef Captures, bool CapturesCXXThis); - unsigned getBlockManglingNumber() const { - return ManglingNumber; - } + unsigned getBlockManglingNumber() const { return ManglingNumber; } - Decl *getBlockManglingContextDecl() const { - return ManglingContextDecl; - } + Decl *getBlockManglingContextDecl() const { return ManglingContextDecl; } void setBlockMangling(unsigned Number, Decl *Ctx) { ManglingNumber = Number; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374470 - [tooling] Teach Tooling to understand compilation with offloading.
Author: hliao Date: Thu Oct 10 16:05:55 2019 New Revision: 374470 URL: http://llvm.org/viewvc/llvm-project?rev=374470&view=rev Log: [tooling] Teach Tooling to understand compilation with offloading. Summary: - So far, we only recognize the host compilation with offloading and skip the offloading part. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68660 Added: cfe/trunk/test/Tooling/clang-check-offload.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=374470&r1=374469&r2=374470&view=diff == --- cfe/trunk/lib/Tooling/Tooling.cpp (original) +++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Oct 10 16:05:55 2019 @@ -91,7 +91,29 @@ static const llvm::opt::ArgStringList *g // We expect to get back exactly one Command job, if we didn't something // failed. Extract that job from the Compilation. const driver::JobList &Jobs = Compilation->getJobs(); - if (Jobs.size() != 1 || !isa(*Jobs.begin())) { + const driver::ActionList &Actions = Compilation->getActions(); + bool OffloadCompilation = false; + if (Jobs.size() > 1) { +for (auto A : Actions){ + // On MacOSX real actions may end up being wrapped in BindArchAction + if (isa(A)) +A = *A->input_begin(); + if (isa(A)) { +// Offload compilation has 2 top-level actions, one (at the front) is +// the original host compilation and the other is offload action +// composed of at least one device compilation. For such case, general +// tooling will consider host-compilation only. For tooling on device +// compilation, device compilation only option, such as +// `--cuda-device-only`, needs specifying. +assert(Actions.size() == 2); +assert(isa(Actions.front())); +OffloadCompilation = true; +break; + } +} + } + if (Jobs.size() == 0 || !isa(*Jobs.begin()) || + (Jobs.size() > 1 && !OffloadCompilation)) { SmallString<256> error_msg; llvm::raw_svector_ostream error_stream(error_msg); Jobs.Print(error_stream, "; ", true); Added: cfe/trunk/test/Tooling/clang-check-offload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Tooling/clang-check-offload.cpp?rev=374470&view=auto == --- cfe/trunk/test/Tooling/clang-check-offload.cpp (added) +++ cfe/trunk/test/Tooling/clang-check-offload.cpp Thu Oct 10 16:05:55 2019 @@ -0,0 +1,4 @@ +// RUN: not clang-check "%s" -- -c -x hip -nogpulib 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374478 - [tooling] Fix assertion on MacOSX.
Author: hliao Date: Thu Oct 10 16:45:20 2019 New Revision: 374478 URL: http://llvm.org/viewvc/llvm-project?rev=374478&view=rev Log: [tooling] Fix assertion on MacOSX. Modified: cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=374478&r1=374477&r2=374478&view=diff == --- cfe/trunk/lib/Tooling/Tooling.cpp (original) +++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Oct 10 16:45:20 2019 @@ -106,7 +106,12 @@ static const llvm::opt::ArgStringList *g // compilation, device compilation only option, such as // `--cuda-device-only`, needs specifying. assert(Actions.size() == 2); -assert(isa(Actions.front())); +assert( +isa(Actions.front()) || +// On MacOSX real actions may end up being wrapped in +// BindArchAction. +(isa(Actions.front()) && + isa(*Actions.front()->input_begin(; OffloadCompilation = true; break; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r375039 - [clangd] Add the missing dependency on `clangLex`.
Author: hliao Date: Wed Oct 16 13:22:54 2019 New Revision: 375039 URL: http://llvm.org/viewvc/llvm-project?rev=375039&view=rev Log: [clangd] Add the missing dependency on `clangLex`. Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt clang-tools-extra/trunk/clangd/tool/CMakeLists.txt Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt?rev=375039&r1=375038&r2=375039&view=diff == --- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt Wed Oct 16 13:22:54 2019 @@ -26,6 +26,7 @@ add_clang_library(clangDaemonTweaks OBJE clangAST clangBasic clangDaemon + clangLex clangToolingCore clangToolingRefactoring clangToolingSyntax Modified: clang-tools-extra/trunk/clangd/tool/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/CMakeLists.txt?rev=375039&r1=375038&r2=375039&view=diff == --- clang-tools-extra/trunk/clangd/tool/CMakeLists.txt (original) +++ clang-tools-extra/trunk/clangd/tool/CMakeLists.txt Wed Oct 16 13:22:54 2019 @@ -21,6 +21,7 @@ clang_target_link_libraries(clangd clangBasic clangFormat clangFrontend + clangLex clangSema clangTooling clangToolingCore ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375245 - [tooling] Relax an assert when multiple GPU targets are specified.
Author: hliao Date: Fri Oct 18 08:03:34 2019 New Revision: 375245 URL: http://llvm.org/viewvc/llvm-project?rev=375245&view=rev Log: [tooling] Relax an assert when multiple GPU targets are specified. Modified: cfe/trunk/lib/Tooling/Tooling.cpp Modified: cfe/trunk/lib/Tooling/Tooling.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=375245&r1=375244&r2=375245&view=diff == --- cfe/trunk/lib/Tooling/Tooling.cpp (original) +++ cfe/trunk/lib/Tooling/Tooling.cpp Fri Oct 18 08:03:34 2019 @@ -105,7 +105,7 @@ static const llvm::opt::ArgStringList *g // tooling will consider host-compilation only. For tooling on device // compilation, device compilation only option, such as // `--cuda-device-only`, needs specifying. -assert(Actions.size() == 2); +assert(Actions.size() > 1); assert( isa(Actions.front()) || // On MacOSX real actions may end up being wrapped in ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375309 - [hip][cuda] Fix the extended lambda name mangling issue.
Author: hliao Date: Fri Oct 18 17:15:19 2019 New Revision: 375309 URL: http://llvm.org/viewvc/llvm-project?rev=375309&view=rev Log: [hip][cuda] Fix the extended lambda name mangling issue. Summary: - HIP/CUDA host side needs to use device kernel symbol name to match the device side binaries. Without a consistent naming between host- and device-side compilations, it's risky that wrong device binaries are executed. Consistent naming is usually not an issue until unnamed types are used, especially the lambda. In this patch, the consistent name mangling is addressed for the extended lambdas, i.e. the lambdas annotated with `__device__`. - In [Itanium C++ ABI][1], the mangling of the lambda is generally unspecified unless, in certain cases, ODR rule is required to ensure consisent naming cross TUs. The extended lambda is such a case as its name may be part of a device kernel function, e.g., the extended lambda is used as a template argument and etc. Thus, we need to force ODR for extended lambdas as they are referenced in both device- and host-side TUs. Furthermore, if a extended lambda is nested in other (extended or not) lambdas, those lambdas are required to follow ODR naming as well. This patch revises the current lambda mangle numbering to force ODR from an extended lambda to all its parent lambdas. - On the other side, the aforementioned ODR naming should not change those lambdas' original linkages, i.e., we cannot replace the original `internal` with `linkonce_odr`; otherwise, we may violate ODR in general. This patch introduces a new field `HasKnownInternalLinkage` in lambda data to decouple the current linkage calculation based on mangling number assigned. [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html Reviewers: tra, rsmith, yaxunl, martong, shafik Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68818 Added: cfe/trunk/test/CodeGenCUDA/unnamed-types.cu Modified: cfe/trunk/include/clang/AST/DeclCXX.h cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/Decl.cpp cfe/trunk/lib/Sema/SemaLambda.cpp cfe/trunk/lib/Sema/TreeTransform.h cfe/trunk/lib/Serialization/ASTReaderDecl.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/include/clang/AST/DeclCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=375309&r1=375308&r2=375309&view=diff == --- cfe/trunk/include/clang/AST/DeclCXX.h (original) +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Oct 18 17:15:19 2019 @@ -389,9 +389,12 @@ class CXXRecordDecl : public RecordDecl /// The number of explicit captures in this lambda. unsigned NumExplicitCaptures : 13; +/// Has known `internal` linkage. +unsigned HasKnownInternalLinkage : 1; + /// The number used to indicate this lambda expression for name /// mangling in the Itanium C++ ABI. -unsigned ManglingNumber = 0; +unsigned ManglingNumber : 31; /// The declaration that provides context for this lambda, if the /// actual DeclContext does not suffice. This is used for lambdas that @@ -406,12 +409,12 @@ class CXXRecordDecl : public RecordDecl /// The type of the call method. TypeSourceInfo *MethodTyInfo; -LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, - bool Dependent, bool IsGeneric, - LambdaCaptureDefault CaptureDefault) - : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), -CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0), -MethodTyInfo(Info) { +LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, bool Dependent, + bool IsGeneric, LambdaCaptureDefault CaptureDefault) +: DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), + CaptureDefault(CaptureDefault), NumCaptures(0), + NumExplicitCaptures(0), HasKnownInternalLinkage(0), ManglingNumber(0), + MethodTyInfo(Info) { IsLambda = true; // C++1z [expr.prim.lambda]p4: @@ -1705,6 +1708,13 @@ public: return getLambdaData().ManglingNumber; } + /// The lambda is known to has internal linkage no matter whether it has name + /// mangling number. + bool hasKnownLambdaInternalLinkage() const { +assert(isLambda() && "Not a lambda closure type!"); +return getLambdaData().HasKnownInternalLinkage; + } + /// Retrieve the declaration that provides additional context for a /// lambda, when the normal declaration context is not specific enough. /// @@ -1718,9 +1728,12 @@ public: /// Set the mangling number and context declaration for a lambda /// class. - void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) { + void setLambdaMangling(unsigned ManglingNumber
r375310 - [clang][driver] Print compilation phases with indentation.
Author: hliao Date: Fri Oct 18 17:17:00 2019 New Revision: 375310 URL: http://llvm.org/viewvc/llvm-project?rev=375310&view=rev Log: [clang][driver] Print compilation phases with indentation. Reviewers: tra, sfantao, echristo Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69124 Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=375310&r1=375309&r2=375310&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Fri Oct 18 17:17:00 2019 @@ -1802,23 +1802,36 @@ bool Driver::HandleImmediateArgs(const C return true; } +enum { + TopLevelAction = 0, + HeadSibAction = 1, + OtherSibAction = 2, +}; + // Display an action graph human-readably. Action A is the "sink" node // and latest-occuring action. Traversal is in pre-order, visiting the // inputs to each action before printing the action itself. static unsigned PrintActions1(const Compilation &C, Action *A, - std::map &Ids) { + std::map &Ids, + Twine Indent = {}, int Kind = TopLevelAction) { if (Ids.count(A)) // A was already visited. return Ids[A]; std::string str; llvm::raw_string_ostream os(str); + auto getSibIndent = [](int K) -> Twine { +return (K == HeadSibAction) ? " " : (K == OtherSibAction) ? "| " : ""; + }; + + Twine SibIndent = Indent + getSibIndent(Kind); + int SibKind = HeadSibAction; os << Action::getClassName(A->getKind()) << ", "; if (InputAction *IA = dyn_cast(A)) { os << "\"" << IA->getInputArg().getValue() << "\""; } else if (BindArchAction *BIA = dyn_cast(A)) { os << '"' << BIA->getArchName() << '"' << ", {" - << PrintActions1(C, *BIA->input_begin(), Ids) << "}"; + << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << "}"; } else if (OffloadAction *OA = dyn_cast(A)) { bool IsFirst = true; OA->doOnEachDependence( @@ -1841,8 +1854,9 @@ static unsigned PrintActions1(const Comp os << ":" << BoundArch; os << ")"; os << '"'; - os << " {" << PrintActions1(C, A, Ids) << "}"; + os << " {" << PrintActions1(C, A, Ids, SibIndent, SibKind) << "}"; IsFirst = false; + SibKind = OtherSibAction; }); } else { const ActionList *AL = &A->getInputs(); @@ -1850,8 +1864,9 @@ static unsigned PrintActions1(const Comp if (AL->size()) { const char *Prefix = "{"; for (Action *PreRequisite : *AL) { -os << Prefix << PrintActions1(C, PreRequisite, Ids); +os << Prefix << PrintActions1(C, PreRequisite, Ids, SibIndent, SibKind); Prefix = ", "; +SibKind = OtherSibAction; } os << "}"; } else @@ -1872,9 +1887,13 @@ static unsigned PrintActions1(const Comp } } + auto getSelfIndent = [](int K) -> Twine { +return (K == HeadSibAction) ? "+- " : (K == OtherSibAction) ? "|- " : ""; + }; + unsigned Id = Ids.size(); Ids[A] = Id; - llvm::errs() << Id << ": " << os.str() << ", " + llvm::errs() << Indent + getSelfIndent(Kind) << Id << ": " << os.str() << ", " << types::getTypeName(A->getType()) << offload_os.str() << "\n"; return Id; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 114de1e - Minor coding style fix. NFC.
Author: Michael Liao Date: 2019-10-22T04:32:30Z New Revision: 114de1eab29c06ac097c0e97feb713d616798f7a URL: https://github.com/llvm/llvm-project/commit/114de1eab29c06ac097c0e97feb713d616798f7a DIFF: https://github.com/llvm/llvm-project/commit/114de1eab29c06ac097c0e97feb713d616798f7a.diff LOG: Minor coding style fix. NFC. llvm-svn: 375478 Added: Modified: clang/lib/Sema/SemaLambda.cpp Removed: diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 749b0f2caaa0..c6b19a0b195c 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -444,7 +444,8 @@ void Sema::handleLambdaNumbering( } auto getMangleNumberingContext = - [this](CXXRecordDecl *Class, Decl *ManglingContextDecl) -> MangleNumberingContext * { + [this](CXXRecordDecl *Class, + Decl *ManglingContextDecl) -> MangleNumberingContext * { // Get mangle numbering context if there's any extra decl context. if (ManglingContextDecl) return &Context.getManglingNumberContext( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5a48678 - [hip] Allow the declaration of functions with variadic arguments in HIP.
Author: Michael Liao Date: 2019-10-25T00:39:24-04:00 New Revision: 5a48678a6a1619fada23641a68c2d95ee57806b1 URL: https://github.com/llvm/llvm-project/commit/5a48678a6a1619fada23641a68c2d95ee57806b1 DIFF: https://github.com/llvm/llvm-project/commit/5a48678a6a1619fada23641a68c2d95ee57806b1.diff LOG: [hip] Allow the declaration of functions with variadic arguments in HIP. Summary: - As variadic parameters have the lowest rank in overload resolution, without real usage of `va_arg`, they are commonly used as the catch-all fallbacks in SFINAE. As the front-end still reports errors on calls to `va_arg`, the declaration of functions with variadic arguments should be allowed in general. Reviewers: jlebar, tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69389 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/test/Driver/hip-toolchain-no-rdc.hip clang/test/Driver/hip-toolchain-rdc.hip Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index c2c7b8bf653b..e33d69c86b3c 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -7694,6 +7694,8 @@ class AMDGPUABIInfo final : public DefaultABIInfo { ABIArgInfo classifyArgumentType(QualType Ty, unsigned &NumRegsLeft) const; void computeInfo(CGFunctionInfo &FI) const override; + Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, +QualType Ty) const override; }; bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const { @@ -7757,6 +7759,11 @@ void AMDGPUABIInfo::computeInfo(CGFunctionInfo &FI) const { } } +Address AMDGPUABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, + QualType Ty) const { + llvm_unreachable("AMDGPU does not support varargs"); +} + ABIArgInfo AMDGPUABIInfo::classifyReturnType(QualType RetTy) const { if (isAggregateTypeForABI(RetTy)) { // Records with non-trivial destructors/copy-constructors should not be diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 70c70dcdbd4d..ae12465d3f8b 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5334,6 +5334,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fcuda-short-ptr"); } + if (IsHIP) +CmdArgs.push_back("-fcuda-allow-variadic-functions"); + // OpenMP offloading device jobs take the argument -fopenmp-host-ir-file-path // to specify the result of the compile phase on the host, so the meaningful // device declarations can be identified. Also, -fopenmp-is-device is passed diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp index d84a454359ad..1053a1a60978 100644 --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -296,6 +296,8 @@ void HIPToolChain::addClangTargetOptions( options::OPT_fno_gpu_allow_device_init, false)) CC1Args.push_back("-fgpu-allow-device-init"); + CC1Args.push_back("-fcuda-allow-variadic-functions"); + // Default to "hidden" visibility, as object level linking will not be // supported for the foreseeable future. if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ, diff --git a/clang/test/Driver/hip-toolchain-no-rdc.hip b/clang/test/Driver/hip-toolchain-no-rdc.hip index 540b93286053..74b53cfb 100644 --- a/clang/test/Driver/hip-toolchain-no-rdc.hip +++ b/clang/test/Driver/hip-toolchain-no-rdc.hip @@ -20,7 +20,7 @@ // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx803" -// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" +// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_803:".*bc"]] "-x" "hip" @@ -48,7 +48,7 @@ // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "a.cu" {{.*}} "-target-cpu" "gfx900" -// CHECK-SAME: "-fcuda-is-device" "-fvisibility" "hidden" +// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden" // CHECK-SAME: "-fapply-global-visibility-to-externs" // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc" // CHECK-SAME: {{.*}} "-o" [[A_BC_900:".*bc"]] "-x" "hip" @@ -92,7 +92,7 @@ // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu" // CHECK-SAME: "-emit-llvm-bc" // CHECK-SAME: {{.*}} "-main-file-name" "b.hip" {{.*}} "-target-cpu" "gfx803" -// CHECK-SAME: "-fcu
[clang] 45787e5 - Fix compilation warning. NFC.
Author: Michael Liao Date: 2019-10-25T01:06:52-04:00 New Revision: 45787e56829f47e45d127882b1cd1821e7022e68 URL: https://github.com/llvm/llvm-project/commit/45787e56829f47e45d127882b1cd1821e7022e68 DIFF: https://github.com/llvm/llvm-project/commit/45787e56829f47e45d127882b1cd1821e7022e68.diff LOG: Fix compilation warning. NFC. Added: Modified: clang/lib/CodeGen/CGBuiltin.cpp Removed: diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 2caa8509ea06..9a56116173ec 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -6874,6 +6874,7 @@ Value *CodeGenFunction::EmitARMMVEBuiltinExpr(unsigned BuiltinID, return ToReturn; } } + llvm_unreachable("unknown custom codegen type."); } static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b952d79 - [cuda][hip] Fix `RegisterVar` function prototype.
Author: Michael Liao Date: 2020-04-03T12:57:09-04:00 New Revision: b952d799cacdb7efd44c1c9468bb11471cc16874 URL: https://github.com/llvm/llvm-project/commit/b952d799cacdb7efd44c1c9468bb11471cc16874 DIFF: https://github.com/llvm/llvm-project/commit/b952d799cacdb7efd44c1c9468bb11471cc16874.diff LOG: [cuda][hip] Fix `RegisterVar` function prototype. Summary: - `RegisterVar` has `void` return type and `size_t` in its variable size parameter in HIP or CUDA 9.0+. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77398 Added: Modified: clang/include/clang/Basic/Cuda.h clang/lib/Basic/Cuda.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/test/CodeGenCUDA/device-stub.cu Removed: diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h index da572957d10d..c2ebf8734304 100644 --- a/clang/include/clang/Basic/Cuda.h +++ b/clang/include/clang/Basic/Cuda.h @@ -117,6 +117,7 @@ enum class CudaFeature { CUDA_USES_FATBIN_REGISTER_END, }; +CudaVersion ToCudaVersion(llvm::VersionTuple); bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature); bool CudaFeatureEnabled(CudaVersion, CudaFeature); diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp index e06d120c58bf..74eb5473b71d 100644 --- a/clang/lib/Basic/Cuda.cpp +++ b/clang/lib/Basic/Cuda.cpp @@ -362,7 +362,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) { } } -static CudaVersion ToCudaVersion(llvm::VersionTuple Version) { +CudaVersion ToCudaVersion(llvm::VersionTuple Version) { int IVer = Version.getMajor() * 10 + Version.getMinor().getValueOr(0); switch(IVer) { diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index 6d92ef33b885..351c5058aa4c 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -440,13 +440,19 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { Builder.CreateCall(RegisterFunc, Args); } + llvm::Type *VarSizeTy = IntTy; + // For HIP or CUDA 9.0+, device variable size is type of `size_t`. + if (CGM.getLangOpts().HIP || + ToCudaVersion(CGM.getTarget().getSDKVersion()) >= CudaVersion::CUDA_90) +VarSizeTy = SizeTy; + // void __cudaRegisterVar(void **, char *, char *, const char *, //int, int, int, int) llvm::Type *RegisterVarParams[] = {VoidPtrPtrTy, CharPtrTy, CharPtrTy, - CharPtrTy,IntTy, IntTy, + CharPtrTy,IntTy, VarSizeTy, IntTy,IntTy}; llvm::FunctionCallee RegisterVar = CGM.CreateRuntimeFunction( - llvm::FunctionType::get(IntTy, RegisterVarParams, false), + llvm::FunctionType::get(VoidTy, RegisterVarParams, false), addUnderscoredPrefixToName("RegisterVar")); // void __cudaRegisterSurface(void **, const struct surfaceReference *, //const void **, const char *, int, int); @@ -476,7 +482,7 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { VarName, VarName, llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()), - llvm::ConstantInt::get(IntTy, VarSize), + llvm::ConstantInt::get(VarSizeTy, VarSize), llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()), llvm::ConstantInt::get(IntTy, 0)}; Builder.CreateCall(RegisterVar, Args); diff --git a/clang/test/CodeGenCUDA/device-stub.cu b/clang/test/CodeGenCUDA/device-stub.cu index 9db5738cdede..0f4a5644fd48 100644 --- a/clang/test/CodeGenCUDA/device-stub.cu +++ b/clang/test/CodeGenCUDA/device-stub.cu @@ -181,10 +181,10 @@ void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); } // Test that we've built a function to register kernels and global vars. // ALL: define internal void @__[[PREFIX]]_register_globals // ALL: call{{.*}}[[PREFIX]]RegisterFunction(i8** %0, {{.*}}kernelfunc{{[^,]*}}, {{[^@]*}}@0 -// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, i32 4, i32 0, i32 0 -// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, i32 4, i32 1, i32 0 -// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}ext_device_var_def{{[^,]*}}, {{[^@]*}}@3, {{.*}}i32 0, i32 4, i32 0, i32 0 -// ALL-DAG: call{{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}ext_constant_var_def{{[^,]*}}, {{[^@]*}}@4, {{.*}}i32 0, i32 4, i32 1, i32 0 +// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}device_var{{[^,]*}}, {{[^@]*}}@1, {{.*}}i32 0, {{i32|i64}} 4, i32 0, i32 0 +// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}constant_var{{[^,]*}}, {{[^@]*}}@2, {{.*}}i32 0, {{i32|i64}} 4, i32 1, i32 0 +// ALL-DAG: call void {{.*}}[[PREFIX]]RegisterVar(i8** %0, {{.*}}ext_
[clang] c97be2c - [hip] Remove `hip_pinned_shadow`.
Author: Michael Liao Date: 2020-04-07T09:51:49-04:00 New Revision: c97be2c377852fad7eb38409aae5692fa417e49b URL: https://github.com/llvm/llvm-project/commit/c97be2c377852fad7eb38409aae5692fa417e49b DIFF: https://github.com/llvm/llvm-project/commit/c97be2c377852fad7eb38409aae5692fa417e49b.diff LOG: [hip] Remove `hip_pinned_shadow`. Summary: - Use `device_builtin_surface` and `device_builtin_texture` for surface/texture reference support. So far, both the host and device use the same reference type, which could be revised later when interface/implementation is stablized. Reviewers: yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D77583 Added: Modified: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/TargetInfo.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/Driver/hip-toolchain-no-rdc.hip clang/test/Driver/hip-toolchain-rdc.hip clang/test/Misc/pragma-attribute-supported-attributes-list.test Removed: clang/test/AST/ast-dump-hip-pinned-shadow.cu clang/test/SemaCUDA/hip-pinned-shadow.cu diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index f55ce2cc84dd..c586f9b9466a 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -322,7 +322,6 @@ class LangOpt { def MicrosoftExt : LangOpt<"MicrosoftExt">; def Borland : LangOpt<"Borland">; def CUDA : LangOpt<"CUDA">; -def HIP : LangOpt<"HIP">; def SYCL : LangOpt<"SYCLIsDevice">; def COnly : LangOpt<"", "!LangOpts.CPlusPlus">; def CPlusPlus : LangOpt<"CPlusPlus">; @@ -1052,13 +1051,6 @@ def CUDADevice : InheritableAttr { let Documentation = [Undocumented]; } -def HIPPinnedShadow : InheritableAttr { - let Spellings = [GNU<"hip_pinned_shadow">, Declspec<"__hip_pinned_shadow__">]; - let Subjects = SubjectList<[Var]>; - let LangOpts = [HIP]; - let Documentation = [HIPPinnedShadowDocs]; -} - def CUDADeviceBuiltin : IgnoredAttr { let Spellings = [GNU<"device_builtin">, Declspec<"__device_builtin__">]; let LangOpts = [CUDA]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index fb1c82a80115..36561c04d395 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -4613,18 +4613,6 @@ only call one function. }]; } -def HIPPinnedShadowDocs : Documentation { - let Category = DocCatType; - let Content = [{ -The GNU style attribute __attribute__((hip_pinned_shadow)) or MSVC style attribute -__declspec(hip_pinned_shadow) can be added to the definition of a global variable -to indicate it is a HIP pinned shadow variable. A HIP pinned shadow variable can -be accessed on both device side and host side. It has external linkage and is -not initialized on device side. It has internal linkage and is initialized by -the initializer on host side. - }]; -} - def CUDADeviceBuiltinSurfaceTypeDocs : Documentation { let Category = DocCatType; let Content = [{ diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1645a9eb17de..8b7d52b88146 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1955,9 +1955,9 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, } } -void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV, bool SkipCheck) { - assert(SkipCheck || (!GV->isDeclaration() && - "Only globals with definition can force usage.")); +void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) { + assert(!GV->isDeclaration() && + "Only globals with definition can force usage."); LLVMUsed.emplace_back(GV); } @@ -2520,7 +2520,6 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { !Global->hasAttr() && !Global->hasAttr() && !Global->hasAttr() && - !(LangOpts.HIP && Global->hasAttr()) && !Global->getType()->isCUDADeviceBuiltinSurfaceType() && !Global->getType()->isCUDADeviceBuiltinTextureType()) return; @@ -3928,10 +3927,8 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, D->getType()->isCUDADeviceBuiltinTextureType()); // HIP pinned shadow of initialized host-side global variables are also // left undefined. - bool IsHIPPinnedShadowVar = - getLangOpts().CUDAIsDevice && D->hasAttr(); - if (getLangOpts().CUDA && (IsCUDASharedVar || IsCUDAShadowVar || - IsCUDADeviceShadowVar || IsHIPPinnedShadowVar)) + if (getLangOpts().CUDA && + (IsCUDASharedVar || IsCUDAShadowVar || IsCUDADeviceShadowVar)) Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy)); else if (D->hasAttr())
[clang] 96c4ec8 - Remove extra whitespace. NFC.
Author: Michael Liao Date: 2020-04-10T03:22:01-04:00 New Revision: 96c4ec8fdbd95048114cf058679bd8fc08ab76b3 URL: https://github.com/llvm/llvm-project/commit/96c4ec8fdbd95048114cf058679bd8fc08ab76b3 DIFF: https://github.com/llvm/llvm-project/commit/96c4ec8fdbd95048114cf058679bd8fc08ab76b3.diff LOG: Remove extra whitespace. NFC. Added: Modified: clang/include/clang/Basic/DiagnosticDriverKinds.td Removed: diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index e35ca843ff56..cba59cb3b66d 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -50,14 +50,14 @@ def warn_drv_avr_stdlib_not_linked: Warning< InGroup; def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">; def err_drv_no_cuda_installation : Error< - "cannot find CUDA installation. Provide its path via --cuda-path, or pass " + "cannot find CUDA installation. Provide its path via --cuda-path, or pass " "-nocudainc to build without CUDA includes.">; def err_drv_no_cuda_libdevice : Error< "cannot find libdevice for %0. Provide path to diff erent CUDA installation " "via --cuda-path, or pass -nocudalib to build without linking with libdevice.">; def err_drv_cuda_version_unsupported : Error< "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), " - "but installation at %3 is %4. Use --cuda-path to specify a diff erent CUDA " + "but installation at %3 is %4. Use --cuda-path to specify a diff erent CUDA " "install, pass a diff erent GPU arch with --cuda-gpu-arch, or pass " "--no-cuda-version-check.">; def warn_drv_unknown_cuda_version: Warning< ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 50472c4 - Remove extra ‘;’. NFC.
Author: Michael Liao Date: 2020-04-15T17:22:03-04:00 New Revision: 50472c422cc6d27a4532a4025c4339fb6920 URL: https://github.com/llvm/llvm-project/commit/50472c422cc6d27a4532a4025c4339fb6920 DIFF: https://github.com/llvm/llvm-project/commit/50472c422cc6d27a4532a4025c4339fb6920.diff LOG: Remove extra ‘;’. NFC. Added: Modified: clang/include/clang/AST/RecursiveASTVisitor.h Removed: diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 10ea91ea9cfa..85eb6259a419 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1993,7 +1993,7 @@ DEF_TRAVERSE_DECL(BindingDecl, { DEF_TRAVERSE_DECL(MSPropertyDecl, { TRY_TO(TraverseDeclaratorHelper(D)); }) -DEF_TRAVERSE_DECL(MSGuidDecl, {}); +DEF_TRAVERSE_DECL(MSGuidDecl, {}) DEF_TRAVERSE_DECL(FieldDecl, { TRY_TO(TraverseDeclaratorHelper(D)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8b6821a - [hip] Fix device-only relocatable code compilation.
Author: Michael Liao Date: 2020-06-10T14:10:41-04:00 New Revision: 8b6821a5843bb321b3738e2519beae7142e62928 URL: https://github.com/llvm/llvm-project/commit/8b6821a5843bb321b3738e2519beae7142e62928 DIFF: https://github.com/llvm/llvm-project/commit/8b6821a5843bb321b3738e2519beae7142e62928.diff LOG: [hip] Fix device-only relocatable code compilation. Summary: - In HIP, just as the regular device-only compilation, the device-only relocatable code compilation should not involve offload bundle. - In addition, that device-only relocatable code compilation should have the similar 3 steps, namely preprocessor, compile, and backend, to the regular code generation with `-emit-llvm`. Reviewers: yaxunl, tra Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81427 Added: clang/test/Driver/hip-rdc-device-only.hip Modified: clang/lib/Driver/Driver.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 8cc5eceaa512..19faf0968e08 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2705,9 +2705,7 @@ class OffloadingActionBuilder final { // backend and assemble phases to output LLVM IR. Except for generating // non-relocatable device coee, where we generate fat binary for device // code and pass to host in Backend phase. - if (CudaDeviceActions.empty() || - (CurPhase == phases::Backend && Relocatable) || - CurPhase == phases::Assemble) + if (CudaDeviceActions.empty()) return ABRT_Success; assert(((CurPhase == phases::Link && Relocatable) || @@ -2781,9 +2779,11 @@ class OffloadingActionBuilder final { } // By default, we produce an action for each device arch. - for (Action *&A : CudaDeviceActions) -A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A, - AssociatedOffloadKind); + if (!Relocatable || CurPhase <= phases::Backend) { +for (Action *&A : CudaDeviceActions) + A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A, + AssociatedOffloadKind); + } return (CompileDeviceOnly && CurPhase == FinalPhase) ? ABRT_Ignore_Host : ABRT_Success; @@ -3668,7 +3668,10 @@ Action *Driver::ConstructPhaseAction( Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC; return C.MakeAction(Input, Output); } -if (Args.hasArg(options::OPT_emit_llvm)) { +if (Args.hasArg(options::OPT_emit_llvm) || +(TargetDeviceOffloadKind == Action::OFK_HIP && + Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, + false))) { types::ID Output = Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC; return C.MakeAction(Input, Output); @@ -4588,8 +4591,19 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, // When using both -save-temps and -emit-llvm, use a ".tmp.bc" suffix for // the unoptimized bitcode so that it does not get overwritten by the ".bc" // optimized bitcode output. -if (!AtTopLevel && C.getArgs().hasArg(options::OPT_emit_llvm) && -JA.getType() == types::TY_LLVM_BC) +auto IsHIPRDCInCompilePhase = [](const JobAction &JA, + const llvm::opt::DerivedArgList &Args) { + // The relocatable compilation in HIP implies -emit-llvm. Similarly, use a + // ".tmp.bc" suffix for the unoptimized bitcode (generated in the compile + // phase.) + return isa(JA) && + JA.getOffloadingDeviceKind() == Action::OFK_HIP && + Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, + false); +}; +if (!AtTopLevel && JA.getType() == types::TY_LLVM_BC && +(C.getArgs().hasArg(options::OPT_emit_llvm) || + IsHIPRDCInCompilePhase(JA, C.getArgs( Suffixed += ".tmp"; Suffixed += '.'; Suffixed += Suffix; diff --git a/clang/test/Driver/hip-rdc-device-only.hip b/clang/test/Driver/hip-rdc-device-only.hip new file mode 100644 index ..4bdff628466a --- /dev/null +++ b/clang/test/Driver/hip-rdc-device-only.hip @@ -0,0 +1,144 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -### -target x86_64-linux-gnu \ +// RUN: -x hip --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \ +// RUN: -c -nogpuinc -nogpulib --cuda-device-only -fgpu-rdc \ +// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ +// RUN: %S/Inputs/hip_multiple_inputs/b.hip \ +// RUN: 2>&1 | FileCheck -check-prefixes=COMMON,EMITBC %s + +// With `-emit-llvm`, the output should be the same as the aforementioned li
[clang] 6dd0580 - [hip] Fix the failed test case due to the additional backend phase.
Author: Michael Liao Date: 2020-06-10T15:06:06-04:00 New Revision: 6dd058083208d58c6a7005bfb092cee085fd9a48 URL: https://github.com/llvm/llvm-project/commit/6dd058083208d58c6a7005bfb092cee085fd9a48 DIFF: https://github.com/llvm/llvm-project/commit/6dd058083208d58c6a7005bfb092cee085fd9a48.diff LOG: [hip] Fix the failed test case due to the additional backend phase. Added: Modified: clang/test/Driver/cuda-phases.cu Removed: diff --git a/clang/test/Driver/cuda-phases.cu b/clang/test/Driver/cuda-phases.cu index 58be50ae2e12..acbf345f85c6 100644 --- a/clang/test/Driver/cuda-phases.cu +++ b/clang/test/Driver/cuda-phases.cu @@ -49,9 +49,10 @@ // BIN_AMD_NRDC-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]]) // BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]]) // BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]]) -// BIN_AMD_RDC-DAG: [[P15:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], [[ARCH]]) -// BIN_AMD_RDC-DAG: [[P16:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P14]]}, -// BIN_AMD_RDC-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P15]]}, object +// BIN_AMD_RDC-DAG: [[P15:[0-9]+]]: backend, {[[P5]]}, ir, (device-[[T]], [[ARCH]]) +// BIN_AMD_RDC-DAG: [[P16:[0-9]+]]: linker, {[[P15]]}, image, (device-[[T]], [[ARCH]]) +// BIN_AMD_RDC-DAG: [[P17:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P14]]}, +// BIN_AMD_RDC-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P16]]}, object // // Test single gpu architecture up to the assemble phase. @@ -109,11 +110,13 @@ // BIN2_AMD-DAG: [[P19:[0-9]+]]: backend, {[[P2]]}, assembler, (host-[[T]]) // BIN2-DAG: [[P20:[0-9]+]]: assembler, {[[P19]]}, object, (host-[[T]]) // BIN2-DAG: [[P21:[0-9]+]]: linker, {[[P20]]}, image, (host-[[T]]) -// BIN2_AMD-DAG: [[P22:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], [[ARCH1]]) -// BIN2_AMD-DAG: [[P23:[0-9]+]]: linker, {[[P12]]}, image, (device-[[T]], [[ARCH2]]) -// BIN2_AMD-DAG: [[P24:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P21]]}, -// BIN2_AMD-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH1]])" {[[P22]]}, -// BIN2_AMD-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH2]])" {[[P23]]}, object +// BIN2_AMD-DAG: [[P22:[0-9]+]]: backend, {[[P5]]}, ir, (device-[[T]], [[ARCH1]]) +// BIN2_AMD-DAG: [[P23:[0-9]+]]: backend, {[[P12]]}, ir, (device-[[T]], [[ARCH2]]) +// BIN2_AMD-DAG: [[P24:[0-9]+]]: linker, {[[P22]]}, image, (device-[[T]], [[ARCH1]]) +// BIN2_AMD-DAG: [[P25:[0-9]+]]: linker, {[[P23]]}, image, (device-[[T]], [[ARCH2]]) +// BIN2_AMD-DAG: [[P26:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P21]]}, +// BIN2_AMD-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH1]])" {[[P24]]}, +// BIN2_AMD-DAG-SAME: "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH2]])" {[[P25]]}, object // // Test two gpu architecturess up to the assemble phase. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e830fa2 - [clang][amdgpu] Prefer not using `fp16` conversion intrinsics.
Author: Michael Liao Date: 2020-06-16T10:21:56-04:00 New Revision: e830fa260da9d3bbe99c4176b4ddb6aa5e6229dd URL: https://github.com/llvm/llvm-project/commit/e830fa260da9d3bbe99c4176b4ddb6aa5e6229dd DIFF: https://github.com/llvm/llvm-project/commit/e830fa260da9d3bbe99c4176b4ddb6aa5e6229dd.diff LOG: [clang][amdgpu] Prefer not using `fp16` conversion intrinsics. Reviewers: yaxunl, arsenm Subscribers: kzhuravl, jvesely, wdng, nhaehnle, dstuttard, tpr, t-tye, kerbowa, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81849 Added: clang/test/CodeGenHIP/half.hip Modified: clang/lib/Basic/Targets/AMDGPU.h Removed: diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index e4194a881e3f..387b91abb537 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -219,6 +219,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { ArrayRef getTargetBuiltins() const override; + bool useFP16ConversionIntrinsics() const override { return false; } + void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; diff --git a/clang/test/CodeGenHIP/half.hip b/clang/test/CodeGenHIP/half.hip new file mode 100644 index ..d5dd43d51fdf --- /dev/null +++ b/clang/test/CodeGenHIP/half.hip @@ -0,0 +1,16 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s + +#define __device__ __attribute__((device)) + +// CHECK-LABEL: @_Z2d0DF16_ +// CHECK: fpext +__device__ float d0(_Float16 x) { + return x; +} + +// CHECK-LABEL: @_Z2d1f +// CHECK: fptrunc +__device__ _Float16 d1(float x) { + return x; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b8409c0 - Fix `-Wreturn-type` warning. NFC.
Author: Michael Liao Date: 2020-07-11T16:20:41-04:00 New Revision: b8409c03ed90807f3d49c7d98dceea98cf461f7a URL: https://github.com/llvm/llvm-project/commit/b8409c03ed90807f3d49c7d98dceea98cf461f7a DIFF: https://github.com/llvm/llvm-project/commit/b8409c03ed90807f3d49c7d98dceea98cf461f7a.diff LOG: Fix `-Wreturn-type` warning. NFC. Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 6d13f1ace83b..1f192180ec45 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -750,6 +750,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor { return new (allocator()) syntax::FloatUserDefinedLiteralExpression; } } +llvm_unreachable("Unknown literal operator kind."); } bool WalkUpFromUserDefinedLiteral(UserDefinedLiteral *S) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ebc9e0f - Fix coding style. NFC.
Author: Michael Liao Date: 2020-06-24T13:13:42-04:00 New Revision: ebc9e0f1f0786b892b4a6eaf50013a18aed31aa5 URL: https://github.com/llvm/llvm-project/commit/ebc9e0f1f0786b892b4a6eaf50013a18aed31aa5 DIFF: https://github.com/llvm/llvm-project/commit/ebc9e0f1f0786b892b4a6eaf50013a18aed31aa5.diff LOG: Fix coding style. NFC. - Remove `else` after `return`. Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f0ab5165584c..5e902aa15bcf 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3656,26 +3656,29 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, } llvm::Constant * -CodeGenModule::GetAddrOfGlobal(GlobalDecl GD, - ForDefinition_t IsForDefinition) { +CodeGenModule::GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition) { const Decl *D = GD.getDecl(); + if (isa(D) || isa(D)) return getAddrOfCXXStructor(GD, /*FnInfo=*/nullptr, /*FnType=*/nullptr, /*DontDefer=*/false, IsForDefinition); - else if (isa(D)) { -auto FInfo = &getTypes().arrangeCXXMethodDeclaration( -cast(D)); + + if (isa(D)) { +auto FInfo = +&getTypes().arrangeCXXMethodDeclaration(cast(D)); auto Ty = getTypes().GetFunctionType(*FInfo); return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false, IsForDefinition); - } else if (isa(D)) { + } + + if (isa(D)) { const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false, IsForDefinition); - } else -return GetAddrOfGlobalVar(cast(D), /*Ty=*/nullptr, - IsForDefinition); + } + + return GetAddrOfGlobalVar(cast(D), /*Ty=*/nullptr, IsForDefinition); } llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dccfaac - [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`.
Author: Michael Liao Date: 2020-06-25T20:46:56-04:00 New Revision: dccfaacf93e1c4801cbcc4686f64eb8a35564ff7 URL: https://github.com/llvm/llvm-project/commit/dccfaacf93e1c4801cbcc4686f64eb8a35564ff7 DIFF: https://github.com/llvm/llvm-project/commit/dccfaacf93e1c4801cbcc4686f64eb8a35564ff7.diff LOG: [InferAddressSpaces] Handle the pair of `ptrtoint`/`inttoptr`. Summary: - `ptrtoint` and `inttoptr` are defined as no-op casts if the integer value as the same size as the pointer value. The pair of `ptrtoint`/`inttoptr` is in fact a no-op cast sequence between different address spaces. Teach `infer-address-spaces` to handle them like a `bitcast`. Reviewers: arsenm, chandlerc Subscribers: jvesely, wdng, nhaehnle, hiraditya, kerbowa, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D81938 Added: llvm/test/Transforms/InferAddressSpaces/AMDGPU/noop-ptrint-pair.ll Modified: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp Removed: diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 73ab9edf318e..8c102d339863 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -1,37 +1,52 @@ -// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s #include "Inputs/cuda.h" // Coerced struct from `struct S` without all generic pointers lowered into // global ones. -// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* } -// CHECK: %struct.T.coerce = type { [2 x float addrspace(1)*] } +// COMMON: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* } +// COMMON: %struct.T.coerce = type { [2 x float addrspace(1)*] } // On the host-side compilation, generic pointer won't be coerced. // HOST-NOT: %struct.S.coerce // HOST-NOT: %struct.T.coerce -// CHECK: define amdgpu_kernel void @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce) // HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x) +// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel1Pi(i32 addrspace(1)*{{.*}} %x.coerce) +// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* +// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* +// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4 +// OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1 +// OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4 +// OPT: ret void __global__ void kernel1(int *x) { x[0]++; } -// CHECK: define amdgpu_kernel void @_Z7kernel2Ri(i32 addrspace(1)* nonnull align 4 dereferenceable(4) %x.coerce) // HOST: define void @_Z22__device_stub__kernel2Ri(i32* nonnull align 4 dereferenceable(4) %x) +// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel2Ri(i32 addrspace(1)*{{.*}} nonnull align 4 dereferenceable(4) %x.coerce) +// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* +// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* +// OPT: [[VAL:%.*]] = load i32, i32 addrspace(1)* %x.coerce, align 4 +// OPT: [[INC:%.*]] = add nsw i32 [[VAL]], 1 +// OPT: store i32 [[INC]], i32 addrspace(1)* %x.coerce, align 4 +// OPT: ret void __global__ void kernel2(int &x) { x++; } -// CHECK: define amdgpu_kernel void @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y) // HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y) +// CHECK-LABEL: define amdgpu_kernel void @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)*{{.*}} %x, i32 addrspace(1)*{{.*}} %y) +// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* __global__ void kernel3(__attribute__((address_space(2))) int *x, __attribute__((address_space(1))) int *y) { y[0] = x[0]; } -// CHECK: define void @_Z4funcPi(i32* %x) +// COMMON-LABEL: define void @_Z4funcPi(i32*{{.*}} %x) +// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]* __device__ void func(int *x) { x[0]++; } @@ -42,16 +57,25 @@ struct S { }; // `by-val` struct will be coerced into a similar struct with all generic // pointers lowerd into global ones. -// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce) // HOST: define void @_Z22__device_s
[clang] d3f437d - [hip] Disable test temporarily due to failures on build servers.
Author: Michael Liao Date: 2020-06-25T22:04:20-04:00 New Revision: d3f437d35189f7567294daf3e60e08326e64994a URL: https://github.com/llvm/llvm-project/commit/d3f437d35189f7567294daf3e60e08326e64994a DIFF: https://github.com/llvm/llvm-project/commit/d3f437d35189f7567294daf3e60e08326e64994a.diff LOG: [hip] Disable test temporarily due to failures on build servers. Added: Modified: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu Removed: diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 8c102d339863..3021e73780f4 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -1,3 +1,4 @@ +// XFAIL: * // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0723b18 - [hip] Re-enable `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`
Author: Michael Liao Date: 2020-06-25T22:29:27-04:00 New Revision: 0723b1891fac8f79f92549e3bcac9112be4ebd43 URL: https://github.com/llvm/llvm-project/commit/0723b1891fac8f79f92549e3bcac9112be4ebd43 DIFF: https://github.com/llvm/llvm-project/commit/0723b1891fac8f79f92549e3bcac9112be4ebd43.diff LOG: [hip] Re-enable `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu` - Require amdgpu target being enabled. Added: Modified: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu Removed: diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 3021e73780f4..99284c04e5cc 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -1,4 +1,4 @@ -// XFAIL: * +// REQUIRES: amdgpu-registered-target // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 471c806 - [hip] Refine `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu`
Author: Michael Liao Date: 2020-06-25T23:57:08-04:00 New Revision: 471c806a45bbac2f0f4274d8bea383d06d397a84 URL: https://github.com/llvm/llvm-project/commit/471c806a45bbac2f0f4274d8bea383d06d397a84 DIFF: https://github.com/llvm/llvm-project/commit/471c806a45bbac2f0f4274d8bea383d06d397a84.diff LOG: [hip] Refine `clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu` - Require target x86 being enabled as well. Added: Modified: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu Removed: diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 99284c04e5cc..2660a5f14f90 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -1,4 +1,6 @@ +// REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target + // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 86e3b73 - [hip] Claim builtin type `__float128` supported if the host target supports it.
Author: Michael Liao Date: 2020-04-21T15:56:40-04:00 New Revision: 86e3b735cd803cc22c9eae15d99ce9df5956aae6 URL: https://github.com/llvm/llvm-project/commit/86e3b735cd803cc22c9eae15d99ce9df5956aae6 DIFF: https://github.com/llvm/llvm-project/commit/86e3b735cd803cc22c9eae15d99ce9df5956aae6.diff LOG: [hip] Claim builtin type `__float128` supported if the host target supports it. Reviewers: tra, yaxunl Subscribers: jvesely, nhaehnle, kerbowa, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78513 Added: clang/test/SemaCUDA/amdgpu-f128.cu Modified: clang/lib/Basic/Targets/AMDGPU.cpp Removed: diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index 3fd9008e4660..b9d7640a10b8 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -363,4 +363,17 @@ void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) { copyAuxTarget(Aux); LongDoubleFormat = SaveLongDoubleFormat; Float128Format = SaveFloat128Format; + // For certain builtin types support on the host target, claim they are + // support to pass the compilation of the host code during the device-side + // compilation. + // FIXME: As the side effect, we also accept `__float128` uses in the device + // code. To rejct these builtin types supported in the host target but not in + // the device target, one approach would support `device_builtin` attribute + // so that we could tell the device builtin types from the host ones. The + // also solves the diff erent representations of the same builtin type, such + // as `size_t` in the MSVC environment. + if (Aux->hasFloat128Type()) { +HasFloat128 = true; +Float128Format = DoubleFormat; + } } diff --git a/clang/test/SemaCUDA/amdgpu-f128.cu b/clang/test/SemaCUDA/amdgpu-f128.cu new file mode 100644 index ..9a0212cdb93c --- /dev/null +++ b/clang/test/SemaCUDA/amdgpu-f128.cu @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -fsyntax-only -verify %s + +// expected-no-diagnostics +typedef __float128 f128_t; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 612720d - [hip] Remove test using `hip_pinned_shadow` attribute. NFC.
Author: Michael Liao Date: 2020-04-27T16:44:59-04:00 New Revision: 612720db874d06a50b793c301e5b3b857e3e7c70 URL: https://github.com/llvm/llvm-project/commit/612720db874d06a50b793c301e5b3b857e3e7c70 DIFF: https://github.com/llvm/llvm-project/commit/612720db874d06a50b793c301e5b3b857e3e7c70.diff LOG: [hip] Remove test using `hip_pinned_shadow` attribute. NFC. Added: Modified: Removed: clang/test/CodeGenCUDA/hip-pinned-shadow.hip diff --git a/clang/test/CodeGenCUDA/hip-pinned-shadow.hip b/clang/test/CodeGenCUDA/hip-pinned-shadow.hip deleted file mode 100644 index 7f0e7544d828.. --- a/clang/test/CodeGenCUDA/hip-pinned-shadow.hip +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: amdgpu-registered-target - -// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ -// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=HIPDEV %s -// RUN: %clang_cc1 -triple x86_64 -std=c++11 \ -// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=HIPHOST %s -// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -std=c++11 -fvisibility hidden -fapply-global-visibility-to-externs \ -// RUN: -O3 -emit-llvm -o - %s | FileCheck -check-prefixes=HIPDEVUNSED %s - -struct textureReference { - int a; -}; - -template -struct texture : public textureReference { -texture() { a = 1; } -}; - -__attribute__((hip_pinned_shadow)) texture tex; -// CUDADEV-NOT: @tex -// CUDAHOST-NOT: call i32 @__hipRegisterVar{{.*}}@tex -// HIPDEV: @tex = external addrspace(1) global %struct.texture -// HIPDEV-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev -// HIPHOST: define{{.*}}@_ZN7textureIfLi2ELi1EEC1Ev -// HIPHOST: call i32 @__hipRegisterVar{{.*}}@tex{{.*}}i32 0, i32 4, i32 0, i32 0) -// HIPDEVUNSED: @tex = external addrspace(1) global %struct.texture -// HIPDEVUNSED-NOT: declare{{.*}}void @_ZN7textureIfLi2ELi1EEC1Ev ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d1c4361 - [clang-format] Add the missing default argument.
Author: Michael Liao Date: 2020-04-30T17:36:43-04:00 New Revision: d1c43615ed068f2f915ccdd959ef583cd5177929 URL: https://github.com/llvm/llvm-project/commit/d1c43615ed068f2f915ccdd959ef583cd5177929 DIFF: https://github.com/llvm/llvm-project/commit/d1c43615ed068f2f915ccdd959ef583cd5177929.diff LOG: [clang-format] Add the missing default argument. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index c9528188c61c..7456e6d5fb48 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1471,7 +1471,7 @@ void UnwrappedLineParser::parseStructuralElement() { } else if (Style.Language == FormatStyle::LK_Proto && FormatTok->Tok.is(tok::less)) { nextToken(); -parseBracedList(/*ContinueOnSemicolons=*/false, +parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false, /*ClosingBraceKind=*/tok::greater); } break; @@ -1824,7 +1824,7 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons, case tok::less: if (Style.Language == FormatStyle::LK_Proto) { nextToken(); -parseBracedList(/*ContinueOnSemicolons=*/false, +parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false, /*ClosingBraceKind=*/tok::greater); } else { nextToken(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f3a3db8 - Add the missing '='. NFC.
Author: Michael Liao Date: 2020-05-02T01:07:44-04:00 New Revision: f3a3db8627e9fa673fa413a2e41fe5443db7c6c3 URL: https://github.com/llvm/llvm-project/commit/f3a3db8627e9fa673fa413a2e41fe5443db7c6c3 DIFF: https://github.com/llvm/llvm-project/commit/f3a3db8627e9fa673fa413a2e41fe5443db7c6c3.diff LOG: Add the missing '='. NFC. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 7456e6d5fb48..96e0bd2276fa 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1471,7 +1471,7 @@ void UnwrappedLineParser::parseStructuralElement() { } else if (Style.Language == FormatStyle::LK_Proto && FormatTok->Tok.is(tok::less)) { nextToken(); -parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false, +parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false, /*ClosingBraceKind=*/tok::greater); } break; @@ -1824,7 +1824,7 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons, case tok::less: if (Style.Language == FormatStyle::LK_Proto) { nextToken(); -parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum*/false, +parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false, /*ClosingBraceKind=*/tok::greater); } else { nextToken(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c7b683c - [PGO][CUDA][HIP] Skip generating profile on the device stub and wrong-side functions.
Author: Michael Liao Date: 2020-08-10T11:01:46-04:00 New Revision: c7b683c126b849dab5c81e7deecfc1e61f8563a0 URL: https://github.com/llvm/llvm-project/commit/c7b683c126b849dab5c81e7deecfc1e61f8563a0 DIFF: https://github.com/llvm/llvm-project/commit/c7b683c126b849dab5c81e7deecfc1e61f8563a0.diff LOG: [PGO][CUDA][HIP] Skip generating profile on the device stub and wrong-side functions. - Skip generating profile data on `__global__` function in the host compilation. It's a host-side stub function only and don't have profile instrumentation generated on the real function body. The extra profile data results in the malformed instrumentation profile data. - Skip generating region mapping on functions in the wrong-side, i.e., + For the device compilation, skip host-only functions; and, + For the host compilation, skip device-only functions (including `__global__` functions.) - As the device-side profiling is not ready yet, only host-side profile code generation is checked. Differential Revision: https://reviews.llvm.org/D85276 Added: clang/test/CodeGenCUDA/profile-coverage-mapping.cu Modified: clang/lib/CodeGen/CodeGenPGO.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index e810f608ab78..be3c50b99f30 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -773,6 +773,11 @@ void CodeGenPGO::assignRegionCounters(GlobalDecl GD, llvm::Function *Fn) { if (!D->hasBody()) return; + // Skip CUDA/HIP kernel launch stub functions. + if (CGM.getLangOpts().CUDA && !CGM.getLangOpts().CUDAIsDevice && + D->hasAttr()) +return; + bool InstrumentRegions = CGM.getCodeGenOpts().hasProfileClangInstr(); llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); if (!InstrumentRegions && !PGOReader) @@ -831,6 +836,18 @@ bool CodeGenPGO::skipRegionMappingForDecl(const Decl *D) { if (!D->getBody()) return true; + // Skip host-only functions in the CUDA device compilation and device-only + // functions in the host compilation. Just roughly filter them out based on + // the function attributes. If there are effectively host-only or device-only + // ones, their coverage mapping may still be generated. + if (CGM.getLangOpts().CUDA && + ((CGM.getLangOpts().CUDAIsDevice && !D->hasAttr() && +!D->hasAttr()) || + (!CGM.getLangOpts().CUDAIsDevice && +(D->hasAttr() || + (!D->hasAttr() && D->hasAttr()) +return true; + // Don't map the functions in system headers. const auto &SM = CGM.getContext().getSourceManager(); auto Loc = D->getBody()->getBeginLoc(); diff --git a/clang/test/CodeGenCUDA/profile-coverage-mapping.cu b/clang/test/CodeGenCUDA/profile-coverage-mapping.cu new file mode 100644 index ..5eae6f10e0ea --- /dev/null +++ b/clang/test/CodeGenCUDA/profile-coverage-mapping.cu @@ -0,0 +1,20 @@ +// RUN: echo "GPU binary would be here" > %t +// RUN: %clang_cc1 -fprofile-instrument=clang -triple x86_64-linux-gnu -target-sdk-version=8.0 -fcuda-include-gpubinary %t -emit-llvm -o - %s | FileCheck --check-prefix=PGOGEN %s +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -triple x86_64-linux-gnu -target-sdk-version=8.0 -fcuda-include-gpubinary %t -emit-llvm -o - %s | FileCheck --check-prefix=COVMAP %s +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -triple x86_64-linux-gnu -target-sdk-version=8.0 -fcuda-include-gpubinary %t -emit-llvm-only -o - %s | FileCheck --check-prefix=MAPPING %s + +#include "Inputs/cuda.h" + +// PGOGEN-NOT: @__profn_{{.*kernel.*}} = +// COVMAP-COUNT-2: section "__llvm_covfun", comdat +// COVMAP-NOT: section "__llvm_covfun", comdat +// MAPPING-NOT: {{.*dfn.*}}: +// MAPPING-NOT: {{.*kernel.*}}: + +__device__ void dfn(int i) {} + +__global__ void kernel(int i) { dfn(i); } + +void host(void) { + kernel<<<1, 1>>>(1); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 276c8dd - [clang][codegen] Refactor argument loading in function prolog. NFC.
Author: Michael Liao Date: 2020-05-05T15:31:51-04:00 New Revision: 276c8dde0b58cfe29035448a27e16eff9fcf2a5a URL: https://github.com/llvm/llvm-project/commit/276c8dde0b58cfe29035448a27e16eff9fcf2a5a DIFF: https://github.com/llvm/llvm-project/commit/276c8dde0b58cfe29035448a27e16eff9fcf2a5a.diff LOG: [clang][codegen] Refactor argument loading in function prolog. NFC. Summary: - Skip copying function arguments and unnecessary casting by using them directly. Reviewers: rjmccall, kerbowa, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79394 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/CodeGenFunction.h Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 55f106e7c300..44f298892ecf 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1016,8 +1016,8 @@ static void forConstantArrayExpansion(CodeGenFunction &CGF, } } -void CodeGenFunction::ExpandTypeFromArgs( -QualType Ty, LValue LV, SmallVectorImpl::iterator &AI) { +void CodeGenFunction::ExpandTypeFromArgs(QualType Ty, LValue LV, + llvm::Function::arg_iterator &AI) { assert(LV.isSimple() && "Unexpected non-simple lvalue during struct expansion."); @@ -1046,17 +1046,17 @@ void CodeGenFunction::ExpandTypeFromArgs( ExpandTypeFromArgs(FD->getType(), SubLV, AI); } } else if (isa(Exp.get())) { -auto realValue = *AI++; -auto imagValue = *AI++; +auto realValue = &*AI++; +auto imagValue = &*AI++; EmitStoreOfComplex(ComplexPairTy(realValue, imagValue), LV, /*init*/ true); } else { // Call EmitStoreOfScalar except when the lvalue is a bitfield to emit a // primitive store. assert(isa(Exp.get())); if (LV.isBitField()) - EmitStoreThroughLValue(RValue::get(*AI++), LV); + EmitStoreThroughLValue(RValue::get(&*AI++), LV); else - EmitStoreOfScalar(*AI++, LV); + EmitStoreOfScalar(&*AI++, LV); } } @@ -2323,19 +2323,13 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // simplify. ClangToLLVMArgMapping IRFunctionArgs(CGM.getContext(), FI); - // Flattened function arguments. - SmallVector FnArgs; - FnArgs.reserve(IRFunctionArgs.totalIRArgs()); - for (auto &Arg : Fn->args()) { -FnArgs.push_back(&Arg); - } - assert(FnArgs.size() == IRFunctionArgs.totalIRArgs()); + assert(Fn->arg_size() == IRFunctionArgs.totalIRArgs()); // If we're using inalloca, all the memory arguments are GEPs off of the last // parameter, which is a pointer to the complete memory area. Address ArgStruct = Address::invalid(); if (IRFunctionArgs.hasInallocaArg()) { -ArgStruct = Address(FnArgs[IRFunctionArgs.getInallocaArgNo()], +ArgStruct = Address(Fn->getArg(IRFunctionArgs.getInallocaArgNo()), FI.getArgStructAlignment()); assert(ArgStruct.getType() == FI.getArgStruct()->getPointerTo()); @@ -2343,7 +2337,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // Name the struct return parameter. if (IRFunctionArgs.hasSRetArg()) { -auto AI = cast(FnArgs[IRFunctionArgs.getSRetArgNo()]); +auto AI = Fn->getArg(IRFunctionArgs.getSRetArgNo()); AI->setName("agg.result"); AI->addAttr(llvm::Attribute::NoAlias); } @@ -2394,7 +2388,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, case ABIArgInfo::Indirect: { assert(NumIRArgs == 1); - Address ParamAddr = Address(FnArgs[FirstIRArg], ArgI.getIndirectAlign()); + Address ParamAddr = + Address(Fn->getArg(FirstIRArg), ArgI.getIndirectAlign()); if (!hasScalarEvaluationKind(Ty)) { // Aggregates and complex variables are accessed by reference. All we @@ -2436,8 +2431,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, ArgI.getCoerceToType() == ConvertType(Ty) && ArgI.getDirectOffset() == 0) { assert(NumIRArgs == 1); -llvm::Value *V = FnArgs[FirstIRArg]; -auto AI = cast(V); +auto AI = Fn->getArg(FirstIRArg); if (const ParmVarDecl *PVD = dyn_cast(Arg)) { if (getNonNullAttr(CurCodeDecl, PVD, PVD->getType(), @@ -2499,6 +2493,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // LLVM expects swifterror parameters to be used in very restricted // ways. Copy the value into a less-restricted temporary. +llvm::Value *V = AI; if (FI.getExtParameterInfo(ArgNo).getABI() == ParameterABI::SwiftErrorResult) { QualType pointeeTy = Ty->getPointeeType(); @@ -2560,7 +2555,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, assert(STy->getNumElements() == NumIRArgs); for (unsigned
[clang] 9142c0b - [clang][codegen] Hoist parameter attribute setting in function prolog.
Author: Michael Liao Date: 2020-05-05T15:31:51-04:00 New Revision: 9142c0b46bfea13d9348ab3d1d706a10ad9e5c8e URL: https://github.com/llvm/llvm-project/commit/9142c0b46bfea13d9348ab3d1d706a10ad9e5c8e DIFF: https://github.com/llvm/llvm-project/commit/9142c0b46bfea13d9348ab3d1d706a10ad9e5c8e.diff LOG: [clang][codegen] Hoist parameter attribute setting in function prolog. Summary: - If the coerced type is still a pointer, it should be set with proper parameter attributes, such as `noalias`, `nonnull`, and etc. Hoist that (pointer) parameter attribute setting so that the coerced pointer parameter could be marked properly. Depends on D79394 Reviewers: rjmccall, kerbowa, yaxunl Subscribers: jvesely, nhaehnle, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79395 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 44f298892ecf..e336741d9111 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2425,15 +2425,18 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, case ABIArgInfo::Extend: case ABIArgInfo::Direct: { - - // If we have the trivial case, handle it with no muss and fuss. - if (!isa(ArgI.getCoerceToType()) && - ArgI.getCoerceToType() == ConvertType(Ty) && - ArgI.getDirectOffset() == 0) { + auto AI = Fn->getArg(FirstIRArg); + llvm::Type *LTy = ConvertType(Arg->getType()); + + // Prepare parameter attributes. So far, only attributes for pointer + // parameters are prepared. See + // http://llvm.org/docs/LangRef.html#paramattrs. + if (ArgI.getDirectOffset() == 0 && LTy->isPointerTy() && + ArgI.getCoerceToType()->isPointerTy()) { assert(NumIRArgs == 1); -auto AI = Fn->getArg(FirstIRArg); if (const ParmVarDecl *PVD = dyn_cast(Arg)) { + // Set `nonnull` attribute if any. if (getNonNullAttr(CurCodeDecl, PVD, PVD->getType(), PVD->getFunctionScopeIndex()) && !CGM.getCodeGenOpts().NullPointerIsValid) @@ -2471,6 +2474,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, AI->addAttr(llvm::Attribute::NonNull); } + // Set `align` attribute if any. const auto *AVAttr = PVD->getAttr(); if (!AVAttr) if (const auto *TOTy = dyn_cast(OTy)) @@ -2488,8 +2492,17 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, } } +// Set 'noalias' if an argument type has the `restrict` qualifier. if (Arg->getType().isRestrictQualified()) AI->addAttr(llvm::Attribute::NoAlias); + } + + // Prepare the argument value. If we have the trivial case, handle it + // with no muss and fuss. + if (!isa(ArgI.getCoerceToType()) && + ArgI.getCoerceToType() == ConvertType(Ty) && + ArgI.getDirectOffset() == 0) { +assert(NumIRArgs == 1); // LLVM expects swifterror parameters to be used in very restricted // ways. Copy the value into a less-restricted temporary. diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 6e4de1f0f5c3..8aeb0f759e6c 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -67,3 +67,10 @@ __global__ void kernel6(struct T t) { t.x[0][0] += 1.f; t.x[1][0] += 2.f; } + +// Check that coerced pointers retain the noalias attribute when qualified with __restrict. +// CHECK: define amdgpu_kernel void @_Z7kernel7Pi(i32 addrspace(1)* noalias %x.coerce) +// HOST: define void @_Z22__device_stub__kernel7Pi(i32* noalias %x) +__global__ void kernel7(int *__restrict x) { + x[0]++; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 81ae2a8 - [clang] Fix '-Wunused-variable' warnings. NFC
Author: Michael Liao Date: 2023-12-24T22:00:57-05:00 New Revision: 81ae2a8bb01d38162e0269fc6819584af6d60b03 URL: https://github.com/llvm/llvm-project/commit/81ae2a8bb01d38162e0269fc6819584af6d60b03 DIFF: https://github.com/llvm/llvm-project/commit/81ae2a8bb01d38162e0269fc6819584af6d60b03.diff LOG: [clang] Fix '-Wunused-variable' warnings. NFC Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 4783affd3220bc..70dc7e54aca125 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3203,13 +3203,13 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D, options::OPT_fstrict_float_cast_overflow, false)) CmdArgs.push_back("-fno-strict-float-cast-overflow"); - if (const Arg *A = Args.getLastArg(options::OPT_fcx_limited_range)) + if (Args.hasArg(options::OPT_fcx_limited_range)) CmdArgs.push_back("-fcx-limited-range"); - if (const Arg *A = Args.getLastArg(options::OPT_fcx_fortran_rules)) + if (Args.hasArg(options::OPT_fcx_fortran_rules)) CmdArgs.push_back("-fcx-fortran-rules"); - if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_limited_range)) + if (Args.hasArg(options::OPT_fno_cx_limited_range)) CmdArgs.push_back("-fno-cx-limited-range"); - if (const Arg *A = Args.getLastArg(options::OPT_fno_cx_fortran_rules)) + if (Args.hasArg(options::OPT_fno_cx_fortran_rules)) CmdArgs.push_back("-fno-cx-fortran-rules"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 73ab5fd - [clang] Fix shared build. NFC.
Author: Michael Liao Date: 2022-03-30T14:05:14-04:00 New Revision: 73ab5fd17b5726543554621410124ebae953dc6b URL: https://github.com/llvm/llvm-project/commit/73ab5fd17b5726543554621410124ebae953dc6b DIFF: https://github.com/llvm/llvm-project/commit/73ab5fd17b5726543554621410124ebae953dc6b.diff LOG: [clang] Fix shared build. NFC. Added: Modified: clang/lib/ExtractAPI/CMakeLists.txt Removed: diff --git a/clang/lib/ExtractAPI/CMakeLists.txt b/clang/lib/ExtractAPI/CMakeLists.txt index 044caa0922483..f194ae342c20f 100644 --- a/clang/lib/ExtractAPI/CMakeLists.txt +++ b/clang/lib/ExtractAPI/CMakeLists.txt @@ -14,4 +14,5 @@ add_clang_library(clangExtractAPI clangBasic clangFrontend clangIndex + clangLex ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 036aeac - [Testing] Fix the shared build. NFC.
Author: Michael Liao Date: 2022-04-22T02:46:54-04:00 New Revision: 036aeac36c00f4390e861118f536150b366beaaf URL: https://github.com/llvm/llvm-project/commit/036aeac36c00f4390e861118f536150b366beaaf DIFF: https://github.com/llvm/llvm-project/commit/036aeac36c00f4390e861118f536150b366beaaf.diff LOG: [Testing] Fix the shared build. NFC. Added: Modified: clang/lib/Testing/CMakeLists.txt Removed: diff --git a/clang/lib/Testing/CMakeLists.txt b/clang/lib/Testing/CMakeLists.txt index 68ed32ba85b1e..49b6787959bc1 100644 --- a/clang/lib/Testing/CMakeLists.txt +++ b/clang/lib/Testing/CMakeLists.txt @@ -16,8 +16,11 @@ add_llvm_library(clangTesting clang_target_link_libraries(clangTesting PRIVATE + clangAST clangBasic clangFrontend + clangLex + clangSerialization ) target_link_libraries(clangTesting ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r370763 - [clangd] Remove redundant semi-colon.
Author: hliao Date: Tue Sep 3 08:02:46 2019 New Revision: 370763 URL: http://llvm.org/viewvc/llvm-project?rev=370763&view=rev Log: [clangd] Remove redundant semi-colon. Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=370763&r1=370762&r2=370763&view=diff == --- clang-tools-extra/trunk/clangd/FindTarget.cpp (original) +++ clang-tools-extra/trunk/clangd/FindTarget.cpp Tue Sep 3 08:02:46 2019 @@ -364,7 +364,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ REL_CASE(TemplateInstantiation); REL_CASE(TemplatePattern); #undef REL_CASE - }; + } llvm_unreachable("Unhandled DeclRelation enum"); } llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclRelationSet RS) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a3490e3 - Remove trailing `;`. NFC.
Author: Michael Liao Date: 2020-01-14T16:52:20-05:00 New Revision: a3490e3e3d38d502179329f76138d96c5b2bab88 URL: https://github.com/llvm/llvm-project/commit/a3490e3e3d38d502179329f76138d96c5b2bab88 DIFF: https://github.com/llvm/llvm-project/commit/a3490e3e3d38d502179329f76138d96c5b2bab88.diff LOG: Remove trailing `;`. NFC. Added: Modified: clang/lib/Tooling/Syntax/Tree.cpp Removed: diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp index 9f028c0be3b4..9a6270ec4cce 100644 --- a/clang/lib/Tooling/Syntax/Tree.cpp +++ b/clang/lib/Tooling/Syntax/Tree.cpp @@ -29,7 +29,7 @@ static void traverse(syntax::Node *N, traverse(static_cast(N), [&](const syntax::Node *N) { Visit(const_cast(N)); }); -}; +} } // namespace syntax::Arena::Arena(SourceManager &SourceMgr, const LangOptions &LangOpts, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r364428 - Make CodeGen depend on ASTMatchers
That change was added long ago to fix the shared library build. Possibly, there are changes removing that dependency then. Just verified that removing that dependency is just fine. On Thu, Sep 10, 2020 at 6:48 AM Vassil Vassilev wrote: > > Hello, > >IIUC, clang's CodeGen does not immediately depend on ASTMatchers. I > was wondering what is the reason for inserting such a dependency to fix > the shared library builds? > >Can you give more details about the failure you are fixing? > >Sorry for the late question. > > Best, Vassil > On 6/26/19 5:13 PM, Michael Liao via cfe-commits wrote: > > Author: hliao > > Date: Wed Jun 26 07:13:43 2019 > > New Revision: 364428 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=364428&view=rev > > Log: > > Make CodeGen depend on ASTMatchers > > > > - Shared library builds are broken due to the missing dependency. > > > > Modified: > > cfe/trunk/lib/CodeGen/CMakeLists.txt > > > > Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt > > URL: > > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=364428&r1=364427&r2=364428&view=diff > > == > > --- cfe/trunk/lib/CodeGen/CMakeLists.txt (original) > > +++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Jun 26 07:13:43 2019 > > @@ -101,6 +101,7 @@ add_clang_library(clangCodeGen > > LINK_LIBS > > clangAnalysis > > clangAST > > + clangASTMatchers > > clangBasic > > clangFrontend > > clangLex > > > > > > ___ > > cfe-commits mailing list > > cfe-commits@lists.llvm.org > > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b22d450 - Remove dependency on clangASTMatchers.
Author: Michael Liao Date: 2020-09-10T22:17:48-04:00 New Revision: b22d45049682d1461b6b786f159681e2e5c2ce24 URL: https://github.com/llvm/llvm-project/commit/b22d45049682d1461b6b786f159681e2e5c2ce24 DIFF: https://github.com/llvm/llvm-project/commit/b22d45049682d1461b6b786f159681e2e5c2ce24.diff LOG: Remove dependency on clangASTMatchers. - It seems no long required for shared library builds. Added: Modified: clang/lib/CodeGen/CMakeLists.txt Removed: diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt index f47ecd9bf846..4039277707c5 100644 --- a/clang/lib/CodeGen/CMakeLists.txt +++ b/clang/lib/CodeGen/CMakeLists.txt @@ -92,7 +92,6 @@ add_clang_library(clangCodeGen LINK_LIBS clangAnalysis clangAST - clangASTMatchers clangBasic clangFrontend clangLex ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r364428 - Make CodeGen depend on ASTMatchers
b22d4504968 was committed last night. On Fri, Sep 11, 2020 at 9:30 AM Vassil Vassilev wrote: > > On 9/11/20 5:13 AM, Michael LIAO wrote: > > That change was added long ago to fix the shared library build. > > Possibly, there are changes removing that dependency then. Just > > verified that removing that dependency is just fine. > > >That's great! Would you commit that change or should I? > > > > > > On Thu, Sep 10, 2020 at 6:48 AM Vassil Vassilev > > wrote: > >> Hello, > >> > >> IIUC, clang's CodeGen does not immediately depend on ASTMatchers. I > >> was wondering what is the reason for inserting such a dependency to fix > >> the shared library builds? > >> > >> Can you give more details about the failure you are fixing? > >> > >> Sorry for the late question. > >> > >> Best, Vassil > >> On 6/26/19 5:13 PM, Michael Liao via cfe-commits wrote: > >>> Author: hliao > >>> Date: Wed Jun 26 07:13:43 2019 > >>> New Revision: 364428 > >>> > >>> URL: http://llvm.org/viewvc/llvm-project?rev=364428&view=rev > >>> Log: > >>> Make CodeGen depend on ASTMatchers > >>> > >>> - Shared library builds are broken due to the missing dependency. > >>> > >>> Modified: > >>> cfe/trunk/lib/CodeGen/CMakeLists.txt > >>> > >>> Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt > >>> URL: > >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=364428&r1=364427&r2=364428&view=diff > >>> == > >>> --- cfe/trunk/lib/CodeGen/CMakeLists.txt (original) > >>> +++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Jun 26 07:13:43 2019 > >>> @@ -101,6 +101,7 @@ add_clang_library(clangCodeGen > >>> LINK_LIBS > >>> clangAnalysis > >>> clangAST > >>> + clangASTMatchers > >>> clangBasic > >>> clangFrontend > >>> clangLex > >>> > >>> > >>> ___ > >>> cfe-commits mailing list > >>> cfe-commits@lists.llvm.org > >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4d4f092 - [clang][codegen] Skip adding default function attributes on intrinsics.
Author: Michael Liao Date: 2020-09-16T14:10:05-04:00 New Revision: 4d4f0922837de3f1aa9862ae8a8d941b3b6e5f78 URL: https://github.com/llvm/llvm-project/commit/4d4f0922837de3f1aa9862ae8a8d941b3b6e5f78 DIFF: https://github.com/llvm/llvm-project/commit/4d4f0922837de3f1aa9862ae8a8d941b3b6e5f78.diff LOG: [clang][codegen] Skip adding default function attributes on intrinsics. - After loading builtin bitcode for linking, skip adding default function attributes on LLVM intrinsics as their attributes are well-defined and retrieved directly from internal definitions. Adding extra attributes on intrinsics results in inconsistent result when `-save-temps` is present. Also, that makes few optimizations conservative. Differential Revision: https://reviews.llvm.org/D87761 Added: clang/test/CodeGenCUDA/Inputs/device-lib-code.ll clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip Modified: clang/lib/CodeGen/CodeGenAction.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 5a6ce0f5dbd5..eda4beff78b7 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -245,8 +245,13 @@ namespace clang { bool LinkInModules() { for (auto &LM : LinkModules) { if (LM.PropagateAttrs) - for (Function &F : *LM.Module) + for (Function &F : *LM.Module) { +// Skip intrinsics. Keep consistent with how intrinsics are created +// in LLVM IR. +if (F.isIntrinsic()) + continue; Gen->CGM().addDefaultFunctionDefinitionAttributes(F); + } CurLinkModule = LM.Module.get(); diff --git a/clang/test/CodeGenCUDA/Inputs/device-lib-code.ll b/clang/test/CodeGenCUDA/Inputs/device-lib-code.ll new file mode 100644 index ..43ec911fb02c --- /dev/null +++ b/clang/test/CodeGenCUDA/Inputs/device-lib-code.ll @@ -0,0 +1,5 @@ +define linkonce_odr protected float @__ocml_fma_f32(float %0, float %1, float %2) local_unnamed_addr { + %4 = tail call float @llvm.fma.f32(float %0, float %1, float %2) + ret float %4 +} +declare float @llvm.fma.f32(float, float, float) diff --git a/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip b/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip new file mode 100644 index ..9e3e436200fc --- /dev/null +++ b/clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip @@ -0,0 +1,18 @@ +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc -disable-llvm-passes -o %t.bc %S/Inputs/device-lib-code.ll +// RUN: %clang_cc1 -x hip -fcuda-is-device -triple amdgcn-amd-amdhsa -mlink-builtin-bitcode %t.bc -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s + +#include "Inputs/cuda.h" + +extern "C" __device__ float __ocml_fma_f32(float x, float y, float z); + +__device__ float foo(float x) { + return __ocml_fma_f32(x, x, x); +} + +// CHECK: {{^}}define{{.*}} @__ocml_fma_f32{{.*}} [[ATTR1:#[0-9]+]] +// CHECK: {{^}}declare{{.*}} @llvm.fma.f32{{.*}} [[ATTR2:#[0-9]+]] +// CHECK: attributes [[ATTR1]] = { convergent +// CHECK: attributes [[ATTR2]] = { +// CHECK-NOT: convergent +// CHECK: } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5dbf80c - [clang][codegen] Annotate `correctly-rounded-divide-sqrt-fp-math` fn-attr for OpenCL only.
Author: Michael Liao Date: 2020-09-28T11:40:32-04:00 New Revision: 5dbf80cad9556e222c4383960007fc0b27ea9541 URL: https://github.com/llvm/llvm-project/commit/5dbf80cad9556e222c4383960007fc0b27ea9541 DIFF: https://github.com/llvm/llvm-project/commit/5dbf80cad9556e222c4383960007fc0b27ea9541.diff LOG: [clang][codegen] Annotate `correctly-rounded-divide-sqrt-fp-math` fn-attr for OpenCL only. - `-cl-fp32-correctly-rounded-divide-sqrt` is an OpenCL-specific option and `correctly-rounded-divide-sqrt-fp-math` should be added for OpenCL at most. Differential revision: https://reviews.llvm.org/D88303 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGen/complex-builtins.c clang/test/CodeGen/complex-libcalls.c clang/test/CodeGen/math-builtins.c clang/test/CodeGen/math-libcalls.c Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index ff41764a4a4d..9ccbe87fab66 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1794,9 +1794,11 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name, llvm::utostr(CodeGenOpts.SSPBufferSize)); FuncAttrs.addAttribute("no-signed-zeros-fp-math", llvm::toStringRef(LangOpts.NoSignedZero)); -FuncAttrs.addAttribute( -"correctly-rounded-divide-sqrt-fp-math", -llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); +if (getLangOpts().OpenCL) { + FuncAttrs.addAttribute( + "correctly-rounded-divide-sqrt-fp-math", + llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); +} // TODO: Reciprocal estimate codegen options should apply to instructions? const std::vector &Recips = CodeGenOpts.Reciprocals; diff --git a/clang/test/CodeGen/complex-builtins.c b/clang/test/CodeGen/complex-builtins.c index 7ee2d6d84857..96c0e7117016 100644 --- a/clang/test/CodeGen/complex-builtins.c +++ b/clang/test/CodeGen/complex-builtins.c @@ -197,10 +197,8 @@ void foo(float f) { // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ctanhl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] }; - // NO__ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } -// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } -// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } - diff --git a/clang/test/CodeGen/complex-libcalls.c b/clang/test/CodeGen/complex-libcalls.c index 248041788293..9bd419a83821 100644 --- a/clang/test/CodeGen/complex-libcalls.c +++ b/clang/test/CodeGen/complex-libcalls.c @@ -197,10 +197,8 @@ void foo(float f) { // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ctanhl({ x86_fp80, x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]] }; - // NO__ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } -// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } -// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } - diff --git a/clang/test/CodeGen/math-builtins.c b/clang/test/CodeGen/math-builtins.c index 13e9c13096f2..8aadd050ee89 100644 --- a/clang/test/CodeGen/math-builtins.c +++ b/clang/test/CodeGen/math-builtins.c @@ -577,13 +577,12 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) { // HAS_ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INTRINSIC]] }; - // NO__ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } // NO__ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} } -// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } // NO__ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} } -// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind "correctly{{.*}} } +// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} } // HAS_ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} } // HAS_ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} } // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} } diff --git a/clang/test/CodeGen/math-libcalls.c b/clang/test/CodeGen/math-libcalls.c index 97a87beb12ec..51bdc5218fde 100644 --- a/clang/test/CodeGen/math-libcalls.c +++ b/clang/test/CodeGen/math-libcalls.c @@ -532,13 +532,12 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) { // HAS_ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INT
[clang] bb8d20d - [cuda][hip] Fix typoes in header wrappers.
Author: Michael Liao Date: 2020-12-21T13:02:47-05:00 New Revision: bb8d20d9f3bb955ae6f6143d24749faf61d573a9 URL: https://github.com/llvm/llvm-project/commit/bb8d20d9f3bb955ae6f6143d24749faf61d573a9 DIFF: https://github.com/llvm/llvm-project/commit/bb8d20d9f3bb955ae6f6143d24749faf61d573a9.diff LOG: [cuda][hip] Fix typoes in header wrappers. Added: Modified: clang/lib/Headers/cuda_wrappers/algorithm clang/lib/Headers/cuda_wrappers/new Removed: diff --git a/clang/lib/Headers/cuda_wrappers/algorithm b/clang/lib/Headers/cuda_wrappers/algorithm index 01af18360d8d..f14a0b00bb04 100644 --- a/clang/lib/Headers/cuda_wrappers/algorithm +++ b/clang/lib/Headers/cuda_wrappers/algorithm @@ -1,4 +1,4 @@ -/*=== complex - CUDA wrapper for === +/*=== algorithm - CUDA wrapper for -=== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/clang/lib/Headers/cuda_wrappers/new b/clang/lib/Headers/cuda_wrappers/new index 7f255314056a..d5fb3b7011de 100644 --- a/clang/lib/Headers/cuda_wrappers/new +++ b/clang/lib/Headers/cuda_wrappers/new @@ -1,4 +1,4 @@ -/*=== complex - CUDA wrapper for --=== +/*=== new - CUDA wrapper for -=== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 23c6d15 - [amdgpu] Add `llvm.amdgcn.endpgm` support.
Author: Michael Liao Date: 2020-11-05T19:06:50-05:00 New Revision: 23c6d1501d80073784cab367d30d50419ffa5706 URL: https://github.com/llvm/llvm-project/commit/23c6d1501d80073784cab367d30d50419ffa5706 DIFF: https://github.com/llvm/llvm-project/commit/23c6d1501d80073784cab367d30d50419ffa5706.diff LOG: [amdgpu] Add `llvm.amdgcn.endpgm` support. - `llvm.amdgcn.endpgm` is added to enable "abort" support. Differential Revision: https://reviews.llvm.org/D90809 Added: llvm/test/CodeGen/AMDGPU/amd.endpgm.ll Modified: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/test/CodeGenCUDA/builtins-amdgcn.cu llvm/include/llvm/IR/IntrinsicsAMDGPU.td llvm/lib/Target/AMDGPU/SOPInstructions.td Removed: diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index f5901e6f8f3b..123a7ad212da 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -214,6 +214,8 @@ BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc") BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc") BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc") +BUILTIN(__builtin_amdgcn_endpgm, "v", "nr") + //===--===// // R600-NI only builtins. //===--===// diff --git a/clang/test/CodeGenCUDA/builtins-amdgcn.cu b/clang/test/CodeGenCUDA/builtins-amdgcn.cu index 1c3a79064595..8f0d0d0801bd 100644 --- a/clang/test/CodeGenCUDA/builtins-amdgcn.cu +++ b/clang/test/CodeGenCUDA/builtins-amdgcn.cu @@ -16,3 +16,9 @@ void test_ds_fmax(float src) { __shared__ float shared; volatile float x = __builtin_amdgcn_ds_fmaxf(&shared, src, 0, 0, false); } + +// CHECK-LABEL: @_Z6endpgmv( +// CHECK: call void @llvm.amdgcn.endpgm() +__global__ void endpgm() { + __builtin_amdgcn_endpgm(); +} diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td index 304377ce28ab..bc04fa40f2a8 100644 --- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td +++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td @@ -1577,6 +1577,10 @@ def int_amdgcn_wqm_vote : Intrinsic<[llvm_i1_ty], // FIXME: Should this be IntrNoMem, IntrHasSideEffects, or IntrWillReturn? def int_amdgcn_kill : Intrinsic<[], [llvm_i1_ty], []>; +def int_amdgcn_endpgm : GCCBuiltin<"__builtin_amdgcn_endpgm">, + Intrinsic<[], [], [IntrNoReturn, IntrCold, IntrNoMem, IntrHasSideEffects] +>; + // Copies the active channels of the source value to the destination value, // with the guarantee that the source value is computed as if the entire // program were executed in Whole Wavefront Mode, i.e. with all channels diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td index 08966d7d62eb..00527171ff11 100644 --- a/llvm/lib/Target/AMDGPU/SOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td @@ -1118,6 +1118,7 @@ let isTerminator = 1 in { def S_ENDPGM : SOPP_Pseudo<"s_endpgm", (ins EndpgmImm:$simm16), "$simm16"> { let isBarrier = 1; let isReturn = 1; + let hasSideEffects = 1; } def S_ENDPGM_SAVED : SOPP_Pseudo<"s_endpgm_saved", (ins)> { @@ -1328,6 +1329,11 @@ def : GCNPat < (S_ENDPGM (i16 0)) >; +def : GCNPat < + (int_amdgcn_endpgm), +(S_ENDPGM (i16 0)) +>; + def : GCNPat < (i64 (ctpop i64:$src)), (i64 (REG_SEQUENCE SReg_64, diff --git a/llvm/test/CodeGen/AMDGPU/amd.endpgm.ll b/llvm/test/CodeGen/AMDGPU/amd.endpgm.ll new file mode 100644 index ..ac9cd0699118 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/amd.endpgm.ll @@ -0,0 +1,50 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck %s + +define amdgpu_kernel void @test0() { +; CHECK-LABEL: test0: +; CHECK: ; %bb.0: +; CHECK-NEXT:s_endpgm + tail call void @llvm.amdgcn.endpgm() + unreachable +} + +define void @test1() { +; CHECK-LABEL: test1: +; CHECK: ; %bb.0: +; CHECK-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) +; CHECK-NEXT:s_endpgm + tail call void @llvm.amdgcn.endpgm() + unreachable +} + +define amdgpu_kernel void @test2(i32* %p, i32 %x) { +; CHECK-LABEL: test2: +; CHECK: ; %bb.0: +; CHECK-NEXT:s_load_dword s2, s[0:1], 0x2c +; CHECK-NEXT:s_waitcnt lgkmcnt(0) +; CHECK-NEXT:s_cmp_lt_i32 s2, 1 +; CHECK-NEXT:s_cbranch_scc0 BB2_2 +; CHECK-NEXT: ; %bb.1: ; %else +; CHECK-NEXT:s_load_dwordx2 s[0:1], s[0:1], 0x24 +; CHECK-NEXT:v_mov_b32_e32 v2, s2 +; CHECK-NEXT:s_waitcnt lgkmcnt(0) +; CHECK-NEXT:v_mov_b32_e32 v0, s0 +; CHECK-NEXT:v_mov_b32_e32 v1, s1 +; CHECK-NEXT:flat_store_dword v[0:1], v2 +; CHECK-NEXT:s_endpgm +; CHECK-NEXT: BB2_2: ; %then +; CHECK-NEXT:s_endpgm + %cond = icmp sgt i32 %x, 0 + br i1 %cond, labe
[clang] 8920ef0 - [hip] Remove the coercion on aggregate kernel arguments.
Author: Michael Liao Date: 2020-11-12T21:19:30-05:00 New Revision: 8920ef06a138c46b208fb6471d500261c4b9bacc URL: https://github.com/llvm/llvm-project/commit/8920ef06a138c46b208fb6471d500261c4b9bacc DIFF: https://github.com/llvm/llvm-project/commit/8920ef06a138c46b208fb6471d500261c4b9bacc.diff LOG: [hip] Remove the coercion on aggregate kernel arguments. - If an aggregate argument is indirectly accessed within kernels, direct passing results in unpromotable `alloca`, which degrade performance significantly. InferAddrSpace pass is enhanced in [D91121](https://reviews.llvm.org/D91121) to take the assumption that generic pointers loaded from the constant memory could be regarded global ones. The need for the coercion on aggregate arguments is mitigated. Differential Revision: https://reviews.llvm.org/D89980 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu clang/test/CodeGenCUDA/kernel-args.cu Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 63502ccf7a38..1e5920322ecd 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -8712,35 +8712,9 @@ class AMDGPUABIInfo final : public DefaultABIInfo { bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const override; - // Coerce HIP pointer arguments from generic pointers to global ones. + // Coerce HIP scalar pointer arguments from generic pointers to global ones. llvm::Type *coerceKernelArgumentType(llvm::Type *Ty, unsigned FromAS, unsigned ToAS) const { -// Structure types. -if (auto STy = dyn_cast(Ty)) { - SmallVector EltTys; - bool Changed = false; - for (auto T : STy->elements()) { -auto NT = coerceKernelArgumentType(T, FromAS, ToAS); -EltTys.push_back(NT); -Changed |= (NT != T); - } - // Skip if there is no change in element types. - if (!Changed) -return STy; - if (STy->hasName()) -return llvm::StructType::create( -EltTys, (STy->getName() + ".coerce").str(), STy->isPacked()); - return llvm::StructType::get(getVMContext(), EltTys, STy->isPacked()); -} -// Array types. -if (auto ATy = dyn_cast(Ty)) { - auto T = ATy->getElementType(); - auto NT = coerceKernelArgumentType(T, FromAS, ToAS); - // Skip if there is no change in that element type. - if (NT == T) -return ATy; - return llvm::ArrayType::get(NT, ATy->getNumElements()); -} // Single value types. if (Ty->isPointerTy() && Ty->getPointerAddressSpace() == FromAS) return llvm::PointerType::get( diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index 2660a5f14f90..dc4659856026 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -9,8 +9,6 @@ // Coerced struct from `struct S` without all generic pointers lowered into // global ones. -// COMMON: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* } -// COMMON: %struct.T.coerce = type { [2 x float addrspace(1)*] } // On the host-side compilation, generic pointer won't be coerced. // HOST-NOT: %struct.S.coerce @@ -61,15 +59,17 @@ struct S { // `by-val` struct will be coerced into a similar struct with all generic // pointers lowerd into global ones. // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* %s.coerce1) -// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce) -// OPT: [[P0:%.*]] = extractvalue %struct.S.coerce %s.coerce, 0 -// OPT: [[P1:%.*]] = extractvalue %struct.S.coerce %s.coerce, 1 -// OPT: [[V0:%.*]] = load i32, i32 addrspace(1)* [[P0]], align 4 +// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S addrspace(4)*{{.*}} byref(%struct.S) align 8 %0) +// OPT: [[R0:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 0 +// OPT: [[P0:%.*]] = load i32*, i32* addrspace(4)* [[R0]], align 8 +// OPT: [[R1:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 1 +// OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8 +// OPT: [[V0:%.*]] = load i32, i32* [[P0]], align 4 // OPT: [[INC:%.*]] = add nsw i32 [[V0]], 1 -// OPT: store i32 [[INC]], i32 addrspace(1)* [[P0]], align 4 -// OPT: [[V1:%.*]] = load float, float addrspace(1)* [[P1]], align 4 +// OPT: store i32 [[INC]], i32* [[P0]], align 4 +// OPT: [[V1:%.*]] = load float, float* [[P1]], align 4 // OPT: [[ADD:%.*]] = fadd contract float [[V1]], 1.00e+00 -// OPT: store float [[ADD]], float addrspace(1)* [[P1]], align 4 +// OPT: store float [[ADD]
[clang] f375885 - [InferAddrSpace] Teach to handle assumed address space.
Author: Michael Liao Date: 2020-11-16T17:06:33-05:00 New Revision: f375885ab86d1b3e82269725c8e9aa49f347b4a7 URL: https://github.com/llvm/llvm-project/commit/f375885ab86d1b3e82269725c8e9aa49f347b4a7 DIFF: https://github.com/llvm/llvm-project/commit/f375885ab86d1b3e82269725c8e9aa49f347b4a7.diff LOG: [InferAddrSpace] Teach to handle assumed address space. - In certain cases, a generic pointer could be assumed as a pointer to the global memory space or other spaces. With a dedicated target hook to query that address space from a given value, infer-address-space pass could infer and propagate that to all its users. Differential Revision: https://reviews.llvm.org/D91121 Added: llvm/test/Transforms/InferAddressSpaces/AMDGPU/assumed-addrspace.ll Modified: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu llvm/docs/AMDGPUUsage.rst llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/Target/TargetMachine.h llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp llvm/test/CodeGen/AMDGPU/GlobalISel/divergent-control-flow.ll Removed: diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu index dc4659856026..da1f4b65f719 100644 --- a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -56,20 +56,24 @@ struct S { int *x; float *y; }; -// `by-val` struct will be coerced into a similar struct with all generic -// pointers lowerd into global ones. +// `by-val` struct is passed by-indirect-alias (a mix of by-ref and indirect +// by-val). However, the enhanced address inferring pass should be able to +// assume they are global pointers. +// // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* %s.coerce1) // COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S addrspace(4)*{{.*}} byref(%struct.S) align 8 %0) // OPT: [[R0:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 0 // OPT: [[P0:%.*]] = load i32*, i32* addrspace(4)* [[R0]], align 8 +// OPT: [[G0:%.*]] = addrspacecast i32* [[P0]] to i32 addrspace(1)* // OPT: [[R1:%.*]] = getelementptr inbounds %struct.S, %struct.S addrspace(4)* %0, i64 0, i32 1 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8 -// OPT: [[V0:%.*]] = load i32, i32* [[P0]], align 4 +// OPT: [[G1:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)* +// OPT: [[V0:%.*]] = load i32, i32 addrspace(1)* [[G0]], align 4 // OPT: [[INC:%.*]] = add nsw i32 [[V0]], 1 -// OPT: store i32 [[INC]], i32* [[P0]], align 4 -// OPT: [[V1:%.*]] = load float, float* [[P1]], align 4 +// OPT: store i32 [[INC]], i32 addrspace(1)* [[G0]], align 4 +// OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4 // OPT: [[ADD:%.*]] = fadd contract float [[V1]], 1.00e+00 -// OPT: store float [[ADD]], float* [[P1]], align 4 +// OPT: store float [[ADD]], float addrspace(1)* [[G1]], align 4 // OPT: ret void __global__ void kernel4(struct S s) { s.x[0]++; @@ -87,19 +91,24 @@ __global__ void kernel5(struct S *s) { struct T { float *x[2]; }; -// `by-val` array is also coerced. +// `by-val` array is passed by-indirect-alias (a mix of by-ref and indirect +// by-val). However, the enhanced address inferring pass should be able to +// assume they are global pointers. +// // HOST: define void @_Z22__device_stub__kernel61T(float* %t.coerce0, float* %t.coerce1) // COMMON-LABEL: define amdgpu_kernel void @_Z7kernel61T(%struct.T addrspace(4)*{{.*}} byref(%struct.T) align 8 %0) // OPT: [[R0:%.*]] = getelementptr inbounds %struct.T, %struct.T addrspace(4)* %0, i64 0, i32 0, i64 0 // OPT: [[P0:%.*]] = load float*, float* addrspace(4)* [[R0]], align 8 +// OPT: [[G0:%.*]] = addrspacecast float* [[P0]] to float addrspace(1)* // OPT: [[R1:%.*]] = getelementptr inbounds %struct.T, %struct.T addrspace(4)* %0, i64 0, i32 0, i64 1 // OPT: [[P1:%.*]] = load float*, float* addrspace(4)* [[R1]], align 8 -// OPT: [[V0:%.*]] = load float, float* [[P0]], align 4 +// OPT: [[G1:%.*]] = addrspacecast float* [[P1]] to float addrspace(1)* +// OPT: [[V0:%.*]] = load float, float addrspace(1)* [[G0]], align 4 // OPT: [[ADD0:%.*]] = fadd contract float [[V0]], 1.00e+00 -// OPT: store float [[ADD0]], float* [[P0]], align 4 -// OPT: [[V1:%.*]] = load float, float* [[P1]], align 4 +// OPT: store float [[ADD0]], float addrspace(1)* [[G0]], align 4 +// OPT: [[V1:%.*]] = load float, float addrspace(1)* [[G1]], align 4 // OPT: [[ADD1:%.*]] = fadd contract float [[V1]], 2.00e+00 -// OPT: store float [[AD
[clang] 8c36eaf - [clang][opencl][codegen] Remove the insertion of `correctly-rounded-divide-sqrt-fp-math` fn-attr.
Author: Michael Liao Date: 2020-10-01T11:07:39-04:00 New Revision: 8c36eaf0377285acb89c319582d9666e60f42007 URL: https://github.com/llvm/llvm-project/commit/8c36eaf0377285acb89c319582d9666e60f42007 DIFF: https://github.com/llvm/llvm-project/commit/8c36eaf0377285acb89c319582d9666e60f42007.diff LOG: [clang][opencl][codegen] Remove the insertion of `correctly-rounded-divide-sqrt-fp-math` fn-attr. - `-cl-fp32-correctly-rounded-divide-sqrt` is already handled in a per-instruction manner by annotating the accuracy required. There's no need to add that fn-attr. So far, there's no in-tree backend handling that attr and that OpenCL specific option. - In case that out-of-tree backends are broken, this change could be reverted if those backends could not be fixed. Differential Revision: https://reviews.llvm.org/D88424 Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/test/CodeGenOpenCL/amdgpu-attrs.cl clang/test/CodeGenOpenCL/fpmath.cl Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index ec7ddf8b5d9e..cb03e025e19e 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1794,11 +1794,6 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name, llvm::utostr(CodeGenOpts.SSPBufferSize)); FuncAttrs.addAttribute("no-signed-zeros-fp-math", llvm::toStringRef(LangOpts.NoSignedZero)); -if (getLangOpts().OpenCL) { - FuncAttrs.addAttribute( - "correctly-rounded-divide-sqrt-fp-math", - llvm::toStringRef(CodeGenOpts.CorrectlyRoundedDivSqrt)); -} // TODO: Reciprocal estimate codegen options should apply to instructions? const std::vector &Recips = CodeGenOpts.Reciprocals; diff --git a/clang/test/CodeGenOpenCL/amdgpu-attrs.cl b/clang/test/CodeGenOpenCL/amdgpu-attrs.cl index 13f8b1191c2b..9156c45f4939 100644 --- a/clang/test/CodeGenOpenCL/amdgpu-attrs.cl +++ b/clang/test/CodeGenOpenCL/amdgpu-attrs.cl @@ -190,5 +190,5 @@ kernel void default_kernel() { // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_SGPR_32_NUM_VGPR_64]] = {{.*}} "amdgpu-flat-work-group-size"="32,64" "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2" // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32_NUM_VGPR_64]] = {{.*}} "amdgpu-flat-work-group-size"="32,64" "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" "amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4" -// CHECK-DAG: attributes [[A_FUNCTION]] = {{.*}} "correctly-rounded-divide-sqrt-fp-math"="false" +// CHECK-DAG: attributes [[A_FUNCTION]] = {{.*}} // CHECK-DAG: attributes [[DEFAULT_KERNEL_ATTRS]] = {{.*}} "amdgpu-flat-work-group-size"="1,256" "amdgpu-implicitarg-num-bytes"="56" diff --git a/clang/test/CodeGenOpenCL/fpmath.cl b/clang/test/CodeGenOpenCL/fpmath.cl index 0108d909c94e..36cb8e68ea7c 100644 --- a/clang/test/CodeGenOpenCL/fpmath.cl +++ b/clang/test/CodeGenOpenCL/fpmath.cl @@ -7,7 +7,6 @@ typedef __attribute__(( ext_vector_type(4) )) float float4; float spscalardiv(float a, float b) { // CHECK: @spscalardiv - // CHECK: #[[ATTR:[0-9]+]] // CHECK: fdiv{{.*}}, // NODIVOPT: !fpmath ![[MD:[0-9]+]] // DIVOPT-NOT: !fpmath ![[MD:[0-9]+]] @@ -16,7 +15,6 @@ float spscalardiv(float a, float b) { float4 spvectordiv(float4 a, float4 b) { // CHECK: @spvectordiv - // CHECK: #[[ATTR2:[0-9]+]] // CHECK: fdiv{{.*}}, // NODIVOPT: !fpmath ![[MD]] // DIVOPT-NOT: !fpmath ![[MD]] @@ -38,18 +36,9 @@ void testdbllit(long *val) { #pragma OPENCL EXTENSION cl_khr_fp64 : enable double dpscalardiv(double a, double b) { // CHECK: @dpscalardiv - // CHECK: #[[ATTR]] // CHECK-NOT: !fpmath return a / b; } #endif -// CHECK: attributes #[[ATTR]] = { -// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false" -// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true" -// CHECK-SAME: } -// CHECK: attributes #[[ATTR2]] = { -// NODIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="false" -// DIVOPT-SAME: "correctly-rounded-divide-sqrt-fp-math"="true" -// CHECK-SAME: } // NODIVOPT: ![[MD]] = !{float 2.50e+00} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b21ad3b - Fix `-Wparentheses` warnings. NFC.
Author: Michael Liao Date: 2020-10-14T10:11:19-04:00 New Revision: b21ad3b66bce942ee6e0f5b1fcfdea31928005a7 URL: https://github.com/llvm/llvm-project/commit/b21ad3b66bce942ee6e0f5b1fcfdea31928005a7 DIFF: https://github.com/llvm/llvm-project/commit/b21ad3b66bce942ee6e0f5b1fcfdea31928005a7.diff LOG: Fix `-Wparentheses` warnings. NFC. Added: Modified: clang/lib/Sema/SemaExpr.cpp Removed: diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index a02db2293bcc..0407d5bb7f6c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6384,10 +6384,10 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, if (Context.isDependenceAllowed() && (Fn->isTypeDependent() || Expr::hasAnyTypeDependentArguments(ArgExprs))) { assert(!getLangOpts().CPlusPlus); -assert(Fn->containsErrors() || - llvm::any_of(ArgExprs, -[](clang::Expr *E) { return E->containsErrors(); }) && - "should only occur in error-recovery path."); +assert((Fn->containsErrors() || +llvm::any_of(ArgExprs, + [](clang::Expr *E) { return E->containsErrors(); })) && + "should only occur in error-recovery path."); QualType ReturnType = llvm::isa_and_nonnull(NDecl) ? dyn_cast(NDecl)->getCallResultType() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d8949a8 - [hip] Fix host object creation from fatbin
Author: Michael Liao Date: 2020-12-02T10:36:01-05:00 New Revision: d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0 URL: https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0 DIFF: https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0.diff LOG: [hip] Fix host object creation from fatbin - `__hip_fatbin` should a symbol in `.hip_fatbin` section. Differential Revision: https://reviews.llvm.org/D92418 Added: Modified: clang/lib/Driver/ToolChains/HIP.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp index a06835eee024..fc1103b48a99 100644 --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -178,8 +178,7 @@ void AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary( ObjStream << "# HIP Object Generator\n"; ObjStream << "# *** Automatically generated by Clang ***\n"; ObjStream << " .type __hip_fatbin,@object\n"; - ObjStream << " .section .hip_fatbin,\"aMS\",@progbits,1\n"; - ObjStream << " .data\n"; + ObjStream << " .section .hip_fatbin,\"a\",@progbits\n"; ObjStream << " .globl __hip_fatbin\n"; ObjStream << " .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign)) << "\n"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1ed506d - [clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC.
Author: Michael Liao Date: 2020-10-20T10:06:24-04:00 New Revision: 1ed506deaddb41870d22f5b48d52ba710e8d6c00 URL: https://github.com/llvm/llvm-project/commit/1ed506deaddb41870d22f5b48d52ba710e8d6c00 DIFF: https://github.com/llvm/llvm-project/commit/1ed506deaddb41870d22f5b48d52ba710e8d6c00.diff LOG: [clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC. Added: Modified: clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/PartialDiagnostic.h Removed: diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index f17b98f74038..3895e1f45894 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic { public: /// Copy constructor. When copied, this "takes" the diagnostic info from the /// input and neuters it. - DiagnosticBuilder(const DiagnosticBuilder &D) { + DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic(D) { DiagObj = D.DiagObj; DiagStorage = D.DiagStorage; IsActive = D.IsActive; diff --git a/clang/include/clang/Basic/PartialDiagnostic.h b/clang/include/clang/Basic/PartialDiagnostic.h index 9e017902b120..9ddf64d2de2c 100644 --- a/clang/include/clang/Basic/PartialDiagnostic.h +++ b/clang/include/clang/Basic/PartialDiagnostic.h @@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic { PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_) : StreamingDiagnostic(Allocator_), DiagID(DiagID) {} - PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) { + PartialDiagnostic(const PartialDiagnostic &Other) + : StreamingDiagnostic(Other), DiagID(Other.DiagID) { Allocator = Other.Allocator; if (Other.DiagStorage) { DiagStorage = getStorage(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e7a6915 - Revert "[clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC."
Author: Michael Liao Date: 2020-10-20T10:25:20-04:00 New Revision: e7a69158635a30cb673e443a3b95ece359c72cc1 URL: https://github.com/llvm/llvm-project/commit/e7a69158635a30cb673e443a3b95ece359c72cc1 DIFF: https://github.com/llvm/llvm-project/commit/e7a69158635a30cb673e443a3b95ece359c72cc1.diff LOG: Revert "[clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC." This reverts commit 1ed506deaddb41870d22f5b48d52ba710e8d6c00. Added: Modified: clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/PartialDiagnostic.h Removed: diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 3895e1f458948..f17b98f740385 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic { public: /// Copy constructor. When copied, this "takes" the diagnostic info from the /// input and neuters it. - DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic(D) { + DiagnosticBuilder(const DiagnosticBuilder &D) { DiagObj = D.DiagObj; DiagStorage = D.DiagStorage; IsActive = D.IsActive; diff --git a/clang/include/clang/Basic/PartialDiagnostic.h b/clang/include/clang/Basic/PartialDiagnostic.h index 9ddf64d2de2c5..9e017902b1205 100644 --- a/clang/include/clang/Basic/PartialDiagnostic.h +++ b/clang/include/clang/Basic/PartialDiagnostic.h @@ -49,8 +49,7 @@ class PartialDiagnostic : public StreamingDiagnostic { PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_) : StreamingDiagnostic(Allocator_), DiagID(DiagID) {} - PartialDiagnostic(const PartialDiagnostic &Other) - : StreamingDiagnostic(Other), DiagID(Other.DiagID) { + PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) { Allocator = Other.Allocator; if (Other.DiagStorage) { DiagStorage = getStorage(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1bcec29 - Only run when `arm` is registered. NFC.
Author: Michael Liao Date: 2020-10-21T09:30:07-04:00 New Revision: 1bcec29afb321976cdcaa632ee6a47567dd651a7 URL: https://github.com/llvm/llvm-project/commit/1bcec29afb321976cdcaa632ee6a47567dd651a7 DIFF: https://github.com/llvm/llvm-project/commit/1bcec29afb321976cdcaa632ee6a47567dd651a7.diff LOG: Only run when `arm` is registered. NFC. Added: Modified: clang/test/Driver/arm-float-abi.c Removed: diff --git a/clang/test/Driver/arm-float-abi.c b/clang/test/Driver/arm-float-abi.c index 74ba3fd3bc57..294f02444769 100644 --- a/clang/test/Driver/arm-float-abi.c +++ b/clang/test/Driver/arm-float-abi.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: not %clang %s -target armv7-apple-ios -mfloat-abi=hard 2>&1 | FileCheck -check-prefix=ARMV7-ERROR %s // RUN: %clang %s -target armv7-apple-ios -mfloat-abi=softfp -### 2>&1 | FileCheck -check-prefix=NOERROR %s // RUN: %clang %s -arch armv7 -target thumbv7-apple-darwin-eabi -mfloat-abi=hard -### 2>&1 | FileCheck -check-prefix=NOERROR %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a2fdf9d - [hip][cuda] Enable extended lambda support on Windows.
Author: Michael Liao Date: 2021-02-04T01:38:29-05:00 New Revision: a2fdf9d4d734732a6fa9288f1ffdf12bf8618123 URL: https://github.com/llvm/llvm-project/commit/a2fdf9d4d734732a6fa9288f1ffdf12bf8618123 DIFF: https://github.com/llvm/llvm-project/commit/a2fdf9d4d734732a6fa9288f1ffdf12bf8618123.diff LOG: [hip][cuda] Enable extended lambda support on Windows. - On Windows, extended lambda has extra issues due to the numbering schemes are different between the host compilation (Microsoft C++ ABI) and the device compilation (Itanium C++ ABI. Additional device side lambda number is required per lambda for the host compilation to correctly mangle the device-side lambda name. - A hybrid numbering context `MSHIPNumberingContext` is introduced to number a lambda for both host- and device-compilations. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D69322 Added: Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/DeclCXX.h clang/include/clang/AST/Mangle.h clang/include/clang/AST/MangleNumberingContext.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/CXXABI.h clang/lib/AST/DeclCXX.cpp clang/lib/AST/ItaniumCXXABI.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/MicrosoftCXXABI.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/CodeGenCUDA/ms-linker-options.cu clang/test/CodeGenCUDA/unnamed-types.cu Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index ce47d54e44b0..ae69a68608b7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -538,6 +538,9 @@ class ASTContext : public RefCountedBase { /// need them (like static local vars). llvm::MapVector MangleNumbers; llvm::MapVector StaticLocalNumbers; + /// Mapping the associated device lambda mangling number if present. + mutable llvm::DenseMap + DeviceLambdaManglingNumbers; /// Mapping that stores parameterIndex values for ParmVarDecls when /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex. diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index e32101bb2276..89006b1cfa7f 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1735,6 +1735,12 @@ class CXXRecordDecl : public RecordDecl { getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage; } + /// Set the device side mangling number. + void setDeviceLambdaManglingNumber(unsigned Num) const; + + /// Retrieve the device side mangling number. + unsigned getDeviceLambdaManglingNumber() const; + /// Returns the inheritance model used for this record. MSInheritanceModel getMSInheritanceModel() const; diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h index 6506ad542cc3..13b436cdca3e 100644 --- a/clang/include/clang/AST/Mangle.h +++ b/clang/include/clang/AST/Mangle.h @@ -107,6 +107,9 @@ class MangleContext { virtual bool shouldMangleCXXName(const NamedDecl *D) = 0; virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0; + virtual bool isDeviceMangleContext() const { return false; } + virtual void setDeviceMangleContext(bool) {} + // FIXME: consider replacing raw_ostream & with something like SmallString &. void mangleName(GlobalDecl GD, raw_ostream &); virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0; diff --git a/clang/include/clang/AST/MangleNumberingContext.h b/clang/include/clang/AST/MangleNumberingContext.h index f1ca6a05dbaf..eb33759682d6 100644 --- a/clang/include/clang/AST/MangleNumberingContext.h +++ b/clang/include/clang/AST/MangleNumberingContext.h @@ -52,6 +52,11 @@ class MangleNumberingContext { /// this context. virtual unsigned getManglingNumber(const TagDecl *TD, unsigned MSLocalManglingNumber) = 0; + + /// Retrieve the mangling number of a new lambda expression with the + /// given call operator within the device context. No device number is + /// assigned if there's no device numbering context is associated. + virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; } }; } // end namespace clang diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 2fca81d25345..1c4942a37112 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -6558,7 +6558,7 @@ class Sema final { /// Number lambda for linkage purposes if necessary. void handleLambdaNumbering( CXXRecordDecl *Class, CXXMethodDecl *Method, - Optional> Mangling = None); + Optional> Mangling = None); //
[clang] 01bf529 - Recommit of a2fdf9d4d734732a6fa9288f1ffdf12bf8618123.
Author: Michael Liao Date: 2021-02-05T11:27:30-05:00 New Revision: 01bf529db2cf465b029e29e537807576bfcbc452 URL: https://github.com/llvm/llvm-project/commit/01bf529db2cf465b029e29e537807576bfcbc452 DIFF: https://github.com/llvm/llvm-project/commit/01bf529db2cf465b029e29e537807576bfcbc452.diff LOG: Recommit of a2fdf9d4d734732a6fa9288f1ffdf12bf8618123. - The failures are all cc1-based tests due to the missing `-aux-triple` options, which is always prepared by the driver in CUDA/HIP compilation. - Add extra check on the missing aux-targetinfo to prevent crashing. [hip][cuda] Enable extended lambda support on Windows. - On Windows, extended lambda has extra issues due to the numbering schemes are different between the host compilation (Microsoft C++ ABI) and the device compilation (Itanium C++ ABI. Additional device side lambda number is required per lambda for the host compilation to correctly mangle the device-side lambda name. - A hybrid numbering context `MSHIPNumberingContext` is introduced to number a lambda for both host- and device-compilations. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D69322 This reverts commit 4874ff02417916cc9ff994b34abcb5e563056546. Added: Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/DeclCXX.h clang/include/clang/AST/Mangle.h clang/include/clang/AST/MangleNumberingContext.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/CXXABI.h clang/lib/AST/DeclCXX.cpp clang/lib/AST/ItaniumCXXABI.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/MicrosoftCXXABI.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Sema/SemaLambda.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/CodeGenCUDA/unnamed-types.cu Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index ce47d54e44b0..ae69a68608b7 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -538,6 +538,9 @@ class ASTContext : public RefCountedBase { /// need them (like static local vars). llvm::MapVector MangleNumbers; llvm::MapVector StaticLocalNumbers; + /// Mapping the associated device lambda mangling number if present. + mutable llvm::DenseMap + DeviceLambdaManglingNumbers; /// Mapping that stores parameterIndex values for ParmVarDecls when /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex. diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index e32101bb2276..89006b1cfa7f 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1735,6 +1735,12 @@ class CXXRecordDecl : public RecordDecl { getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage; } + /// Set the device side mangling number. + void setDeviceLambdaManglingNumber(unsigned Num) const; + + /// Retrieve the device side mangling number. + unsigned getDeviceLambdaManglingNumber() const; + /// Returns the inheritance model used for this record. MSInheritanceModel getMSInheritanceModel() const; diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h index 6506ad542cc3..13b436cdca3e 100644 --- a/clang/include/clang/AST/Mangle.h +++ b/clang/include/clang/AST/Mangle.h @@ -107,6 +107,9 @@ class MangleContext { virtual bool shouldMangleCXXName(const NamedDecl *D) = 0; virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0; + virtual bool isDeviceMangleContext() const { return false; } + virtual void setDeviceMangleContext(bool) {} + // FIXME: consider replacing raw_ostream & with something like SmallString &. void mangleName(GlobalDecl GD, raw_ostream &); virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0; diff --git a/clang/include/clang/AST/MangleNumberingContext.h b/clang/include/clang/AST/MangleNumberingContext.h index f1ca6a05dbaf..eb33759682d6 100644 --- a/clang/include/clang/AST/MangleNumberingContext.h +++ b/clang/include/clang/AST/MangleNumberingContext.h @@ -52,6 +52,11 @@ class MangleNumberingContext { /// this context. virtual unsigned getManglingNumber(const TagDecl *TD, unsigned MSLocalManglingNumber) = 0; + + /// Retrieve the mangling number of a new lambda expression with the + /// given call operator within the device context. No device number is + /// assigned if there's no device numbering context is associated. + virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; } }; } // end namespace clang diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index ea20ada56abc..68420fcbb85f 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/
[clang] 6ec36d1 - [cuda] Mark builtin texture/surface reference variable as 'externally_initialized'.
Author: Michael Liao Date: 2021-08-09T13:27:40-04:00 New Revision: 6ec36d18ec7b29b471bbe50502beb5b35de3975c URL: https://github.com/llvm/llvm-project/commit/6ec36d18ec7b29b471bbe50502beb5b35de3975c DIFF: https://github.com/llvm/llvm-project/commit/6ec36d18ec7b29b471bbe50502beb5b35de3975c.diff LOG: [cuda] Mark builtin texture/surface reference variable as 'externally_initialized'. - They need to be preserved even if there's no reference within the device code as the host code may need to initialize them based on the application logic. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D107718 Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGenCUDA/surface.cu clang/test/CodeGenCUDA/texture.cu Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 49a1396b58e3a..13520861fe9b6 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4438,7 +4438,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, if (GV && LangOpts.CUDA) { if (LangOpts.CUDAIsDevice) { if (Linkage != llvm::GlobalValue::InternalLinkage && - (D->hasAttr() || D->hasAttr())) + (D->hasAttr() || D->hasAttr() || + D->getType()->isCUDADeviceBuiltinSurfaceType() || + D->getType()->isCUDADeviceBuiltinTextureType())) GV->setExternallyInitialized(true); } else { getCUDARuntime().internalizeDeviceSideVar(D, Linkage); diff --git a/clang/test/CodeGenCUDA/surface.cu b/clang/test/CodeGenCUDA/surface.cu index 0bf17091081b1..eedae5473fcfc 100644 --- a/clang/test/CodeGenCUDA/surface.cu +++ b/clang/test/CodeGenCUDA/surface.cu @@ -19,7 +19,7 @@ struct __attribute__((device_builtin_surface_type)) surface : public }; // On the device side, surface references are represented as `i64` handles. -// DEVICE: @surf ={{.*}} addrspace(1) global i64 undef, align 4 +// DEVICE: @surf ={{.*}} addrspace(1) externally_initialized global i64 undef, align 4 // On the host side, they remain in the original type. // HOST: @surf = internal global %struct.surface // HOST: @0 = private unnamed_addr constant [5 x i8] c"surf\00" diff --git a/clang/test/CodeGenCUDA/texture.cu b/clang/test/CodeGenCUDA/texture.cu index 8a966194340aa..0bb8cd48dcaa7 100644 --- a/clang/test/CodeGenCUDA/texture.cu +++ b/clang/test/CodeGenCUDA/texture.cu @@ -19,8 +19,8 @@ struct __attribute__((device_builtin_texture_type)) texture : public textureRefe }; // On the device side, texture references are represented as `i64` handles. -// DEVICE: @tex ={{.*}} addrspace(1) global i64 undef, align 4 -// DEVICE: @norm ={{.*}} addrspace(1) global i64 undef, align 4 +// DEVICE: @tex ={{.*}} addrspace(1) externally_initialized global i64 undef, align 4 +// DEVICE: @norm ={{.*}} addrspace(1) externally_initialized global i64 undef, align 4 // On the host side, they remain in the original type. // HOST: @tex = internal global %struct.texture // HOST: @norm = internal global %struct.texture ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 948308e - Fix `-Wunused-variable` warning. NFC.
Author: Michael Liao Date: 2021-06-28T22:50:36-04:00 New Revision: 948308ef34dc7da8bb741a85eb9941cc2b05d227 URL: https://github.com/llvm/llvm-project/commit/948308ef34dc7da8bb741a85eb9941cc2b05d227 DIFF: https://github.com/llvm/llvm-project/commit/948308ef34dc7da8bb741a85eb9941cc2b05d227.diff LOG: Fix `-Wunused-variable` warning. NFC. Added: Modified: clang/lib/CodeGen/CGCall.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 35b34179cc23..4ff6c632b61d 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2173,7 +2173,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, // Add "sample-profile-suffix-elision-policy" attribute for internal linkage // functions with -funique-internal-linkage-names. if (TargetDecl && CodeGenOpts.UniqueInternalLinkageNames) { -if (auto *Fn = dyn_cast(TargetDecl)) { +if (isa(TargetDecl)) { if (this->getFunctionLinkage(CalleeInfo.getCalleeDecl()) == llvm::GlobalValue::InternalLinkage) FuncAttrs.addAttribute("sample-profile-suffix-elision-policy", ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4e5d9c8 - [Internalize] Preserve variables externally initialized.
Author: Michael Liao Date: 2021-07-08T10:48:19-04:00 New Revision: 4e5d9c88033f1fc5d5206a02d8303bc6de43cf2b URL: https://github.com/llvm/llvm-project/commit/4e5d9c88033f1fc5d5206a02d8303bc6de43cf2b DIFF: https://github.com/llvm/llvm-project/commit/4e5d9c88033f1fc5d5206a02d8303bc6de43cf2b.diff LOG: [Internalize] Preserve variables externally initialized. - ``externally_initialized`` variables would be initialized or modified elsewhere. Particularly, CUDA or HIP may have host code to initialize or modify ``externally_initialized`` device variables, which may not be explicitly referenced on the device side but may still be used through the host side interfaces. Not preserving them triggers the elimination of them in the GlobalDCE and breaks the user code. Reviewed By: yaxunl Differential Revision: https://reviews.llvm.org/D105135 Added: llvm/test/Transforms/Internalize/externally-initialized.ll Modified: clang/test/CodeGenCUDA/host-used-device-var.cu clang/test/CodeGenCUDA/unused-global-var.cu llvm/lib/Transforms/IPO/Internalize.cpp Removed: diff --git a/clang/test/CodeGenCUDA/host-used-device-var.cu b/clang/test/CodeGenCUDA/host-used-device-var.cu index b94ef689b3162..6bb5757052946 100644 --- a/clang/test/CodeGenCUDA/host-used-device-var.cu +++ b/clang/test/CodeGenCUDA/host-used-device-var.cu @@ -15,14 +15,14 @@ #include "Inputs/cuda.h" -// Check device variables used by neither host nor device functioins are not kept. - -// DEV-NEG-NOT: @v1 +// DEV-DAG: @v1 __device__ int v1; -// DEV-NEG-NOT: @v2 +// DEV-DAG: @v2 __constant__ int v2; +// Check device variables used by neither host nor device functioins are not kept. + // DEV-NEG-NOT: @_ZL2v3 static __device__ int v3; diff --git a/clang/test/CodeGenCUDA/unused-global-var.cu b/clang/test/CodeGenCUDA/unused-global-var.cu index 1dbb3a22563c8..c091e83eda70a 100644 --- a/clang/test/CodeGenCUDA/unused-global-var.cu +++ b/clang/test/CodeGenCUDA/unused-global-var.cu @@ -15,14 +15,14 @@ // DCE before internalization. This test makes sure unused global variables // are eliminated. -// Check unused device/constant variables are eliminated. - -// NEGCHK-NOT: @v1 +// CHECK-DAG: @v1 __device__ int v1; -// NEGCHK-NOT: @v2 +// CHECK-DAG: @v2 __constant__ int v2; +// Check unused device/constant variables are eliminated. + // NEGCHK-NOT: @_ZL2v3 constexpr int v3 = 1; diff --git a/llvm/lib/Transforms/IPO/Internalize.cpp b/llvm/lib/Transforms/IPO/Internalize.cpp index 008712c87988b..cf8da0baebe41 100644 --- a/llvm/lib/Transforms/IPO/Internalize.cpp +++ b/llvm/lib/Transforms/IPO/Internalize.cpp @@ -101,6 +101,12 @@ bool InternalizePass::shouldPreserveGV(const GlobalValue &GV) { if (GV.hasDLLExportStorageClass()) return true; + // As the name suggests, externally initialized variables need preserving as + // they would be initialized elsewhere externally. + if (const auto *G = dyn_cast(&GV)) +if (G->isExternallyInitialized()) + return true; + // Already local, has nothing to do. if (GV.hasLocalLinkage()) return false; diff --git a/llvm/test/Transforms/Internalize/externally-initialized.ll b/llvm/test/Transforms/Internalize/externally-initialized.ll new file mode 100644 index 0..4c24e53543db9 --- /dev/null +++ b/llvm/test/Transforms/Internalize/externally-initialized.ll @@ -0,0 +1,7 @@ +; RUN: opt < %s -internalize -S | FileCheck %s +; RUN: opt < %s -passes=internalize -S | FileCheck %s + +; CHECK: @G0 +; CHECK-NOT: internal +; CHECK-SAME: global i32 +@G0 = protected externally_initialized global i32 0, align 4 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bf22593 - [InferAddressSpaces] Support assumed addrspaces from addrspace predicates.
Author: Michael Liao Date: 2021-11-08T16:51:57-05:00 New Revision: bf225939bc3acf936c962f24423d3bb5ddd4c93f URL: https://github.com/llvm/llvm-project/commit/bf225939bc3acf936c962f24423d3bb5ddd4c93f DIFF: https://github.com/llvm/llvm-project/commit/bf225939bc3acf936c962f24423d3bb5ddd4c93f.diff LOG: [InferAddressSpaces] Support assumed addrspaces from addrspace predicates. - CUDA cannot associate memory space with pointer types. Even though Clang could add extra attributes to specify the address space explicitly on a pointer type, it breaks the portability between Clang and NVCC. - This change proposes to assume the address space from a pointer from the assumption built upon target-specific address space predicates, such as `__isGlobal` from CUDA. E.g., ``` foo(float *p) { __builtin_assume(__isGlobal(p)); // From there, we could assume p is a global pointer instead of a // generic one. } ``` This makes the code portable without introducing the implementation-specific features. Note that NVCC starts to support __builtin_assume from version 11. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D112041 Added: llvm/test/Transforms/InferAddressSpaces/AMDGPU/builtin-assumed-addrspace.ll llvm/test/Transforms/InferAddressSpaces/NVPTX/builtin-assumed-addrspace.ll Modified: clang/test/CodeGen/thinlto-distributed-newpm.ll llvm/include/llvm/Analysis/AssumptionCache.h llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/Target/TargetMachine.h llvm/lib/Analysis/AssumptionCache.cpp llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp llvm/lib/Target/NVPTX/NVPTXTargetMachine.h llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp llvm/test/Other/loop-pm-invalidation.ll llvm/test/Other/new-pass-manager.ll llvm/test/Other/new-pm-lto-defaults.ll llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll llvm/test/Transforms/LoopRotate/pr35210.ll llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp Removed: diff --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll b/clang/test/CodeGen/thinlto-distributed-newpm.ll index 8f7fc5e9b8411..87dc19f29e1ba 100644 --- a/clang/test/CodeGen/thinlto-distributed-newpm.ll +++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll @@ -47,11 +47,11 @@ ; CHECK-O: Running pass: PromotePass ; CHECK-O: Running analysis: DominatorTreeAnalysis on main ; CHECK-O: Running analysis: AssumptionAnalysis on main +; CHECK-O: Running analysis: TargetIRAnalysis on main ; CHECK-O: Running pass: DeadArgumentEliminationPass ; CHECK-O: Running pass: InstCombinePass on main ; CHECK-O: Running analysis: TargetLibraryAnalysis on main ; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main -; CHECK-O: Running analysis: TargetIRAnalysis on main ; CHECK-O: Running analysis: AAManager on main ; CHECK-O: Running analysis: BasicAA on main ; CHECK-O: Running analysis: ScopedNoAliasAA on main diff --git a/llvm/include/llvm/Analysis/AssumptionCache.h b/llvm/include/llvm/Analysis/AssumptionCache.h index 51d04bd8cf022..12dd9b04c9323 100644 --- a/llvm/include/llvm/Analysis/AssumptionCache.h +++ b/llvm/include/llvm/Analysis/AssumptionCache.h @@ -29,6 +29,7 @@ namespace llvm { class AssumeInst; class Function; class raw_ostream; +class TargetTransformInfo; class Value; /// A cache of \@llvm.assume calls within a function. @@ -59,6 +60,8 @@ class AssumptionCache { /// We track this to lazily populate our assumptions. Function &F; + TargetTransformInfo *TTI; + /// Vector of weak value handles to calls of the \@llvm.assume /// intrinsic. SmallVector AssumeHandles; @@ -103,7 +106,8 @@ class AssumptionCache { public: /// Construct an AssumptionCache from a function by scanning all of /// its instructions. - AssumptionCache(Function &F) : F(F) {} + AssumptionCache(Function &F, TargetTransformInfo *TTI = nullptr) + : F(F), TTI(TTI) {} /// This cache is designed to be self-updating and so it should never be /// invalidated. @@ -174,9 +178,7 @@ class AssumptionAnalysis : public AnalysisInfoMixin { public: using Result = AssumptionCache; - AssumptionCache run(Function &F, FunctionAnalysisManager &) { -return AssumptionCache(F); - } + AssumptionCache run(Function &F, FunctionAnalysisManager &); }; /// Printer pass for the \c AssumptionAnalysis results. diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index e3cf87612e9c3..4312c2ae0de63 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTrans
[clang] cd61d2a - [clang][CodeGen][NFC] Fix `llvm-else-after-return`
Author: Michael Liao Date: 2023-01-25T13:53:35-05:00 New Revision: cd61d2abe0fdfcee52e16998f7f3fda82572cd6f URL: https://github.com/llvm/llvm-project/commit/cd61d2abe0fdfcee52e16998f7f3fda82572cd6f DIFF: https://github.com/llvm/llvm-project/commit/cd61d2abe0fdfcee52e16998f7f3fda82572cd6f.diff LOG: [clang][CodeGen][NFC] Fix `llvm-else-after-return` Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 12d602fed6932..38e6ec6634e88 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3318,7 +3318,8 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { if (MustBeEmitted(Global)) EmitOMPDeclareReduction(DRD); return; -} else if (auto *DMD = dyn_cast(Global)) { +} +if (auto *DMD = dyn_cast(Global)) { if (MustBeEmitted(Global)) EmitOMPDeclareMapper(DMD); return; @@ -4687,16 +4688,17 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) { return LangAS::sycl_global; if (LangOpts.CUDA && LangOpts.CUDAIsDevice) { -if (D && D->hasAttr()) - return LangAS::cuda_constant; -else if (D && D->hasAttr()) - return LangAS::cuda_shared; -else if (D && D->hasAttr()) - return LangAS::cuda_device; -else if (D && D->getType().isConstQualified()) - return LangAS::cuda_constant; -else - return LangAS::cuda_device; +if (D) { + if (D->hasAttr()) +return LangAS::cuda_constant; + if (D->hasAttr()) +return LangAS::cuda_shared; + if (D->hasAttr()) +return LangAS::cuda_device; + if (D->getType().isConstQualified()) +return LangAS::cuda_constant; +} +return LangAS::cuda_device; } if (LangOpts.OpenMP) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4edde41 - [clang][APINotes] Fix build error due to `-fpermissive` on GCC. NFC
Author: Michael Liao Date: 2023-08-17T15:00:39-04:00 New Revision: 4edde41daed5e5e0b9aab2322215ddc2535f4cfd URL: https://github.com/llvm/llvm-project/commit/4edde41daed5e5e0b9aab2322215ddc2535f4cfd DIFF: https://github.com/llvm/llvm-project/commit/4edde41daed5e5e0b9aab2322215ddc2535f4cfd.diff LOG: [clang][APINotes] Fix build error due to `-fpermissive` on GCC. NFC Added: Modified: clang/lib/APINotes/APINotesWriter.cpp Removed: diff --git a/clang/lib/APINotes/APINotesWriter.cpp b/clang/lib/APINotes/APINotesWriter.cpp index 1a3d66a547f6ad..aad4c886bdd66d 100644 --- a/clang/lib/APINotes/APINotesWriter.cpp +++ b/clang/lib/APINotes/APINotesWriter.cpp @@ -891,7 +891,7 @@ unsigned getFunctionInfoSize(const FunctionInfo &FI) { } /// Emit a serialized representation of the function information. -static void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) { +void emitFunctionInfo(raw_ostream &OS, const FunctionInfo &FI) { emitCommonEntityInfo(OS, FI); uint8_t flags = 0; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7b12d8b - [clang][Tests] Fix shared build. NFC
Author: Michael Liao Date: 2023-10-12T12:24:18-04:00 New Revision: 7b12d8bf8a1ff1540e32345b045f813644708a71 URL: https://github.com/llvm/llvm-project/commit/7b12d8bf8a1ff1540e32345b045f813644708a71 DIFF: https://github.com/llvm/llvm-project/commit/7b12d8bf8a1ff1540e32345b045f813644708a71.diff LOG: [clang][Tests] Fix shared build. NFC Added: Modified: clang/unittests/AST/Interp/CMakeLists.txt Removed: diff --git a/clang/unittests/AST/Interp/CMakeLists.txt b/clang/unittests/AST/Interp/CMakeLists.txt index e8d41091af40cda..8fa5c85064dbce5 100644 --- a/clang/unittests/AST/Interp/CMakeLists.txt +++ b/clang/unittests/AST/Interp/CMakeLists.txt @@ -5,7 +5,10 @@ add_clang_unittest(InterpTests clang_target_link_libraries(InterpTests PRIVATE clangAST + clangASTMatchers clangBasic + clangFrontend + clangSerialization clangTooling ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4f4e687 - [test][clang][driver] Add required features.
Author: Michael Liao Date: 2020-03-24T17:08:21-04:00 New Revision: 4f4e68799fd55c7023e685161de6f6bb1ada16d5 URL: https://github.com/llvm/llvm-project/commit/4f4e68799fd55c7023e685161de6f6bb1ada16d5 DIFF: https://github.com/llvm/llvm-project/commit/4f4e68799fd55c7023e685161de6f6bb1ada16d5.diff LOG: [test][clang][driver] Add required features. - to avoid false alarms on builds without that features. Added: Modified: clang/test/Driver/save-temps.c Removed: diff --git a/clang/test/Driver/save-temps.c b/clang/test/Driver/save-temps.c index b0cfa4fd814a..a26ba9f4ec0d 100644 --- a/clang/test/Driver/save-temps.c +++ b/clang/test/Driver/save-temps.c @@ -1,3 +1,6 @@ +// REQUIRES: x86-registered-target +// REQUIRES: arm-registered-target + // RUN: %clang -target x86_64-apple-darwin -save-temps -arch x86_64 %s -### 2>&1 \ // RUN: | FileCheck %s // CHECK: "-o" "save-temps.i" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d264f02 - Fix `-Wreturn-type` warning. NFC.
Author: Michael Liao Date: 2020-03-26T00:53:24-04:00 New Revision: d264f02c6f502960e2bcdd332f250efc702d09f2 URL: https://github.com/llvm/llvm-project/commit/d264f02c6f502960e2bcdd332f250efc702d09f2 DIFF: https://github.com/llvm/llvm-project/commit/d264f02c6f502960e2bcdd332f250efc702d09f2.diff LOG: Fix `-Wreturn-type` warning. NFC. Added: Modified: clang/lib/Basic/Targets/X86.cpp Removed: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index f35b520de657..8a7d0f17760e 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -1842,6 +1842,7 @@ Optional X86TargetInfo::getCPUCacheLineSize() const { case CK_Generic: return None; } + return None; } bool X86TargetInfo::validateOutputSize(const llvm::StringMap &FeatureMap, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6a9ad5f - [cuda][hip] Add CUDA builtin surface/texture reference support.
Author: Michael Liao Date: 2020-03-26T14:44:52-04:00 New Revision: 6a9ad5f3f4ac66f0cae592e911f4baeb6ee5eca6 URL: https://github.com/llvm/llvm-project/commit/6a9ad5f3f4ac66f0cae592e911f4baeb6ee5eca6 DIFF: https://github.com/llvm/llvm-project/commit/6a9ad5f3f4ac66f0cae592e911f4baeb6ee5eca6.diff LOG: [cuda][hip] Add CUDA builtin surface/texture reference support. Summary: - Even though the bindless surface/texture interfaces are promoted, there are still code using surface/texture references. For example, [PR#26400](https://bugs.llvm.org/show_bug.cgi?id=26400) reports the compilation issue for code using `tex2D` with texture references. For better compatibility, this patch proposes the support of surface/texture references. - Due to the absent documentation and magic headers, it's believed that `nvcc` does use builtins for texture support. From the limited NVVM documentation[^nvvm] and NVPTX backend texture/surface related tests[^test], it's believed that surface/texture references are supported by replacing their reference types, which are annotated with `device_builtin_surface_type`/`device_builtin_texture_type`, with the corresponding handle-like object types, `cudaSurfaceObject_t` or `cudaTextureObject_t`, in the device-side compilation. On the host side, that global handle variables are registered and will be established and updated later when corresponding binding/unbinding APIs are called[^bind]. Surface/texture references are most like device global variables but represented in different types on the host and device sides. - In this patch, the following changes are proposed to support that behavior: + Refine `device_builtin_surface_type` and `device_builtin_texture_type` attributes to be applied on `Type` decl only to check whether a variable is of the surface/texture reference type. + Add hooks in code generation to replace that reference types with the correponding object types as well as all accesses to them. In particular, `nvvm.texsurf.handle.internal` should be used to load object handles from global reference variables[^texsurf] as well as metadata annotations. + Generate host-side registration with proper template argument parsing. --- [^nvvm]: https://docs.nvidia.com/cuda/pdf/NVVM_IR_Specification.pdf [^test]: https://raw.githubusercontent.com/llvm/llvm-project/master/llvm/test/CodeGen/NVPTX/tex-read-cuda.ll [^bind]: See section 3.2.11.1.2 ``Texture reference API` in [CUDA C Programming Guide](https://docs.nvidia.com/cuda/pdf/CUDA_C_Programming_Guide.pdf). [^texsurf]: According to NVVM IR, `nvvm.texsurf.handle` should be used. But, the current backend doesn't have that supported. We may revise that later. Reviewers: tra, rjmccall, yaxunl, a.sidorin Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76365 Added: clang/test/CodeGenCUDA/surface.cu clang/test/CodeGenCUDA/texture.cu Modified: clang/include/clang/AST/Type.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/AST/Type.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CGCUDARuntime.h clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h clang/lib/Headers/__clang_cuda_runtime_wrapper.h clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCUDA/attr-declspec.cu clang/test/SemaCUDA/attributes-on-non-cuda.cu clang/test/SemaCUDA/bad-attributes.cu llvm/include/llvm/IR/Operator.h Removed: diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index b8f49127bbd0..673d37109eb6 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2111,6 +2111,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { /// than implicitly __strong. bool isObjCARCImplicitlyUnretainedType() const; + /// Check if the type is the CUDA device builtin surface type. + bool isCUDADeviceBuiltinSurfaceType() const; + /// Check if the type is the CUDA device builtin texture type. + bool isCUDADeviceBuiltinTextureType() const; + /// Return the implicit lifetime for this type, which must not be dependent. Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const; diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 5a90b2be2cbf..96bfdd313f47 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1064,16 +1064,20 @@ def CUDADeviceBuiltin : IgnoredAttr { let LangOpts = [CUDA]; } -def CUDADeviceBuiltinSurfaceType : IgnoredAttr { +def CUDADev
Re: [clang] d264f02 - Fix `-Wreturn-type` warning. NFC.
Thanks for catching that. On Thu, Mar 26, 2020 at 11:14 PM David Blaikie wrote: > > Usually this sort of thing is addressed with llvm_unreachable, rather than a > return statement that's not expected to be reached by any valid execution of > LLVM (it'd require a carefully hand-crafted CPU kind to reach that return > (since all the actual enumerators result in returns earlier, in the switch > statement above), which probably isn't an intended code path?) > > I've made that change in 819e540208d5d62e7841d0dbdef3580eecc2c2b6 > > On Wed, Mar 25, 2020 at 9:59 PM Michael Liao via cfe-commits > wrote: >> >> >> Author: Michael Liao >> Date: 2020-03-26T00:53:24-04:00 >> New Revision: d264f02c6f502960e2bcdd332f250efc702d09f2 >> >> URL: >> https://github.com/llvm/llvm-project/commit/d264f02c6f502960e2bcdd332f250efc702d09f2 >> DIFF: >> https://github.com/llvm/llvm-project/commit/d264f02c6f502960e2bcdd332f250efc702d09f2.diff >> >> LOG: Fix `-Wreturn-type` warning. NFC. >> >> Added: >> >> >> Modified: >> clang/lib/Basic/Targets/X86.cpp >> >> Removed: >> >> >> >> >> diff --git a/clang/lib/Basic/Targets/X86.cpp >> b/clang/lib/Basic/Targets/X86.cpp >> index f35b520de657..8a7d0f17760e 100644 >> --- a/clang/lib/Basic/Targets/X86.cpp >> +++ b/clang/lib/Basic/Targets/X86.cpp >> @@ -1842,6 +1842,7 @@ Optional >> X86TargetInfo::getCPUCacheLineSize() const { >> case CK_Generic: >>return None; >>} >> + return None; >> } >> >> bool X86TargetInfo::validateOutputSize(const llvm::StringMap >> &FeatureMap, >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5be9b8c - [cuda][hip] Add CUDA builtin surface/texture reference support.
Author: Michael Liao Date: 2020-03-27T17:18:49-04:00 New Revision: 5be9b8cbe2b2253f78a09a863bef18e574737465 URL: https://github.com/llvm/llvm-project/commit/5be9b8cbe2b2253f78a09a863bef18e574737465 DIFF: https://github.com/llvm/llvm-project/commit/5be9b8cbe2b2253f78a09a863bef18e574737465.diff LOG: [cuda][hip] Add CUDA builtin surface/texture reference support. Summary: - Re-commit after fix Sema checks on partial template specialization. Reviewers: tra, rjmccall, yaxunl, a.sidorin Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76365 Added: clang/test/CodeGenCUDA/surface.cu clang/test/CodeGenCUDA/texture.cu Modified: clang/include/clang/AST/Type.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/AST/Type.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CGCUDARuntime.h clang/lib/CodeGen/CGExprAgg.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h clang/lib/Headers/__clang_cuda_runtime_wrapper.h clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCUDA/attr-declspec.cu clang/test/SemaCUDA/attributes-on-non-cuda.cu clang/test/SemaCUDA/bad-attributes.cu llvm/include/llvm/IR/Operator.h Removed: diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 3a2411b4ed29..6b46fc5ad312 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2111,6 +2111,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase { /// than implicitly __strong. bool isObjCARCImplicitlyUnretainedType() const; + /// Check if the type is the CUDA device builtin surface type. + bool isCUDADeviceBuiltinSurfaceType() const; + /// Check if the type is the CUDA device builtin texture type. + bool isCUDADeviceBuiltinTextureType() const; + /// Return the implicit lifetime for this type, which must not be dependent. Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const; diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 5a90b2be2cbf..96bfdd313f47 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1064,16 +1064,20 @@ def CUDADeviceBuiltin : IgnoredAttr { let LangOpts = [CUDA]; } -def CUDADeviceBuiltinSurfaceType : IgnoredAttr { +def CUDADeviceBuiltinSurfaceType : InheritableAttr { let Spellings = [GNU<"device_builtin_surface_type">, Declspec<"__device_builtin_surface_type__">]; let LangOpts = [CUDA]; + let Subjects = SubjectList<[CXXRecord]>; + let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs]; } -def CUDADeviceBuiltinTextureType : IgnoredAttr { +def CUDADeviceBuiltinTextureType : InheritableAttr { let Spellings = [GNU<"device_builtin_texture_type">, Declspec<"__device_builtin_texture_type__">]; let LangOpts = [CUDA]; + let Subjects = SubjectList<[CXXRecord]>; + let Documentation = [CUDADeviceBuiltinTextureTypeDocs]; } def CUDAGlobal : InheritableAttr { diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index a1cf25ed3929..2c89dc6f4952 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -4624,6 +4624,28 @@ the initializer on host side. }]; } +def CUDADeviceBuiltinSurfaceTypeDocs : Documentation { + let Category = DocCatType; + let Content = [{ +The ``device_builtin_surface_type`` attribute can be applied to a class +template when declaring the surface reference. A surface reference variable +could be accessed on the host side and, on the device side, might be translated +into an internal surface object, which is established through surface bind and +unbind runtime APIs. + }]; +} + +def CUDADeviceBuiltinTextureTypeDocs : Documentation { + let Category = DocCatType; + let Content = [{ +The ``device_builtin_texture_type`` attribute can be applied to a class +template when declaring the texture reference. A texture reference variable +could be accessed on the host side and, on the device side, might be translated +into an internal texture object, which is established through texture bind and +unbind runtime APIs. + }]; +} + def LifetimeOwnerDocs : Documentation { let Category = DocCatDecl; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 762dd1469236..c642c2ba36c8 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -7967,6 +7967,22 @@ def err_cuda_ovl_target : Error< def not
[clang] cb63893 - Fix GCC warning on enum class bitfield. NFC.
Author: Michael Liao Date: 2020-03-28T10:20:34-04:00 New Revision: cb6389360b05e8f89d09ff133a4ba1fd011866c5 URL: https://github.com/llvm/llvm-project/commit/cb6389360b05e8f89d09ff133a4ba1fd011866c5 DIFF: https://github.com/llvm/llvm-project/commit/cb6389360b05e8f89d09ff133a4ba1fd011866c5.diff LOG: Fix GCC warning on enum class bitfield. NFC. Added: Modified: clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CGCUDARuntime.h Removed: diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index ed02a7dc9173..6d92ef33b885 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -466,18 +466,19 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { for (auto &&Info : DeviceVars) { llvm::GlobalVariable *Var = Info.Var; llvm::Constant *VarName = makeConstantString(getDeviceSideName(Info.D)); -switch (Info.Flags.Kind) { +switch (Info.Flags.getKind()) { case DeviceVarFlags::Variable: { uint64_t VarSize = CGM.getDataLayout().getTypeAllocSize(Var->getValueType()); - llvm::Value *Args[] = {&GpuBinaryHandlePtr, - Builder.CreateBitCast(Var, VoidPtrTy), - VarName, - VarName, - llvm::ConstantInt::get(IntTy, Info.Flags.Extern), - llvm::ConstantInt::get(IntTy, VarSize), - llvm::ConstantInt::get(IntTy, Info.Flags.Constant), - llvm::ConstantInt::get(IntTy, 0)}; + llvm::Value *Args[] = { + &GpuBinaryHandlePtr, + Builder.CreateBitCast(Var, VoidPtrTy), + VarName, + VarName, + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern()), + llvm::ConstantInt::get(IntTy, VarSize), + llvm::ConstantInt::get(IntTy, Info.Flags.isConstant()), + llvm::ConstantInt::get(IntTy, 0)}; Builder.CreateCall(RegisterVar, Args); break; } @@ -485,16 +486,16 @@ llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() { Builder.CreateCall( RegisterSurf, {&GpuBinaryHandlePtr, Builder.CreateBitCast(Var, VoidPtrTy), VarName, - VarName, llvm::ConstantInt::get(IntTy, Info.Flags.SurfTexType), - llvm::ConstantInt::get(IntTy, Info.Flags.Extern)}); + VarName, llvm::ConstantInt::get(IntTy, Info.Flags.getSurfTexType()), + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern())}); break; case DeviceVarFlags::Texture: Builder.CreateCall( RegisterTex, {&GpuBinaryHandlePtr, Builder.CreateBitCast(Var, VoidPtrTy), VarName, - VarName, llvm::ConstantInt::get(IntTy, Info.Flags.SurfTexType), - llvm::ConstantInt::get(IntTy, Info.Flags.Normalized), - llvm::ConstantInt::get(IntTy, Info.Flags.Extern)}); + VarName, llvm::ConstantInt::get(IntTy, Info.Flags.getSurfTexType()), + llvm::ConstantInt::get(IntTy, Info.Flags.isNormalized()), + llvm::ConstantInt::get(IntTy, Info.Flags.isExtern())}); break; } } diff --git a/clang/lib/CodeGen/CGCUDARuntime.h b/clang/lib/CodeGen/CGCUDARuntime.h index b26132420d65..19e70a2022a5 100644 --- a/clang/lib/CodeGen/CGCUDARuntime.h +++ b/clang/lib/CodeGen/CGCUDARuntime.h @@ -42,17 +42,30 @@ class CGCUDARuntime { public: // Global variable properties that must be passed to CUDA runtime. - struct DeviceVarFlags { -enum DeviceVarKind : unsigned { + class DeviceVarFlags { + public: +enum DeviceVarKind { Variable, // Variable Surface, // Builtin surface Texture, // Builtin texture }; -DeviceVarKind Kind : 2; + + private: +unsigned Kind : 2; unsigned Extern : 1; unsigned Constant : 1; // Constant variable. unsigned Normalized : 1; // Normalized texture. int SurfTexType; // Type of surface/texutre. + + public: +DeviceVarFlags(DeviceVarKind K, bool E, bool C, bool N, int T) +: Kind(K), Extern(E), Constant(C), Normalized(N), SurfTexType(T) {} + +DeviceVarKind getKind() const { return static_cast(Kind); } +bool isExtern() const { return Extern; } +bool isConstant() const { return Constant; } +bool isNormalized() const { return Normalized; } +int getSurfTexType() const { return SurfTexType; } }; CGCUDARuntime(CodeGenModule &CGM) : CGM(CGM) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d142ec6 - Fix compilation warning. NFC.
Author: Michael Liao Date: 2019-11-04T10:01:50-05:00 New Revision: d142ec6fef9a053c9fd9edb5a388203cdb121e65 URL: https://github.com/llvm/llvm-project/commit/d142ec6fef9a053c9fd9edb5a388203cdb121e65 DIFF: https://github.com/llvm/llvm-project/commit/d142ec6fef9a053c9fd9edb5a388203cdb121e65.diff LOG: Fix compilation warning. NFC. Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index d8c18effd62c..d550eea94670 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1527,8 +1527,8 @@ getDeploymentTargetFromEnvironmentVariables(const Driver &TheDriver, Targets[Darwin::TvOS] = ""; } else { // Don't allow conflicts in any other platform. -int FirstTarget = llvm::array_lengthof(Targets); -for (int I = 0; I != llvm::array_lengthof(Targets); ++I) { +unsigned FirstTarget = llvm::array_lengthof(Targets); +for (unsigned I = 0; I != llvm::array_lengthof(Targets); ++I) { if (Targets[I].empty()) continue; if (FirstTarget == llvm::array_lengthof(Targets)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 15140e4 - [hip] Enable pointer argument lowering through coercing type.
Author: Michael Liao Date: 2019-11-05T13:05:05-05:00 New Revision: 15140e4bacf94fbc509e5a139909aefcd1cc3363 URL: https://github.com/llvm/llvm-project/commit/15140e4bacf94fbc509e5a139909aefcd1cc3363 DIFF: https://github.com/llvm/llvm-project/commit/15140e4bacf94fbc509e5a139909aefcd1cc3363.diff LOG: [hip] Enable pointer argument lowering through coercing type. Reviewers: tra, rjmccall, yaxunl Subscribers: jvesely, nhaehnle, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69826 Added: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu Modified: clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/TargetInfo.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 62e8fa037013..e832e4c28334 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1305,6 +1305,15 @@ static void CreateCoercedStore(llvm::Value *Src, DstTy = Dst.getType()->getElementType(); } + llvm::PointerType *SrcPtrTy = llvm::dyn_cast(SrcTy); + llvm::PointerType *DstPtrTy = llvm::dyn_cast(DstTy); + if (SrcPtrTy && DstPtrTy && + SrcPtrTy->getAddressSpace() != DstPtrTy->getAddressSpace()) { +Src = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DstTy); +CGF.Builder.CreateStore(Src, Dst, DstIsVolatile); +return; + } + // If the source and destination are integer or pointer types, just do an // extension or truncation to the desired type. if ((isa(SrcTy) || isa(SrcTy)) && diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index e33d69c86b3c..26c527d7c983 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -7685,6 +7685,42 @@ class AMDGPUABIInfo final : public DefaultABIInfo { bool isHomogeneousAggregateSmallEnough(const Type *Base, uint64_t Members) const override; + // Coerce HIP pointer arguments from generic pointers to global ones. + llvm::Type *coerceKernelArgumentType(llvm::Type *Ty, unsigned FromAS, + unsigned ToAS) const { +// Structure types. +if (auto STy = dyn_cast(Ty)) { + SmallVector EltTys; + bool Changed = false; + for (auto T : STy->elements()) { +auto NT = coerceKernelArgumentType(T, FromAS, ToAS); +EltTys.push_back(NT); +Changed |= (NT != T); + } + // Skip if there is no change in element types. + if (!Changed) +return STy; + if (STy->hasName()) +return llvm::StructType::create( +EltTys, (STy->getName() + ".coerce").str(), STy->isPacked()); + return llvm::StructType::get(getVMContext(), EltTys, STy->isPacked()); +} +// Arrary types. +if (auto ATy = dyn_cast(Ty)) { + auto T = ATy->getElementType(); + auto NT = coerceKernelArgumentType(T, FromAS, ToAS); + // Skip if there is no change in that element type. + if (NT == T) +return ATy; + return llvm::ArrayType::get(NT, ATy->getNumElements()); +} +// Single value types. +if (Ty->isPointerTy() && Ty->getPointerAddressSpace() == FromAS) + return llvm::PointerType::get( + cast(Ty)->getElementType(), ToAS); +return Ty; + } + public: explicit AMDGPUABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {} @@ -7812,14 +7848,22 @@ ABIArgInfo AMDGPUABIInfo::classifyKernelArgumentType(QualType Ty) const { // TODO: Can we omit empty structs? - // Coerce single element structs to its element. + llvm::Type *LTy = nullptr; if (const Type *SeltTy = isSingleElementStruct(Ty, getContext())) -return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0))); +LTy = CGT.ConvertType(QualType(SeltTy, 0)); + + if (getContext().getLangOpts().HIP) { +if (!LTy) + LTy = CGT.ConvertType(Ty); +LTy = coerceKernelArgumentType( +LTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default), +/*ToAS=*/getContext().getTargetAddressSpace(LangAS::cuda_device)); + } // If we set CanBeFlattened to true, CodeGen will expand the struct to its // individual elements, which confuses the Clover OpenCL backend; therefore we // have to set it to false here. Other args of getDirect() are just defaults. - return ABIArgInfo::getDirect(nullptr, 0, nullptr, false); + return ABIArgInfo::getDirect(LTy, 0, nullptr, false); } ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty, diff --git a/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu new file mode 100644 index ..cb8a75882d4d --- /dev/null +++ b/clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s +// RUN: %clang_cc1
[clang] 0a220de - [HIP] Fix visibility for 'extern' device variables.
Author: Michael Liao Date: 2019-11-05T14:19:32-05:00 New Revision: 0a220de9e9ca3e6786df6c03fd37668815805c62 URL: https://github.com/llvm/llvm-project/commit/0a220de9e9ca3e6786df6c03fd37668815805c62 DIFF: https://github.com/llvm/llvm-project/commit/0a220de9e9ca3e6786df6c03fd37668815805c62.diff LOG: [HIP] Fix visibility for 'extern' device variables. Summary: - Fix a bug which misses the change for a variable to be set with target-specific attributes. Reviewers: yaxunl Subscribers: jvesely, nhaehnle, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63020 Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGenCUDA/amdgpu-visibility.cu Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 49df82cea42b..be8f389e1809 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3575,6 +3575,9 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, } } + if (GV->isDeclaration()) +getTargetCodeGenInfo().setTargetAttributes(D, GV, *this); + LangAS ExpectedAS = D ? D->getType().getAddressSpace() : (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default); @@ -3584,9 +3587,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace, ExpectedAS, Ty); - if (GV->isDeclaration()) -getTargetCodeGenInfo().setTargetAttributes(D, GV, *this); - return GV; } diff --git a/clang/test/CodeGenCUDA/amdgpu-visibility.cu b/clang/test/CodeGenCUDA/amdgpu-visibility.cu index 9f44eb047f82..f23e562a4f29 100644 --- a/clang/test/CodeGenCUDA/amdgpu-visibility.cu +++ b/clang/test/CodeGenCUDA/amdgpu-visibility.cu @@ -13,6 +13,16 @@ __constant__ int c; __device__ int g; +// CHECK-DEFAULT: @e = external addrspace(1) global +// CHECK-PROTECTED: @e = external protected addrspace(1) global +// CHECK-HIDDEN: @e = external protected addrspace(1) global +extern __device__ int e; + +// dummy one to hold reference to `e`. +__device__ int f() { + return e; +} + // CHECK-DEFAULT: define amdgpu_kernel void @_Z3foov() // CHECK-PROTECTED: define protected amdgpu_kernel void @_Z3foov() // CHECK-HIDDEN: define protected amdgpu_kernel void @_Z3foov() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c4afc65 - Fix compilation warning. NFC.
Author: Michael Liao Date: 2019-11-21T12:07:13-05:00 New Revision: c4afc6566a64e6be3f77271781a147bb5ff98b0c URL: https://github.com/llvm/llvm-project/commit/c4afc6566a64e6be3f77271781a147bb5ff98b0c DIFF: https://github.com/llvm/llvm-project/commit/c4afc6566a64e6be3f77271781a147bb5ff98b0c.diff LOG: Fix compilation warning. NFC. Added: Modified: clang/lib/Driver/Driver.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 90f3cea5b2af..c1173e3ddbf0 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3498,7 +3498,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, Actions.push_back( C.MakeAction(MergerInputs, types::TY_Image)); - if (Arg *A = Args.getLastArg(options::OPT_emit_interface_stubs)) { + if (Args.hasArg(options::OPT_emit_interface_stubs)) { llvm::SmallVector PhaseList; if (Args.hasArg(options::OPT_c)) { llvm::SmallVector CompilePhaseList; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 59e69fe - Fix warning on extra ';'. NFC.
Author: Michael Liao Date: 2019-12-03T16:02:55-05:00 New Revision: 59e69fefab883984e81c77aef58ba587060e87f2 URL: https://github.com/llvm/llvm-project/commit/59e69fefab883984e81c77aef58ba587060e87f2 DIFF: https://github.com/llvm/llvm-project/commit/59e69fefab883984e81c77aef58ba587060e87f2.diff LOG: Fix warning on extra ';'. NFC. Added: Modified: clang/lib/Format/TokenAnnotator.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 93cb36961ee5..d5d394e61926 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2597,7 +2597,7 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const FormatToken &Right) const { static bool isKeywordWithCondition(const FormatToken &Tok) { return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch, tok::kw_constexpr); -}; +} bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Left, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 59312cb - Fix warning on unused variable. NFC.
Author: Michael Liao Date: 2019-12-03T21:16:10-05:00 New Revision: 59312cb0b81ca13f0674dde66b8e87a8d51d4dda URL: https://github.com/llvm/llvm-project/commit/59312cb0b81ca13f0674dde66b8e87a8d51d4dda DIFF: https://github.com/llvm/llvm-project/commit/59312cb0b81ca13f0674dde66b8e87a8d51d4dda.diff LOG: Fix warning on unused variable. NFC. Added: Modified: clang/lib/AST/Expr.cpp Removed: diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index a73531ad5fad..3bc2ea60aa14 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1678,7 +1678,7 @@ MemberExpr *MemberExpr::Create( MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl, NameInfo, T, VK, OK, NOUR); - if (FieldDecl *Field = dyn_cast(MemberDecl)) { + if (isa(MemberDecl)) { DeclContext *DC = MemberDecl->getDeclContext(); // dyn_cast_or_null is used to handle objC variables which do not // have a declaration context. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fa9dd41 - [opencl] Fix address space deduction on array variables.
Author: Michael Liao Date: 2019-12-04T09:37:50-05:00 New Revision: fa9dd410a9a9aa65ce6731cbe1ee12c5941eb3e8 URL: https://github.com/llvm/llvm-project/commit/fa9dd410a9a9aa65ce6731cbe1ee12c5941eb3e8 DIFF: https://github.com/llvm/llvm-project/commit/fa9dd410a9a9aa65ce6731cbe1ee12c5941eb3e8.diff LOG: [opencl] Fix address space deduction on array variables. Summary: - The deduced address space needs applying to its element type as well. Reviewers: Anastasia Subscribers: yaxunl, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70981 Added: Modified: clang/lib/Sema/SemaDecl.cpp clang/test/SemaOpenCL/address-spaces.cl Removed: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index d35037273106..660be458a698 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6128,7 +6128,26 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) && Var->hasGlobalStorage()) ImplAS = LangAS::opencl_global; +// If the original type from a decayed type is an array type and that array +// type has no address space yet, deduce it now. +if (auto DT = dyn_cast(Type)) { + auto OrigTy = DT->getOriginalType(); + if (!OrigTy.getQualifiers().hasAddressSpace() && OrigTy->isArrayType()) { +// Add the address space to the original array type and then propagate +// that to the element type through `getAsArrayType`. +OrigTy = Context.getAddrSpaceQualType(OrigTy, ImplAS); +OrigTy = QualType(Context.getAsArrayType(OrigTy), 0); +// Re-generate the decayed type. +Type = Context.getDecayedType(OrigTy); + } +} Type = Context.getAddrSpaceQualType(Type, ImplAS); +// Apply any qualifiers (including address space) from the array type to +// the element type. This implements C99 6.7.3p8: "If the specification of +// an array type includes any type qualifiers, the element type is so +// qualified, not the array type." +if (Type->isArrayType()) + Type = QualType(Context.getAsArrayType(Type), 0); Decl->setType(Type); } } diff --git a/clang/test/SemaOpenCL/address-spaces.cl b/clang/test/SemaOpenCL/address-spaces.cl index 55a55dc75050..09a6dd0ba53f 100644 --- a/clang/test/SemaOpenCL/address-spaces.cl +++ b/clang/test/SemaOpenCL/address-spaces.cl @@ -241,3 +241,10 @@ void func_multiple_addr(void) { __private private_int_t var5; // expected-warning {{multiple identical address spaces specified for type}} __private private_int_t *var6;// expected-warning {{multiple identical address spaces specified for type}} } + +void func_with_array_param(const unsigned data[16]); + +__kernel void k() { + unsigned data[16]; + func_with_array_param(data); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f2ace9d - Add `QualType::hasAddressSpace`. NFC.
Author: Michael Liao Date: 2019-12-06T13:08:55-05:00 New Revision: f2ace9d6005b4ffc6f6fc068c1aac897d871df7a URL: https://github.com/llvm/llvm-project/commit/f2ace9d6005b4ffc6f6fc068c1aac897d871df7a DIFF: https://github.com/llvm/llvm-project/commit/f2ace9d6005b4ffc6f6fc068c1aac897d871df7a.diff LOG: Add `QualType::hasAddressSpace`. NFC. - Add that as a shorthand of .getQualifiers().hasAddressSpace(). - Simplify related code. Added: Modified: clang/include/clang/AST/Type.h clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaType.cpp clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp Removed: diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 02c9aa403b5a..caf2a3dd79a3 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1046,6 +1046,9 @@ class QualType { ID.AddPointer(getAsOpaquePtr()); } + /// Check if this type has any address space qualifier. + inline bool hasAddressSpace() const; + /// Return the address space of this type. inline LangAS getAddressSpace() const; @@ -6276,6 +6279,11 @@ inline void QualType::removeLocalCVRQualifiers(unsigned Mask) { removeLocalFastQualifiers(Mask); } +/// Check if this type has any address space qualifier. +inline bool QualType::hasAddressSpace() const { + return getQualifiers().hasAddressSpace(); +} + /// Return the address space of this type. inline LangAS QualType::getAddressSpace() const { return getQualifiers().getAddressSpace(); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 660be458a698..0e38d6bfaf93 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6118,7 +6118,7 @@ bool Sema::inferObjCARCLifetime(ValueDecl *decl) { } void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { - if (Decl->getType().getQualifiers().hasAddressSpace()) + if (Decl->getType().hasAddressSpace()) return; if (VarDecl *Var = dyn_cast(Decl)) { QualType Type = Var->getType(); @@ -6132,7 +6132,7 @@ void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) { // type has no address space yet, deduce it now. if (auto DT = dyn_cast(Type)) { auto OrigTy = DT->getOriginalType(); - if (!OrigTy.getQualifiers().hasAddressSpace() && OrigTy->isArrayType()) { + if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) { // Add the address space to the original array type and then propagate // that to the element type through `getAsArrayType`. OrigTy = Context.getAddrSpaceQualType(OrigTy, ImplAS); @@ -16094,7 +16094,7 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, } // TR 18037 does not allow fields to be declared with address space - if (T.getQualifiers().hasAddressSpace() || T->isDependentAddressSpaceType() || + if (T.hasAddressSpace() || T->isDependentAddressSpaceType() || T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) { Diag(Loc, diag::err_field_with_address_space); Record->setInvalidDecl(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index c53a4b789bed..e2c37f8f5238 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5445,15 +5445,15 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, Expr *Arg = ArgRes.get(); QualType ArgType = Arg->getType(); if (!ParamType->isPointerType() || -ParamType.getQualifiers().hasAddressSpace() || +ParamType.hasAddressSpace() || !ArgType->isPointerType() || -!ArgType->getPointeeType().getQualifiers().hasAddressSpace()) { +!ArgType->getPointeeType().hasAddressSpace()) { OverloadParams.push_back(ParamType); continue; } QualType PointeeType = ParamType->getPointeeType(); -if (PointeeType.getQualifiers().hasAddressSpace()) +if (PointeeType.hasAddressSpace()) continue; NeedsNewDecl = true; diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 7421754d95ca..cc9d1a4f6256 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -7853,9 +7853,8 @@ ExprResult InitializationSequence::Perform(Sema &S, // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope QualType ETy = Entity.getType(); - Qualifiers TyQualifiers = ETy.getQualifiers(); - bool HasGlobalAS = TyQualifiers.hasAddressSpace() && - TyQualifiers.getAddressSpace() == LangAS::opencl_global; + bool HasGlobalAS = ETy.hasAddressSpace() && + ETy.getAddressSpace() == LangAS::opencl_global; if (S.getLangOpts().OpenCLVersion >= 200 && ETy->isAtomicType() && !HasGlobalAS && diff --git a/clang/lib/Sema/SemaOverload.c
[clang] 6626e5a - Fix compilation warning from GCC7. NFC.
Author: Michael Liao Date: 2019-12-09T10:11:27-05:00 New Revision: 6626e5a06a99b29b388f2dffde2c16f8eb5ded46 URL: https://github.com/llvm/llvm-project/commit/6626e5a06a99b29b388f2dffde2c16f8eb5ded46 DIFF: https://github.com/llvm/llvm-project/commit/6626e5a06a99b29b388f2dffde2c16f8eb5ded46.diff LOG: Fix compilation warning from GCC7. NFC. Added: Modified: clang/lib/Sema/SemaDeclCXX.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c8b95983f03c..d0857a5de817 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -7103,6 +7103,7 @@ class DefaultedComparisonVisitor { ResultList Results; switch (DCK) { +default: case DefaultedComparisonKind::None: llvm_unreachable("not a defaulted comparison"); @@ -7592,6 +7593,7 @@ class DefaultedComparisonSynthesizer return StmtError(); switch (DCK) { +default: case DefaultedComparisonKind::None: llvm_unreachable("not a defaulted comparison"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits