This is an archive of the discontinued LLVM Phabricator instance.

[IR] Stop trying to delete other signatures of User::operator new when we override one signature in a class derived from User
ClosedPublic

Authored by craig.topper on Jun 12 2017, 3:19 PM.

Details

Summary

User has 3 signatures for operator new today. They take a single size, a size and a number of users, and a size, number of users, and descriptor size.

Historically there used to only be one signature that took size and a number of uses. Long ago derived classes implemented their own versions that took just a size and would call the size and use count version. Then they left an unimplemented signature for the size and use count signature from User. As we moved to C++11 this unimplemented signature because = delete.

Since then operator new has picked up two new signatures for operator new. But when the 3 argument version was added it was never added to the delete list in all of the derived classes where the 2 argument version is deleted. This makes things inconsistent.

I believe once one version of operator new is created in a derived class name hiding will take care of making all of the base class signatures unavailable. So I don't think the deleted lines are needed at all.

This patch removes all of the deletes in cases where there is an override or there is already a delete of another signature (that should trigger name hiding too).

Diff Detail

Event Timeline

craig.topper created this revision.Jun 12 2017, 3:19 PM

Trying to allocate a ShuffleVector with the explicit use count form before the patch

lib/AsmParser/LLParser.cpp:5822:10: error: call to deleted function 'operator new'
  Inst = new (3) ShuffleVectorInst(Op0, Op1, Op2);
         ^   ~~~
include/llvm/IR/Instructions.h:2237:9: note: candidate function has been explicitly deleted
  void *operator new(size_t, unsigned) = delete;
        ^
include/llvm/IR/Instructions.h:2233:9: note: candidate function not viable: requires single argument 's', but 2 arguments were provided
  void *operator new(size_t s) {

After the patch

lib/AsmParser/LLParser.cpp:5822:10: error: no matching function for call to 'operator new'
  Inst = new (3) ShuffleVectorInst(Op0, Op1, Op2);
         ^   ~~~
include/llvm/IR/Instructions.h:2225:9: note: candidate function not viable: requires single argument 's', but 2 arguments were provided
  void *operator new(size_t s) {
dblaikie accepted this revision.Jun 12 2017, 3:52 PM

Sounds good to me, then :)

This revision is now accepted and ready to land.Jun 12 2017, 3:52 PM
This revision was automatically updated to reflect the committed changes.