Skip to content

[embedded] [IRGen] Avoid creating "aliases" for type metadata address points in client modules#87045

Merged
aschwaighofer merged 1 commit intoswiftlang:mainfrom
aschwaighofer:embedded_typemetadata_duplicate_symbol_fix
Feb 7, 2026
Merged

[embedded] [IRGen] Avoid creating "aliases" for type metadata address points in client modules#87045
aschwaighofer merged 1 commit intoswiftlang:mainfrom
aschwaighofer:embedded_typemetadata_duplicate_symbol_fix

Conversation

@aschwaighofer
Copy link
Contributor

We don't need to export the type metadata address point alias in clients that lazily emit other module's type metadata. There will be an exported metadata symbol in the originating module for that purpose.

Instead, satisfy any local uses of the metadata address point uses by its underlying address computation.

This is to workaround a bug where LLVM generates the wrong assembly for weak aliases that point to an offset of another symbol.

@"$e1C7MyClassCySiGN" = weak_odr hidden alias %swift.type, getelementptr
inbounds (<{ ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }>,
ptr @"$e1C7MyClassCySiGMf", i32 0, i32 1)

Generates:

.weak_reference _$e1C7MyClassCySiGN
.private_extern _$e1C7MyClassCySiGN
.alt_entry  _$e1C7MyClassCySiGN
  _$e1C7MyClassCySiGN = _$e1C7MyClassCySiGMf+8

Instead of

.weak_definition _$e1C7MyClassCySiGN
.private_extern _$e1C7MyClassCySiGN
.alt_entry  _$e1C7MyClassCySiGN
  _$e1C7MyClassCySiGN = _$e1C7MyClassCySiGMf+8

Leading for "weak"ness to be ignored and duplicate type medata symbol linkage errors.

rdar://169573918

… points in client modules

We don't need to export the type metadata address point alias in clients that
lazily emit other module's type metadata. There will be an exported
metadata symbol in the originating module for that purpose.

Instead, satisfy any local uses of the metadata address point uses by its
underlying address computation.

This is to workaround a bug where LLVM generates the wrong assembly for
weak aliases that point to an offset of another symbol.

```
@"$e1C7MyClassCySiGN" = weak_odr hidden alias %swift.type, getelementptr
inbounds (<{ ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }>,
ptr @"$e1C7MyClassCySiGMf", i32 0, i32 1)
```

Generates:

```
.weak_reference _$e1C7MyClassCySiGN
.private_extern _$e1C7MyClassCySiGN
.alt_entry  _$e1C7MyClassCySiGN
  _$e1C7MyClassCySiGN = _$e1C7MyClassCySiGMf+8
```

Instead of

```
.weak_definition _$e1C7MyClassCySiGN
.private_extern _$e1C7MyClassCySiGN
.alt_entry  _$e1C7MyClassCySiGN
  _$e1C7MyClassCySiGN = _$e1C7MyClassCySiGMf+8
```

Leading for "weak"ness to be ignored and duplicate type medata symbol linkage
errors.

rdar://169573918
@aschwaighofer
Copy link
Contributor Author

@swift-ci test

@aschwaighofer aschwaighofer added the embedded Embedded Swift label Feb 6, 2026
@aschwaighofer aschwaighofer merged commit 2852361 into swiftlang:main Feb 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded Embedded Swift

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant