Skip to content

Commit ca4a63f

Browse files
committed
Merge from 'main' to 'sycl-web' (#1)
Build issue was resolved by using a temporary fork of intel/vc-intrinsics with the function getAnyName disabled. Will be reverted after compatibility with D99173 has been resolved.
2 parents 2fe5d80 + bb8ce25 commit ca4a63f

File tree

13 files changed

+155
-51
lines changed

13 files changed

+155
-51
lines changed

llvm/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ Changes to the OCaml bindings
121121
Changes to the C API
122122
--------------------
123123

124+
* The C API function ``LLVMIntrinsicCopyOverloadedName`` has been deprecated.
125+
Please migrate to ``LLVMIntrinsicCopyOverloadedName2`` which takes an extra
126+
module argument and which also handles unnamed types.
127+
('D99173' <https://reviews.llvm.org/D99173>'_)
124128

125129
Changes to the Go bindings
126130
--------------------------

llvm/include/llvm-c/Core.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,19 +2514,27 @@ LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID,
25142514
*/
25152515
const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength);
25162516

2517+
/** Deprecated: Use LLVMIntrinsicCopyOverloadedName2 instead. */
2518+
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2519+
LLVMTypeRef *ParamTypes,
2520+
size_t ParamCount,
2521+
size_t *NameLength);
2522+
25172523
/**
25182524
* Copies the name of an overloaded intrinsic identified by a given list of
25192525
* parameter types.
25202526
*
25212527
* Unlike LLVMIntrinsicGetName, the caller is responsible for freeing the
25222528
* returned string.
25232529
*
2530+
* This version also supports unnamed types.
2531+
*
25242532
* @see llvm::Intrinsic::getName()
25252533
*/
2526-
const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
2527-
LLVMTypeRef *ParamTypes,
2528-
size_t ParamCount,
2529-
size_t *NameLength);
2534+
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2535+
LLVMTypeRef *ParamTypes,
2536+
size_t ParamCount,
2537+
size_t *NameLength);
25302538

