In the O0 pipeline, `SampleProfileProbePass` runs before
`AddDiscriminatorsPass`. The
pseudo-probe pass stores probe IDs in the discriminator field using a
special encoding
(bits [2:0] = 0x7 as marker). When `AddDiscriminatorsPass` later
processes instructions
on the same source line, it calls `cloneWithBaseDiscriminator()` which
overwrites these
pseudo-probe discriminators with DWARF base discriminators, breaking
sample profile
matching.
This patch adds a check to `cloneWithBaseDiscriminator()` to detect and
preserve
pseudo-probe discriminators, similar to the existing check in
`cloneByMultiplyingDuplicationFactor()`.
In optimized pipelines (O1+), AddDiscriminators runs before pseudo-probe
instrumentation,
so this issue doesn't manifest. However, the fix makes the code robust
regardless of
pass ordering.