[llvm-dev] Dereferenceable load semantics & LICM

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 7 10:25:22 PDT 2017

Hi Piotr,

On April 7, 2017 at 8:02:01 AM, Piotr Padlewski
(piotr.padlewski at gmail.com) wrote:
> But we already have that behavior with dereferenceable variables.
> void foo(i8* dereferenceable(8) %ptr) {
> if (false) {
> ; what if %x is not actually dereferenceable?
> %x = load i8, i8* %ptr
> }
> }

For that example ^, we'd say that calling foo with a
non-dereferenceable pointer will immediately cause UB.

-- Sanjoy

> Now we can hoist the load, even that it would be never executed.
> This is the same with global properties - it gives us guarantee that
> property holds non locally and if it doesn't then it is UB
> and things like this might happen.
> I understand your concerns about the speculate function attribute, the
> examples that you showed in the review are pretty disturbing,
> but loads and stores seems to be much safere in that maner. Maybe you know
> some examples like this, but with load and stores?
> It just seems weird to me that we already depend on very similar mechanics,
> but this one seems like a bad idea.
> Best
> Piotr

More information about the llvm-dev mailing list