File: sparc-ret-3.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A8-2019-q3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 571,828 kB
  • sloc: ansic: 2,937,651; cpp: 881,644; ada: 597,189; makefile: 65,528; asm: 56,499; xml: 46,621; exp: 24,747; sh: 19,684; python: 7,256; pascal: 4,370; awk: 3,497; perl: 2,695; yacc: 316; ml: 285; f90: 234; lex: 198; objc: 194; haskell: 119
file content (53 lines) | stat: -rw-r--r-- 1,423 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* PR target/80968 */
/* { dg-do compile } */
/* { dg-skip-if "no register windows" { *-*-* } { "-mflat" } { "" } } */
/* { dg-require-effective-target ilp32 } */
/* { dg-options "-mcpu=ultrasparc -O" } */

/* Make sure references to the stack frame do not slip into the delay slot
   of a return instruction.  */

struct crypto_shash {
	unsigned int descsize;
};
struct crypto_shash *tfm;

struct shash_desc {
	struct crypto_shash *tfm;
	unsigned int flags;

	void *__ctx[] __attribute__((aligned(8)));
};

static inline unsigned int crypto_shash_descsize(struct crypto_shash *tfm)
{
	return tfm->descsize;
}

static inline void *shash_desc_ctx(struct shash_desc *desc)
{
	return desc->__ctx;
}

#define SHASH_DESC_ON_STACK(shash, ctx)				  \
	char __##shash##_desc[sizeof(struct shash_desc) +	  \
			      crypto_shash_descsize(ctx)] __attribute__((aligned(8))); \
	struct shash_desc *shash = (struct shash_desc *)__##shash##_desc

extern int crypto_shash_update(struct shash_desc *, const void *, unsigned int);

unsigned int bug(unsigned int crc, const void *address, unsigned int length)
{
	SHASH_DESC_ON_STACK(shash, tfm);
	unsigned int *ctx = (unsigned int *)shash_desc_ctx(shash);
	int err;

	shash->tfm = tfm;
	shash->flags = 0;
	*ctx = crc;

	err = crypto_shash_update(shash, address, length);

	return *ctx;
}
/* { dg-final { scan-assembler "ld\[ \t\]*\\\[%i5\\+8\\\], %i0\n\[^\n\]*return\[ \t\]*%i7\\+8" } } */