Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/amd-common' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
rocm-hcc committed Mar 25, 2019
2 parents 896e5dc + c27696c commit 785f31d
Show file tree
Hide file tree
Showing 95 changed files with 1,538 additions and 602 deletions.
35 changes: 35 additions & 0 deletions docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,41 @@ the configuration (without a prefix: ``Auto``).
int a; // My comment a vs. int a; // My comment a
int b = 2; // comment b int b = 2; // comment about b

**AllowAllArgumentsOnNextLine** (``bool``)
If a function call or braced initializer list doesn't fit on a
line, allow putting all arguments onto the next line, even if
``BinPackArguments`` is ``false``.

.. code-block:: c++

true:
callFunction(
a, b, c, d);

false:
callFunction(a,
b,
c,
d);

**AllowAllConstructorInitializersOnNextLine** (``bool``)
If a constructor definition with a member initializer list doesn't
fit on a single line, allow putting all member initializers onto the next
line, if ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is true.
Note that this parameter has no effect if
```ConstructorInitializerAllOnOneLineOrOnePerLine``` is false.

.. code-block:: c++

true:
MyClass::MyClass() :
member0(0), member1(2) {}

false:
MyClass::MyClass() :
member0(0),
member1(2) {}

**AllowAllParametersOfDeclarationOnNextLine** (``bool``)
If the function declaration doesn't fit on a line,
allow putting all parameters of a function declaration onto
Expand Down
5 changes: 3 additions & 2 deletions docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ release of Clang. Users of the build system should adjust accordingly.
AST Matchers
------------

- Add language support for clang-formatting C# files
- Add Microsoft coding style to encapsulate default C# formatting style
- ...

clang-format
------------

- Add language support for clang-formatting C# files
- Add Microsoft coding style to encapsulate default C# formatting style
- Added new option `PPDIS_BeforeHash` (in configuration: `BeforeHash`) to
`IndentPPDirectives` which indents preprocessor directives before the hash.

Expand Down
14 changes: 14 additions & 0 deletions include/clang/AST/GlobalDecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ class GlobalDecl {
return Result;
}

GlobalDecl getWithCtorType(CXXCtorType Type) {
assert(isa<CXXConstructorDecl>(getDecl()));
GlobalDecl Result(*this);
Result.Value.setInt(Type);
return Result;
}

GlobalDecl getWithDtorType(CXXDtorType Type) {
assert(isa<CXXDestructorDecl>(getDecl()));
GlobalDecl Result(*this);
Result.Value.setInt(Type);
return Result;
}

GlobalDecl getWithMultiVersionIndex(unsigned Index) {
assert(isa<FunctionDecl>(getDecl()) &&
!isa<CXXConstructorDecl>(getDecl()) &&
Expand Down
6 changes: 4 additions & 2 deletions include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,14 @@ def err_pp_hash_error : Error<"%0">;
}

def pp_include_next_in_primary : Warning<
"#include_next in primary source file">,
"#include_next in primary source file; "
"will search from start of include path">,
InGroup<DiagGroup<"include-next-outside-header">>;
def pp_include_macros_out_of_predefines : Error<
"the #__include_macros directive is only for internal use by -imacros">;
def pp_include_next_absolute_path : Warning<
"#include_next with absolute path">,
"#include_next in file found relative to primary source file or found by "
"absolute path; will search from start of include path">,
InGroup<DiagGroup<"include-next-absolute-path">>;
def ext_c99_whitespace_required_after_macro_name : ExtWarn<
"ISO C99 requires whitespace after the macro name">, InGroup<C99>;
Expand Down
8 changes: 6 additions & 2 deletions include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -7200,8 +7200,9 @@ def err_cuda_device_exceptions : Error<
def err_dynamic_var_init : Error<
"dynamic initialization is not supported for "
"__device__, __constant__, and __shared__ variables.">;
def err_shared_var_init : Error<
"initialization is not supported for __shared__ variables.">;
def warn_shared_var_init : Warning<
"initialization is not supported for __shared__ variables.">,
InGroup<DiagGroup<"cuda-shared-init">>, DefaultError;
def err_device_static_local_var : Error<
"within a %select{__device__|__global__|__host__|__host__ __device__}0 "
"function, only __shared__ variables or const variables without device "
Expand Down Expand Up @@ -9232,6 +9233,9 @@ def warn_omp_used_different_allocator : Warning<
InGroup<OpenMPClauses>;
def note_omp_previous_allocator : Note<
"previous allocator is specified here">;
def err_expected_allocator_clause : Error<"expected an 'allocator' clause "
"inside of the target region; provide an 'allocator' clause or use 'requires'"
" directive with the 'dynamic_allocators' clause">;
} // end of OpenMP category

let CategoryName = "Related Result Type Issue" in {
Expand Down
37 changes: 36 additions & 1 deletion include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,38 @@ struct FormatStyle {
/// \endcode
bool AlignTrailingComments;

/// \brief If a function call or braced initializer list doesn't fit on a
/// line, allow putting all arguments onto the next line, even if
/// ``BinPackArguments`` is ``false``.
/// \code
/// true:
/// callFunction(
/// a, b, c, d);
///
/// false:
/// callFunction(a,
/// b,
/// c,
/// d);
/// \endcode
bool AllowAllArgumentsOnNextLine;

/// \brief If a constructor definition with a member initializer list doesn't
/// fit on a single line, allow putting all member initializers onto the next
/// line, if ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is true.
/// Note that this parameter has no effect if
/// ```ConstructorInitializerAllOnOneLineOrOnePerLine``` is false.
/// \code
/// true:
/// MyClass::MyClass() :
/// member0(0), member1(2) {}
///
/// false:
/// MyClass::MyClass() :
/// member0(0),
/// member1(2) {}
bool AllowAllConstructorInitializersOnNextLine;

/// If the function declaration doesn't fit on a line,
/// allow putting all parameters of a function declaration onto
/// the next line even if ``BinPackParameters`` is ``false``.
Expand Down Expand Up @@ -1169,7 +1201,7 @@ struct FormatStyle {

/// A vector of prefixes ordered by the desired groups for Java imports.
///
/// Each group is seperated by a newline. Static imports will also follow the
/// Each group is separated by a newline. Static imports will also follow the
/// same grouping convention above all non-static imports. One group's prefix
/// can be a subset of another - the longest prefix is always matched. Within
/// a group, the imports are ordered lexicographically.
Expand Down Expand Up @@ -1761,6 +1793,9 @@ struct FormatStyle {
AlignEscapedNewlines == R.AlignEscapedNewlines &&
AlignOperands == R.AlignOperands &&
AlignTrailingComments == R.AlignTrailingComments &&
AllowAllArgumentsOnNextLine == R.AllowAllArgumentsOnNextLine &&
AllowAllConstructorInitializersOnNextLine ==
R.AllowAllConstructorInitializersOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOnNextLine &&
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
Expand Down
4 changes: 2 additions & 2 deletions include/clang/Tooling/Inclusions/IncludeStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct IncludeStyle {
/// used for ordering ``#includes``.
///
/// `POSIX extended
/// <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
/// <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html>`_
/// regular expressions are supported.
///
/// These regular expressions are matched against the filename of an include
Expand All @@ -79,7 +79,7 @@ struct IncludeStyle {
/// If none of the regular expressions match, INT_MAX is assigned as
/// category. The main header for a source file automatically gets category 0.
/// so that it is generally kept at the beginning of the ``#includes``
/// (http://llvm.org/docs/CodingStandards.html#include-style). However, you
/// (https://llvm.org/docs/CodingStandards.html#include-style). However, you
/// can also assign negative priorities if you have certain headers that
/// always need to be first.
///
Expand Down
17 changes: 12 additions & 5 deletions lib/Basic/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ bool X86TargetInfo::initFeatureMap(
if (Kind != CK_Lakemont)
setFeatureEnabledImpl(Features, "x87", true);

// Enable cmpxchg8 for i586 and greater CPUs. Include generic for backwards
// compatibility.
if (Kind >= CK_i586 || Kind == CK_Generic)
setFeatureEnabledImpl(Features, "cx8", true);

switch (Kind) {
case CK_Generic:
case CK_i386:
Expand Down Expand Up @@ -777,6 +782,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasMOVBE = true;
} else if (Feature == "+sgx") {
HasSGX = true;
} else if (Feature == "+cx8") {
HasCX8 = true;
} else if (Feature == "+cx16") {
HasCX16 = true;
} else if (Feature == "+fxsr") {
Expand Down Expand Up @@ -1275,12 +1282,12 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
break;
}

if (CPU >= CK_i486) {
if (CPU >= CK_i486 || CPU == CK_Generic) {
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
}
if (CPU >= CK_i586)
if (HasCX8)
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
if (HasCX16 && getTriple().getArch() == llvm::Triple::x86_64)
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
Expand Down Expand Up @@ -1394,6 +1401,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
.Case("clflushopt", HasCLFLUSHOPT)
.Case("clwb", HasCLWB)
.Case("clzero", HasCLZERO)
.Case("cx8", HasCX8)
.Case("cx16", HasCX16)
.Case("f16c", HasF16C)
.Case("fma", HasFMA)
Expand Down Expand Up @@ -1819,10 +1827,9 @@ void X86TargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {
#define PROC(ENUM, STRING, IS64BIT) \
if (IS64BIT || getTriple().getArch() == llvm::Triple::x86) \
Values.emplace_back(STRING);
// Go through CPUKind checking to ensure that the alias is de-aliased and
// 64 bit-ness is checked.
// For aliases we need to lookup the CPUKind to check get the 64-bit ness.
#define PROC_ALIAS(ENUM, ALIAS) \
if (checkCPUKind(getCPUKind(ALIAS))) \
if (checkCPUKind(CK_##ENUM)) \
Values.emplace_back(ALIAS);
#include "clang/Basic/X86Target.def"
}
Expand Down
11 changes: 8 additions & 3 deletions lib/Basic/Targets/X86.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
bool HasMPX = false;
bool HasSHSTK = false;
bool HasSGX = false;
bool HasCX8 = false;
bool HasCX16 = false;
bool HasFXSR = false;
bool HasXSAVE = false;
Expand Down Expand Up @@ -345,9 +346,8 @@ class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo {
(1 << TargetInfo::LongDouble));

// x86-32 has atomics up to 8 bytes
// FIXME: Check that we actually have cmpxchg8b before setting
// MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
MaxAtomicPromoteWidth = 64;
MaxAtomicInlineWidth = 32;
}

BuiltinVaListKind getBuiltinVaListKind() const override {
Expand Down Expand Up @@ -383,6 +383,11 @@ class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo {
return X86TargetInfo::validateOperandSize(Constraint, Size);
}

void setMaxAtomicWidth() override {
if (hasFeature("cx8"))
MaxAtomicInlineWidth = 64;
}

ArrayRef<Builtin::Info> getTargetBuiltins() const override;
};

Expand Down
5 changes: 2 additions & 3 deletions lib/CodeGen/CGAMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,13 @@ void CGAMPRuntime::EmitCXXAMPDeserializer(CodeGenFunction &CGF,
}

// Emit code to call the deserializing constructor
llvm::Constant *Callee = CGM.getAddrOfCXXStructor(DeserializeConstructor,
StructorType::Complete);
llvm::Constant *Callee = CGM.getAddrOfCXXStructor(GlobalDecl(DeserializeConstructor,Dtor_Complete));

const FunctionProtoType *FPT =
DeserializeConstructor->getType()->castAs<FunctionProtoType>();

const CGFunctionInfo &DesFnInfo =
CGM.getTypes().arrangeCXXStructorDeclaration(DeserializeConstructor, StructorType::Complete);
CGM.getTypes().arrangeCXXStructorDeclaration(GlobalDecl(DeserializeConstructor, Dtor_Complete));

for (unsigned I = 1, E = DeserializerArgs.size(); I != E; ++I) {
auto T = FPT->getParamType(I-1);
Expand Down
7 changes: 7 additions & 0 deletions lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5097,6 +5097,13 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(

switch (BuiltinID) {
default: break;
case NEON::BI__builtin_neon_vpadd_v:
case NEON::BI__builtin_neon_vpaddq_v:
// We don't allow fp/int overloading of intrinsics.
if (VTy->getElementType()->isFloatingPointTy() &&
Int == Intrinsic::aarch64_neon_addp)
Int = Intrinsic::aarch64_neon_faddp;
break;
case NEON::BI__builtin_neon_vabs_v:
case NEON::BI__builtin_neon_vabsq_v:
if (VTy->getElementType()->isFloatingPointTy())
Expand Down
39 changes: 13 additions & 26 deletions lib/CodeGen/CGCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,50 +203,37 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
return false;
}

llvm::Function *CodeGenModule::codegenCXXStructor(const CXXMethodDecl *MD,
StructorType Type) {
const CGFunctionInfo &FnInfo =
getTypes().arrangeCXXStructorDeclaration(MD, Type);
llvm::Function *CodeGenModule::codegenCXXStructor(GlobalDecl GD) {
const CGFunctionInfo &FnInfo = getTypes().arrangeCXXStructorDeclaration(GD);
auto *Fn = cast<llvm::Function>(
getAddrOfCXXStructor(MD, Type, &FnInfo, /*FnType=*/nullptr,
getAddrOfCXXStructor(GD, &FnInfo, /*FnType=*/nullptr,
/*DontDefer=*/true, ForDefinition));

GlobalDecl GD;
if (const auto *DD = dyn_cast<CXXDestructorDecl>(MD)) {
GD = GlobalDecl(DD, toCXXDtorType(Type));
} else {
const auto *CD = cast<CXXConstructorDecl>(MD);
GD = GlobalDecl(CD, toCXXCtorType(Type));
}

setFunctionLinkage(GD, Fn);

CodeGenFunction(*this).GenerateCode(GD, Fn, FnInfo);
setNonAliasAttributes(GD, Fn);
SetLLVMFunctionAttributesForDefinition(MD, Fn);
SetLLVMFunctionAttributesForDefinition(cast<CXXMethodDecl>(GD.getDecl()), Fn);
return Fn;
}

llvm::FunctionCallee CodeGenModule::getAddrAndTypeOfCXXStructor(
const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo,
llvm::FunctionType *FnType, bool DontDefer,
ForDefinition_t IsForDefinition) {
GlobalDecl GD, const CGFunctionInfo *FnInfo, llvm::FunctionType *FnType,
bool DontDefer, ForDefinition_t IsForDefinition) {
auto *MD = cast<CXXMethodDecl>(GD.getDecl());

GlobalDecl GD;
if (auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
GD = GlobalDecl(CD, toCXXCtorType(Type));
} else {
if (isa<CXXDestructorDecl>(MD)) {
// Always alias equivalent complete destructors to base destructors in the
// MS ABI.
if (getTarget().getCXXABI().isMicrosoft() &&
Type == StructorType::Complete && MD->getParent()->getNumVBases() == 0)
Type = StructorType::Base;
GD = GlobalDecl(cast<CXXDestructorDecl>(MD), toCXXDtorType(Type));
GD.getDtorType() == Dtor_Complete &&
MD->getParent()->getNumVBases() == 0)
GD = GD.getWithDtorType(Dtor_Base);
}

if (!FnType) {
if (!FnInfo)
FnInfo = &getTypes().arrangeCXXStructorDeclaration(MD, Type);
FnInfo = &getTypes().arrangeCXXStructorDeclaration(GD);
FnType = getTypes().GetFunctionType(*FnInfo);
}

Expand Down Expand Up @@ -313,7 +300,7 @@ CodeGenFunction::BuildAppleKextVirtualDestructorCall(
assert(DD->isVirtual() && Type != Dtor_Base);
// Compute the function type we're calling.
const CGFunctionInfo &FInfo = CGM.getTypes().arrangeCXXStructorDeclaration(
DD, StructorType::Complete);
GlobalDecl(DD, Dtor_Complete));
llvm::Type *Ty = CGM.getTypes().GetFunctionType(FInfo);
return ::BuildAppleKextVirtualCall(*this, GlobalDecl(DD, Type), Ty, RD);
}
Loading

0 comments on commit 785f31d

Please sign in to comment.