Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (intel#39)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/test/Driver/clang-offload-bundler.c
  • Loading branch information
linkren committed Dec 19, 2020
2 parents 9c6c41b + b9fb063 commit 79c65d4
Show file tree
Hide file tree
Showing 139 changed files with 9,424 additions and 8,318 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once

namespace std {
namespace experimental {

template <typename ret_t, typename... args_t>
struct coroutine_traits {
using promise_type = typename ret_t::promise_type;
};

template <class promise_t>
struct coroutine_handle {
static constexpr coroutine_handle from_address(void *addr) noexcept { return {}; };
};

} // namespace experimental
} // namespace std

struct never_suspend {
bool await_ready() noexcept { return false; }
template <typename coro_t>
void await_suspend(coro_t handle) noexcept {}
void await_resume() noexcept {}
};

struct task {
struct promise_type {
task get_return_object() noexcept { return {}; }
never_suspend initial_suspend() noexcept { return {}; }
never_suspend final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@
// RUN: {key: readability-identifier-naming.LocalPointerPrefix, value: 'l_'}, \
// RUN: {key: readability-identifier-naming.LocalConstantPointerCase, value: CamelCase}, \
// RUN: {key: readability-identifier-naming.LocalConstantPointerPrefix, value: 'lc_'}, \
// RUN: ]}' -- -fno-delayed-template-parsing -Dbad_macro \
// RUN: ]}' -- -fno-delayed-template-parsing -Dbad_macro -std=c++17 -fcoroutines-ts \
// RUN: -I%S/Inputs/readability-identifier-naming \
// RUN: -isystem %S/Inputs/readability-identifier-naming/system

// clang-format off

#include <system-header.h>
#include <coroutines.h>
#include "user-header.h"
// NO warnings or fixes expected from declarations within header files without
// the -header-filter= option
Expand Down Expand Up @@ -287,7 +288,7 @@ class COverriding : public AOverridden {
// Overriding a badly-named base isn't a new violation.
void BadBaseMethod() override {}
// CHECK-FIXES: {{^}} void v_Bad_Base_Method() override {}

void foo() {
BadBaseMethod();
// CHECK-FIXES: {{^}} v_Bad_Base_Method();
Expand Down Expand Up @@ -614,3 +615,14 @@ template<typename type_t>
auto GetRes(type_t& Param) -> decltype(Param.res());
// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for parameter 'Param'
// CHECK-FIXES: auto GetRes(type_t& a_param) -> decltype(a_param.res());

// Check implicit declarations in coroutines

struct async_obj {
public:
never_suspend operator co_await() const noexcept;
};

task ImplicitDeclTest(async_obj &a_object) {
co_await a_object; // CHECK-MESSAGES-NOT: warning: invalid case style for local variable
}
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -4004,7 +4004,7 @@ As ``global_device`` and ``global_host`` are a subset of
``__global/opencl_global`` address spaces it is allowed to convert
``global_device`` and ``global_host`` address spaces to
``__global/opencl_global`` address spaces (following ISO/IEC TR 18037 5.1.3
"Address space nesting and rules for pointers).
"Address space nesting and rules for pointers").
}];
}

Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7770,6 +7770,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
}
CmdArgs.push_back(TCArgs.MakeArgString(UB));
CmdArgs.push_back("-unbundle");
CmdArgs.push_back("-allow-missing-bundles");

// All the inputs are encoded as commands.
C.addCommand(std::make_unique<Command>(
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaCoroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
auto *VD = VarDecl::Create(Context, FD, FD->getLocation(), FD->getLocation(),
&PP.getIdentifierTable().get("__promise"), T,
Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
VD->setImplicit();
CheckVariableDeclarationType(VD);
if (VD->isInvalidDecl())
return nullptr;
Expand Down Expand Up @@ -1577,6 +1578,7 @@ bool CoroutineStmtBuilder::makeGroDeclAndReturnStmt() {
S.Context, &FD, FD.getLocation(), FD.getLocation(),
&S.PP.getIdentifierTable().get("__coro_gro"), GroType,
S.Context.getTrivialTypeSourceInfo(GroType, Loc), SC_None);
GroDecl->setImplicit();

S.CheckVariableDeclarationType(GroDecl);
if (GroDecl->isInvalidDecl())
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5990,8 +5990,9 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
return QualType();
}

return Context.getConstantArrayType(ElemTy, Res, VLATy->getSizeExpr(),
ArrayType::Normal, 0);
QualType FoldedArrayType = Context.getConstantArrayType(
ElemTy, Res, VLATy->getSizeExpr(), ArrayType::Normal, 0);
return Qs.apply(Context, FoldedArrayType);
}

static void
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
if (Stop(N))
return true;

if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc(), nullptr))
break;
PostCallback(N);

Expand All @@ -3158,7 +3158,7 @@ struct DOTGraphTraits<ExplodedGraph*> : public DefaultDOTGraphTraits {
return false;
}

