Skip to content

Commit 4c57b00

Browse files
committed
Module-unique names for mutated callsites.
1 parent 197e0f5 commit 4c57b00

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,19 @@ static inline void reportFatalOnTokenType(const Instruction *I) {
358358

359359
static void emitAssignName(Instruction *I, IRBuilder<> &B) {
360360
if (!I->hasName() || I->getType()->isAggregateType() ||
361-
expectIgnoredInIRTranslation(I) ||
362-
// TODO: this is a temporary workaround meant to prevent inserting
363-
// internal noise into the generated binary; remove once we rework
364-
// the entire aggregate removal machinery.
365-
I->getName().starts_with("spv.mutated_callsite"))
361+
expectIgnoredInIRTranslation(I))
366362
return;
363+
364+
if (isa<CallBase>(I)) {
365+
// TODO: this is a temporary workaround meant to prevent inserting internal
366+
// noise into the generated binary; remove once we rework the entire
367+
// aggregate removal machinery.
368+
StringRef Name = I->getName();
369+
if (Name.starts_with("spv.mutated_callsite"))
370+
return;
371+
if (Name.starts_with("spv.named_mutated_callsite"))
372+
I->setName(Name.substr(Name.rfind('.') + 1));
373+
}
367374
reportFatalOnTokenType(I);
368375
setInsertPointAfterDef(B, I);
369376
LLVMContext &Ctx = I->getContext();

llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,10 @@ bool SPIRVPrepareFunctions::removeAggregateTypesFromCalls(Function *F) {
606606
CB->getFunctionType()->isVarArg());
607607

608608
if (!CB->hasName())
609-
CB->setName("spv.mutated_callsite");
609+
CB->setName("spv.mutated_callsite." + F->getName());
610+
else
611+
CB->setName(
612+
"spv.named_mutated_callsite." + F->getName() + "." + CB->getName());
610613

611614
addFunctionTypeMutation(
612615
F->getParent()->getOrInsertNamedMetadata("spv.mutated_callsites"),

0 commit comments

Comments
 (0)