[all-commits] [llvm/llvm-project] 7c215a: [clang][Interp] Explicitly handle RVO Pointer

Timm Bäder via All-commits all-commits at lists.llvm.org
Wed Nov 30 01:42:24 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7c215a457178174187cb975e6ee7d96105ea0ef8
      https://github.com/llvm/llvm-project/commit/7c215a457178174187cb975e6ee7d96105ea0ef8
  Author: Timm Bäder <tbaeder at redhat.com>
  Date:   2022-11-30 (Wed, 30 Nov 2022)

  Changed paths:
    M clang/lib/AST/Interp/ByteCodeStmtGen.cpp
    M clang/lib/AST/Interp/Interp.h
    M clang/lib/AST/Interp/InterpFrame.cpp
    M clang/lib/AST/Interp/InterpFrame.h
    M clang/lib/AST/Interp/Opcodes.td
    M clang/test/AST/Interp/records.cpp

  Log Message:
  -----------
  [clang][Interp] Explicitly handle RVO Pointer

The calling convention is:

[RVO pointer]
[instance pointer]
[... args ...]

We handle the instance pointer ourselves, BUT for the RVO pointer, we
just assumed in visitReturnStmt() that it is on top of the stack. Which
isn't true if there are other args present (and a this pointer, maybe).

Fix this by recording the RVO pointer explicitly when creating an
InterpFrame, just like we do with the instance/This pointer.

There is already a "RVOAndParams()" test in test/AST/Inter/records.cpp,
that was supposed to test this, however, it didn't trigger any
problematic behavior because the parameter and the return value have the
same type.

Differential Revision: https://reviews.llvm.org/D137392




More information about the All-commits mailing list