static bool isNodeHidden(const ExplodedNode *N) {
static bool isNodeHidden(const ExplodedNode *N, const ExplodedGraph *G) {
return N->isTrivial();
}

Expand Down
47 changes: 39 additions & 8 deletions clang/test/Driver/clang-offload-bundler.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
// CK-HELP: {{.*}}one. The resulting file can also be unbundled into different files by
// CK-HELP: {{.*}}this tool if -unbundle is provided.
// CK-HELP: {{.*}}USAGE: clang-offload-bundler [options]
// CK-HELP: {{.*}}-allow-missing-bundles {{.*}}- Create empty files if bundles are missing when unbundling
// CK-HELP: {{.*}}-inputs=<string> - [<input file>,...]
// CK-HELP: {{.*}}-outputs=<string> - [<output file>,...]
// CK-HELP: {{.*}}-targets=<string> - [<offload kind>-<target triple>,...]
Expand Down Expand Up @@ -90,7 +91,7 @@
// RUN: not clang-offload-bundler -type=i -targets=openmp-powerpc64le-linux,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9A
// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -inputs=%t.i,%t.tgt1,%t.tgt2 -outputs=%t.bundle.i 2>&1 | FileCheck %s --check-prefix CK-ERR9B
// CK-ERR9A: error: expecting exactly one host target but got 0
// CK-ERR9B: error: expecting exactly one host target but got 2
// CK-ERR9B: error: Duplicate targets are not allowed

// RUN: not clang-offload-bundler -type=i -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i -unbundle -check-section 2>&1 | FileCheck %s --check-prefix CK-ERR10
// CK-ERR10: error: -unbundle and -check-section are not compatible options
Expand Down Expand Up @@ -195,17 +196,17 @@
// RUN: diff %t.tgt2 %t.res.tgt2

// Check if we can unbundle a file with no magic strings.
// RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.s -unbundle
// RUN: clang-offload-bundler -type=s -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.s,%t.res.tgt1,%t.res.tgt2 -inputs=%t.s -unbundle -allow-missing-bundles
// RUN: diff %t.s %t.res.s
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2
// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.s -unbundle
// RUN: clang-offload-bundler -type=s -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.s,%t.res.tgt2 -inputs=%t.s -unbundle -allow-missing-bundles
// RUN: diff %t.s %t.res.s
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2

// Check that bindler prints an error if given host bundle does not exist in the fat binary.
// RUN: not clang-offload-bundler -type=s -targets=host-x86_64-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.s,%t.res.tgt1 -inputs=%t.bundle3.s -unbundle 2>&1 | FileCheck %s --check-prefix CK-NO-HOST-BUNDLE
// RUN: not clang-offload-bundler -type=s -targets=host-x86_64-xxx-linux-gnu,openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.s,%t.res.tgt1 -inputs=%t.bundle3.s -unbundle -allow-missing-bundles 2>&1 | FileCheck %s --check-prefix CK-NO-HOST-BUNDLE
// CK-NO-HOST-BUNDLE: error: Can't find bundle for the host target

//
Expand Down Expand Up @@ -243,11 +244,11 @@
// RUN: diff %t.tgt1 %t.res.tgt1

// Check if we can unbundle a file with no magic strings.
// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.bc,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bc -unbundle
// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.bc,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bc -unbundle -allow-missing-bundles
// RUN: diff %t.bc %t.res.bc
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2
// RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.bc,%t.res.tgt2 -inputs=%t.bc -unbundle
// RUN: clang-offload-bundler -type=bc -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.bc,%t.res.tgt2 -inputs=%t.bc -unbundle -allow-missing-bundles
// RUN: diff %t.bc %t.res.bc
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2
Expand Down Expand Up @@ -283,11 +284,11 @@
// RUN: diff %t.tgt1 %t.res.tgt1

// Check if we can unbundle a file with no magic strings.
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.o -unbundle
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.o -unbundle -allow-missing-bundles
// RUN: diff %t.o %t.res.o
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2
// RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.o -unbundle
// RUN: clang-offload-bundler -type=o -targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.o -unbundle -allow-missing-bundles
// RUN: diff %t.o %t.res.o
// RUN: diff %t.empty %t.res.tgt1
// RUN: diff %t.empty %t.res.tgt2
Expand Down Expand Up @@ -353,6 +354,36 @@
// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu.{{.+}}.bundle3.o
// CHECK-AR-TGT2-LIST: openmp-x86_64-pc-linux-gnu.{{.+}}.bundle4.o

//
// Check error due to missing bundles
//
// RUN: clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa-gfx900 -inputs=%t.bc,%t.tgt1 -outputs=%t.hip.bundle.bc
// RUN: not clang-offload-bundler -type=bc -inputs=%t.hip.bundle.bc -outputs=%t.tmp.bc -unbundle \
// RUN: -targets=hip-amdgcn-amd-amdhsa-gfx906 \
// RUN: 2>&1 | FileCheck -check-prefix=MISS1 %s
// RUN: not clang-offload-bundler -type=bc -inputs=%t.hip.bundle.bc -outputs=%t.tmp.bc,%t.tmp2.bc -unbundle \
// RUN: -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx900 \
// RUN: 2>&1 | FileCheck -check-prefix=MISS1 %s
// MISS1: error: Can't find bundles for hip-amdgcn-amd-amdhsa-gfx906
// RUN: not clang-offload-bundler -type=bc -inputs=%t.hip.bundle.bc -outputs=%t.tmp.bc,%t.tmp2.bc -unbundle \
// RUN: -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx803 \
// RUN: 2>&1 | FileCheck -check-prefix=MISS2 %s
// MISS2: error: Can't find bundles for hip-amdgcn-amd-amdhsa-gfx803 and hip-amdgcn-amd-amdhsa-gfx906
// RUN: not clang-offload-bundler -type=bc -inputs=%t.hip.bundle.bc -outputs=%t.tmp.bc,%t.tmp2.bc,%t.tmp3.bc -unbundle \
// RUN: -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx1010 \
// RUN: 2>&1 | FileCheck -check-prefix=MISS3 %s
// MISS3: error: Can't find bundles for hip-amdgcn-amd-amdhsa-gfx1010, hip-amdgcn-amd-amdhsa-gfx803, and hip-amdgcn-amd-amdhsa-gfx906

//
// Check error due to duplicate targets
//
// RUN: not clang-offload-bundler -type=bc -targets=host-%itanium_abi_triple,hip-amdgcn-amd-amdhsa-gfx900,hip-amdgcn-amd-amdhsa-gfx900 \
// RUN: -inputs=%t.bc,%t.tgt1,%t.tgt1 -outputs=%t.hip.bundle.bc 2>&1 | FileCheck -check-prefix=DUP %s
// RUN: not clang-offload-bundler -type=bc -inputs=%t.hip.bundle.bc -outputs=%t.tmp.bc,%t.tmp2.bc -unbundle \
// RUN: -targets=hip-amdgcn-amd-amdhsa-gfx906,hip-amdgcn-amd-amdhsa-gfx906 \
// RUN: 2>&1 | FileCheck -check-prefix=DUP %s
// DUP: error: Duplicate targets are not allowed

// Some code so that we can create a binary out of this file.
int A = 0;
void test_func(void) {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/hip-autolink.hip
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// RUN: %clang --target=i386-pc-windows-msvc --cuda-gpu-arch=gfx906 -nogpulib \
// RUN: --cuda-host-only %s -### 2>&1 | FileCheck --check-prefix=HOST %s

// DEV: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
// DEV: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
// DEV-SAME: "-fno-autolink"

// HOST: "-cc1" "-triple" "i386-pc-windows-msvc{{.*}}"
Expand Down
11 changes: 8 additions & 3 deletions clang/test/Driver/hip-code-object-version.hip
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@
// RUN: --offload-arch=gfx906 -nogpulib \
// RUN: %s 2>&1 | FileCheck -check-prefix=V4 %s

// V4: "-mllvm" "--amdhsa-code-object-version=4"
// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

// Check bundle ID for code object version default

// RUN: %clang -### -target x86_64-linux-gnu \
// RUN: --offload-arch=gfx906 -nogpulib \
// RUN: %s 2>&1 | FileCheck -check-prefix=V4 %s
// RUN: %s 2>&1 | FileCheck -check-prefix=VD %s

// V4: "-mllvm" "--amdhsa-code-object-version=4"
// V4: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
// VD: "-mllvm" "--amdhsa-code-object-version=4"
// VD: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"

// Check invalid code object version option.

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/hip-device-compile.hip
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// RUN: %S/Inputs/hip_multiple_inputs/a.cu \
// RUN: 2>&1 | FileCheck -check-prefixes=CHECK,ASM %s

// CHECK: {{".*clang.*"}} "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
// CHECK: {{".*clang.*"}} "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// BC-SAME: "-emit-llvm-bc"
// LL-SAME: "-emit-llvm"
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Driver/hip-host-cpu-features.hip
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
// RUN: %clang -### -c -target x86_64-linux-gnu -msse3 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=HOSTSSE3
// RUN: %clang -### -c -target x86_64-linux-gnu --gpu-use-aux-triple-only -march=znver2 --cuda-gpu-arch=gfx803 -nogpulib %s 2>&1 | FileCheck %s -check-prefix=NOHOSTCPU

// HOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
// HOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
// HOSTCPU-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// HOSTCPU-SAME: "-aux-target-cpu" "znver2"

// HOSTSSE3: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
// HOSTSSE3: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
// HOSTSSE3-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// HOSTSSE3-SAME: "-aux-target-feature" "+sse3"

// NOHOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version=4" "-triple" "amdgcn-amd-amdhsa"
// NOHOSTCPU: "-cc1" "-mllvm" "--amdhsa-code-object-version={{[0-9]+}}" "-triple" "amdgcn-amd-amdhsa"
// NOHOSTCPU-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
// NOHOSTCPU-NOT: "-aux-target-cpu" "znver2"
Loading

0 comments on commit 79c65d4

Please sign in to comment.