search for: maybe_divide

Displaying 7 results from an estimated 7 matches for "maybe_divide".

2016 Feb 29
2
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
ok thanks. A more reduced test case can show different behavior between O2 and O0. Say we have unsigned maybe_divide (unsigned *ptr) { int flag = false; unsigned val = 500/ptr[0]; if (flag) return val; return (unsigned)(intptr_t)ptr); } int main() { unsigned g = 0; return maybe_divide(&g); } At O2, it runs fine, but at O0 it core dumps. what is the right behavior? David On Sat...
2016 Feb 29
2
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
...i <mehdi.amini at apple.com> wrote: > > On Feb 29, 2016, at 10:38 AM, Xinliang David Li via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > ok thanks. A more reduced test case can show different behavior between O2 > and O0. > > Say we have > > unsigned maybe_divide (unsigned *ptr) { > int flag = false; > unsigned val = 500/ptr[0]; > if (flag) > return val; > return (unsigned)(intptr_t)ptr); > } > > int main() { > unsigned g = 0; > return maybe_divide(&g); > } > > > At O2, it runs fine, bu...
2016 Feb 29
1
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
...inliangli at gmail.com> wrote: > yes -- it is UB if user writes code like this. So we agree that given that the user wrote exactly what you have above, there is no guarantee from the compiler to generate anything meaningful? > What if the g=0 is > speculatively moved above the call of maybe_divide at O2? My point is that You mean, the program was initially something like g = 42 maybe_divide(&g) g = 0 which LLVM optimized to g = 0 maybe_divide(&g) ? That code motion is legal only if `maybe_divide` is `readnone` -- if LLVM speculates the store without first inferring `readnone`...
2016 Feb 28
0
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
...4:21 PM, Xinliang David Li <xinliangli at gmail.com> wrote: > So in this case, ptr[0] = 10 is propagated into one copy of maybe_devide (in > source a), and ptr[0]=10 in caller_a is DSEed ? `ptr[0] = 10` is not really propagated anywhere. What happens is that `source-a` 's copy of `maybe_divide` gets optimized to a `ret (unsigned) ptr` (after inlining in the body of `always_false`)[1], so it is able to DSE the store `ptr[0] = 10`. But `source-b` s copy of `maybe_divide` still has the load and the division (since it does not have access to `always_false` 's body), so if `caller_a` end...
2016 Feb 29
0
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
...; > On Feb 29, 2016, at 10:38 AM, Xinliang David Li via llvm-dev > > <llvm-dev at lists.llvm.org> wrote: > > > > ok thanks. A more reduced test case can show different behavior between > O2 > > and O0. > > > > Say we have > > > > unsigned maybe_divide (unsigned *ptr) { > > int flag = false; > > unsigned val = 500/ptr[0]; > > if (flag) > > return val; > > return (unsigned)(intptr_t)ptr); > > } > > > > int main() { > > unsigned g = 0; > > return maybe_divide(&amp...
2016 Feb 28
2
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
So in this case, ptr[0] = 10 is propagated into one copy of maybe_devide (in source a), and ptr[0]=10 in caller_a is DSEed ? David On Sat, Feb 27, 2016 at 1:41 PM, Sanjoy Das via llvm-dev < llvm-dev at lists.llvm.org> wrote: > Just as a reality check, I wrote up a demonstration where one link > order causes a SIGFPE and another doesn't (and the program is well > defined, as
2016 Feb 29
0
Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")
> On Feb 29, 2016, at 10:38 AM, Xinliang David Li via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > ok thanks. A more reduced test case can show different behavior between O2 and O0. > > Say we have > > unsigned maybe_divide (unsigned *ptr) { > int flag = false; > unsigned val = 500/ptr[0]; > if (flag) > return val; > return (unsigned)(intptr_t)ptr); > } > > int main() { > unsigned g = 0; > return maybe_divide(&g); > } > > > At O2, it runs fi...