This is an archive of the discontinued LLVM Phabricator instance.

[IR] Move optional data in llvm::Function into a hungoff uselist
ClosedPublic

Authored by vsk on Oct 16 2015, 1:36 PM.

Diff Detail

Event Timeline

vsk updated this revision to Diff 37632.Oct 16 2015, 1:36 PM
vsk retitled this revision from to WIP: clean up the way optional Function data is managed.
vsk updated this object.
vsk added a subscriber: llvm-commits.
sanjoy added a subscriber: sanjoy.Oct 18 2015, 3:47 PM
sanjoy added inline comments.
include/llvm/IR/Function.h
67

Was the earlier comment incorrect? (i.e. CallingConvention should have been 3-15 earlier)?

If so, you might want to correct that mistake separately and check that in, and rebase this patch over that. That'll make the diff clearer.

Also, why did you choose bit 15? Doesn't it make sense to group this together with the rest of the Has* enums, before CallingConvention? (What you have here is fine btw, I'm just curious).

159–161

I'm not sure this is correct -- are you | ing over the new calling convention over what was there previously? Won't setting the calling convention to 4 and then to 2 end up setting it to 6?

500

Add a doxygen comment.

lib/IR/Function.cpp
973

Minor: I'd call ConstantPointerNull::get only if C is nullptr.

Also, do you really need to support the setHungoffOperand(nullptr) case? I think creating and passing in a i8* null or whatever should be up to the caller.

vsk updated this revision to Diff 37779.Oct 19 2015, 11:16 AM
vsk updated this object.

Thanks for the review.

  • Addressed correctness issue Sanjoy pointed out by rebasing to D13826.
  • Added comments where requested.
vsk marked 4 inline comments as done.Oct 19 2015, 11:24 AM

Addressed some inline comments.

include/llvm/IR/Function.h
67

Yes, CallingConvention should have been 3-15 earlier. I will correct it in D13826.

I chose bit 15 because of an incorrect assumption. I thought the SubclassData field is serialized, and that we needed to be sensitive about re-ordering the bits in it. I'll switch over to bit 4 in D13826.

lib/IR/Function.cpp
974

Fixed.

Yes, we have to remap setHungoffOperand(nullptr) to a real Constant. llvm assumes that operands are non-null all over the place, in ways that can't be guarded against by checking hasPersonality, hasPrefixData etc. The previous API got around this problem by deleting its operand when nullptr is set.

vsk updated this revision to Diff 37781.Oct 19 2015, 11:26 AM
vsk marked 2 inline comments as done.
  • Fix brain-o where I didn't use bit 3 for HasPersonalityFn.
sanjoy added inline comments.Oct 19 2015, 1:04 PM
lib/IR/Function.cpp
974

By not supporting setHungoffOperand(nullptr), I meant putting an assert(C && "nullptr not allowed!") here.

vsk updated this revision to Diff 37793.Oct 19 2015, 2:12 PM
  • Disallow nullptr argument to setHungoffOperand().
vsk updated this revision to Diff 38599.Oct 27 2015, 2:46 PM
vsk retitled this revision from WIP: clean up the way optional Function data is managed to [IR] Move optional data in llvm::Function into a hungoff uselist.
vsk updated this object.
vsk added a reviewer: dexonsmith.
  • Rebased to master for the required CallingConv changes.
  • First real candidate diff is ready.
vsk added a comment.Nov 6 2015, 11:26 AM

Gentle ping

I'm not familiar with all of the pieces you're touching here, but apart from the minor nit mentioned inline I don't have much to add.

lib/IR/Function.cpp
330

Can you use dropAllReferences here?

vsk updated this revision to Diff 40085.Nov 12 2015, 1:42 PM
vsk updated this object.
  • Updated diff according to Sanjoy's suggestion.
vsk added a comment.Dec 2 2015, 12:45 PM

This isn't urgent but it's been a while. Ping?

This revision was automatically updated to reflect the committed changes.