[clang] [clang] fix emitvaarg when struct is null (PR #72624)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 17 01:00:54 PST 2023


Jolyon0202 wrote:

demoļ¼š
```
#include <stdio.h>
extern void *memset (void *__s, int __c, size_t __n);
typedef __builtin_va_list va_list;

struct S94 {
  struct __attribute__((aligned(16))) {
  } a;
};

struct S94 s94;

void check94va(int z, ...) {
  va_list ap;
  __builtin_va_start(ap, z);
  struct S94 arg1 =  __builtin_va_arg(ap, struct S94);
  long long int tmp = __builtin_va_arg(ap, long long);
  printf("result = %lld\n", tmp);
  if (tmp != 2LL) {
    printf("Fails!!!!\n");
  }
  __builtin_va_end(ap);
}

int main(void) {
  memset(&s94, '\0', sizeof(s94));
  printf("sizeof(s94) = %ld\n", sizeof(s94));
  check94va(1, s94, 2LL);
  return 0;
}
```
found two bug need to fix:
1  If the alignment of S94(null struct) is less than 16, the result is correct. 
2  ICE of AI.getCoerceToType() in debugbuild.(AI can not getcoerceTotype when it's null)



https://github.com/llvm/llvm-project/pull/72624


More information about the cfe-commits mailing list