<commit_before>#include <stddef.h>

#include "../type.h"
#include "../type_nav.h"
#include "../pack.h"

#include "macros.h"

#include "forwards.h"

#include "val.h"
#include "ctx.h"
#include "blk.h"

#include "out.h"

#include "stack.h"

void v_stack_adj(out_ctx *octx, v_stackt amt, int sub)
{
	out_flush_volatile(
			octx,
			out_op(
				octx, sub ? op_minus : op_plus,
				v_new_sp(octx, NULL),
				out_new_l(
					octx,
					type_nav_btype(cc1_type_nav, type_intptr_t),
					amt)));
}

static void align_sz(unsigned *psz, unsigned align)
{
	/* align greater than size - we increase
	 * size so it can be aligned to 'align' */
	if(align > *psz)
		*psz = pack_to_align(*psz, align);
}

const out_val *out_aalloc(
		out_ctx *octx, unsigned sz, unsigned align, type *in_ty)
{
	type *ty = type_ptr_to(in_ty
		? in_ty : type_nav_btype(cc1_type_nav, type_nchar));

	align_sz(&sz, align);

	/* packing takes care of everything */
	pack_next(&octx->cur_stack_sz, NULL, sz, align);

	return v_new_bp3_below(octx, NULL, ty, octx->cur_stack_sz);
}

void out_adealloc(out_ctx *octx, const out_val **val)
{
	/* TODO: reclaim stack */
	out_val_release(octx, *val);
	*val = NULL;
}

void v_aalloc_noop(out_ctx *octx, unsigned sz, unsigned align, const char *why)
{
	(void)why;

	align_sz(&sz, align);

	octx->cur_stack_sz += sz;
}

void v_stack_needalign(out_ctx *octx, unsigned align)
{
	/* aligning the stack isn't sufficient here - if the stack is adjusted after,
	 * it might not be at a 16-byte alignment */
	octx->max_align = MAX(octx->max_align, align);
}
<commit_msg>Correctly record no-op stack allocations<commit_after>#include <stddef.h>

#include "../type.h"
#include "../type_nav.h"
#include "../pack.h"

#include "macros.h"

#include "forwards.h"

#include "val.h"
#include "ctx.h"
#include "blk.h"

#include "out.h"

#include "stack.h"

void v_stack_adj(out_ctx *octx, v_stackt amt, int sub)
{
	out_flush_volatile(
			octx,
			out_op(
				octx, sub ? op_minus : op_plus,
				v_new_sp(octx, NULL),
				out_new_l(
					octx,
					type_nav_btype(cc1_type_nav, type_intptr_t),
					amt)));
}

static void align_sz(unsigned *psz, unsigned align)
{
	/* align greater than size - we increase
	 * size so it can be aligned to 'align' */
	if(align > *psz)
		*psz = pack_to_align(*psz, align);
}

const out_val *out_aalloc(
		out_ctx *octx, unsigned sz, unsigned align, type *in_ty)
{
	type *ty = type_ptr_to(in_ty
		? in_ty : type_nav_btype(cc1_type_nav, type_nchar));

	align_sz(&sz, align);

	/* packing takes care of everything */
	pack_next(&octx->cur_stack_sz, NULL, sz, align);

	return v_new_bp3_below(octx, NULL, ty, octx->cur_stack_sz);
}

void out_adealloc(out_ctx *octx, const out_val **val)
{
	/* TODO: reclaim stack */
	out_val_release(octx, *val);
	*val = NULL;
}

void v_aalloc_noop(out_ctx *octx, unsigned sz, unsigned align, const char *why)
{
	(void)why;

	align_sz(&sz, align);

	octx->stack_n_alloc += sz;
	octx->cur_stack_sz += sz;
}

void v_stack_needalign(out_ctx *octx, unsigned align)
{
	/* aligning the stack isn't sufficient here - if the stack is adjusted after,
	 * it might not be at a 16-byte alignment */
	octx->max_align = MAX(octx->max_align, align);
}

{'fraction_non_alphanumeric': 0.141464948129519, 'fraction_numerical': 0.0031436655139893115, 'mean_word_length': 4.157212317666127, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5131770', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1291, 'n_words': 320}