From 139ae0da30a29899932f86c1be71334d4c174f51 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Thu, 3 Sep 2015 06:17:52 +0200 Subject: [PATCH] ASR pass: disable caller padding by default The feature is fundamentally broken. See the comment in the code. Change-Id: If36b06b0732cc4d18f20240ed96d30a7959b0d21 --- minix/llvm/passes/asr/ASRPass.cpp | 8 ++++++++ minix/llvm/passes/include/asr/ASRPass.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/minix/llvm/passes/asr/ASRPass.cpp b/minix/llvm/passes/asr/ASRPass.cpp index 39593ba12..22439aad3 100644 --- a/minix/llvm/passes/asr/ASRPass.cpp +++ b/minix/llvm/passes/asr/ASRPass.cpp @@ -562,6 +562,14 @@ bool ASRPass::runOnModule(Module &M) { if (Instruction *I = dyn_cast(U)) { Function *parent = I->getParent()->getParent(); /* XXX Skipping MAGIC_ENTRY_POINT shouldn't be necessary. Check why. */ + /* ..the reason is that main() typically contains the message loop, which loops + * forever making calls. These calls are getting padded, and AllocaInst causes a + * stack pointer adjustment every time a call is made. This stack memory is never + * released, since the function never returns. The result is that we eventually + * run out of stack. Since MINIX3 also uses user-level threads these days, the + * problem is not limited to main(), and for this reason I have disabled caller + * padding by default. -dcvmoole + */ if(MAGIC_IS_MAGIC_FUNC(M, parent) || parent->getName().equals(MAGIC_ENTRY_POINT)) { continue; } diff --git a/minix/llvm/passes/include/asr/ASRPass.h b/minix/llvm/passes/include/asr/ASRPass.h index dd4d49436..6a8f239f7 100644 --- a/minix/llvm/passes/include/asr/ASRPass.h +++ b/minix/llvm/passes/include/asr/ASRPass.h @@ -23,7 +23,7 @@ #define STACKFRAME_DEFAULT_MAX_PADDING 5000 #define STACKFRAME_DEFAULT_DO_PERMUTATE 1 #define STACKFRAME_DEFAULT_STATIC_PADDING 1 -#define STACKFRAME_DEFAULT_CALLER_PADDING 1 +#define STACKFRAME_DEFAULT_CALLER_PADDING 0 // broken, disabled (see note in code) #define HEAP_MAP_DEFAULT_DO_PERMUTATE 1 -- 2.44.0