Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from llvm:main #10

Merged
merged 24 commits into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
da81ec6
[SimplifyCFG] Volatile memory operations do not trap
LebedevRI Jul 2, 2021
35d4593
Add C API files for the LLVM dialect
apaszke Jul 2, 2021
51fecd1
[InstCombine] Don't combine PHI before catchswitch
aheejin Jul 1, 2021
53fef0b
[NFCI][SimplifyCFG] simplifyUnreachable(): Use poison constant to rep…
LebedevRI Jul 2, 2021
0111da2
[GlobalISel] Add re-association combine for G_PTR_ADD to allow better…
aemerson Jun 27, 2021
aa319f5
[lldb] [gdb-remote client] Support switching PID along with TID
mgorny Apr 11, 2021
7dd8f98
[NFC][SimplifyCFG] Autogenerate checklines in a few tests
LebedevRI Jul 2, 2021
5d689cf
[NFC][CUDA] Fix order of round(f) definition in __clang_cuda_math.h f…
fodinabor Jul 2, 2021
f30251f
[GlobalISel] Clean up CombinerHelper::apply* functions to return void.
aemerson Jul 2, 2021
707bda6
[lldb/test] Fix failure caused by synthetic symbol name refactoring
medismailben Jul 2, 2021
261c56f
[NFC][Codegen] Tune a few tests to not end with a naked `unreachable`…
LebedevRI Jul 2, 2021
f9d8b8d
[NFC][Codegen] Autogenerate check lines in PowerPC/2007-11-16-landing…
LebedevRI Jul 2, 2021
dd1c4bd
Name all DEATH tests using 'DeathTest' suffix.
hctim Jul 2, 2021
cb5de7c
[mlir][Vector] NFC - Compress vector to outerproduct lowering.
nicolasvasilache Jul 2, 2021
bf7f846
Fix test so it doesn't try to write to the test directory, only to %t
dwblaikie Jul 2, 2021
a5c3f10
[lldb] Update shebang in heap.py and crashlog.py
JDevlieghere Jul 2, 2021
24f4c3e
Lex: add a callback for `#pragma mark`
compnerd Jul 2, 2021
b8a021d
[mlir][sparse] support for negation and subtractions
aartbik Jul 2, 2021
52b5491
Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes"
JDevlieghere Jul 2, 2021
6b0d266
Revert "Create synthetic symbol names on demand to improve memory con…
JDevlieghere Jul 2, 2021
252a1ee
[ThinLTO] Respect ClearDSOLocalOnDeclarations for unimported functions
MaskRay Jul 3, 2021
af331e8
[SelectionDAG] Rename memory VT argument for getMaskedGather/getMaske…
topperc Jul 3, 2021
c063946
[AIX] Adjust CSR order to avoid breaking ABI regarding traceback
Jul 3, 2021
fbc329e
[AArch64] Add S/UQXTRN tablegen patterns.
davemgreen Jul 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Lex/PPCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ class PPCallbacks {
StringRef Str) {
}

/// Callback invoked when a \#pragma mark comment is read.
virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
}

/// Callback invoked when a \#pragma detect_mismatch directive is
/// read.
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ class Preprocessor {

public:
void HandlePragmaOnce(Token &OnceTok);
void HandlePragmaMark();
void HandlePragmaMark(Token &MarkTok);
void HandlePragmaPoison();
void HandlePragmaSystemHeader(Token &SysHeaderTok);
void HandlePragmaDependency(Token &DependencyTok);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Headers/__clang_cuda_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ __DEVICE__ long long llrint(double __a) { return __nv_llrint(__a); }
__DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); }
__DEVICE__ long long llround(double __a) { return __nv_llround(__a); }
__DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); }
__DEVICE__ double round(double __a) { return __nv_round(__a); }
__DEVICE__ float roundf(float __a) { return __nv_roundf(__a); }
__DEVICE__ double log(double __a) { return __nv_log(__a); }
__DEVICE__ double log10(double __a) { return __nv_log10(__a); }
__DEVICE__ float log10f(float __a) { return __nv_log10f(__a); }
Expand Down Expand Up @@ -270,8 +272,6 @@ __DEVICE__ float rnorm4df(float __a, float __b, float __c, float __d) {
__DEVICE__ float rnormf(int __dim, const float *__t) {
return __nv_rnormf(__dim, __t);
}
__DEVICE__ double round(double __a) { return __nv_round(__a); }
__DEVICE__ float roundf(float __a) { return __nv_roundf(__a); }
__DEVICE__ double rsqrt(double __a) { return __nv_rsqrt(__a); }
__DEVICE__ float rsqrtf(float __a) { return __nv_rsqrtf(__a); }
__DEVICE__ double scalbn(double __a, int __b) { return __nv_scalbn(__a, __b); }
Expand Down
10 changes: 7 additions & 3 deletions clang/lib/Lex/Pragma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,13 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
HeaderInfo.MarkFileIncludeOnce(getCurrentFileLexer()->getFileEntry());
}

