diff options
author | Neil Henning <neil.henning@amd.com> | 2018-10-08 10:32:33 +0000 |
---|---|---|
committer | Neil Henning <neil.henning@amd.com> | 2018-10-08 10:32:33 +0000 |
commit | 57f5d0a885cf05d57da946cf5cf13ead2cb077b1 (patch) | |
tree | 46aa8539cb9e3adb26ca3ee67197a8c06b3a5b84 /llvm/lib/IR | |
parent | 627d1469987a38cc9efcfbc63556b0b1342f4373 (diff) | |
download | bcm5719-llvm-57f5d0a885cf05d57da946cf5cf13ead2cb077b1.tar.gz bcm5719-llvm-57f5d0a885cf05d57da946cf5cf13ead2cb077b1.zip |
[IRBuilder] Fixup CreateIntrinsic to allow specifying Types to Mangle.
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 (https://reviews.llvm.org/D51969).
Differential Revision: https://reviews.llvm.org/D52087
llvm-svn: 343962
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 91c950da71b..a9818995677 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -731,28 +731,29 @@ CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint, return createCallHelper(FnGCRelocate, Args, this, Name); } -CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, - Value *LHS, Value *RHS, - const Twine &Name) { +CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V, + Instruction *FMFSource, + const Twine &Name) { Module *M = BB->getModule(); - Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() }); - return createCallHelper(Fn, { LHS, RHS }, this, Name); + Function *Fn = Intrinsic::getDeclaration(M, ID, {V->getType()}); + return createCallHelper(Fn, {V}, this, Name, FMFSource); } -CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, - Instruction *FMFSource, - const Twine &Name) { +CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS, + Value *RHS, + Instruction *FMFSource, + const Twine &Name) { Module *M = BB->getModule(); - Function *Fn = Intrinsic::getDeclaration(M, ID); - return createCallHelper(Fn, {}, this, Name); + Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() }); + return createCallHelper(Fn, {LHS, RHS}, this, Name, FMFSource); } CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID, + ArrayRef<Type *> Types, ArrayRef<Value *> Args, Instruction *FMFSource, const Twine &Name) { - assert(!Args.empty() && "Expected at least one argument to intrinsic"); Module *M = BB->getModule(); - Function *Fn = Intrinsic::getDeclaration(M, ID, { Args.front()->getType() }); + Function *Fn = Intrinsic::getDeclaration(M, ID, Types); return createCallHelper(Fn, Args, this, Name, FMFSource); } |