<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/100639>100639</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [asan] Custom poisoning on stack is broken by optimizations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:optimizations,
            llvm:instcombine,
            compiler-rt:sanitizer
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            vitalybuka
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          vitalybuka
      </td>
    </tr>
</table>

<pre>
    This is reproducer on 
https://github.com/abseil/abseil-cpp/blob/c98bd9c8840f9ded87cf1fd1238455468d325628/absl/strings/cord_test.cc

Note: Revision is important as we are planing to land absl:: workaround.

libc++ also hit that issue

[https://github.com/llvm/llvm-project/pull/79536/files#diff-534bc2907ddb3b074ded1353d18fd7d578daf1707943b3039bab4ed975aba3b3R772](https://www.google.com/url?sa=D&q=https%3A%2F%2Fgithub.com%2Fllvm%2Fllvm-project%2Fpull%2F79536%2Ffiles%23diff-534bc2907ddb3b074ded1353d18fd7d578daf1707943b3039bab4ed975aba3b3R772)

```
// This must not be static to avoid aggressive optimizations.
ABSL_ATTRIBUTE_WEAK
size_t FalseReport(const absl::Cord& a, bool f);

ABSL_ATTRIBUTE_NOINLINE
size_t FalseReport(const absl::Cord& a, bool f) {
  absl::Cord b;
  const absl::Cord& ref = f ? b : a;
  // Test that sanitizers report nothing here. Without
  // InlineData::Rep::annotated_this() compiler can unconditionally load
  // poisoned parts, assuming that local variable is fully accessible.
  return ref.size();
}

TEST(CordSanitizerTest, SanitizesCordFalseReport) {
  absl::Cord c;
  for (int i = 0; i < 1000; ++i)
 c.Append("a");
  FalseReport(c, false);
}
```

I will add minimized repro later.

The issues is in InstCombine or SimplifyCFG, and likely should be fixed with `llvm::mustSuppressSpeculation`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVV2P6jYb_DXm5t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