void Preprocessor::HandlePragmaMark() {
void Preprocessor::HandlePragmaMark(Token &MarkTok) {
assert(CurPPLexer && "No current lexer?");
CurLexer->ReadToEndOfLine();

SmallString<64> Buffer;
CurLexer->ReadToEndOfLine(&Buffer);
if (Callbacks)
Callbacks->PragmaMark(MarkTok.getLocation(), Buffer);
}

/// HandlePragmaPoison - Handle \#pragma GCC poison. PoisonTok is the 'poison'.
Expand Down Expand Up @@ -992,7 +996,7 @@ struct PragmaMarkHandler : public PragmaHandler {

void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
Token &MarkTok) override {
PP.HandlePragmaMark();
PP.HandlePragmaMark(MarkTok);
}
};

Expand Down
62 changes: 62 additions & 0 deletions clang/unittests/Lex/PPCallbacksTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ class PragmaOpenCLExtensionCallbacks : public PPCallbacks {
unsigned State;
};

class PragmaMarkCallbacks : public PPCallbacks {
public:
struct Mark {
SourceLocation Location;
std::string Trivia;
};

std::vector<Mark> Marks;

void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
Marks.emplace_back(Mark{Loc, Trivia.str()});
}
};

// PPCallbacks test fixture.
class PPCallbacksTest : public ::testing::Test {
protected:
Expand Down Expand Up @@ -256,6 +270,36 @@ class PPCallbacksTest : public ::testing::Test {
return Callbacks->Results;
}

std::vector<PragmaMarkCallbacks::Mark>
PragmaMarkCall(const char *SourceText) {
std::unique_ptr<llvm::MemoryBuffer> SourceBuf =
llvm::MemoryBuffer::getMemBuffer(SourceText, "test.c");
SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));

HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
Diags, LangOpts, Target.get());
TrivialModuleLoader ModLoader;

Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
SourceMgr, HeaderInfo, ModLoader, /*IILookup=*/nullptr,
/*OwnsHeaderSearch=*/false);
PP.Initialize(*Target);

auto *Callbacks = new PragmaMarkCallbacks;
PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(Callbacks));

// Lex source text.
PP.EnterMainSourceFile();
while (true) {
Token Tok;
PP.Lex(Tok);
if (Tok.is(tok::eof))
break;
}

return Callbacks->Marks;
}