25312539
/**
25322540
* Obtain if the intrinsic identified by the given ID is overloaded.

llvm/include/llvm/IR/Intrinsics.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ namespace Intrinsic {
5555
/// version of getName if overloads are required.
5656
StringRef getName(ID id);
5757

58-
/// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
59-
/// Note, this version of getName supports overloads, but not unnamed types.
60-
/// It is less efficient than the StringRef version of this function. If no
61-
/// overloads are required, it is safe to use this version, but better to use
62-
/// the StringRef version.
63-
std::string getName(ID Id, ArrayRef<Type *> Tys);
58+
/// Return the LLVM name for an intrinsic, without encoded types for
59+
/// overloading, such as "llvm.ssa.copy".
60+
StringRef getBaseName(ID id);
6461

65-
/// Return the LLVM name for an intrinsic, such as "llvm.ssa.copy.p0s_s.1".
66-
/// Note, this version of getName supports overloads and unnamed types, but is
67-
/// less efficient than the StringRef version of this function. If no
62+
/// Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx" or
63+
/// "llvm.ssa.copy.p0s_s.1". Note, this version of getName supports overloads.
64+
/// This is less efficient than the StringRef version of this function. If no
6865
/// overloads are required, it is safe to use this version, but better to use
69-
/// the StringRef version. A function type FT can be provided to avoid
70-
/// computing it. It is used (or computed) if one of the types is based on an
71-
/// unnamed type.
72-
std::string getName(ID Id, ArrayRef<Type *> Tys, Module *M, FunctionType *FT);
66+
/// the StringRef version. If one of the types is based on an unnamed type, a
67+
/// function type will be computed. Providing FT will avoid this computation.
68+
std::string getName(ID Id, ArrayRef<Type *> Tys, Module *M,
69+
FunctionType *FT = nullptr);
70+
71+
/// Return the LLVM name for an intrinsic. This is a special version only to
72+
/// be used by LLVMIntrinsicCopyOverloadedName. It only supports overloads
73+
/// based on named types.
74+
std::string getNameNoUnnamedTypes(ID Id, ArrayRef<Type *> Tys);
7375

7476
/// Return the function type for an intrinsic.
7577
FunctionType *getType(LLVMContext &Context, ID id,

llvm/lib/CodeGen/MachineOperand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
935935
case MachineOperand::MO_IntrinsicID: {
936936
Intrinsic::ID ID = getIntrinsicID();
937937
if (ID < Intrinsic::num_intrinsics)
938-
OS << "intrinsic(@" << Intrinsic::getName(ID, None) << ')';
938+
OS << "intrinsic(@" << Intrinsic::getBaseName(ID) << ')';
939939
else if (IntrinsicInfo)
940940
OS << "intrinsic(@" << IntrinsicInfo->getName(ID) << ')';
941941
else

llvm/lib/CodeGen/ReplaceWithVeclib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
142142
// converted to scalar above.
143143
std::string ScalarName;
144144
if (Intrinsic::isOverloaded(IntrinsicID)) {
145-
ScalarName = Intrinsic::getName(IntrinsicID, ScalarTypes);
145+
ScalarName = Intrinsic::getName(IntrinsicID, ScalarTypes, CI.getModule());
146146
} else {
147147
ScalarName = Intrinsic::getName(IntrinsicID).str();
148148
}

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
145145
unsigned OpNo = getOpcode() == ISD::INTRINSIC_WO_CHAIN ? 0 : 1;
146146
unsigned IID = cast<ConstantSDNode>(getOperand(OpNo))->getZExtValue();
147147
if (IID < Intrinsic::num_intrinsics)
148-
return Intrinsic::getName((Intrinsic::ID)IID, None);
148+
return Intrinsic::getBaseName((Intrinsic::ID)IID).str();
149149
else if (!G)
150150
return "Unknown intrinsic";
151151
else if (const TargetIntrinsicInfo *TII = G->getTarget().getIntrinsicInfo())

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,7 @@ void SelectionDAGISel::CannotYetSelect(SDNode *N) {
37773777
unsigned iid =
37783778
cast<ConstantSDNode>(N->getOperand(HasInputChain))->getZExtValue();
37793779
if (iid < Intrinsic::num_intrinsics)
3780-
Msg << "intrinsic %" << Intrinsic::getName((Intrinsic::ID)iid, None);
3780+
Msg << "intrinsic %" << Intrinsic::getBaseName((Intrinsic::ID)iid);
37813781
else if (const TargetIntrinsicInfo *TII = TM.getIntrinsicInfo())
37823782
Msg << "target intrinsic %" << TII->getName(iid);
37833783
else

llvm/lib/IR/AutoUpgrade.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
778778
Intrinsic::lifetime_start : Intrinsic::invariant_start;
779779
auto Args = F->getFunctionType()->params();
780780
Type* ObjectPtr[1] = {Args[1]};
781-
if (F->getName() != Intrinsic::getName(ID, ObjectPtr)) {
781+
if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) {
782782
rename(F);
783783
NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr);
784784
return true;
@@ -792,7 +792,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
792792

793793
auto Args = F->getFunctionType()->params();
794794
Type* ObjectPtr[1] = {Args[IsLifetimeEnd ? 1 : 2]};
795-
if (F->getName() != Intrinsic::getName(ID, ObjectPtr)) {
795+
if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) {
796796
rename(F);
797797
NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr);
798798
return true;
@@ -814,7 +814,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
814814
case 'm': {
815815
if (Name.startswith("masked.load.")) {
816816
Type *Tys[] = { F->getReturnType(), F->arg_begin()->getType() };
817-
if (F->getName() != Intrinsic::getName(Intrinsic::masked_load, Tys)) {
817+
if (F->getName() !=
818+
Intrinsic::getName(Intrinsic::masked_load, Tys, F->getParent())) {
818819
rename(F);
819820
NewFn = Intrinsic::getDeclaration(F->getParent(),
820821
Intrinsic::masked_load,
@@ -825,7 +826,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
825826
if (Name.startswith("masked.store.")) {
826827
auto Args = F->getFunctionType()->params();
827828
Type *Tys[] = { Args[0], Args[1] };
828-
if (F->getName() != Intrinsic::getName(Intrinsic::masked_store, Tys)) {
829+
if (F->getName() !=
830+
Intrinsic::getName(Intrinsic::masked_store, Tys, F->getParent())) {
829831
rename(F);
830832
NewFn = Intrinsic::getDeclaration(F->getParent(),
831833
Intrinsic::masked_store,
@@ -837,7 +839,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
837839
// to the new overload which includes an address space
838840
if (Name.startswith("masked.gather.")) {
839841
Type *Tys[] = {F->getReturnType(), F->arg_begin()->getType()};
840-
if (F->getName() != Intrinsic::getName(Intrinsic::masked_gather, Tys)) {
842+
if (F->getName() !=
843+
Intrinsic::getName(Intrinsic::masked_gather, Tys, F->getParent())) {
841844
rename(F);
842845
NewFn = Intrinsic::getDeclaration(F->getParent(),
843846
Intrinsic::masked_gather, Tys);
@@ -847,7 +850,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
847850
if (Name.startswith("masked.scatter.")) {
848851
auto Args = F->getFunctionType()->params();
849852
Type *Tys[] = {Args[0], Args[1]};
850-
if (F->getName() != Intrinsic::getName(Intrinsic::masked_scatter, Tys)) {
853+
if (F->getName() !=
854+
Intrinsic::getName(Intrinsic::masked_scatter, Tys, F->getParent())) {
851855
rename(F);
852856
NewFn = Intrinsic::getDeclaration(F->getParent(),
853857
Intrinsic::masked_scatter, Tys);
@@ -928,7 +932,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
928932
if (Name.startswith("objectsize.")) {
929933
Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() };
930934
if (F->arg_size() == 2 || F->arg_size() == 3 ||
931-
F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) {
935+
F->getName() !=
936+
Intrinsic::getName(Intrinsic::objectsize, Tys, F->getParent())) {
932937
rename(F);
933938
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::objectsize,
934939
Tys);
@@ -941,7 +946,8 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
941946
if (Name == "prefetch") {
942947
// Handle address space overloading.
943948
Type *Tys[] = {F->arg_begin()->getType()};
944-
if (F->getName() != Intrinsic::getName(Intrinsic::prefetch, Tys)) {
949+
if (F->getName() !=
950+
Intrinsic::getName(Intrinsic::prefetch, Tys, F->getParent())) {
945951
rename(F);
946952
NewFn =
947953
Intrinsic::getDeclaration(F->getParent(), Intrinsic::prefetch, Tys);

llvm/lib/IR/Core.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,18 @@ const char *LLVMIntrinsicCopyOverloadedName(unsigned ID,
24112411
size_t *NameLength) {
24122412
auto IID = llvm_map_to_intrinsic_id(ID);
24132413
ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
2414-
auto Str = llvm::Intrinsic::getName(IID, Tys);
2414+
auto Str = llvm::Intrinsic::getNameNoUnnamedTypes(IID, Tys);
2415+
*NameLength = Str.length();
2416+
return strdup(Str.c_str());
2417+
}
2418+
2419+
const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
2420+
LLVMTypeRef *ParamTypes,
2421+
size_t ParamCount,
2422+
size_t *NameLength) {
2423+
auto IID = llvm_map_to_intrinsic_id(ID);
2424+
ArrayRef<Type *> Tys(unwrap(ParamTypes), ParamCount);
2425+
auto Str = llvm::Intrinsic::getName(IID, Tys, unwrap(Mod));
24152426
*NameLength = Str.length();
24162427
return strdup(Str.c_str());
24172428
}

llvm/lib/IR/Function.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -831,37 +831,53 @@ static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
831831
return Result;
832832
}
833833

834+
StringRef Intrinsic::getBaseName(ID id) {
835+
assert(id < num_intrinsics && "Invalid intrinsic ID!");
836+
return IntrinsicNameTable[id];
837+
}
838+
834839
StringRef Intrinsic::getName(ID id) {
835840
assert(id < num_intrinsics && "Invalid intrinsic ID!");
836841
assert(!Intrinsic::isOverloaded(id) &&
837842
"This version of getName does not support overloading");
838-
return IntrinsicNameTable[id];
843+
return getBaseName(id);
839844
}
840845

841-
std::string Intrinsic::getName(ID Id, ArrayRef<Type *> Tys, Module *M,
842-
FunctionType *FT) {
843-
assert(Id < num_intrinsics && "Invalid intrinsic ID!");
846+
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef<Type *> Tys,
847+
Module *M, FunctionType *FT,
848+
bool EarlyModuleCheck) {
849+
850+
assert(Id < Intrinsic::num_intrinsics && "Invalid intrinsic ID!");
844851
assert((Tys.empty() || Intrinsic::isOverloaded(Id)) &&
845852
"This version of getName is for overloaded intrinsics only");
853+
(void)EarlyModuleCheck;
854+
assert((!EarlyModuleCheck || M ||
855+
!any_of(Tys, [](Type *T) { return isa<PointerType>(T); })) &&
856+
"Intrinsic overloading on pointer types need to provide a Module");
846857
bool HasUnnamedType = false;
847-
std::string Result(IntrinsicNameTable[Id]);
848-
for (Type *Ty : Tys) {
858+
std::string Result(Intrinsic::getBaseName(Id));
859+
for (Type *Ty : Tys)
849860
Result += "." + getMangledTypeStr(Ty, HasUnnamedType);
850-
}
851-
assert((M || !HasUnnamedType) && "unnamed types need a module");
852-
if (M && HasUnnamedType) {
861+
if (HasUnnamedType) {
862+
assert(M && "unnamed types need a module");
853863
if (!FT)
854-
FT = getType(M->getContext(), Id, Tys);
864+
FT = Intrinsic::getType(M->getContext(), Id, Tys);
855865
else
856-
assert((FT == getType(M->getContext(), Id, Tys)) &&
866+
assert((FT == Intrinsic::getType(M->getContext(), Id, Tys)) &&
857867
"Provided FunctionType must match arguments");
858868
return M->getUniqueIntrinsicName(Result, Id, FT);
859869
}
860870
return Result;
861871
}
862872

863-
std::string Intrinsic::getName(ID Id, ArrayRef<Type *> Tys) {
864-
return getName(Id, Tys, nullptr, nullptr);
873+
std::string Intrinsic::getName(ID Id, ArrayRef<Type *> Tys, Module *M,
874+
FunctionType *FT) {
875+
assert(M && "We need to have a Module");
876+
return getIntrinsicNameImpl(Id, Tys, M, FT, true);
877+
}
878+
879+
std::string Intrinsic::getNameNoUnnamedTypes(ID Id, ArrayRef<Type *> Tys) {
880+
return getIntrinsicNameImpl(Id, Tys, nullptr, nullptr, false);
865881
}
866882

867883
/// IIT_Info - These are enumerators that describe the entries returned by the

0 commit comments

Comments
 (0)