llvm-beanz wrote:

> any chance you could A/B test this on a bootstrap of clang, for instance? To 
> help validate that this really is NFC/dead code?

I did a little more archeology, and I'm actually struggling to find any point 
in the history where this change was required. The difference between the two 
sides of the if is really that if the declaration is a specialization 
declaration, it creates the pointed-to object then explicitly queries for the 
size and alignment before creating the pointer type.

On the other side of the branch it calls `getOrCreateType` with the pointer 
type, which eventually calls into `CGDebugInfo::CreatePointerLikeType`, which 
as far back as I've looked 
(https://github.com/llvm/llvm-project/commit/443f6773029a45a705ae2873fb620904289513dd),
 has always included alignment and size.

Here's a simplified diff of the two sides of the branch with comments and 
whitespace differences removed to make it more clear:
```diff
--- /Users/cbieneman/dev/scratch/a      2024-12-12 09:29:27
+++ /Users/cbieneman/dev/scratch/b      2024-12-12 09:29:32
@@ -1,10 +1,4 @@
-const PointerType *ThisPtrTy = cast<PointerType>(ThisPtr);
-uint64_t Size = CGM.getContext().getTypeSize(ThisPtrTy);
-auto Align = getTypeAlignIfRequired(ThisPtrTy, CGM.getContext());
-llvm::DIType *PointeeType =
-    getOrCreateType(ThisPtrTy->getPointeeType(), Unit);
-llvm::DIType *ThisPtrType =
-DBuilder.createPointerType(PointeeType, Size, Align);
+llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
 TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
 ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
 Elts.push_back(ThisPtrType);
```

Is there something I'm missing that explicitly setting the alignment handles? I 
feel like if `getOrCreateType` didn't properly handle the type's alignment we 
would be in a world of different hurt.

https://github.com/llvm/llvm-project/pull/119445
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to