Skip to content

Commit

Permalink
Merged master:09311459e37 into amd-gfx:0f31e70c1aa
Browse files Browse the repository at this point in the history
Local branch amd-gfx 0f31e70 Merged master:41eeded8043 into amd-gfx:936fb7dd0a6
Remote branch master 0931145 [InstCombine] Extend  fold to non-splat vectors
  • Loading branch information
Sw authored and Sw committed Dec 5, 2019
2 parents 0f31e70 + 0931145 commit d6d21f5
Show file tree
Hide file tree
Showing 56 changed files with 1,353 additions and 334 deletions.
153 changes: 152 additions & 1 deletion clang-tools-extra/clangd/unittests/RenameTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//

#include "Annotations.h"
#include "ClangdServer.h"
#include "SyncAPI.h"
#include "TestFS.h"
#include "TestTU.h"
#include "index/Ref.h"
Expand Down Expand Up @@ -575,7 +577,7 @@ TEST(RenameTest, MainFileReferencesOnly) {
expectedResult(Code, NewName));
}

TEST(RenameTests, CrossFile) {
TEST(CrossFileRenameTests, DirtyBuffer) {
Annotations FooCode("class [[Foo]] {};");
std::string FooPath = testPath("foo.cc");
Annotations FooDirtyBuffer("class [[Foo]] {};\n// this is dirty buffer");
Expand Down Expand Up @@ -658,6 +660,155 @@ TEST(RenameTests, CrossFile) {
testing::HasSubstr("too many occurrences"));
}

TEST(CrossFileRenameTests, WithUpToDateIndex) {
MockCompilationDatabase CDB;
CDB.ExtraClangFlags = {"-xc++"};
class IgnoreDiagnostics : public DiagnosticsConsumer {
void onDiagnosticsReady(PathRef File,
std::vector<Diag> Diagnostics) override {}
} DiagConsumer;
// rename is runnning on the "^" point in FooH, and "[[]]" ranges are the
// expcted rename occurrences.
struct Case {
llvm::StringRef FooH;
llvm::StringRef FooCC;
} Cases [] = {
{
// classes.
R"cpp(
class [[Fo^o]] {
[[Foo]]();
~[[Foo]]();
};
)cpp",
R"cpp(
#include "foo.h"
[[Foo]]::[[Foo]]() {}
[[Foo]]::~[[Foo]]() {}
void func() {
[[Foo]] foo;
}
)cpp",
},
{
// class methods.
R"cpp(
class Foo {
void [[f^oo]]();
};
)cpp",
R"cpp(
#include "foo.h"
void Foo::[[foo]]() {}
void func(Foo* p) {
p->[[foo]]();
}
)cpp",
},
{
// functions.
R"cpp(
void [[f^oo]]();
)cpp",
R"cpp(
#include "foo.h"
void [[foo]]() {}
void func() {
[[foo]]();
}
)cpp",
},
{
// typedefs.
R"cpp(
typedef int [[IN^T]];
[[INT]] foo();
)cpp",
R"cpp(
#include "foo.h"
[[INT]] foo() {}
)cpp",
},
{
// usings.
R"cpp(
using [[I^NT]] = int;
[[INT]] foo();
)cpp",
R"cpp(
#include "foo.h"
[[INT]] foo() {}
)cpp",
},
{
// variables.
R"cpp(
static const int [[VA^R]] = 123;
)cpp",
R"cpp(
#include "foo.h"
int s = [[VAR]];
)cpp",
},
{
// scope enums.
R"cpp(
enum class [[K^ind]] { ABC };
)cpp",
R"cpp(
#include "foo.h"
[[Kind]] ff() {
return [[Kind]]::ABC;
}
)cpp",
},
{
// enum constants.
R"cpp(
enum class Kind { [[A^BC]] };
)cpp",
R"cpp(
#include "foo.h"
Kind ff() {
return Kind::[[ABC]];
}
)cpp",
},
};

for (const auto& T : Cases) {
Annotations FooH(T.FooH);
Annotations FooCC(T.FooCC);
std::string FooHPath = testPath("foo.h");
std::string FooCCPath = testPath("foo.cc");

MockFSProvider FS;
FS.Files[FooHPath] = FooH.code();
FS.Files[FooCCPath] = FooCC.code();

auto ServerOpts = ClangdServer::optsForTest();
ServerOpts.CrossFileRename = true;
ServerOpts.BuildDynamicSymbolIndex = true;
ClangdServer Server(CDB, FS, DiagConsumer, ServerOpts);

// Add all files to clangd server to make sure the dynamic index has been
// built.
runAddDocument(Server, FooHPath, FooH.code());
runAddDocument(Server, FooCCPath, FooCC.code());

llvm::StringRef NewName = "NewName";
auto FileEditsList =
llvm::cantFail(runRename(Server, FooHPath, FooH.point(), NewName));
EXPECT_THAT(applyEdits(std::move(FileEditsList)),
UnorderedElementsAre(
Pair(Eq(FooHPath), Eq(expectedResult(T.FooH, NewName))),
Pair(Eq(FooCCPath), Eq(expectedResult(T.FooCC, NewName)))));
}
}

