Partial progress towards replacing in-tree uses of Type::getPointerTo().
This needs to be done before deprecating the API.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| clang/lib/CodeGen/Address.h | ||
|---|---|---|
| 135 ↗ | (On Diff #529089) | In these cases, what we want to do is remove the BitCast, which is no longer necessary. |
If getPointerTo() is used just to support an unnecessary bitcast, just get rid of the bitcast.
| clang/lib/CodeGen/Address.h | ||
|---|---|---|
| 135 ↗ | (On Diff #529089) | Thank you for your feedback! I've updated the revision accordingly. |
Some tests that run with -no-opaque-pointers began failing after I updated the revision to get rid of bitcasts.
The bitcasts are still needed if running Clang with -no-opaque-pointers.
I have finished migrating these tests and removed the flag in https://reviews.llvm.org/D152447, so this should no longer be an issue.
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | Can remove this bit cast. | |
| clang/lib/CodeGen/CGBuiltin.cpp | ||
| 222–223 | We should be using the overload that take as a context rather than a type, to create an opaque pointers. The variable name should also drop the mention of the specific type. Same for other uses. | |
| 324 | Remove bitcast | |
| 415–416 | Remove bitcast | |
| 4658 | Remove bitcast (more below...) | |
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | Wouldn't removing the bitcast cause behavior change for uses of CreateElementBitCast that supply a Name that is not ""? | |
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | This will never actually create an instruction, so the name is already ignored now. It would make sense to remove the parameter altogether. | |
- Update uses of PointerType::get(Ty) & PointerType::getUnqual to be in overloaded form of PointerType::get that takes LLVMContext&
- Remove more unnecessary bitcasts which were previously overlooked.
- Remove pointee type info from Type variable names
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | Thank you for the clarification. I've updated the revision to get rid of the bitcast. I'll prepare a separate commit that gets rid of the Name parameter. | |
Please use clang-format on the modified lines.
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | The argument can be removed. Idea for a follow-up: I would also consider removing this method because it does not do what its name says. | |
| clang/lib/CodeGen/CGBuiltin.cpp | ||
| 9349–9350 | Braces are now redundant. | |
| clang/lib/CodeGen/CGCUDANV.cpp | ||
| 238–240 | These are all the same types. Replace the variables with single PtrTy? | |
| 271–272 | Pass Context | |
| 538–542 | Pass Context | |
| clang/lib/CodeGen/CGCXX.cpp | ||
| 177 | This looks wrong. It used to be GetFunctionType(TargetDecl). | |
| 185–186 | What's the reason for this change? | |
| clang/lib/CodeGen/CGException.cpp | ||
| 2120 | I guess this was intended to be named RecordTy. | |
| clang/lib/CodeGen/CGExprConstant.cpp | ||
| 1944–1946 | ||
| clang/lib/CodeGen/CGObjCRuntime.cpp | ||
| 374–375 | Pass context here | |
| 384–385 | Pass context here. | |
| clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
| 816–818 | ||
| 1925–1928 | ||
| 2551–2554 | I think this can be simplified further to just: | |
- Apply suggestions from barannikov88
- Used git clang-format to tidy up code format
Thank you for your feedback!
| clang/lib/CodeGen/CGBuilder.h | ||
|---|---|---|
| 161–162 | Thank you for the suggestion. I have a follow-up reivision for removing the Name parameter. (https://reviews.llvm.org/D152551) After this revision gets merged, I can update the follow-up revision to replace CreateElementBitCast also. | |
| clang/lib/CodeGen/CGCUDANV.cpp | ||
| 238–240 | Thank you for the suggestion. Unifying them to a single PtrTy adds a lot of diff, | |
| clang/lib/CodeGen/CGCXX.cpp | ||
| 177 | I've simply moved the line defining AliasValueType closer to its use. Moving the line to below isn't necessary, and it's rather causing confusion. | |
| 185–186 | Since AliasType got removed above, the assert condition needs to be updated one way or another. The assert was written in 2010 (before opaque pointers), With opaque pointers enabled, I thought the assert needs to be updated to check equality of both the pointee types & address spaces separately in order to preserve the original intent. | |
- Rebase onto latest llvm-project main : 2cd4dc59792578f833b838e3c9a376a4bcafc568
- Use llvm::PointerType::getUnqual whenever possible
| clang/lib/CodeGen/TargetInfo.cpp | ||
|---|---|---|
| 2057 | getLLVMContext doesn't seem available in this context. Below is the build error message I get when using getLLVMContext. ~/llvm-project/clang/lib/CodeGen/TargetInfo.cpp: In member function 'void {anonymous}::X86_32ABIInfo::addFieldToArgStruct(llvm::SmallVector<llvm::Type*, 6>&, clang::CharUnits&, clang::CodeGen::ABIArgInfo&, clang::QualType) const':
~/llvm-project/clang/lib/CodeGen/TargetInfo.cpp:2057:41: error: 'getLLVMContext' was not declared in this scope; did you mean 'getVMContext'?On line 2066, getVMContext is used when a LLVMContext& is needed. | |
I do not have commit access yet.
Could one of the reviewers land this patch for me?
Please use "Youngsuk Kim <youngsuk.kim@hpe.com>" to commit the change. Thank you!
@JOE1994
Please run the testsuite locally (ninja check-clang), there is at least one test that crashes (CodeGen/constructor-attribute.c).
| clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
|---|---|---|
| 2551–2554 | I was wrong, addr can be null here. Sorry. | |
- Fix nullptr bug (fixes Clang regression test : Clang :: CodeGen/constructor-attribute.c )
- Following feedback from @barannikov88
- Rebase onto latest main : a76376cdb034d817803cbdb2f3f451487807124d
| clang/lib/CodeGen/ItaniumCXXABI.cpp | ||
|---|---|---|
| 2551–2554 | Thanks for finding this! Updating code to handle the nullptr case fixes the Clang regression test Clang :: CodeGen/constructor-attribute.c. | |
With the updated revision, I don't see new test failures from ninja check-clang & ninja check-llvm & ninja check-clang-unit & ninja check-llvm-unit .
getUnqual