This is an archive of the discontinued LLVM Phabricator instance.

[IR] Merge createReplacementInstr into ConstantExpr::getAsInstruction
ClosedPublic

Authored by foad on Oct 29 2021, 2:47 AM.

Details

Summary

createReplacementInstr was a trivial wrapper around
ConstantExpr::getAsInstruction, which also inserted the new instruction
into a basic block. Implement this directly in getAsInstruction by
adding an InsertBefore parameter and change all callers to use it. NFC.

A follow-up patch will remove createReplacementInstr.

Diff Detail

Event Timeline

foad created this revision.Oct 29 2021, 2:47 AM
foad requested review of this revision.Oct 29 2021, 2:47 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 29 2021, 2:47 AM
hsmhsm accepted this revision.Oct 29 2021, 3:17 AM

Thanks for this clean-up patch. Looks good to me. However, please wait for some time if in case other reviewers have any comments.

This revision is now accepted and ready to land.Oct 29 2021, 3:17 AM
yaxunl added inline comments.Oct 29 2021, 6:47 AM
llvm/include/llvm/IR/Constants.h
1318

Can you add a comment about the insertion location when 'InsertBefore' is nullptr? Thanks.

foad updated this revision to Diff 383341.Oct 29 2021, 7:03 AM

Add comment about InsertBefore.

yaxunl accepted this revision.Oct 29 2021, 7:04 AM

LGTM. Thanks!

foad added inline comments.Oct 29 2021, 7:05 AM
llvm/include/llvm/IR/Constants.h
1318

Done, although there are loads of InsertBefore arguments in Instructions.h that all work the same way, and no comments explaining them :)

This revision was landed with ongoing or failed builds.Oct 29 2021, 7:18 AM
This revision was automatically updated to reflect the committed changes.