================
@@ -3053,24 +3098,38 @@ void OMPTraitInfo::getAsVariantMatchInfo(ASTContext
&ASTCtx,
TraitProperty::user_condition_unknown &&
"Ill-formed user condition, expected unknown trait property!");
+ // Identify the condition by its original expression; substitution may
+ // fold different template parameters to the same value.
+ assert(Selector.OriginalCondition && "missing original condition");
+ const Expr *Condition =
+ Selector.OriginalCondition->IgnoreParenImpCasts();
+ llvm::FoldingSetNodeID ID;
+ Condition->Profile(ID, ASTCtx, /*Canonical=*/true);
+ ParameterOwnerProfiler(ID).TraverseStmt(Condition);
+ llvm::FoldingSetNodeIDRef Profile = ID.Intern(ASTCtx.getAllocator());
+ // Use the full profile rather than a hash to avoid collisions.
+ StringRef ConditionIdentity(
+ reinterpret_cast<const char *>(Profile.data()),
+ Profile.size() * sizeof(unsigned));
+
if (std::optional<APSInt> CondVal =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
: TraitProperty::user_condition_true,
- "<condition>");
+ ConditionIdentity);
else
- VMI.addTrait(TraitProperty::user_condition_false, "<condition>");
+ VMI.addTrait(TraitProperty::user_condition_false, ConditionIdentity);
continue;
}
std::optional<llvm::APSInt> Score;
llvm::APInt *ScorePtr = nullptr;
if (Selector.ScoreOrCondition) {
+ // A non-constant score adds an inactive trait, not a user condition.
if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
ScorePtr = &*Score;
else
- VMI.addTrait(TraitProperty::user_condition_false,
- "<non-constant-score>");
+ VMI.addTrait(TraitProperty::invalid, "<non-constant-score>");
----------------
MattPD wrote:
At b165f599, the example selects TASKYIELD again.
https://github.com/llvm/llvm-project/pull/231668
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits