Merge branch 'master' into merge-2.073

Conflicts:
	tests/d2/dmd-testsuite
This commit is contained in:
Martin 2017-03-09 01:11:03 +01:00
commit 97188a1a27
12 changed files with 122 additions and 93 deletions

View file

@ -39,6 +39,7 @@ addons:
apt: apt:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- george-edison55-precise-backports # more recent CMake
packages: packages:
- libconfig++8-dev - libconfig++8-dev
- gdb - gdb
@ -51,6 +52,8 @@ addons:
- libedit2 - libedit2
- libedit-dev - libedit-dev
- libcurl3:i386 - libcurl3:i386
- cmake
- cmake-data
before_install: before_install:
- -
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then if [ "${TRAVIS_OS_NAME}" = "linux" ]; then

View file

@ -640,15 +640,7 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (!isunion) if (!isunion)
*nextoffset = ofs; *nextoffset = ofs;
if (alignment == STRUCTALIGN_DEFAULT) if (alignment != STRUCTALIGN_DEFAULT)
{
if ((global.params.is64bit || global.params.isOSX) && memalignsize == 16)
{
}
else if (8 < memalignsize)
memalignsize = 8;
}
else
{ {
if (memalignsize < alignment) if (memalignsize < alignment)
memalignsize = alignment; memalignsize = alignment;

View file

@ -240,7 +240,12 @@ struct Target
*/ */
extern (C++) static uint fieldalign(Type type) extern (C++) static uint fieldalign(Type type)
{ {
return type.alignsize(); const size = type.alignsize();
if ((global.params.is64bit || global.params.isOSX) && (size == 16 || size == 32))
return size;
return (8 < size) ? 8 : size;
} }
/*********************************** /***********************************

View file

@ -59,6 +59,9 @@ cl::list<std::string> runargs(
"Runs the resulting program, passing the remaining arguments to it"), "Runs the resulting program, passing the remaining arguments to it"),
cl::Positional, cl::PositionalEatsArgs); cl::Positional, cl::PositionalEatsArgs);
cl::opt<bool> invokedByLDMD("ldmd", cl::desc("Invoked by LDMD?"),
cl::ZeroOrMore, cl::ReallyHidden);
static cl::opt<ubyte, true> useDeprecated( static cl::opt<ubyte, true> useDeprecated(
cl::desc("Allow deprecated code/language features:"), cl::ZeroOrMore, cl::desc("Allow deprecated code/language features:"), cl::ZeroOrMore,
clEnumValues(clEnumValN(0, "de", "Do not allow deprecated features"), clEnumValues(clEnumValN(0, "de", "Do not allow deprecated features"),
@ -329,7 +332,7 @@ static cl::list<std::string, StringsAdapter> modFileAliasStrings(
cl::location(modFileAliasStringsStore)); cl::location(modFileAliasStringsStore));
cl::opt<llvm::Reloc::Model> mRelocModel( cl::opt<llvm::Reloc::Model> mRelocModel(
"relocation-model", cl::desc("Relocation model"), "relocation-model", cl::desc("Relocation model"), cl::ZeroOrMore,
#if LDC_LLVM_VER < 309 #if LDC_LLVM_VER < 309
cl::init(llvm::Reloc::Default), cl::init(llvm::Reloc::Default),
#endif #endif

View file

@ -44,6 +44,7 @@ extern llvm::SmallVector<const char *, 32> allArguments;
*/ */
extern cl::list<std::string> fileList; extern cl::list<std::string> fileList;
extern cl::list<std::string> runargs; extern cl::list<std::string> runargs;
extern cl::opt<bool> invokedByLDMD;
extern cl::opt<bool> compileOnly; extern cl::opt<bool> compileOnly;
extern cl::opt<bool> useDIP1000; extern cl::opt<bool> useDIP1000;
extern cl::opt<bool> noAsm; extern cl::opt<bool> noAsm;

View file

@ -357,6 +357,8 @@ void translateArgs(size_t originalArgc, char **originalArgv,
assert(ldcArgs.size() == 1); assert(ldcArgs.size() == 1);
const std::string ldcPath = ldcArgs[0]; const std::string ldcPath = ldcArgs[0];
ldcArgs.push_back("-ldmd");
bool vdmd = false; bool vdmd = false;
bool noFiles = true; bool noFiles = true;
@ -464,14 +466,8 @@ void translateArgs(size_t originalArgc, char **originalArgv,
* -wi * -wi
* -O * -O
* -o- * -o-
*/ * -od
else if (strcmp(p + 1, "od") == 0) { * -of
ldcArgs.push_back(p);
// DMD creates static libraries in the objects directory (unless using
// an absolute output path via `-of`).
ldcArgs.push_back("-create-static-lib-in-objdir");
}
/* -of
* -op * -op
*/ */
else if (strcmp(p + 1, "o") == 0) { else if (strcmp(p + 1, "o") == 0) {
@ -600,7 +596,7 @@ void translateArgs(size_t originalArgc, char **originalArgv,
} }
} else { } else {
const auto ext = ls::path::extension(p); const auto ext = ls::path::extension(p);
if (ext.equals_lower("exe")) { if (ext.equals_lower(".exe")) {
// should be for Windows targets only // should be for Windows targets only
ldcArgs.push_back(concat("-of=", p)); ldcArgs.push_back(concat("-of=", p));
continue; continue;
@ -674,10 +670,6 @@ std::string locateBinary(std::string exeName) {
return ""; return "";
} }
static size_t addStrlen(size_t acc, const char *str) {
return acc + (str ? strlen(str) : 0);
}
// In driver/main.d // In driver/main.d
int main(int argc, char **argv); int main(int argc, char **argv);
@ -701,38 +693,41 @@ int cppmain(int argc, char **argv) {
args.push_back(nullptr); args.push_back(nullptr);
// Check if we need to write out a response file. // Check if we can get away without a response file.
size_t totalLen = std::accumulate(args.begin(), args.end(), 0, addStrlen); const size_t totalLen = std::accumulate(
if (totalLen > maxCommandLineLen()) { args.begin(), args.end() - 1,
int rspFd; args.size() * 3, // quotes + space
llvm::SmallString<128> rspPath; [](size_t acc, const char *arg) { return acc + strlen(arg); });
if (ls::fs::createUniqueFile("ldmd-%%-%%-%%-%%.rsp", rspFd, rspPath)) { if (totalLen <= maxCommandLineLen()) {
error("Could not open temporary response file."); return execute(ldcPath, args.data());
}
{
llvm::raw_fd_ostream rspOut(rspFd, /*shouldClose=*/true);
for (auto arg : args) {
rspOut << arg << '\n';
}
}
std::string rspArg = "@";
rspArg += rspPath.str();
std::vector<const char *> newArgs;
newArgs.push_back(argv[0]);
newArgs.push_back(rspArg.c_str());
newArgs.push_back(nullptr);
int rc = execute(ldcPath, &newArgs[0]);
if (ls::fs::remove(rspPath.str())) {
warning("Could not remove response file.");
}
return rc;
} }
return execute(ldcPath, &args[0]); int rspFd;
llvm::SmallString<128> rspPath;
if (ls::fs::createUniqueFile("ldmd-%%-%%-%%-%%.rsp", rspFd, rspPath)) {
error("Could not open temporary response file.");
}
{
llvm::raw_fd_ostream rspOut(rspFd, /*shouldClose=*/true);
// skip argv[0] and terminating NULL
for (auto it = args.begin() + 1, end = args.end() - 1; it != end; ++it) {
rspOut << *it << '\n';
}
}
std::string rspArg = "@";
rspArg += rspPath.str();
args.resize(1);
args.push_back(rspArg.c_str());
args.push_back(nullptr);
int rc = execute(ldcPath, args.data());
if (ls::fs::remove(rspPath.str())) {
warning("Could not remove response file.");
}
return rc;
} }

View file

@ -45,12 +45,6 @@ static llvm::cl::opt<bool> staticFlag(
"Create a statically linked binary, including all system dependencies"), "Create a statically linked binary, including all system dependencies"),
llvm::cl::ZeroOrMore); llvm::cl::ZeroOrMore);
// used by LDMD
static llvm::cl::opt<bool> createStaticLibInObjdir(
"create-static-lib-in-objdir",
llvm::cl::desc("Create static library in -od directory (DMD-compliant)"),
llvm::cl::ZeroOrMore, llvm::cl::ReallyHidden);
static llvm::cl::opt<std::string> static llvm::cl::opt<std::string>
ltoLibrary("flto-binary", ltoLibrary("flto-binary",
llvm::cl::desc("Set the linker LTO plugin library file (e.g. " llvm::cl::desc("Set the linker LTO plugin library file (e.g. "
@ -73,22 +67,29 @@ static void CreateDirectoryOnDisk(llvm::StringRef fileName) {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static std::string getOutputName(bool const sharedLib) { static std::string getOutputName(bool const sharedLib) {
if (global.params.exefile) const auto &triple = *global.params.targetTriple;
return global.params.exefile;
const char *extension = nullptr;
if (sharedLib) {
extension = global.dll_ext;
} else if (triple.isOSWindows()) {
extension = "exe";
}
if (global.params.exefile) {
// DMD adds the default extension if there is none
return opts::invokedByLDMD && extension
? FileName::defaultExt(global.params.exefile, extension)
: global.params.exefile;
}
// Infer output name from first object file. // Infer output name from first object file.
std::string result = global.params.objfiles->dim std::string result = global.params.objfiles->dim
? FileName::removeExt((*global.params.objfiles)[0]) ? FileName::removeExt((*global.params.objfiles)[0])
: "a.out"; : "a.out";
const char *extension = nullptr; if (sharedLib && !triple.isWindowsMSVCEnvironment())
if (sharedLib) { result = "lib" + result;
extension = global.dll_ext;
if (!global.params.targetTriple->isWindowsMSVCEnvironment())
result = "lib" + result;
} else if (global.params.targetTriple->isOSWindows()) {
extension = "exe";
}
if (global.params.run) { if (global.params.run) {
// If `-run` is passed, the executable is temporary and is removed // If `-run` is passed, the executable is temporary and is removed
@ -100,11 +101,9 @@ static std::string getOutputName(bool const sharedLib) {
tempFilename); tempFilename);
if (!EC) if (!EC)
result = tempFilename.str(); result = tempFilename.str();
} else { } else if (extension) {
if (extension) { result += '.';
result += "."; result += extension;
result += extension;
}
} }
return result; return result;
@ -840,15 +839,21 @@ int createStaticLibrary() {
// output filename // output filename
std::string libName; std::string libName;
if (global.params.libname) { // explicit if (global.params.libname) { // explicit
libName = global.params.libname; // DMD adds the default extension if there is none
libName = opts::invokedByLDMD
? FileName::defaultExt(global.params.libname, global.lib_ext)
: global.params.libname;
} else { // infer from first object file } else { // infer from first object file
libName = global.params.objfiles->dim libName = global.params.objfiles->dim
? FileName::removeExt((*global.params.objfiles)[0]) ? FileName::removeExt((*global.params.objfiles)[0])
: "a.out"; : "a.out";
libName.push_back('.'); libName += '.';
libName.append(global.lib_ext); libName += global.lib_ext;
} }
if (createStaticLibInObjdir && global.params.objdir &&
// DMD creates static libraries in the objects directory (unless using an
// absolute output path via `-of`).
if (opts::invokedByLDMD && global.params.objdir &&
!FileName::absolute(libName.c_str())) { !FileName::absolute(libName.c_str())) {
libName = FileName::combine(global.params.objdir, libName.c_str()); libName = FileName::combine(global.params.objdir, libName.c_str());
} }

View file

@ -1023,7 +1023,7 @@ int cppmain(int argc, char **argv) {
global.dll_ext = "dll"; global.dll_ext = "dll";
global.lib_ext = (global.params.mscoff ? "lib" : "a"); global.lib_ext = (global.params.mscoff ? "lib" : "a");
} else { } else {
global.dll_ext = "so"; global.dll_ext = global.params.targetTriple->isOSDarwin() ? "dylib" : "so";
global.lib_ext = "a"; global.lib_ext = "a";
} }

View file

@ -1,6 +1,6 @@
project(runtime) project(runtime)
cmake_minimum_required(VERSION 2.8.5) cmake_minimum_required(VERSION 2.8.9)
# #
# Main configuration. # Main configuration.
@ -480,7 +480,12 @@ macro(build_runtime_variants d_flags c_flags ld_flags path_suffix outlist_target
"${path_suffix}" "${path_suffix}"
${outlist_targets} ${outlist_targets}
) )
build_profile_runtime ("${d_flags}" "${c_flags}" "${ld_flags}" "${path_suffix}" ${outlist_targets})
if(LDC_WITH_PGO)
build_profile_runtime("${d_flags};${D_FLAGS};${D_FLAGS_RELEASE}" "${c_flags}" "${ld_flags}" "${path_suffix}" ${outlist_targets})
get_target_suffix("" "${path_suffix}" target_suffix)
set_common_library_properties(ldc-profile-rt${target_suffix})
endif()
endmacro() endmacro()
# Setup the build of profile-rt # Setup the build of profile-rt

View file

@ -16,8 +16,6 @@ if (LDC_WITH_PGO)
if (NOT (LDC_LLVM_VER GREATER 309)) if (NOT (LDC_LLVM_VER GREATER 309))
set(PROFRT_EXTRA_LDFLAGS "Ws2_32.lib") set(PROFRT_EXTRA_LDFLAGS "Ws2_32.lib")
endif() endif()
else()
set(PROFRT_EXTRA_FLAGS "-fPIC -O3")
endif() endif()
CHECK_CXX_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
@ -115,9 +113,4 @@ if (LDC_WITH_PGO)
# Install D interface files to profile-rt. # Install D interface files to profile-rt.
install(DIRECTORY ${PROFILERT_DIR}/d/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d") install(DIRECTORY ${PROFILERT_DIR}/d/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.d")
endif()
else()
# No profiling supported, define NOP macro
macro(build_profile_runtime c_flags ld_flags path_suffix outlist_targets)
endmacro()
endif()

View file

@ -0,0 +1,27 @@
// RUN: %ldc -c -output-ll -O3 -of=%t.ll %s && FileCheck %s < %t.ll
import core.simd;
struct S17237
{
bool a;
struct
{
bool b;
int8 c;
}
}
int4 globalIntFour;
// CHECK-DAG: globalIntFour{{.*}} = {{.*}} align 16
S17237 globalStruct;
// CHECK-DAG: constant %{{.*}}.S17237 zeroinitializer{{(, comdat)?}}, align 32
// CHECK-DAG: @{{.*}}globalStruct{{.*}}S17237 = {{.*}} zeroinitializer{{(, comdat)?}}, align 32
// CHECK-LABEL: define <8 x i32> @foo(
extern(C) int8 foo(S17237* s)
{
// CHECK: %[[GEP:[0-9]]] = getelementptr {{.*}}S17237* %s_arg
// CHECK: = load {{.*}}<8 x i32>* %[[GEP]], align 32
return s.c;
}

@ -1 +1 @@
Subproject commit f14832dd223d2f21007d44dfab17ebb5e38a56a5 Subproject commit bdecaa5d46c7c1cae28cde42eab8d0ded708118f