aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGClass.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-06-22Revert "Try to implement lambdas with inalloca parameters by forwarding ↵Amy Huang1-85/+14
without use of inallocas." Causes a clang crash (see crbug.com/1457256). This reverts commit 015049338d7e8e0e81f2ad2f94e5a43e2e3f5220.
2023-06-20Try to implement lambdas with inalloca parameters by forwarding without use ↵Amy Huang1-14/+85
of inallocas. Differential Revision: https://reviews.llvm.org/D137872
2023-06-16[clang] Replace use of Type::getPointerTo() (NFC)Youngsuk Kim1-15/+9
Partial progress towards replacing in-tree uses of `Type::getPointerTo()`. This needs to be done before deprecating the API. Reviewed By: nikic, barannikov88 Differential Revision: https://reviews.llvm.org/D152321
2023-06-12[Clang] Remove uses of PointerType::getWithSamePointeeType (NFC)Nikita Popov1-2/+2
No longer relevant with opaque pointers.
2023-02-15[CodeGen] Add a flag to `Address` and `Lvalue` that is used to keepAkira Hatanaka1-2/+2
track of whether the pointer is known not to be null The flag will be used for the arm64e work we plan to upstream in the future (see https://lists.llvm.org/pipermail/llvm-dev/2019-October/136091.html). Currently the flag has no effect on code generation. Differential Revision: https://reviews.llvm.org/D142584
2023-01-14[clang] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata1-3/+3
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14[clang] Add #include <optional> (NFC)Kazu Hirata1-0/+1
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-17llvm::Optional::value => operator*/operator->Fangrui Song1-3/+3
std::optional::value() has undesired exception checking semantics and is unavailable in older Xcode (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). The call sites block std::optional migration. This makes `ninja clang` work in the absence of llvm::Optional::value.
2022-12-03[CodeGen] Use std::nullopt instead of None (NFC)Kazu Hirata1-2/+2
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-08Fix duplicate word typos; NFCRageking81-1/+1
This revision fixes typos where there are 2 consecutive words which are duplicated. There should be no code changes in this revision (only changes to comments and docs). Do let me know if there are any undesirable changes in this revision. Thanks.
2022-09-03[clang] Qualify auto in range-based for loops (NFC)Kazu Hirata1-2/+2
2022-08-31[msan] Use Debug Info to point to affected fieldsVitaly Buka1-0/+29
Reviewed By: kstoimenov Differential Revision: https://reviews.llvm.org/D132909
2022-08-30[msan] Add more specific messages for use-after-destroyVitaly Buka1-13/+24
Reviewed By: kda, kstoimenov Differential Revision: https://reviews.llvm.org/D132907
2022-08-23[clang] Create alloca to pass into static lambdaVitaly Buka1-3/+4
"this" parameter of lambda if undef, notnull and differentiable. So we need to pass something consistent. Any alloca will work. It will be eliminated as unused later by optimizer. Otherwise we generate code which Msan is expected to catch. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D132275
2022-08-08[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-1/+1
With C++17 there is no Clang pedantic warning or MSVC C5051. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D131346
2022-07-26[WPD] Use new llvm.public.type.test intrinsic for potentially publicly ↵Arthur Eubanks1-4/+10
visible classes Turning on opaque pointers has uncovered an issue with WPD where we currently pattern match away `assume(type.test)` in WPD so that a later LTT doesn't resolve the type test to undef and introduce an `assume(false)`. The pattern matching can fail in cases where we transform two `assume(type.test)`s into `assume(phi(type.test.1, type.test.2))`. Currently we create `assume(type.test)` for all virtual calls that might be devirtualized. This is to support `-Wl,--lto-whole-program-visibility`. To prevent this, all virtual calls that may not be in the same LTO module instead use a new `llvm.public.type.test` intrinsic in place of the `llvm.type.test`. Then when we know if `-Wl,--lto-whole-program-visibility` is passed or not, we can either replace all `llvm.public.type.test` with `llvm.type.test`, or replace all `llvm.public.type.test` with `true`. This prevents WPD from trying to pattern match away `assume(type.test)` for public virtual calls when failing the pattern matching will result in miscompiles. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D128955
2022-07-13[clang] Use value instead of getValue (NFC)Kazu Hirata1-2/+2
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-3/+3
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-3/+3
2022-06-16[clang] Don't emit type test/assume for virtual classes that should never ↵Arthur Eubanks1-2/+2
participate in WPD Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D127876
2022-03-16Stricter use-after-dtor detection for trivial members.Evgenii Stepanov1-67/+60
Poison trivial class members one-by-one in the reverse order of their construction, instead of all-at-once at the very end. For example, in the following code access to `x` from `~B` will produce an undefined value. struct A { struct B b; int x; }; Reviewed By: kda Differential Revision: https://reviews.llvm.org/D119600
2022-03-16Use-after-dtor detection for trivial base classes.Evgenii Stepanov1-14/+51
-fsanitize-memory-use-after-dtor detects memory access after a subobject is destroyed but its memory is not yet deallocated. This is done by poisoning each object memory near the end of its destructor. Subobjects (members and base classes) do this in their respective destructors, and the parent class does the same for its members with trivial destructors. Inexplicably, base classes with trivial destructors are not handled at all. This change fixes this oversight by adding the base class poisoning logic to the parent class destructor. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D119300
2022-02-23[clang] Remove Address::deprecated() from CGClass.cppArthur Eubanks1-5/+4
2022-02-23[clang] Remove getPointerElementType() in EmitVTableTypeCheckedLoad()Arthur Eubanks1-2/+3
2022-02-22[clang] Remove an Address::deprecated() call in CGClass.cppArthur Eubanks1-1/+1
2022-02-17[CodeGen] Rename deprecated Address constructorNikita Popov1-3/+3
To make uses of the deprecated constructor easier to spot, and to ensure that no new uses are introduced, rename it to Address::deprecated(). While doing the rename, I've filled in element types in cases where it was relatively obvious, but we're still left with 135 calls to the deprecated constructor.
2022-02-14[CGBuilder] Remove CreateBitCast() methodNikita Popov1-2/+2
Use CreateElementBitCast() instead, or don't work on Address where not necessary.
2022-02-11[NFC] clang-format one function.Evgenii Stepanov1-16/+16
fix code formatting Differential Revision: https://reviews.llvm.org/D119299
2022-01-27[NFC][Clang][OpaquePtr] Move away from deprecated Address constructor in ↵Arthur Eubanks1-1/+2
EmitCXXMemberDataPointerAddress()
2022-01-25[NFC] Remove uses of PointerType::getElementType()Nikita Popov1-3/+2
Instead use either Type::getPointerElementType() or Type::getNonOpaquePointerElementType(). This is part of D117885, in preparation for deprecating the API.
2021-12-27[CodeGen] Avoid more pointer element type accessesNikita Popov1-2/+2
2021-12-21[CodeGen] Avoid more pointer element type accessesNikita Popov1-22/+10
2021-12-21[CodeGen] Avoid some pointer element type accessesNikita Popov1-9/+9
This avoids some pointer element type accesses when compiling C++ code.
2021-10-08Don't update the vptr at the start of the destructor of a final class.Richard Smith1-0/+5
In this case, we know statically that we're destroying the most-derived class, so the vptr must already point to the current class and never needs to be updated.
2021-09-16Fix vtbl field addr spaceYaxun (Sam) Liu1-6/+7
Storing the vtable field of an object should use the same address space as the this pointer. Currently it is assumed to be addr space 0 but this may not be true. This assumption (added in 054cc3b1b469de4b0cb25d1dc3af43c679c5dc44) caused issues for the out-of-tree CHERI targets. Reviewed by: John McCall, Alexander Richardson Differential Revision: https://reviews.llvm.org/D109841
2021-07-17[OpaquePtr] Remove uses of CreateGEP() without element typeNikita Popov1-0/+1
Remove uses of to-be-deprecated API. In cases where the correct element type was not immediately obvious to me, fall back to explicit getPointerElementType().
2021-07-17[OpaquePtr] Remove uses of CGF.Builder.CreateConstInBoundsGEP1_64() without typeNikita Popov1-1/+1
Remove uses of to-be-deprecated API.
2021-07-17[OpaquePtr] Remove uses of CreateConstInBoundsGEP2_64() without typeNikita Popov1-8/+5
Remove uses of to-be-deprecated API.
2021-06-08[CUDA][HIP] Fix store of vtbl in ctorYaxun (Sam) Liu1-1/+3
vtbl itself is in default global address space. When clang emits ctor, it gets a pointer to the vtbl field based on the this pointer, then stores vtbl to the pointer. Since this pointer can point to any address space (e.g. an object created in stack), this pointer points to default address space, therefore the pointer to vtbl field in this object should also be in default address space. Currently, clang incorrectly casts the pointer to vtbl field in this object to global address space. This caused assertions in backend. This patch fixes that by removing the incorrect addr space cast. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D103835
2021-04-15Implemented [[clang::musttail]] attribute for guaranteed tail calls.Joshua Haberman1-1/+1
This is a Clang-only change and depends on the existing "musttail" support already implemented in LLVM. The [[clang::musttail]] attribute goes on a return statement, not a function definition. There are several constraints that the user must follow when using [[clang::musttail]], and these constraints are verified by Sema. Tail calls are supported on regular function calls, calls through a function pointer, member function calls, and even pointer to member. Future work would be to throw a warning if a users tries to pass a pointer or reference to a local variable through a musttail call. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D99517
2021-03-12[OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC)Nikita Popov1-8/+8
This removes some (but not all) uses of type-less CreateGEP() and CreateInBoundsGEP() APIs, which are incompatible with opaque pointers. There are a still a number of tricky uses left, as well as many more variation APIs for CreateGEP.
2021-02-22[clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to ↵Melanie Blower1-5/+5
NoSanitizeList.h This patch responds to a comment from @vitalybuka in D96203: suggestion to do the change incrementally, and start by modifying this file name. I modified the file name and made the other changes that follow from that rename. Reviewers: vitalybuka, echristo, MaskRay, jansvoboda11, aaron.ballman Differential Revision: https://reviews.llvm.org/D96974
2020-12-08UBSAN: emit distinctive trapsTim Northover1-1/+1
Sometimes people get minimal crash reports after a UBSAN incident. This change tags each trap with an integer representing the kind of failure encountered, which can aid in tracking down the root cause of the problem.
2020-12-07[NFC][MSan] Round up OffsetPtr in PoisonMembersVitaly Buka1-17/+16
getFieldOffset(layoutStartOffset) is expected to point to the first trivial field or the one which follows non-trivial. So it must be byte aligned already. However this is not obvious without assumptions about callers. This patch will avoid the need in such assumptions. Depends on D92727. Differential Revision: https://reviews.llvm.org/D92728
2020-12-07[CodeGen][MSan] Don't use offsets of zero-sized fieldsVitaly Buka1-2/+13
Such fields will likely have offset zero making __sanitizer_dtor_callback poisoning wrong regions. E.g. it can poison base class member from derived class constructor. Differential Revision: https://reviews.llvm.org/D92727
2020-12-05[NFC][CodeGen] Simplify SanitizeDtorMembers::EmitVitaly Buka1-22/+16
2020-11-20[AMDGPU] Set the default globals address space to 1Alex Richardson1-4/+8
This will ensure that passes that add new global variables will create them in address space 1 once the passes have been updated to no longer default to the implicit address space zero. This also changes AutoUpgrade.cpp to add -G1 to the DataLayout if it wasn't already to present to ensure bitcode backwards compatibility. Reviewed by: arsenm Differential Revision: https://reviews.llvm.org/D84345
2020-10-13[AST] Change return type of getTypeInfoInChars to a proper struct instead of ↵Bevin Hansson1-4/+3
std::pair. Followup to D85191. This changes getTypeInfoInChars to return a TypeInfoChars struct instead of a std::pair of CharUnits. This lets the interface match getTypeInfo more closely. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D86447
2020-06-20[clang/llvm] As part of using inclusive language withinEric Christopher1-1/+1
the llvm project, migrate away from the use of blacklist and whitelist.
2020-06-11[clang] Frontend components for the relative vtables ABI (round 2)Leonard Chan1-2/+7
This patch contains all of the clang changes from D72959. - Generalize the relative vtables ABI such that it can be used by other targets. - Add an enum VTableComponentLayout which controls whether components in the vtable should be pointers to other structs or relative offsets to those structs. Other ABIs can change this enum to restructure how components in the vtable are laid out/accessed. - Add methods to ConstantInitBuilder for inserting relative offsets to a specified position in the aggregate being constructed. - Fix failing tests under new PM and ASan and MSan issues. See D72959 for background info. Differential Revision: https://reviews.llvm.org/D77592