[llvm-dev] Is read and write variables always translated to load and store IR instructions?

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sat Jan 19 13:36:43 PST 2019


Hi,

On Sat, 19 Jan 2019 at 17:09, Peng Yu via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> It seems that read and write access to variables are translated to
> load and store IR instructions.
>
> Are they only translated to load and store IR instructions in .ll
> code? Could read and write accesses be translated to other IR
> instructions (for .0.0.preopt.bc only)? Thanks.

I think this is more a question for cfe-dev since llvm-dev only really
gets involved once the IR has been generated.

That said, a proper answer probably involves some quite involved
discussions about just what counts as an access. At the very least
Clang will also generate calls to @llvm.memcpy.* for struct copies.
For example:

    typedef struct {
      int a;
    } Foo;

    void func(Foo f) {
      Foo g = f;
    }

will cause Clang to initialize 'g' with a memcpy. memset can be
generated similarly if you set a struct to 0.

Cheers.

Tim.


More information about the llvm-dev mailing list