Skip to content

Conversation

nunoplopes
Copy link
Member

Continuing the discussion in https://discourse.llvm.org/t/codegen-layout-of-si-class-type-info-doesnt-match-the-actual-size/73274

Before we had this code:
@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr

now we'll produce:
@_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]

This is because we may not know the exact size of this data, and clang issues gep inbounds with idx=2. Before, that gep would always result in poison.

…ptr]

Before we had this code:
@_ZTVN10__cxxabiv117__class_type_infoE = external global ptr

now we'll produce:
@_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr]

This is because we may not know the exact size of this data, and clang
issues gep inbounds with idx=2. Before, that gep would always result
in poison.
@nunoplopes nunoplopes requested a review from a team as a code owner September 7, 2023 11:07
@github-actions github-actions bot added the clang:codegen IR generation bugs: mangling, exceptions, etc. label Sep 7, 2023
@@ -14,8 +14,8 @@ class B : A {
// NO-AS: @_ZTISt9type_info = external constant ptr
// AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1)
// NO-AS: @_ZTIi = external constant ptr
// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global ptr addrspace(1)
// NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global [0 x ptr]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be [0 x ptr addrspace(1)]? Not sure that makes any semantic difference, but it would be more clear. (So use llvm::ArrayType::get(CGM.GlobalsInt8PtrTy, 0).)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, changed!

@efriedma-quic
Copy link
Collaborator

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants