Skip to content

type_info name alignment on s390x #140052

Open
@iii-i

Description

@iii-i

On the s390x platform clang generates type_info names with alignment 1:

$ cat test.cpp && bin/clang -S test.cpp -mllvm -print-after-all 2>&1|grep "^@_ZTS1A ="
#include <typeinfo>
struct A {};
const std::type_info &q() { return typeid(A); }
@_ZTS1A = linkonce_odr dso_local constant [3 x i8] c"1A\00", comdat, align 1

Normally external symbols are aligned on a 2-byte boundary on s390x, and this is what GCC does for type_info names. Looking at the code that generates it:

  auto Align = CGM.getContext().getTypeAlignInChars(CGM.getContext().CharTy);

  llvm::GlobalVariable *GV = CGM.CreateOrReplaceCXXRuntimeVariable(
      Name, Init->getType(), Linkage, Align.getAsAlign());

The alignment used here is more or less alignof(char). I wonder if we should apply a more restrictive alignment? I have not looked into details, but clang uses alignment 2 for char arrays on s390x, so there must be some common code infrastructure for this purpose.

@uweigand @dominik-steenken

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions