This is an archive of the discontinued LLVM Phabricator instance.

Explicitly initialize opaque pointer mode in CodeGenAction
ClosedPublic

Authored by MatzeB on Nov 4 2022, 5:41 PM.

Details

Summary

Explicitly call LLVMContext::setOpaquePointers in CodeGenAction before loading any IR files. With this we use the mode specified on the command-line rather than lazily initializing it based on the contents of the IR.

This helps when using -fthinlto-index which may end up mixing files with typed and opaque pointer types which fails when the first file happened to use typed pointers since we cannot downgrade IR with opaque pointer types to typed pointer types.

Diff Detail

Event Timeline

MatzeB created this revision.Nov 4 2022, 5:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 5:41 PM
MatzeB requested review of this revision.Nov 4 2022, 5:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 5:41 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MatzeB edited the summary of this revision. (Show Details)Nov 4 2022, 5:42 PM
MatzeB edited the summary of this revision. (Show Details)
MatzeB retitled this revision from Explicitely initialize opaque pointer mode when -fthinlto-index is used to Explicitly initialize opaque pointer mode when -fthinlto-index is used.Nov 4 2022, 5:44 PM
nikic added inline comments.Nov 5 2022, 1:21 AM
clang/lib/CodeGen/CodeGenAction.cpp
1138

I think it would be fine to always do this, not just for the ThinLTO case.

clang/test/CodeGen/thinlto-opaque-typed-mix.ll
15

What's the false doing here?

MatzeB updated this revision to Diff 473747.Nov 7 2022, 10:58 AM
MatzeB retitled this revision from Explicitly initialize opaque pointer mode when -fthinlto-index is used to Explicitly initialize opaque pointer mode in CodeGenAction.
MatzeB edited the summary of this revision. (Show Details)

address review feedback.

MatzeB marked 2 inline comments as done.Nov 7 2022, 10:59 AM
This revision is now accepted and ready to land.Nov 7 2022, 11:06 AM
MatzeB edited the summary of this revision. (Show Details)Nov 7 2022, 11:27 AM
This revision was automatically updated to reflect the committed changes.