TEST(CrossFileRenameTests, CrossFileOnLocalSymbol) {
// cross-file rename should work for function-local symbols, even there is no
// index provided.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/unittests/SyncAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos) {
llvm::Expected<FileEdits> runRename(ClangdServer &Server, PathRef File,
Position Pos, llvm::StringRef NewName) {
llvm::Optional<llvm::Expected<FileEdits>> Result;
Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
Server.rename(File, Pos, NewName, /*WantFormat=*/false, capture(Result));
return std::move(*Result);
}

Expand Down
54 changes: 50 additions & 4 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1231,10 +1231,10 @@ are listed below.

**-f[no-]trapping-math**

``-fno-trapping-math`` allows optimizations that assume that
floating point operations cannot generate traps such as divide-by-zero,
overflow and underflow. Defaults to ``-ftrapping-math``.
Currently this option has no effect.
Control floating point exception behavior. ``-fno-trapping-math`` allows optimizations that assume that floating point operations cannot generate traps such as divide-by-zero, overflow and underflow.

- The option ``-ftrapping-math`` behaves identically to ``-ffp-exception-behavior=strict``.
- The option ``-fno-trapping-math`` behaves identically to ``-ffp-exception-behavior=ignore``. This is the default.

.. option:: -ffp-contract=<value>

Expand Down Expand Up @@ -1319,6 +1319,52 @@ are listed below.

Defaults to ``-fno-finite-math``.

.. _opt_frounding-math:

**-f[no-]rounding-math**

Force floating-point operations to honor the dynamically-set rounding mode by default.

The result of a floating-point operation often cannot be exactly represented in the result type and therefore must be rounded. IEEE 754 describes different rounding modes that control how to perform this rounding, not all of which are supported by all implementations. C provides interfaces (``fesetround`` and ``fesetenv``) for dynamically controlling the rounding mode, and while it also recommends certain conventions for changing the rounding mode, these conventions are not typically enforced in the ABI. Since the rounding mode changes the numerical result of operations, the compiler must understand something about it in order to optimize floating point operations.

Note that floating-point operations performed as part of constant initialization are formally performed prior to the start of the program and are therefore not subject to the current rounding mode. This includes the initialization of global variables and local ``static`` variables. Floating-point operations in these contexts will be rounded using ``FE_TONEAREST``.

- The option ``-fno-rounding-math`` allows the compiler to assume that the rounding mode is set to ``FE_TONEAREST``. This is the default.
- The option ``-frounding-math`` forces the compiler to honor the dynamically-set rounding mode. This prevents optimizations which might affect results if the rounding mode changes or is different from the default; for example, it prevents floating-point operations from being reordered across most calls and prevents constant-folding when the result is not exactly representable.

.. option:: -ffp-model=<value>

Specify floating point behavior. ``-ffp-model`` is an umbrella
option that encompasses functionality provided by other, single
purpose, floating point options. Valid values are: ``precise``, ``strict``,
and ``fast``.
Details:

* ``precise`` Disables optimizations that are not value-safe on floating-point data, although FP contraction (FMA) is enabled (``-ffp-contract=fast``). This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and ``-ffp-exception-behavior=strict``, and disables contractions (FMA). All of the ``-ffast-math`` enablements are disabled.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and ``ffp-contract=fast``

Note: If your command line specifies multiple instances
of the ``-ffp-model`` option, or if your command line option specifies
``-ffp-model`` and later on the command line selects a floating point
option that has the effect of negating part of the ``ffp-model`` that
has been selected, then the compiler will issue a diagnostic warning
that the override has occurred.

.. option:: -ffp-exception-behavior=<value>

Specify the floating-point exception behavior.

Valid values are: ``ignore``, ``maytrap``, and ``strict``.
The default value is ``ignore``. Details:

* ``ignore`` The compiler assumes that the exception status flags will not be read and that floating point exceptions will be masked.
* ``maytrap`` The compiler avoids transformations that may raise exceptions that would not have been raised by the original code. Constant folding performed by the compiler is exempt from this option.
* ``strict`` The compiler ensures that all transformations strictly preserve the floating point exception semantics of the original code.




.. _controlling-code-generation:

Controlling Code Generation
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,10 @@ class FunctionDecl : public DeclaratorDecl,
bool usesSEHTry() const { return FunctionDeclBits.UsesSEHTry; }
void setUsesSEHTry(bool UST) { FunctionDeclBits.UsesSEHTry = UST; }

/// Indicates the function uses Floating Point constrained intrinsics
bool usesFPIntrin() const { return FunctionDeclBits.UsesFPIntrin; }
void setUsesFPIntrin(bool Val) { FunctionDeclBits.UsesFPIntrin = Val; }

/// Whether this function has been deleted.
///
/// A function that is "deleted" (via the C++0x "= delete" syntax)
Expand Down
7 changes: 5 additions & 2 deletions clang/include/clang/AST/DeclBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1534,10 +1534,13 @@ class DeclContext {

/// Store the ODRHash after first calculation.
uint64_t HasODRHash : 1;

/// Indicates if the function uses Floating Point Constrained Intrinsics
uint64_t UsesFPIntrin : 1;
};

/// Number of non-inherited bits in FunctionDeclBitfields.
enum { NumFunctionDeclBits = 25 };
enum { NumFunctionDeclBits = 26 };

/// Stores the bits used by CXXConstructorDecl. If modified
/// NumCXXConstructorDeclBits and the accessor
Expand All @@ -1554,7 +1557,7 @@ class DeclContext {
/// exactly 64 bits and thus the width of NumCtorInitializers
/// will need to be shrunk if some bit is added to NumDeclContextBitfields,
/// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
uint64_t NumCtorInitializers : 23;
uint64_t NumCtorInitializers : 22;
uint64_t IsInheritingConstructor : 1;

/// Whether this constructor has a trail-allocated explicit specifier.
Expand Down
10 changes: 5 additions & 5 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1120,27 +1120,27 @@ def OpenCLAccess : Attr {
}

def OpenCLPrivateAddressSpace : TypeAttr {
let Spellings = [Keyword<"__private">, Keyword<"private">];
let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">];
let Documentation = [OpenCLAddressSpacePrivateDocs];
}

def OpenCLGlobalAddressSpace : TypeAttr {
let Spellings = [Keyword<"__global">, Keyword<"global">];
let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">];
let Documentation = [OpenCLAddressSpaceGlobalDocs];
}

def OpenCLLocalAddressSpace : TypeAttr {
let Spellings = [Keyword<"__local">, Keyword<"local">];
let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">];
let Documentation = [OpenCLAddressSpaceLocalDocs];
}

def OpenCLConstantAddressSpace : TypeAttr {
let Spellings = [Keyword<"__constant">, Keyword<"constant">];
let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">];
let Documentation = [OpenCLAddressSpaceConstantDocs];
}

def OpenCLGenericAddressSpace : TypeAttr {
let Spellings = [Keyword<"__generic">, Keyword<"generic">];
let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">];
let Documentation = [OpenCLAddressSpaceGenericDocs];
}

Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ def warn_drv_experimental_isel_incomplete_opt : Warning<
"-fexperimental-isel support is incomplete for this architecture at the current optimization level">,
InGroup<ExperimentalISel>;

def warn_drv_experimental_fp_control_incomplete_opt : Warning<
"Support for floating point control option %0 is incomplete and experimental">,
InGroup<ExperimentalFloatControl>;

def warn_drv_moutline_unsupported_opt : Warning<
"The '%0' architecture does not support -moutline; flag ignored">,
InGroup<OptionIgnored>;
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ def SpirCompat : DiagGroup<"spir-compat">;
// Warning for the experimental-isel options.
def ExperimentalISel : DiagGroup<"experimental-isel">;

// Warning for the experimental float control options.
def ExperimentalFloatControl : DiagGroup<"experimental-float-control">;

// A warning group specifically for warnings related to function
// multiversioning.
def FunctionMultiVersioning : DiagGroup<"function-multiversion">;
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating poi
LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math")
/// FP_CONTRACT mode (on/off/fast).
ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP contraction type")
ENUM_LANGOPT(FPRoundingMode, FPRoundingModeKind, 3, FPR_ToNearest, "FP Rounding Mode type")
ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Ignore, "FP Exception Behavior Mode type")
LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")
LANGOPT(HexagonQdsp6Compat , 1, 0, "hexagon-qdsp6 backward compatibility")
LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")
Expand Down
28 changes: 28 additions & 0 deletions clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,34 @@ class LangOptions : public LangOptionsBase {
FEA_On
};

// Values of the following enumerations correspond to metadata arguments
// specified for constrained floating-point intrinsics:
// http://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics.

/// Possible rounding modes.
enum FPRoundingModeKind {
/// Rounding to nearest, corresponds to "round.tonearest".
FPR_ToNearest,
/// Rounding toward -Inf, corresponds to "round.downward".
FPR_Downward,
/// Rounding toward +Inf, corresponds to "round.upward".
FPR_Upward,
/// Rounding toward zero, corresponds to "round.towardzero".
FPR_TowardZero,
/// Is determined by runtime environment, corresponds to "round.dynamic".
FPR_Dynamic
};

/// Possible floating point exception behavior.
enum FPExceptionModeKind {
/// Assume that floating-point exceptions are masked.
FPE_Ignore,
/// Transformations do not cause new exceptions but may hide some.
FPE_MayTrap,
/// Strictly preserve the floating-point exception semantics.
FPE_Strict
};

enum class LaxVectorConversionKind {
/// Permit no implicit vector bitcasts.
None,
Expand Down
Loading

0 comments on commit d6d21f5

Please sign in to comment.