Skip to content

Commit

Permalink
Merged master:1ed2ca68191f into amd-gfx:3a9a669b4cd8
Browse files Browse the repository at this point in the history
Local branch amd-gfx 3a9a669 Merged master:7979f24954ed into amd-gfx:c0143b8db6c2
Remote branch master 1ed2ca6 [flang][driver] Use --match-full-lines in tests for
  • Loading branch information
Sw authored and Sw committed Nov 2, 2020
2 parents 3a9a669 + 1ed2ca6 commit cc8bae5
Show file tree
Hide file tree
Showing 114 changed files with 7,897 additions and 3,982 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/remote/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ int main(int argc, char *argv[]) {

std::thread HotReloadThread([&Index, &Status, &FS]() {
llvm::vfs::Status LastStatus = *Status;
static constexpr auto RefreshFrequency = std::chrono::seconds(90);
static constexpr auto RefreshFrequency = std::chrono::seconds(30);
while (!clang::clangd::shutdownRequested()) {
hotReload(*Index, llvm::StringRef(IndexPath), LastStatus, FS);
std::this_thread::sleep_for(RefreshFrequency);
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUN
set(CLANGD_TEST_DEPS
clangd
ClangdTests
# No tests for these, but we should still make sure they build.
clangd-indexer
# No tests for it, but we should still make sure they build.
dexp
)

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

lit.llvm.initialize(lit_config, config)
lit.llvm.llvm_config.use_clang()
lit.llvm.llvm_config.use_default_substitutions()

config.name = 'Clangd'
config.suffixes = ['.test']
Expand All @@ -26,3 +27,6 @@ def calculate_arch_features(arch_string):

if config.clangd_build_xpc:
config.available_features.add('clangd-xpc-support')

if config.clangd_enable_remote:
config.available_features.add('clangd-remote-index')
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ config.clang_libs_dir = "@CLANG_LIBS_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.host_triple = "@LLVM_HOST_TRIPLE@"
config.python_executable = "@Python3_EXECUTABLE@"

# Support substitution of the tools and libs dirs with user parameters. This is
# used when we can't determine the tool dir at configuration time.
Expand All @@ -23,6 +24,7 @@ except KeyError:
config.clangd_source_dir = "@CMAKE_CURRENT_SOURCE_DIR@/.."
config.clangd_binary_dir = "@CMAKE_CURRENT_BINARY_DIR@/.."
config.clangd_build_xpc = @CLANGD_BUILD_XPC@
config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@

# Delegate logic to lit.cfg.py.
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py")
10 changes: 10 additions & 0 deletions clang-tools-extra/clangd/test/remote-index/Inputs/Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace clang {
namespace clangd {
namespace remote {
int getFoo(bool Argument);
char Character;
} // namespace remote
} // namespace clangd
} // namespace clang

namespace llvm {} // namespace llvm
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/test/remote-index/Inputs/Source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "Header.h"

namespace {} // namespace
39 changes: 39 additions & 0 deletions clang-tools-extra/clangd/test/remote-index/pipeline.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# RUN: rm -rf %t
# RUN: clangd-indexer %S/Inputs/Source.cpp > %t.idx
# RUN: %python %S/pipeline_helper.py --input-file-name=%s --project-root=%S --index-file=%t.idx | FileCheck %s
# REQUIRES: clangd-remote-index

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
# CHECK: "id": 0,
# CHECK-NEXT: "jsonrpc": "2.0",
---
{"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"Character"}}
# CHECK: "id": 1,
# CHECK-NEXT: "jsonrpc": "2.0",
# CHECK-NEXT: "result": [
# CHECK-NEXT: {
# CHECK-NEXT: "containerName": "clang::clangd::remote",
# CHECK-NEXT: "kind": 13,
# CHECK-NEXT: "location": {
# CHECK-NEXT: "range": {
# CHECK-NEXT: "end": {
# CHECK-NEXT: "character": {{.*}},
# CHECK-NEXT: "line": {{.*}}
# CHECK-NEXT: },
# CHECK-NEXT: "start": {
# CHECK-NEXT: "character": {{.*}},
# CHECK-NEXT: "line": {{.*}}
# CHECK-NEXT: }
# CHECK-NEXT: },
# CHECK-NEXT: "uri": "file://{{.*}}/Header.h"
# CHECK-NEXT: },
# CHECK-NEXT: "name": "Character",
# CHECK-NEXT: "score": {{.*}}
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT:}
---
{"jsonrpc":"2.0","id":4,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}
---
75 changes: 75 additions & 0 deletions clang-tools-extra/clangd/test/remote-index/pipeline_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env python
#
#===- pipeline_helper.py - Remote Index pipeline Helper *- python -------*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===------------------------------------------------------------------------===#

import argparse
import os
import subprocess
from socket import socket
import sys
import time
import threading


def kill_server_after_delay(server_process):
time.sleep(10)
if server_process.poll() is None:
server_process.kill()


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--input-file-name', required=True)
parser.add_argument('--project-root', required=True)
parser.add_argument('--index-file', required=True)

args = parser.parse_args()

# Grab an available port.
with socket() as s:
s.bind(('localhost', 0))
server_address = 'localhost:' + str(s.getsockname()[1])

index_server_process = subprocess.Popen([
'clangd-index-server', '--server-address=' + server_address,
args.index_file, args.project_root
],
stderr=subprocess.PIPE)

# This will kill index_server_process if it hangs without printing init
# message.
shutdown_thread = threading.Thread(
target=kill_server_after_delay, args=(index_server_process,))
shutdown_thread.daemon = True
shutdown_thread.start()

# Wait for the server to warm-up.
found_init_message = False
while index_server_process.poll() is None:
if b'Server listening' in index_server_process.stderr.readline():
found_init_message = True
break

if not found_init_message:
sys.exit(1)

in_file = open(args.input_file_name)

clangd_process = subprocess.Popen([
'clangd', '--remote-index-address=' + server_address,
'--project-root=' + args.project_root, '--lit-test', '--sync'
],
stdin=in_file)

clangd_process.wait()
index_server_process.kill()


if __name__ == '__main__':
main()
5 changes: 2 additions & 3 deletions clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ MATCHER_P(DeclNamed, Name, "") {

MATCHER_P(DeclKind, Kind, "") {
if (NamedDecl *ND = dyn_cast<NamedDecl>(arg))
if (ND->getDeclKindName() == Kind)
if (ND->getDeclKindName() == llvm::StringRef(Kind))
return true;
if (auto *Stream = result_listener->stream()) {
llvm::raw_os_ostream OS(*Stream);
Expand Down Expand Up @@ -104,8 +104,7 @@ MATCHER(EqInc, "") {
std::tie(Expected.HashLine, Expected.Written);
}

// FIXME: figure out why it fails on clang-ppc64le-rhel buildbot.
TEST(ParsedASTTest, DISABLED_TopLevelDecls) {
TEST(ParsedASTTest, TopLevelDecls) {
TestTU TU;
TU.HeaderCode = R"(
int header1();
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an object file which can
///< linker.
CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
CODEGENOPT(MergeFunctions , 1, 0) ///< Set when -fmerge-functions is enabled.
CODEGENOPT(MemProf , 1, 0) ///< Set when -fmemory-profile is enabled.
CODEGENOPT(MSVolatile , 1, 0) ///< Set when /volatile:ms is enabled.
CODEGENOPT(NoCommon , 1, 0) ///< Set when -fno-common or C++ is enabled.
CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// Name of the profile file to use with -fprofile-sample-use.
std::string SampleProfileFile;

/// Name of the profile file to use as output for with -fmemory-profile.
std::string MemoryProfileOutput;

/// Name of the profile file to use as input for -fprofile-instr-use
std::string ProfileInstrumentUsePath;

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,9 @@ def fsymbol_partition_EQ : Joined<["-"], "fsymbol-partition=">, Group<f_Group>,
Flags<[CC1Option]>;

defm memory_profile : OptInFFlag<"memory-profile", "Enable", "Disable", " heap memory profiling">;
def fmemory_profile_EQ : Joined<["-"], "fmemory-profile=">,
Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<directory>">,
HelpText<"Enable heap memory profiling and dump results into <directory>">;

// Begin sanitizer flags. These should all be core options exposed in all driver
// modes.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
if (LangOpts.Coroutines)
addCoroutinePassesToExtensionPoints(PMBuilder);

if (CodeGenOpts.MemProf) {
if (!CodeGenOpts.MemoryProfileOutput.empty()) {
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addMemProfilerPasses);
PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
Expand Down Expand Up @@ -1421,7 +1421,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
if (CodeGenOpts.UniqueInternalLinkageNames)
MPM.addPass(UniqueInternalLinkageNamesPass());

if (CodeGenOpts.MemProf) {
if (!CodeGenOpts.MemoryProfileOutput.empty()) {
MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
MPM.addPass(ModuleMemProfilerPass());
}
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,13 @@ void CodeGenModule::Release() {
!LangOpts.isSignReturnAddressWithAKey());
}

if (!CodeGenOpts.MemoryProfileOutput.empty()) {
llvm::LLVMContext &Ctx = TheModule.getContext();
getModule().addModuleFlag(
llvm::Module::Error, "MemProfProfileFilename",
llvm::MDString::get(Ctx, CodeGenOpts.MemoryProfileOutput));
}

if (LangOpts.CUDAIsDevice && getTriple().isNVPTX()) {
// Indicate whether __nvvm_reflect should be configured to flush denormal
// floating point values to 0. (This corresponds to its "__CUDA_FTZ"
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
D.CCCIsCXX();

NeedsMemProfRt = Args.hasFlag(options::OPT_fmemory_profile,
options::OPT_fmemory_profile_EQ,
options::OPT_fno_memory_profile, false);

// Finally, initialize the set of available and recoverable sanitizers.
Expand Down
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4309,9 +4309,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.getLastArg(options::OPT_save_temps_EQ))
Args.AddLastArg(CmdArgs, options::OPT_save_temps_EQ);

if (Args.hasFlag(options::OPT_fmemory_profile,
options::OPT_fno_memory_profile, false))
Args.AddLastArg(CmdArgs, options::OPT_fmemory_profile);
auto *MemProfArg = Args.getLastArg(options::OPT_fmemory_profile,
options::OPT_fmemory_profile_EQ,
options::OPT_fno_memory_profile);
if (MemProfArg &&
!MemProfArg->getOption().matches(options::OPT_fno_memory_profile))
MemProfArg->render(Args, CmdArgs);

// Embed-bitcode option.
// Only white-listed flags below are allowed to be embedded.
Expand Down
10 changes: 9 additions & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,15 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.ThinLinkBitcodeFile =
std::string(Args.getLastArgValue(OPT_fthin_link_bitcode_EQ));

Opts.MemProf = Args.hasArg(OPT_fmemory_profile);
// The memory profile runtime appends the pid to make this name more unique.
const char *MemProfileBasename = "memprof.profraw";
if (Args.hasArg(OPT_fmemory_profile_EQ)) {
SmallString<128> Path(
std::string(Args.getLastArgValue(OPT_fmemory_profile_EQ)));
llvm::sys::path::append(Path, MemProfileBasename);
Opts.MemoryProfileOutput = std::string(Path);
} else if (Args.hasArg(OPT_fmemory_profile))
Opts.MemoryProfileOutput = MemProfileBasename;

Opts.MSVolatile = Args.hasArg(OPT_fms_volatile);

Expand Down
12 changes: 12 additions & 0 deletions clang/test/CodeGen/memory-profile-filename.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test that we get the expected module flag metadata for the memory profile
// filename.
// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NONE
// RUN: %clang -target x86_64-linux-gnu -fmemory-profile -S -emit-llvm -o - %s | FileCheck %s --check-prefix=DEFAULTNAME
// RUN: %clang -target x86_64-linux-gnu -fmemory-profile=/tmp -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CUSTOMNAME
int main(void) {
return 0;
}

// NONE-NOT: MemProfProfileFilename
// DEFAULTNAME: !{i32 1, !"MemProfProfileFilename", !"memprof.profraw"}
// CUSTOMNAME: !{i32 1, !"MemProfProfileFilename", !"/tmp{{.*}}memprof.profraw"}
4 changes: 4 additions & 0 deletions clang/test/Driver/fmemprof.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// RUN: %clangxx -target x86_64-linux-gnu -fmemory-profile %s -### 2>&1 | FileCheck %s
// RUN: %clangxx -target x86_64-linux-gnu -fmemory-profile=foo %s -### 2>&1 | FileCheck %s --check-prefix=DIR
// RUN: %clangxx -target x86_64-linux-gnu -fmemory-profile -fno-memory-profile %s -### 2>&1 | FileCheck %s --check-prefix=OFF
// RUN: %clangxx -target x86_64-linux-gnu -fmemory-profile=foo -fno-memory-profile %s -### 2>&1 | FileCheck %s --check-prefix=OFF
// CHECK: "-cc1" {{.*}} "-fmemory-profile"
// CHECK: ld{{.*}}libclang_rt.memprof{{.*}}libclang_rt.memprof_cxx
// DIR: "-cc1" {{.*}} "-fmemory-profile=foo"
// DIR: ld{{.*}}libclang_rt.memprof{{.*}}libclang_rt.memprof_cxx
// OFF-NOT: "-fmemory-profile"
// OFF-NOT: libclang_rt.memprof
4 changes: 2 additions & 2 deletions compiler-rt/lib/fuzzer/FuzzerMutate.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class MutationDispatcher {
size_t Mutate_InsertByte(uint8_t *Data, size_t Size, size_t MaxSize);
/// Mutates data by inserting several repeated bytes.
size_t Mutate_InsertRepeatedBytes(uint8_t *Data, size_t Size, size_t MaxSize);
/// Mutates data by chanding one byte.
/// Mutates data by changing one byte.
size_t Mutate_ChangeByte(uint8_t *Data, size_t Size, size_t MaxSize);
/// Mutates data by chanding one bit.
/// Mutates data by changing one bit.
size_t Mutate_ChangeBit(uint8_t *Data, size_t Size, size_t MaxSize);
/// Mutates data by copying/inserting a part of data into a different place.
size_t Mutate_CopyPart(uint8_t *Data, size_t Size, size_t MaxSize);
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/memprof/TestCases/atexit_stats.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Check atexit option.

// RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=atexit=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT
// RUN: %env_memprof_opts=log_path=stderr:atexit=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:atexit=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOATEXIT

// CHECK: MemProfiler exit stats:
// CHECK: Stats: {{[0-9]+}}M malloced ({{[0-9]+}}M for overhead) by {{[0-9]+}} calls
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/memprof/TestCases/dump_process_map.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Check print_module_map option.

// RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=print_module_map=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP
// RUN: %env_memprof_opts=log_path=stderr:print_module_map=1 %run %t 2>&1 | FileCheck %s
// RUN: %env_memprof_opts=log_path=stderr:print_module_map=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOMAP

// CHECK: Process memory map follows:
// CHECK: dump_process_map.cpp.tmp
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/memprof/TestCases/log_path_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//
// RUN: %clangxx_memprof %s -o %t

// Regular run.
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always
// stderr log_path
// RUN: %env_memprof_opts=log_path=stderr %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-GOOD --dump-input=always

// Good log_path.
// RUN: rm -f %t.log.*
Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/test/memprof/TestCases/malloc-size-too-big.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: %clangxx_memprof -O0 %s -o %t
// RUN: %env_memprof_opts=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY
// RUN: %env_memprof_opts=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SUMMARY
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
// Test print_summary
// RUN: %env_memprof_opts=allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY
// RUN: %env_memprof_opts=log_path=stderr:allocator_may_return_null=0:print_summary=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOSUMMARY

#include <stdio.h>
#include <stdlib.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Check mem_info_cache_entries option.

// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=mem_info_cache_entries=15:print_mem_info_cache_miss_rate=1:print_mem_info_cache_miss_rate_details=1 %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_memprof -O0 %s -o %t && %env_memprof_opts=log_path=stderr:mem_info_cache_entries=15:print_mem_info_cache_miss_rate=1:print_mem_info_cache_miss_rate_details=1 %run %t 2>&1 | FileCheck %s

// CHECK: Set 14 miss rate: 0 / {{.*}} = 0.00%
// CHECK-NOT: Set
Expand Down
Loading

0 comments on commit cc8bae5

Please sign in to comment.