forked from OSchip/llvm-project
Don't drop the llvm. prefix when renaming.
If the llvm. prefix is dropped other parts of llvm don't see this as an intrinsic. This means that the number of regular symbols depends on the context the module is loaded into, which causes LTO to abort. Fixes PR30509. llvm-svn: 283117
This commit is contained in:
parent
30914f3d1c
commit
d7325ee702
|
@ -31,6 +31,8 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static void rename(GlobalValue *GV) { GV->setName(GV->getName() + ".old"); }
|
||||||
|
|
||||||
// Upgrade the declarations of the SSE4.1 functions whose arguments have
|
// Upgrade the declarations of the SSE4.1 functions whose arguments have
|
||||||
// changed their type from v4f32 to v2i64.
|
// changed their type from v4f32 to v2i64.
|
||||||
static bool UpgradeSSE41Function(Function* F, Intrinsic::ID IID,
|
static bool UpgradeSSE41Function(Function* F, Intrinsic::ID IID,
|
||||||
|
@ -42,7 +44,7 @@ static bool UpgradeSSE41Function(Function* F, Intrinsic::ID IID,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Yes, it's old, replace it with new version.
|
// Yes, it's old, replace it with new version.
|
||||||
F->setName(F->getName() + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +60,7 @@ static bool UpgradeX86IntrinsicsWith8BitMask(Function *F, Intrinsic::ID IID,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Move this function aside and map down.
|
// Move this function aside and map down.
|
||||||
F->setName(F->getName() + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -135,13 +137,13 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
|
|
||||||
case 'c': {
|
case 'c': {
|
||||||
if (Name.startswith("ctlz.") && F->arg_size() == 1) {
|
if (Name.startswith("ctlz.") && F->arg_size() == 1) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz,
|
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz,
|
||||||
F->arg_begin()->getType());
|
F->arg_begin()->getType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Name.startswith("cttz.") && F->arg_size() == 1) {
|
if (Name.startswith("cttz.") && F->arg_size() == 1) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::cttz,
|
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::cttz,
|
||||||
F->arg_begin()->getType());
|
F->arg_begin()->getType());
|
||||||
return true;
|
return true;
|
||||||
|
@ -154,7 +156,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
Type* ObjectPtr[1] = {Args[1]};
|
Type* ObjectPtr[1] = {Args[1]};
|
||||||
if (F->getName() !=
|
if (F->getName() !=
|
||||||
Intrinsic::getName(Intrinsic::invariant_start, ObjectPtr)) {
|
Intrinsic::getName(Intrinsic::invariant_start, ObjectPtr)) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(
|
NewFn = Intrinsic::getDeclaration(
|
||||||
F->getParent(), Intrinsic::invariant_start, ObjectPtr);
|
F->getParent(), Intrinsic::invariant_start, ObjectPtr);
|
||||||
return true;
|
return true;
|
||||||
|
@ -165,7 +167,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
Type* ObjectPtr[1] = {Args[2]};
|
Type* ObjectPtr[1] = {Args[2]};
|
||||||
if (F->getName() !=
|
if (F->getName() !=
|
||||||
Intrinsic::getName(Intrinsic::invariant_end, ObjectPtr)) {
|
Intrinsic::getName(Intrinsic::invariant_end, ObjectPtr)) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::invariant_end, ObjectPtr);
|
Intrinsic::invariant_end, ObjectPtr);
|
||||||
return true;
|
return true;
|
||||||
|
@ -177,7 +179,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
if (Name.startswith("masked.load.")) {
|
if (Name.startswith("masked.load.")) {
|
||||||
Type *Tys[] = { F->getReturnType(), F->arg_begin()->getType() };
|
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->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::masked_load,
|
Intrinsic::masked_load,
|
||||||
Tys);
|
Tys);
|
||||||
|
@ -188,7 +190,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
auto Args = F->getFunctionType()->params();
|
auto Args = F->getFunctionType()->params();
|
||||||
Type *Tys[] = { Args[0], Args[1] };
|
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->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::masked_store,
|
Intrinsic::masked_store,
|
||||||
Tys);
|
Tys);
|
||||||
|
@ -204,7 +206,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
if (F->arg_size() == 2 && Name.startswith("objectsize.")) {
|
if (F->arg_size() == 2 && Name.startswith("objectsize.")) {
|
||||||
Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() };
|
Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() };
|
||||||
if (F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) {
|
if (F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::objectsize, Tys);
|
Intrinsic::objectsize, Tys);
|
||||||
return true;
|
return true;
|
||||||
|
@ -371,13 +373,13 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
|
|
||||||
// frcz.ss/sd may need to have an argument dropped
|
// frcz.ss/sd may need to have an argument dropped
|
||||||
if (IsX86 && Name.startswith("xop.vfrcz.ss") && F->arg_size() == 2) {
|
if (IsX86 && Name.startswith("xop.vfrcz.ss") && F->arg_size() == 2) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::x86_xop_vfrcz_ss);
|
Intrinsic::x86_xop_vfrcz_ss);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (IsX86 && Name.startswith("xop.vfrcz.sd") && F->arg_size() == 2) {
|
if (IsX86 && Name.startswith("xop.vfrcz.sd") && F->arg_size() == 2) {
|
||||||
F->setName(Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||||
Intrinsic::x86_xop_vfrcz_sd);
|
Intrinsic::x86_xop_vfrcz_sd);
|
||||||
return true;
|
return true;
|
||||||
|
@ -395,13 +397,13 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
else
|
else
|
||||||
ShiftID = Name[18] == 'd' ? Intrinsic::x86_avx512_mask_psrl_di_512
|
ShiftID = Name[18] == 'd' ? Intrinsic::x86_avx512_mask_psrl_di_512
|
||||||
: Intrinsic::x86_avx512_mask_psrl_qi_512;
|
: Intrinsic::x86_avx512_mask_psrl_qi_512;
|
||||||
F->setName("llvm.x86." + Name + ".old");
|
rename(F);
|
||||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ShiftID);
|
NewFn = Intrinsic::getDeclaration(F->getParent(), ShiftID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Fix the FMA4 intrinsics to remove the 4
|
// Fix the FMA4 intrinsics to remove the 4
|
||||||
if (IsX86 && Name.startswith("fma4.")) {
|
if (IsX86 && Name.startswith("fma4.")) {
|
||||||
F->setName("llvm.x86.fma" + Name.substr(5));
|
rename(F);
|
||||||
NewFn = F;
|
NewFn = F;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +412,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
|
||||||
auto Params = F->getFunctionType()->params();
|
auto Params = F->getFunctionType()->params();
|
||||||
auto Idx = Params[2];
|
auto Idx = Params[2];
|
||||||
if (Idx->getScalarType()->isFloatingPointTy()) {
|
if (Idx->getScalarType()->isFloatingPointTy()) {
|
||||||
F->setName("llvm.x86." + Name + ".old");
|
rename(F);
|
||||||
unsigned IdxSize = Idx->getPrimitiveSizeInBits();
|
unsigned IdxSize = Idx->getPrimitiveSizeInBits();
|
||||||
unsigned EltSize = Idx->getScalarSizeInBits();
|
unsigned EltSize = Idx->getScalarSizeInBits();
|
||||||
Intrinsic::ID Permil2ID;
|
Intrinsic::ID Permil2ID;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
target triple = "x86_64-unknown-linux-gnu"
|
||||||
|
%foo = type { }
|
||||||
|
declare <4 x %foo*> @llvm.masked.load.v4p0foo.p0v4p0foo(<4 x %foo*>*, i32, <4 x i1>, <4 x %foo*>)
|
|
@ -0,0 +1,8 @@
|
||||||
|
; RUN: llvm-as %s -o %t1.o
|
||||||
|
; RUN: llvm-as %p/Inputs/intrinsic.ll -o %t2.o
|
||||||
|
; RUN: llvm-lto2 -o %t3.o %t1.o %t2.o -r %t1.o,foo
|
||||||
|
|
||||||
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
target triple = "x86_64-unknown-linux-gnu"
|
||||||
|
%foo = type { }
|
||||||
|
declare void @foo( %foo* )
|
Loading…
Reference in New Issue