[PATCH] D59254: [RFC] Implementation of Clang randstruct

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 10:53:27 PDT 2019


jfb added a comment.

In D59254#1566895 <https://reviews.llvm.org/D59254#1566895>, @shawnl wrote:

> My point is that most languages these days that intend to be compiled to machine code want compatibility with the C ABI, and randstruct will be part of that (and can be made compatible between languages by sharing the seed). LLVM knows what a struct is.


Basic stuff, sure LLVM can know about and move fields around, especially if clang slaps an attribute on the struct saying it's fine.

However, struct layout is deeply ingrained in code generation. Too deeply to just move it to LLVM. Consider this simple example:

  template <int Size>
  struct Arr {
      int arr[Size];
  };
  
  struct A { int a, b, c; char d, e, f, g; };
  
  Arr<__builtin_offsetof(A, d)> arr;

There's way more complex stuff that falls out of how C and C++ specify the language. That complexity really shouldn't be in scope for this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59254/new/

https://reviews.llvm.org/D59254





More information about the cfe-commits mailing list