PragmaOpenCLExtensionCallbacks::CallbackParameters
PragmaOpenCLExtensionCall(const char *SourceText) {
LangOptions OpenCLLangOpts;
Expand Down Expand Up @@ -424,6 +468,24 @@ TEST_F(PPCallbacksTest, OpenCLExtensionPragmaDisabled) {
ASSERT_EQ(ExpectedState, Parameters.State);
}

TEST_F(PPCallbacksTest, CollectMarks) {
const char *Source =
"#pragma mark\n"
"#pragma mark\r\n"
"#pragma mark - trivia\n"
"#pragma mark - trivia\r\n";

auto Marks = PragmaMarkCall(Source);

ASSERT_EQ(4u, Marks.size());
ASSERT_TRUE(Marks[0].Trivia.empty());
ASSERT_TRUE(Marks[1].Trivia.empty());
ASSERT_FALSE(Marks[2].Trivia.empty());
ASSERT_FALSE(Marks[3].Trivia.empty());
ASSERT_EQ(" - trivia", Marks[2].Trivia);
ASSERT_EQ(" - trivia", Marks[3].Trivia);
}

TEST_F(PPCallbacksTest, DirectiveExprRanges) {
const auto &Results1 = DirectiveExprRange("#if FLUZZY_FLOOF\n#endif\n");
EXPECT_EQ(Results1.size(), 1U);
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/gwp_asan/tests/backtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ __attribute__((optnone)) void TouchMemory(void *Ptr) {
*(reinterpret_cast<volatile char *>(Ptr)) = 7;
}

TEST_F(BacktraceGuardedPoolAllocator, DoubleFree) {
TEST_F(BacktraceGuardedPoolAllocatorDeathTest, DoubleFree) {
void *Ptr = AllocateMemory(GPA);
DeallocateMemory(GPA, Ptr);

Expand All @@ -45,7 +45,7 @@ TEST_F(BacktraceGuardedPoolAllocator, DoubleFree) {
ASSERT_DEATH(DeallocateMemory2(GPA, Ptr), DeathRegex);
}

TEST_F(BacktraceGuardedPoolAllocator, UseAfterFree) {
TEST_F(BacktraceGuardedPoolAllocatorDeathTest, UseAfterFree) {
void *Ptr = AllocateMemory(GPA);
DeallocateMemory(GPA, Ptr);

Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/gwp_asan/tests/enable_disable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

constexpr size_t Size = 100;

TEST_F(DefaultGuardedPoolAllocator, Fork) {
TEST_F(DefaultGuardedPoolAllocatorDeathTest, Fork) {
void *P;
pid_t Pid = fork();
EXPECT_GE(Pid, 0);
Expand Down
5 changes: 5 additions & 0 deletions compiler-rt/lib/gwp_asan/tests/harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ class BacktraceGuardedPoolAllocator : public Test {
gwp_asan::GuardedPoolAllocator GPA;
};

// https://github.com/google/googletest/blob/master/docs/advanced.md#death-tests-and-threads
using DefaultGuardedPoolAllocatorDeathTest = DefaultGuardedPoolAllocator;
using CustomGuardedPoolAllocatorDeathTest = CustomGuardedPoolAllocator;
using BacktraceGuardedPoolAllocatorDeathTest = BacktraceGuardedPoolAllocator;

#endif // GWP_ASAN_TESTS_HARNESS_H_
4 changes: 2 additions & 2 deletions compiler-rt/lib/scudo/standalone/tests/chunk_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static void initChecksum(void) {
scudo::HashAlgorithm = scudo::Checksum::HardwareCRC32;
}

TEST(ScudoChunkTest, ChunkBasic) {
TEST(ScudoChunkDeathTest, ChunkBasic) {
initChecksum();
const scudo::uptr Size = 0x100U;
scudo::Chunk::UnpackedHeader Header = {};
Expand Down Expand Up @@ -60,7 +60,7 @@ TEST(ScudoChunkTest, ChunkCmpXchg) {
free(Block);
}

TEST(ScudoChunkTest, CorruptHeader) {
TEST(ScudoChunkDeathTest, CorruptHeader) {
initChecksum();
const scudo::uptr Size = 0x100U;
scudo::Chunk::UnpackedHeader Header = {};
Expand Down
14 changes: 8 additions & 6 deletions compiler-rt/lib/scudo/standalone/tests/combined_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ template <class TypeParam> struct ScudoCombinedTest : public Test {
std::unique_ptr<AllocatorT> Allocator;
};

template <typename T> using ScudoCombinedDeathTest = ScudoCombinedTest<T>;

#if SCUDO_FUCHSIA
#define SCUDO_TYPED_TEST_ALL_TYPES(FIXTURE, NAME) \
SCUDO_TYPED_TEST_TYPE(FIXTURE, NAME, AndroidSvelteConfig) \
Expand Down Expand Up @@ -166,7 +168,7 @@ void ScudoCombinedTest<Config>::BasicTest(scudo::uptr SizeLog) {
}

#define SCUDO_MAKE_BASIC_TEST(SizeLog) \
SCUDO_TYPED_TEST(ScudoCombinedTest, BasicCombined##SizeLog) { \
SCUDO_TYPED_TEST(ScudoCombinedDeathTest, BasicCombined##SizeLog) { \
this->BasicTest(SizeLog); \
}

Expand Down Expand Up @@ -314,7 +316,7 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateLargeDecreasing) {
Allocator->deallocate(P, Origin);
}

SCUDO_TYPED_TEST(ScudoCombinedTest, ReallocateSame) {
SCUDO_TYPED_TEST(ScudoCombinedDeathTest, ReallocateSame) {
auto *Allocator = this->Allocator.get();

// Check that reallocating a chunk to a slightly smaller or larger size
Expand Down Expand Up @@ -365,7 +367,7 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, IterateOverChunks) {
}
}

SCUDO_TYPED_TEST(ScudoCombinedTest, UseAfterFree) {
SCUDO_TYPED_TEST(ScudoCombinedDeathTest, UseAfterFree) {
auto *Allocator = this->Allocator.get();

// Check that use-after-free is detected.
Expand All @@ -392,7 +394,7 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, UseAfterFree) {
}
}

SCUDO_TYPED_TEST(ScudoCombinedTest, DisableMemoryTagging) {
SCUDO_TYPED_TEST(ScudoCombinedDeathTest, DisableMemoryTagging) {
auto *Allocator = this->Allocator.get();

if (Allocator->useMemoryTaggingTestOnly()) {
Expand Down Expand Up @@ -490,7 +492,7 @@ SCUDO_TYPED_TEST(ScudoCombinedTest, ThreadedCombined) {

// Test that multiple instantiations of the allocator have not messed up the
// process's signal handlers (GWP-ASan used to do this).
TEST(ScudoCombinedTest, SKIP_ON_FUCHSIA(testSEGV)) {
TEST(ScudoCombinedDeathTest, SKIP_ON_FUCHSIA(testSEGV)) {
const scudo::uptr Size = 4 * scudo::getPageSizeCached();
scudo::MapPlatformData Data = {};
void *P = scudo::map(nullptr, Size, "testSEGV", MAP_NOACCESS, &Data);
Expand Down Expand Up @@ -528,7 +530,7 @@ struct DeathConfig {
template <class A> using TSDRegistryT = scudo::TSDRegistrySharedT<A, 1U, 1U>;
};

TEST(ScudoCombinedTest, DeathCombined) {
TEST(ScudoCombinedDeathTest, DeathCombined) {
using AllocatorT = TestAllocator<DeathConfig>;
auto Allocator = std::unique_ptr<AllocatorT>(new AllocatorT());

Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/lib/scudo/standalone/tests/map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST(ScudoMapTest, PageSize) {
static_cast<scudo::uptr>(getpagesize()));
}

TEST(ScudoMapTest, MapNoAccessUnmap) {
TEST(ScudoMapDeathTest, MapNoAccessUnmap) {
const scudo::uptr Size = 4 * scudo::getPageSizeCached();
scudo::MapPlatformData Data = {};
void *P = scudo::map(nullptr, Size, MappingName, MAP_NOACCESS, &Data);
Expand All @@ -29,7 +29,7 @@ TEST(ScudoMapTest, MapNoAccessUnmap) {
scudo::unmap(P, Size, UNMAP_ALL, &Data);
}

TEST(ScudoMapTest, MapUnmap) {
TEST(ScudoMapDeathTest, MapUnmap) {
const scudo::uptr Size = 4 * scudo::getPageSizeCached();
EXPECT_DEATH(
{
Expand All @@ -46,7 +46,7 @@ TEST(ScudoMapTest, MapUnmap) {
"");
}

TEST(ScudoMapTest, MapWithGuardUnmap) {
TEST(ScudoMapDeathTest, MapWithGuardUnmap) {
const scudo::uptr PageSize = scudo::getPageSizeCached();
const scudo::uptr Size = 4 * PageSize;
scudo::MapPlatformData Data = {};
Expand Down
12 changes: 7 additions & 5 deletions compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#if SCUDO_LINUX
namespace scudo {

TEST(MemtagBasicTest, Unsupported) {
TEST(MemtagBasicDeathTest, Unsupported) {
if (archSupportsMemoryTagging())
GTEST_SKIP();

Expand Down Expand Up @@ -63,6 +63,8 @@ class MemtagTest : public ::testing::Test {
uptr Addr = 0;
};

using MemtagDeathTest = MemtagTest;

TEST_F(MemtagTest, ArchMemoryTagGranuleSize) {
EXPECT_GT(archMemoryTagGranuleSize(), 1u);
EXPECT_TRUE(isPowerOfTwo(archMemoryTagGranuleSize()));
Expand All @@ -77,7 +79,7 @@ TEST_F(MemtagTest, ExtractTag) {
EXPECT_EQ(0xffffull, Tags);
}

TEST_F(MemtagTest, AddFixedTag) {
TEST_F(MemtagDeathTest, AddFixedTag) {
for (uptr Tag = 0; Tag < 0x10; ++Tag)
EXPECT_EQ(Tag, extractTag(addFixedTag(Addr, Tag)));
if (SCUDO_DEBUG) {
Expand All @@ -94,7 +96,7 @@ TEST_F(MemtagTest, UntagPointer) {
}
}

TEST_F(MemtagTest, ScopedDisableMemoryTagChecks) {
TEST_F(MemtagDeathTest, ScopedDisableMemoryTagChecks) {
u8 *P = reinterpret_cast<u8 *>(addFixedTag(Addr, 1));
EXPECT_NE(P, Buffer);

Expand All @@ -120,7 +122,7 @@ TEST_F(MemtagTest, SelectRandomTagWithMask) {
}
}

TEST_F(MemtagTest, SKIP_NO_DEBUG(LoadStoreTagUnaligned)) {
TEST_F(MemtagDeathTest, SKIP_NO_DEBUG(LoadStoreTagUnaligned)) {
for (uptr P = Addr; P < Addr + 4 * archMemoryTagGranuleSize(); ++P) {
if (P % archMemoryTagGranuleSize() == 0)
continue;
Expand All @@ -141,7 +143,7 @@ TEST_F(MemtagTest, LoadStoreTag) {
loadTag(Base + archMemoryTagGranuleSize()));
}

TEST_F(MemtagTest, SKIP_NO_DEBUG(StoreTagsUnaligned)) {
TEST_F(MemtagDeathTest, SKIP_NO_DEBUG(StoreTagsUnaligned)) {
for (uptr P = Addr; P < Addr + 4 * archMemoryTagGranuleSize(); ++P) {
uptr Tagged = addFixedTag(P, 5);
if (Tagged % archMemoryTagGranuleSize() == 0)
Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/lib/scudo/standalone/tests/report_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

#include "report.h"

TEST(ScudoReportTest, Check) {
TEST(ScudoReportDeathTest, Check) {
CHECK_LT(-1, 1);
EXPECT_DEATH(CHECK_GT(-1, 1),
"\\(-1\\) > \\(1\\) \\(\\(u64\\)op1=18446744073709551615, "
"\\(u64\\)op2=1");
}

TEST(ScudoReportTest, Generic) {
TEST(ScudoReportDeathTest, Generic) {
// Potentially unused if EXPECT_DEATH isn't defined.
UNUSED void *P = reinterpret_cast<void *>(0x42424242U);
EXPECT_DEATH(scudo::reportError("TEST123"), "Scudo ERROR.*TEST123");
Expand Down Expand Up @@ -45,7 +45,7 @@ TEST(ScudoReportTest, Generic) {
"Scudo ERROR.*42424242.*123.*456");
}

TEST(ScudoReportTest, CSpecific) {
TEST(ScudoReportDeathTest, CSpecific) {
EXPECT_DEATH(scudo::reportAlignmentNotPowerOfTwo(123), "Scudo ERROR.*123");
EXPECT_DEATH(scudo::reportCallocOverflow(123, 456), "Scudo ERROR.*123.*456");
EXPECT_DEATH(scudo::reportInvalidPosixMemalignAlignment(789),
Expand Down
Loading