llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.85k stars 11.47k forks source link

clang issues aligned vptr loads for packed structs #36622

Open ec04fc15-fa35-46f2-80e1-5d271f2ef708 opened 6 years ago

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 6 years ago
Bugzilla Link 37274
Version trunk
OS Linux
CC @DougGregor

Extended Description

Testcase:

struct [[gnu::packed]] B { virtual void f(); }; static_assert(alignof(B) == 1); void f(B &b) { b.f(); }

The static_assert passes, and yet Clang generates an aligned vptr load:

%3 = load %struct.B*, %struct.B** %2, align 8, !dbg !​14

GCC appears to correctly handle this case:

https://godbolt.org/g/GJkafy

llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-codegen

Author: None (ec04fc15-fa35-46f2-80e1-5d271f2ef708)

| | | | --- | --- | | Bugzilla Link | [37274](https://llvm.org/bz37274) | | Version | trunk | | OS | Linux | | CC | @DougGregor | ## Extended Description Testcase: struct [[gnu::packed]] B { virtual void f(); }; static_assert(alignof(B) == 1); void f(B &b) { b.f(); } The static_assert passes, and yet Clang generates an aligned vptr load: %3 = load %struct.B*, %struct.B** %2, align 8, !dbg !​14 GCC appears to correctly handle this case: https://godbolt.org/g/GJkafy