This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] partially revert 2b4fa5348ee157b6b1a1af44d0137ca8c7a71573 to fix Objective-C static variable initialization
Needs ReviewPublic

Authored by arphaman on Jan 8 2020, 1:14 PM.

Details

Summary

The following commit:

commit 2b4fa5348ee157b6b1a1af44d0137ca8c7a71573
Author: Richard Smith <richard-llvm@metafoo.co.uk>
Date:   Sun Sep 29 05:08:46 2019 +0000

    For P0784R7: compute whether a variable has constant destruction if it
    has a constexpr destructor.

started emitting static variables in Objective-C with C++ acquire/release checks. This is not supported for Objective-C. I can't revert the commit right now, so this is a partial revert of the change, to make sure next week's release branch isn't broken.

Diff Detail

Event Timeline

arphaman created this revision.Jan 8 2020, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2020, 1:14 PM
rjmccall added inline comments.Jan 8 2020, 1:29 PM
clang/lib/CodeGen/CGDecl.cpp
377

The long-term fix here is probably for needsDestruction to say that variables of static storage duration of non-trivial ARC type and/or non-trivial C struct type don't need destruction.

arphaman marked an inline comment as done.Jan 10 2020, 2:31 PM
arphaman added inline comments.
clang/lib/CodeGen/CGDecl.cpp
377

I don't have time to fix it properly right now, but I filed https://github.com/llvm/llvm-project/issues/93 to keep track of the issue. Can this be committed now before the branch next week to avoid shipping this bug in the release?

rsmith added inline comments.Jan 10 2020, 2:56 PM
clang/lib/CodeGen/CGDecl.cpp
377

A correct fix looks to be pretty trivial and this patch appears to break C++20 semantics, so let's fix it properly.

rjmccall added inline comments.Jan 10 2020, 3:10 PM
clang/lib/CodeGen/CGDecl.cpp
377

I agree.

rsmith added inline comments.Jan 10 2020, 3:19 PM
clang/lib/CodeGen/CGDecl.cpp
377

Done in llvmorg-10-init-17084-g7a38468e34e. Thanks for the report and the testcase :)