This is an archive of the discontinued LLVM Phabricator instance.

Fix infinite recursion during IR emission if a constant-initialized lifetime-extended temporary object's initializer refers back to the same object.
ClosedPublic

Authored by rsmith on Mar 1 2021, 1:58 PM.

Details

Summary

GetAddrOfGlobalTemporary previously tried to emit the initializer of
a global temporary before updating the global temporary map. Emitting the
initializer could recurse back into GetAddrOfGlobalTemporary for the same
temporary, resulting in an infinite recursion.

Diff Detail

Event Timeline

rsmith requested review of this revision.Mar 1 2021, 1:58 PM
rsmith created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2021, 1:58 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rsmith added a comment.Mar 1 2021, 2:03 PM

@rjmccall We could alternatively address this by creating and registering the global first, and only then building and adding its initializer, but either way we're going to need some special-case code to detect and handle this situation (because we might need to change the type of the global to match the emitted constant). Happy to switch to that approach if you prefer.

rjmccall accepted this revision.Mar 1 2021, 9:08 PM

No, I like this approach, thanks.

This revision is now accepted and ready to land.Mar 1 2021, 9:08 PM