diff options
author | Jeroen Dobbelaere <jeroen.dobbelaere@synopsys.com> | 2021-06-14 14:52:29 +0200 |
---|---|---|
committer | Jeroen Dobbelaere <jeroen.dobbelaere@synopsys.com> | 2021-06-14 14:52:29 +0200 |
commit | bb8ce25e88218be60d2a4ea9c9b0b721809eff27 (patch) | |
tree | e72f60d66fe0fce564a53648aae5dae7b9340079 /llvm/lib/IR/AutoUpgrade.cpp | |
parent | 9f967eed89e66e39909c59ec0246dc2877d75f51 (diff) | |
download | llvm-bb8ce25e88218be60d2a4ea9c9b0b721809eff27.zip llvm-bb8ce25e88218be60d2a4ea9c9b0b721809eff27.tar.gz llvm-bb8ce25e88218be60d2a4ea9c9b0b721809eff27.tar.bz2 |
Intrinsic::getName: require a Module argument
Ensure that we provide a `Module` when checking if a rename of an intrinsic is necessary.
This fixes the issue that was detected by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32288
(as mentioned by @fhahn), after committing D91250.
Note that the `LLVMIntrinsicCopyOverloadedName` is being deprecated in favor of `LLVMIntrinsicCopyOverloadedName2`.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D99173
Diffstat (limited to 'llvm/lib/IR/AutoUpgrade.cpp')
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index 7e14a07..851e8e4 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -778,7 +778,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { Intrinsic::lifetime_start : Intrinsic::invariant_start; auto Args = F->getFunctionType()->params(); Type* ObjectPtr[1] = {Args[1]}; - if (F->getName() != Intrinsic::getName(ID, ObjectPtr)) { + if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr); return true; @@ -792,7 +792,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { auto Args = F->getFunctionType()->params(); Type* ObjectPtr[1] = {Args[IsLifetimeEnd ? 1 : 2]}; - if (F->getName() != Intrinsic::getName(ID, ObjectPtr)) { + if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr); return true; @@ -814,7 +814,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { case 'm': { if (Name.startswith("masked.load.")) { Type *Tys[] = { F->getReturnType(), F->arg_begin()->getType() }; - if (F->getName() != Intrinsic::getName(Intrinsic::masked_load, Tys)) { + if (F->getName() != + Intrinsic::getName(Intrinsic::masked_load, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::masked_load, @@ -825,7 +826,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { if (Name.startswith("masked.store.")) { auto Args = F->getFunctionType()->params(); Type *Tys[] = { Args[0], Args[1] }; - if (F->getName() != Intrinsic::getName(Intrinsic::masked_store, Tys)) { + if (F->getName() != + Intrinsic::getName(Intrinsic::masked_store, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::masked_store, @@ -837,7 +839,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { // to the new overload which includes an address space if (Name.startswith("masked.gather.")) { Type *Tys[] = {F->getReturnType(), F->arg_begin()->getType()}; - if (F->getName() != Intrinsic::getName(Intrinsic::masked_gather, Tys)) { + if (F->getName() != + Intrinsic::getName(Intrinsic::masked_gather, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::masked_gather, Tys); @@ -847,7 +850,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { if (Name.startswith("masked.scatter.")) { auto Args = F->getFunctionType()->params(); Type *Tys[] = {Args[0], Args[1]}; - if (F->getName() != Intrinsic::getName(Intrinsic::masked_scatter, Tys)) { + if (F->getName() != + Intrinsic::getName(Intrinsic::masked_scatter, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::masked_scatter, Tys); @@ -928,7 +932,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { if (Name.startswith("objectsize.")) { Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() }; if (F->arg_size() == 2 || F->arg_size() == 3 || - F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) { + F->getName() != + Intrinsic::getName(Intrinsic::objectsize, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::objectsize, Tys); @@ -941,7 +946,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { if (Name == "prefetch") { // Handle address space overloading. Type *Tys[] = {F->arg_begin()->getType()}; - if (F->getName() != Intrinsic::getName(Intrinsic::prefetch, Tys)) { + if (F->getName() != + Intrinsic::getName(Intrinsic::prefetch, Tys, F->getParent())) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::prefetch, Tys); |