[all-commits] [llvm/llvm-project] 1fbb6d: Fix assert in generated `direct` property getter/s...

Michael Wyman via All-commits all-commits at lists.llvm.org
Tue Oct 11 21:16:42 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1fbb6d8b34dec217179d8e46d8c5d8e243047045
      https://github.com/llvm/llvm-project/commit/1fbb6d8b34dec217179d8e46d8c5d8e243047045
  Author: Michael Wyman <michael at mwyman.com>
  Date:   2022-10-11 (Tue, 11 Oct 2022)

  Changed paths:
    M clang/lib/CodeGen/CGObjC.cpp
    M clang/test/CodeGenObjC/direct-method.m

  Log Message:
  -----------
  Fix assert in generated `direct` property getter/setters due to removal of `_cmd` parameter.

This fixes a bug from https://reviews.llvm.org/D131424 that removed the implicit `_cmd` parameter as an argument to `objc_direct` method implementations. In many cases the generated getter/setter will call `objc_getProperty` or `objc_setProperty`, both of which require the selector of the getter/setter; since `_cmd` didn't automatically have backing storage, attempting to load the address asserted.

For direct property generated getters/setters, this now passes an undefined/uninitialized/poison value as the `_cmd` argument to `objc_getProperty`/`objc_setProperty`. Prior to removing the `_cmd` argument from the ABI of direct methods, it was left uninitialized/undefined; although references within hand-implemented methods would load the selector in the method prologue, generated getters/setters never did and just forwarded the undefined value that was passed as the argument.

This change keeps the generated code mostly similar to before, passing an uninitialized/undefined/poison value; for setters, the value argument may be moved to another register.

Added a test that triggers the assert prior to the implementation code.

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




More information about the All-commits mailing list