This is an archive of the discontinued LLVM Phabricator instance.

[IRBuilder] Fixup CreateIntrinsic to allow specifying Types to Mangle.

Authored by sheredom on Sep 14 2018, 4:35 AM.



The IRBuilder CreateIntrinsic method wouldn't allow you to specify the types that you wanted the intrinsic to be mangled with. To fix this I've:

  • Added an ArrayRef<Type *> member to both CreateIntrinsic overloads.
  • Used that array to pass into the Intrinsic::getDeclaration call.
  • Added a CreateUnaryIntrinsic to replace the most common use of CreateIntrinsic where the type was auto-deduced from operand 0.
  • Added a bunch more unit tests to test Create*Intrinsic calls that weren't being tested (including the FMF flag that wasn't checked).

This was suggested as part of the AMDGPU specific atomic optimizer review (

Diff Detail


Event Timeline

sheredom created this revision.Sep 14 2018, 4:35 AM
nhaehnle added inline comments.Sep 17 2018, 2:59 AM
690–693 ↗(On Diff #165470)

I think it'd be best to remove this overload. It made sense with the "magic but broken" type deduction that was there before, but now anybody wishing to create a no-argument intrinsic can just pass {} to the overload below.

sheredom updated this revision to Diff 166653.Sep 24 2018, 5:11 AM

Removed the no-args overload as per Nicolai's suggestion.

sheredom marked an inline comment as done.Sep 24 2018, 5:12 AM
nhaehnle accepted this revision.Oct 2 2018, 2:43 AM


This revision is now accepted and ready to land.Oct 2 2018, 2:43 AM
arsenm accepted this revision.Oct 2 2018, 4:28 PM


This revision was automatically updated to reflect the committed changes.