This is an archive of the discontinued LLVM Phabricator instance.

[IR] Add a few asserts to provide a better failure signature if you try to create a load/store/alloca with no alignment or insertion position
ClosedPublic

Authored by craig.topper on Jul 14 2020, 4:09 PM.

Details

Summary

If no alignment is specified we try to find the datalayout by using the insert position to get the module so we can get the datalayout. But if those are null, then we deference a null pointer.

This patch adds asserts to make the failure a little more obvious than just seg faulting.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 14 2020, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2020, 4:09 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
efriedma accepted this revision.Jul 14 2020, 4:29 PM

LGTM with one minor comment

llvm/lib/IR/Instructions.cpp
1265

Maybe also assert BB->getParent() is non-null? Someone mentioned an issue in some downstream code where the function was null.

This revision is now accepted and ready to land.Jul 14 2020, 4:29 PM
This revision was automatically updated to reflect the committed changes.