From fb418bf2e6270d215ba465105beb70caf6943bf4 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Wed, 23 Feb 2011 23:50:53 +0100 Subject: [PATCH 1/3] Added -disable-red-zone flag. This will disable the usage of the 'red-zone' in ABIs that make use of it (like x86). This mimics the exact flag used by clang. It is comparable to the -mno-red-zone flag in gcc. - thanks to wilkie --- gen/cl_options.cpp | 4 ++++ gen/cl_options.h | 1 + gen/functions.cpp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/gen/cl_options.cpp b/gen/cl_options.cpp index cbb8c5c1..7d500aa3 100644 --- a/gen/cl_options.cpp +++ b/gen/cl_options.cpp @@ -100,6 +100,10 @@ cl::opt output_s("output-s", cl::opt output_o("output-o", cl::desc("Write native object")); +// Disabling Red Zone +cl::opt disableRedZone("disable-red-zone", + cl::desc("Do not emit code that uses the red zone."), + cl::init(false)); // DDoc options static cl::opt doDdoc("D", diff --git a/gen/cl_options.h b/gen/cl_options.h index f7bf623a..8965a20e 100644 --- a/gen/cl_options.h +++ b/gen/cl_options.h @@ -26,6 +26,7 @@ namespace opts { extern cl::opt output_ll; extern cl::opt output_s; extern cl::opt output_o; + extern cl::opt disableRedZone; extern cl::opt ddocDir; extern cl::opt ddocFile; extern cl::opt jsonFile; diff --git a/gen/functions.cpp b/gen/functions.cpp index 8065dc0e..32c25bd8 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -22,6 +22,7 @@ #include "gen/dvalue.h" #include "gen/abi.h" #include "gen/nested.h" +#include "gen/cl_options.h" using namespace llvm::Attribute; @@ -501,6 +502,9 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // parameter attributes if (!fdecl->isIntrinsic()) { set_param_attrs(f, func, fdecl); + if (opts::disableRedZone) { + func->addFnAttr(NoRedZone); + } } // main From 8275ffeb9856ec4c6970b4200e77c152fe8657f3 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 24 Feb 2011 13:08:36 +0100 Subject: [PATCH 2/3] Fix casting of associative arrays; thanks to alexey --- gen/llvmhelpers.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 47c4f4ec..d674bdb0 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -742,6 +742,14 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to) { Type* fromtype = val->getType()->toBasetype(); Type* totype = to->toBasetype(); + +#if DMDV2 + if (fromtype->ty == Taarray) + fromtype = ((TypeAArray*)fromtype)->getImpl()->type; + if (totype->ty == Taarray) + totype = ((TypeAArray*)totype)->getImpl()->type; +#endif + if (fromtype->equals(totype)) return val; From 252c21c03be6faf42a9abcf173787892f0fa6ae1 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 24 Feb 2011 13:20:03 +0100 Subject: [PATCH 3/3] trivial fix for inactive debug code --- dmd/struct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmd/struct.c b/dmd/struct.c index 7d6d3936..7af158d0 100644 --- a/dmd/struct.c +++ b/dmd/struct.c @@ -151,7 +151,7 @@ void AggregateDeclaration::alignmember( unsigned size, // alignment requirement of field unsigned *poffset) { - //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); + //printf("salign = %d, size = %d, offset = %d\n",salign,size, *poffset); if (salign > 1) { assert(size != 3); @@ -160,7 +160,7 @@ void AggregateDeclaration::alignmember( sa = salign; *poffset = (*poffset + sa - 1) & ~(sa - 1); } - //printf("result = %d\n",offset); + //printf("result = %d\n", *poffset); }