https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101941

--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #21)
> Jakub: I see it is about error attributed call in the split out part of
> function. Then we really want to prevent the split. Keeping track of those
> should be possible in the recursive walk (where we keep track of SSA names
> used). Not sure how common it would be in practice though.

That is exactly what my patch does, we disallow splitting out the basic blocks
that lead to the basic block that contains a function call that has an
error/warning attribute on it.

Here is a testcase which shows that we still able to split out basic blocks
that would not lead into the function and all (and we did before my patch too):
struct crypto_aes_ctx {
  char key_dec[128];
};
int rfc4106_set_hash_subkey_hash_subkey;
void __write_overflow(void)__attribute__((__error__("")));
void __write_overflow1(void);
void aes_encrypt(void*);
void fortify_panic(const char*) __attribute__((__noreturn__)) ;
char *rfc4106_set_hash_subkey(struct crypto_aes_ctx *ctx) {
  void *a = &ctx->key_dec[0];
  unsigned p_size =  __builtin_object_size(a, 0);
  if (p_size < 16) {
    __write_overflow1();
    fortify_panic(__func__);
  }
  if (p_size < 32) {
    __write_overflow();
    fortify_panic(__func__);
  }
  aes_encrypt(ctx);
  return ctx->key_dec;
}
char *(*gg)(struct crypto_aes_ctx *) = rfc4106_set_hash_subkey;
void a(void)
{
  struct crypto_aes_ctx ctx;
  rfc4106_set_hash_subkey(&ctx);
}
void b(void)
{
  struct crypto_aes_ctx ctx;
  ctx.key_dec[0] = 0;
  rfc4106_set_hash_subkey(&ctx);
}

Reply via email to