search for: __builtin_unreachable

Displaying 20 results from an estimated 51 matches for "__builtin_unreachable".

2011 Mar 12
0
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
...it > leaves a somewhat bulky function call in the emitted code. It > also doesn't let give the compiler any opportunity to optimize > based on our assertion that the code is unreachable. A much > better alternative is to use an intrinsic, provided by Clang and > GCC 4.5, called __builtin_unreachable; it has the semantics > of being undefined behavior if reached, much like LLVM's own > "unreachable" instruction, which incidentally is what Clang > generates for it. > > This patch keeps the old behavior of llvm_unreachable in > +Asserts (!defined(NDEBUG)) builds...
2011 Mar 12
1
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
...y good for code size, as it leaves a somewhat bulky function call in the emitted code. It also doesn't let give the compiler any opportunity to optimize based on our assertion that the code is unreachable. A much better alternative is to use an intrinsic, provided by Clang and GCC 4.5, called __builtin_unreachable; it has the semantics of being undefined behavior if reached, much like LLVM's own "unreachable" instruction, which incidentally is what Clang generates for it. This patch keeps the old behavior of llvm_unreachable in +Asserts (!defined(NDEBUG)) builds, but changes the behavior in...
2011 Mar 12
4
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
...y good for code size, as it leaves a somewhat bulky function call in the emitted code. It also doesn't let give the compiler any opportunity to optimize based on our assertion that the code is unreachable. A much better alternative is to use an intrinsic, provided by Clang and GCC 4.5, called __builtin_unreachable; it has the semantics of being undefined behavior if reached, much like LLVM's own "unreachable" instruction, which incidentally is what Clang generates for it. This patch keeps the old behavior of llvm_unreachable in +Asserts (!defined(NDEBUG)) builds, but changes the behavior in...
2011 Mar 12
0
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
Hi John, > This patch implements the current consensus of PR8973: > http://llvm.org/bugs/show_bug.cgi?id=8973. > > The macro llvm_unreachable is used in LLVM to indicate that > a particular place in a function is not supposed to be reachable > during execution. Like an assert macro, it takes a string > argument. In +Asserts builds, this string argument, together with >
2011 Mar 12
0
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
Hi Sebastian, >>> This patch implements the current consensus of PR8973: >>> http://llvm.org/bugs/show_bug.cgi?id=8973. >>> >>> The macro llvm_unreachable is used in LLVM to indicate that >>> a particular place in a function is not supposed to be reachable >>> during execution. Like an assert macro, it takes a string >>> argument. In
2012 Oct 23
3
[LLVMdev] precondition suggestion to LLVM
...n't know if I well understood. I've find this link in the second link which seemed what i was looking for: http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt .If I put around the code block (inside my function with precondition (x>0 && y>0)) a contruct like that that use __builtin_unreachable: int foo(int x, int y){ if(x>0 && y>0){ ...function codeblock... } { __builtin_unreachable (); } } I can get the optimization without really having a branch jump in the machine code?Thank you again, Niko Zarzani > Date: Mon, 22 Oct 2012 23:41:43 -0400 > Fr...
2011 Mar 12
3
[LLVMdev] [patch] Change llvm_unreachable to use __builtin_unreachable() in -asserts
On 12.03.2011, at 11:17, Duncan Sands wrote: > Hi John, > >> This patch implements the current consensus of PR8973: >> http://llvm.org/bugs/show_bug.cgi?id=8973. >> >> The macro llvm_unreachable is used in LLVM to indicate that >> a particular place in a function is not supposed to be reachable >> during execution. Like an assert macro, it takes a
2012 Oct 23
0
[LLVMdev] precondition suggestion to LLVM
...l understood. I've find this link in the > second link which seemed what i was looking for: > http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt . > If I put around the code block (inside my function with precondition (x>0 && > y>0)) a contruct like that that use __builtin_unreachable: > > int foo(int x, int y){ > > if(x>0 && y>0){ > ...function codeblock... > } > { > __builtin_unreachable (); > } > > } > > I can get the optimization without really having a branch jump in the > machine code? In the...
2017 Apr 18
3
__builtin_expect hint ignored
...se_2(); long case_3(); long case_1(); long case_else(); long test(long a) { switch (__builtin_expect(a, 2)) { case 2: return case_2(); case 3: return case_3(); case 1: return case_1(); case 0: case 4: case 5: return case_else(); default: __builtin_unreachable(); } }
2013 Oct 24
2
[LLVMdev] Exploiting 'unreachable' for optimization purposes
...__assume intrinsic) both optimize away the comparison in test2. void f1(); void f2(); void abort() __attribute__((noreturn)); void test1(int x) { if (x < 0) abort(); // the following comparison is optimized away if (x < 0) f1(); else f2(); } void test2(int x) { if (x < 0) __builtin_unreachable(); // the following comparison is NOT optimized away if (x < 0) f1(); else f2(); } - Stephan
2014 Apr 15
2
[LLVMdev] Emit code for 'unreachable'
...achable', if they need that. Does that sound right? > Personally I'm in favor, but others may disagree. Right now clang inserts calls to llvm.trap(), and that's how we get ud2's when falling off the end of a function with a return type. That may be the preferred approach for __builtin_unreachable(), since other clients of LLVM at -O0 may actually want it to produce code quickly without inserting any debugging aids. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/57546086/attachment.html>
2012 Oct 23
0
[LLVMdev] precondition suggestion to LLVM
You may want to check this out: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/053924.html and also http://llvm.org/PR810 - xi On 10/22/12 6:05 PM, Niko Zarzani wrote: > Hi all, > Is there any way to tell LLVM some additional information about the > variables in the code in order to make better optimization? > For example, if my function has a certain precondition (such
2013 Oct 24
0
[LLVMdev] Exploiting 'unreachable' for optimization purposes
...t; > void f1(); > > void f2(); > > void abort() __attribute__((noreturn)); > > void test1(int x) { > if (x < 0) abort(); > // the following comparison is optimized away > if (x < 0) f1(); else f2(); > } > > void test2(int x) { > if (x < 0) __builtin_unreachable(); > // the following comparison is NOT optimized away > if (x < 0) f1(); else f2(); > } > > - Stephan > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.ed...
2020 Jul 24
7
Zero length function pointer equality
LLVM can produce zero length functions from cases like this (when optimizations are enabled): void f1() { __builtin_unreachable(); } int f2() { /* missing return statement */ } This code is valid, so long as the functions are never called. I believe C++ requires that all functions have a distinct address (ie: &f1 != &f2) and LLVM optimizes code on this basis (assert(f1 == f2) gets optimized into an unconditional a...
2020 Jul 25
2
[cfe-dev] Zero length function pointer equality
...tps://reviews.llvm.org/D32330 > > On Fri, Jul 24, 2020 at 2:46 AM David Blaikie via cfe-dev > <cfe-dev at lists.llvm.org> wrote: > > > > LLVM can produce zero length functions from cases like this (when > > optimizations are enabled): > > > > void f1() { __builtin_unreachable(); } > > int f2() { /* missing return statement */ } > > > > This code is valid, so long as the functions are never called. > > > > I believe C++ requires that all functions have a distinct address (ie: > > &f1 != &f2) and LLVM optimizes code on this basi...
2020 Jul 24
2
Zero length function pointer equality
...PM Richard Smith <richard at metafoo.co.uk> wrote: > > On Thu, 23 Jul 2020 at 17:46, David Blaikie <dblaikie at gmail.com> wrote: >> >> LLVM can produce zero length functions from cases like this (when >> optimizations are enabled): >> >> void f1() { __builtin_unreachable(); } >> int f2() { /* missing return statement */ } >> >> This code is valid, so long as the functions are never called. >> >> I believe C++ requires that all functions have a distinct address (ie: >> &f1 != &f2) and LLVM optimizes code on this basis (ass...
2012 Dec 19
2
[LLVMdev] LLVM 3.2 on Xcode
...ng to do with hires images or some such… it takes a long time to fix that up in a project as large as this, but I'm not sure there's anything we can do about it. Second, a build of the ALL_BUILD target in Xcode produces 16 warnings about 8 functions declared noreturn, but without a expected __builtin_unreachable() before the end of the function. (The first attempt to build produced 2 errors, the first an unable to create directory error for runtime/libprofile/LLVM.build/Debug/profile_rt-static.build/Objects-normal/x86_64; the second a libtool failure… both went away upon a rebuild.) Third, a build of the c...
2012 Oct 22
5
[LLVMdev] precondition suggestion to LLVM
Hi all,Is there any way to tell LLVM some additional information about the variables in the code in order to make better optimization?For example, if my function has a certain precondition (such as x>0) then it will be possible to better optimize the code given that information (which the compiler does not know).I am new in this field and I don't know if there are ways to tell the compiler
2020 May 03
2
[RFC] [Windows SEH] Local_Unwind (Jumping out of a _finally)
...report EH state ranges that only contain memory/computation instructions (for obvious reason). I’m not sure which part of that concerns you. I think we need rules about how LLVM is allowed to transform the following code: void foo(volatile int *pv) { __try { if (cond()) { ++*pv; __builtin_unreachable(); } } __except(1) { } __try { if (cond()) { ++*pv; __builtin_unreachable(); } } __except(1) { } } In this case, the *pv operation may throw, but I believe it would be semantics preserving to merge the two identical if-then blocks. The call.setup proposal I sent not l...
2012 Dec 19
0
[LLVMdev] LLVM 3.2 on Xcode
...do with hires images or some such… it takes a long time to fix that up in a project as large as this, but I'm not sure there's anything we can do about it. > Second, a build of the ALL_BUILD target in Xcode produces 16 warnings about 8 functions declared noreturn, but without a expected __builtin_unreachable() before the end of the function. (The first attempt to build produced 2 errors, the first an unable to create directory error for runtime/libprofile/LLVM.build/Debug/profile_rt-static.build/Objects-normal/x86_64; the second a libtool failure… both went away upon a rebuild.) > Third, a build of...