[llvm-dev] Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 24 23:47:04 PST 2016


On Wed, Feb 24, 2016 at 11:44 PM, Hal Finkel <hfinkel at anl.gov> wrote:
>> The only optimizations I can think of that are okay are algebraic
>> simplifications that don't exploit no-overflow, inbounds or exact
>
> Why? Can you provide an example using nsw, inbounds, etc.?

I think the same case as the general UB applies:

void foo(int n) available_externally {
  if (n s< (n +nsw 1)) abort();
}

void bar() {
  if (< runtine cond always false>)
    foo(INT_SMAX);
}

Now foo() can be simplified to "ret void" using the nsw, and the call
to foo(INT_SMAX) can be hoisted.  This is a problem if we link to an
unrefined @foo.

-- Sanjoy


More information about the llvm-dev mailing list