similar to: Another tail call optimization question

Displaying 20 results from an estimated 700 matches similar to: "Another tail call optimization question"

2020 Oct 06
2
Optimizing assembly generated for tail call
Hello, I recently found that LLVM generates sub-optimal assembly for a tail call optimization case. Below is an example (https://godbolt.org/z/ao15xE): > void g1(); > void g2(); > void f(bool v) { > if (v) { > g1(); > } else { > g2(); > } > } > The assembly generated is as follow: > f(bool): # @f(bool) > testb %dil, %dil > je .LBB0_2 >
2020 Sep 04
2
Performance of JIT execution
Hello, I recently noticed a performance issue of JIT execution vs native code of the following simple logic which computes the Fibonacci sequence: uint64_t fib(int n) { if (n <= 2) { return 1; } else { return fib(n-1) + fib(n-2); } } When compiled natively using clang++ with -O3, it took 0.17s to compute fib(40). However, when executing using LLJIT, fed with the IR output of "clang++
2020 Aug 07
2
JIT interaction with linkonce_odr global variables
Hello, I recently hit an issue when JIT'ing my generated IR using llvm::orc::LLJIT. My IR contains the following definition of a global variable: > $_ZZ23TestStaticVarInFunctionbE1x = comdat any > @_ZZ23TestStaticVarInFunctionbE1x = linkonce_odr dso_local global i32 123, > comdat, align 4 > And in my host process, there exists the same symbol. I would expect LLJIT to resolve the
2020 Sep 25
2
Understanding tail call
Hi friendly LLVM Devs, I'm trying to understand the technical details of tail call optimization, but unfortunately I hit some issues that I couldn't figure out myself. So I tried the following two really simple functions: > extern void g(int*); > void f1() { > int x; > g(&x); > } > void f2(int* x) { > g(x); > } > It turns out that 'f1'
2020 Jun 13
2
target-features attribute prevents inlining?
Thank you so much David! After thinking a bit more I agree with you that attempting to add 'target-features' to my functions seem to be the safest approach of all. I noticed that if I mark the clang++ function as 'AlwaysInline', the inlining is performed normally. Is this a potential bug, given what you said that LLVM may accidentally move code using advanced cpu features outside
2020 Nov 05
1
LLJIT global constants string becomes invalid in generated code
Hi, Recently I hit an issue that LLJIT crashes when CodeGenOpt::Less or higher is given. After investigation, it turned out that the issue is some global constant string in the IR, like > @.str.117 = private unnamed_addr constant [9 x i8] c"lineitem\00", align 1 > becomes an invalid pointer in the generated code. > $1 = 0xf7fab054 <error: Cannot access memory at address
2005 Aug 18
4
SYSLINUX 3.10-pre11
I have just pushed out SYSLINUX 3.10-pre11. This version hopefully should fix Curtis' bug (display file garbage) as well as the NOESCAPE problem. Curtis, Alex and Paul, could you try this version out, please? -hpa
2020 Jun 13
2
target-features attribute prevents inlining?
Hi David, Thanks for your quick response! I now understand the reason that inlining cannot be done on functions with different target-attributes. Thanks for your explanation! However, I think I didn't fully understand your solution; it would be nice if you would like to elaborate a bit more. Here's a bit more info on my current workflow: (1) The clang++ compiler builds C++ source file
2014 Apr 29
2
Issues with syslinux_run_command(str) and parameters
> > Thanks Ady, you were spot on, and I should have tested that scenario! > I narrowed the issue down to a line in my config: > > > ALLOWEDOPTIONS 0 > > > The comment next to it in my config indicates this was added to > disallow users dropping to the console with Escape or Tab, a > restriction I would like to keep. BUT, when this is set whichsys >
2020 Jun 13
2
target-features attribute prevents inlining?
Hello, I'm new to LLVM and I recently hit a weird problem about inlining behavior. I managed to get a minimal repro and the symptom of the issue, but I couldn't understand the root cause or how I should properly handle this issue. Below is an IR code consisting of two functions '_Z2fnP10TestStructi' and 'testfn', with the latter calling the former. One would expect the
2017 Jun 21
2
How to prevent optimizing away a call + its arguments
Hi llvm-dev, I have a C function: __attribute__((__visibility__("default"))) __attribute__((used)) __attribute__((noinline)) void please_do_not_optimize_me_away(int arg1, void *arg2) { asm volatile("" :::); } (the purpose is that this function will be used dynamically at runtime, perhaps by interposing the function, or via the debugger) I really thought this will not get
2005 Aug 14
1
"NOESCAPE 1" is easily escapable
(I apologise if this has already been reported - the archive isn't very searchable.) At present the NOESCAPE keyword seems rather useless, because a boot prompt is offered whenever attempts to load a boot image is interrupted using <Ctrl>C. Intuitively, I would expect "NOESCAPE 1" to lock this down also, and that {sys,pxe,iso.ext}linux would simply fall through to the
2014 Apr 29
2
Issues with syslinux_run_command(str) and parameters
> More context to this: syslinux_run_command calls into load_kernel(), and somewhere behind load_kernel things break. This is also broken at the boot: console prompt. Any commands executed at the boot: prompt also lose all parameters. > > > With the latest 6.03pre I'm seeing an issue where no parameters are passed to the image executed via syslinux_run_command(). > > An
2017 Jun 22
8
How to prevent optimizing away a call + its arguments
On Wed, Jun 21, 2017 at 05:25:04PM -0700, Mehdi AMINI via llvm-dev wrote: > Hi Kuba, > > Try: > > __attribute__(optnone) > > See > https://clang.llvm.org/docs/AttributeReference.html#optnone-clang-optnone Actually, it should be enough to use: __attribute__((noinline)) void please_do_not_optimize_me_away(int arg1, void *arg2) { asm
2020 Aug 14
2
Exceptions and performance
On Thu, Aug 13, 2020 at 6:11 PM Haoran Xu <haoranxu510 at gmail.com> wrote: > > Thanks for the insights David! > > For your first 3 points, is it correct to understand it as following: the external function prototypes are missing reliable information on whether the function throws and what exceptions it may throw (due to C++'s design failures and that it is impractical to
2018 Mar 16
3
Hacking at EuroLLVM 2018
Hello, We have booked a couple of slots during EuroLLVM this year that we would like to dedicate to real hacking!!! Therefore, we would like to offer to the attendees this year an opportunity to escape from the presentation sessions and dive into fun coding to learn something new or to solve some interesting problems. The current proposal is to have 2 x 45 mins on Monday afternoon and 2 x 45
2020 Aug 13
3
Exceptions and performance
There is a fair amount of dispute and detail here, and real benchmarks can be difficult to write, because you often end up in arguments about whether or not the two styles of coding are equivalent or not. But I agree with Dave--exceptions generally inhibit optimization. One way to think about this is that, generally speaking, the less the compiler can prove about a program, the less aggressive
2018 Nov 08
2
Compile with both arm and thumb mode
Hi I would like to use clang to cross compile the ARM binary. I hope the target binary contains both arm and thumb instruction sets. I use the flag -mhwdiv=arm,thumb. I compiled several binaries. However, I found that the thumb mode instructions are few. Even for very big program like gcc. The number of thumb mode instruction is less than 100. I get the ground truth from the mapping table.
2020 Aug 14
2
Exceptions and performance
On Thu, Aug 13, 2020 at 4:38 PM Haoran Xu <haoranxu510 at gmail.com> wrote: > > Hello David and Sterling, thanks for the reply! > > I have no intention to heat up the discussion, please pardon me if I asked questions that might sound silly to you -- it's just that I truly didn't understand since I'm not expert in llvm or optimizer or exception handling at all. >
2020 Feb 12
2
tool options to generate spill code
Hello, For the following test case, reg.c #include <stdio.h> int getinput() { static int u=10; return u++; } int main() { int a,b,c,d,e,f,g; a=getinput(); b=getinput(); c=getinput(); d=getinput(); e=getinput(); f=getinput(); g=getinput(); printf("%d %d %d %d %d %d %d\n",a,b,c,d,e,f,g); a=b=c=d=e=f=g=0; return 0; } *1.