From 0b19b81ac93303db88fde287a165adb9f05c8870 Mon Sep 17 00:00:00 2001 From: kai Date: Mon, 11 Mar 2013 22:01:34 +0100 Subject: [PATCH 1/5] Add new intrinsic LDC_never_inline. LDC_never_inline is a complementary intrinsic to LDC_allow_inline. It tells the LLVM optimizer to never inline a function. This can be useful if inlining creates incorrect code. A possible application is core.thread.getStackTop(). --- dmd2/declaration.h | 3 +++ dmd2/func.c | 1 + dmd2/idgen.c | 1 + dmd2/statement.c | 4 ++++ gen/functions.cpp | 5 +++++ 5 files changed, 14 insertions(+) diff --git a/dmd2/declaration.h b/dmd2/declaration.h index ee488b2d..af7b9952 100644 --- a/dmd2/declaration.h +++ b/dmd2/declaration.h @@ -930,6 +930,9 @@ struct FuncDeclaration : Declaration // true if overridden with the pragma(allow_inline); stmt bool allowInlining; + // true if set with pragma(LDC_no_inline) + bool neverInline; + // true if has inline assembler bool inlineAsm; #endif diff --git a/dmd2/func.c b/dmd2/func.c index 7a7b55bc..2f43947c 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -103,6 +103,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla // LDC isArrayOp = false; allowInlining = false; + neverInline = false; availableExternally = true; // assume this unless proven otherwise // function types in ldc don't merge if the context parameter differs diff --git a/dmd2/idgen.c b/dmd2/idgen.c index edd66bf9..8b71d3f8 100644 --- a/dmd2/idgen.c +++ b/dmd2/idgen.c @@ -278,6 +278,7 @@ Msgtable msgtable[] = { "LDC_va_arg" }, { "LDC_verbose" }, { "LDC_allow_inline" }, + { "LDC_never_inline" }, { "LDC_inline_asm" }, { "LDC_inline_ir" }, { "LDC_fence" }, diff --git a/dmd2/statement.c b/dmd2/statement.c index 15da3909..9f064312 100644 --- a/dmd2/statement.c +++ b/dmd2/statement.c @@ -3175,6 +3175,10 @@ Statement *PragmaStatement::semantic(Scope *sc) { sc->func->allowInlining = true; } + else if (ident == Id::LDC_never_inline) + { + sc->func->neverInline = true; + } #endif #if DMDV2 else if (ident == Id::startaddress) diff --git a/gen/functions.cpp b/gen/functions.cpp index 51a0f48f..4b1bcb3b 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -815,6 +815,11 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) } } + if (fdecl->neverInline) + { + fdecl->ir.irFunc->setNeverInline(); + } + if (fdecl->llvmInternal == LLVMglobal_crt_ctor || fdecl->llvmInternal == LLVMglobal_crt_dtor) { AppendFunctionToLLVMGlobalCtorsDtors(func, fdecl->priority, fdecl->llvmInternal == LLVMglobal_crt_ctor); From 5854fbfeb1b670fe987aa73e649d2ac40cfa044c Mon Sep 17 00:00:00 2001 From: kai Date: Mon, 11 Mar 2013 22:32:33 +0100 Subject: [PATCH 2/5] Fix comments --- dmd2/declaration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd2/declaration.h b/dmd2/declaration.h index af7b9952..7193296c 100644 --- a/dmd2/declaration.h +++ b/dmd2/declaration.h @@ -927,10 +927,10 @@ struct FuncDeclaration : Declaration // Functions that wouldn't have gotten semantic3'ed if we weren't inlining set this flag. bool availableExternally; - // true if overridden with the pragma(allow_inline); stmt + // true if overridden with the pragma(LDC_allow_inline); stmt bool allowInlining; - // true if set with pragma(LDC_no_inline) + // true if set with the pragma(LDC_never_inline); stmt bool neverInline; // true if has inline assembler From d33bfb0d42a117f0495f304921343a209a2441a4 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 11 Mar 2013 22:45:44 +0100 Subject: [PATCH 3/5] LLVM 3.1: Use -O1 instead of -O3 for std.exception tests. --- runtime/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index f7a146c0..87d17dd1 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -599,7 +599,16 @@ function(add_tests module_files) endfunction() testcase(debug "-g;-d-debug") - testcase(release "-O3;-release") + + # Building the std.exception tests on x86_64 triggers an infinite + # recursion in scalar evolution on LLVM 3.1 (only), see the list of + # known LLVM bugs for details. + if(${LDC_LLVM_VER} EQUAL 301 AND ${HOST_BITNESS} EQUAL 64 AND + "${testroot}" STREQUAL "phobos_std_exception") + testcase(release "-O1;-release") + else() + testcase(release "-O3;-release") + endif() # On 64 bit multilib builds, run the tests in 32 bit mode as well. if(MULTILIB AND ${HOST_BITNESS} EQUAL 64) From 480d668ec9941cc06abde8f1fae2dba3b308040b Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 11 Mar 2013 22:55:47 +0100 Subject: [PATCH 4/5] Travis: Print "ldc2 -version" output after build is complete. This is useful as it contains the host arch, ... --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b1bcc67d..565a3213 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ env: script: - cmake -DD_VERSION=$DVER -DLLVM_CONFIG=/usr/bin/llvm-config-$LLVM_VERSION - make + - bin/ldc2 -version # For environment info. - ctest --output-on-failure -R $TESTSUITE_FILTER notifications: From 1ca562db7eaab15b5f01ba01c7149b4aba925665 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 11 Mar 2013 23:03:04 +0100 Subject: [PATCH 5/5] README: We no longer support D1. --- README | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README b/README index ba19f8a5..ab0534f0 100644 --- a/README +++ b/README @@ -4,8 +4,9 @@ LDC – the LLVM D Compiler The LDC project aims to provide a portable D programming language compiler with modern optimization and code generation capabilities. -The compiler uses the official DMD frontends to support both D1 and D2, -and relies on the LLVM Core libraries for code generation. +The compiler uses the official DMD frontends to support the latest +version of D2, and relies on the LLVM Core libraries for code +generation. LDC is fully Open Source; the parts of the code not taken/adapted from other projects are BSD-licensed (see the LICENSE file for details). @@ -13,6 +14,9 @@ other projects are BSD-licensed (see the LICENSE file for details). Please consult the D wiki for further information: http://wiki.dlang.org/LDC +D1 is no longer available; see the 'd1' Git branch for the last +version supporting it. + Installation ------------ @@ -36,7 +40,7 @@ For the impatient, a quick guide for building on *nix systems: 3) Build and install LDC: $ mkdir build && cd build # Out-of-source builds are recommended. - $ cmake .. # Use -DD_VERSION=1 to build the D1 compiler. + $ cmake .. $ make $ make install # Or run LDC directly from the bin/ directory.