[llvm] [IR] Make instr-create fns with Instruction *InsertBefore non-default (PR #86132)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 03:41:31 PDT 2024


https://github.com/nikic commented:

I guess this is okay (and I wouldn't want to block this), but this does seem like a good point to reconsider the overall design. I think there are two broad alternatives:

 1. Only have a single method which takes an InsertionPoint type. This type is basically a union of BasicBlock::iterator, BasicBlock *, or "none". The pro is that we have a good bit less code duplication. The con is that it's a bit less efficient -- though my primary concern would actually the the additional header cost this may impose.
 2. Remove the "create and insert" support entirely, and instead explicitly call insertBefore() or ... and this is what most code really should be doing ... use IRBuilder. There's a decent chance that code not using IRBuilder also fails to preserve debug locations.

Probably option 2 would be ideal, but it's also the option that involves the most work :)

https://github.com/llvm/llvm-project/pull/86132


More information about the llvm-commits mailing list