From 14a5771b66aba08241fbbba9ade293421ecb60cf Mon Sep 17 00:00:00 2001 From: Alessandro Di Federico Date: Sat, 3 Dec 2016 08:47:41 +0100 Subject: [PATCH] Prevent re-specializing an helper in the same way --- variablemanager.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/variablemanager.cpp b/variablemanager.cpp index 43e4adfe5..f25305351 100644 --- a/variablemanager.cpp +++ b/variablemanager.cpp @@ -313,6 +313,20 @@ bool CorrectCPUStateUsagePass::runOnModule(Module& TheModule) { // If the callee was already a specialization, preserve its // specialized arguments if (CurrentSpecialization != Specializations.end()) { + + // Check if we're good with this specialization + bool SpecializationMatches = false; + for (auto &P : CurrentSpecialization->SpecializedArgs) { + if (P.first == TheUse.getOperandNo()) { + assert(P.second == CurrentOffset); + SpecializationMatches = true; + break; + } + } + + if (SpecializationMatches) + continue; + Original = CurrentSpecialization->Original; SpecializedArgs = CurrentSpecialization->SpecializedArgs; }