[llvm-dev] tool options to generate spill code (original) (raw)
Aaron Smith via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 12 07:55:42 PST 2020
- Previous message: [llvm-dev] tool options to generate spill code
- Next message: [llvm-dev] tool options to generate spill code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
If you use -O0 to generate LLVM IR you must pass -disable-O0-optnone or it cannot be optimized. If you look at the LLVM IR for #2 and #3 it will say "optnone" [1] in the attributes which will prevent any optimization like mem2reg [2] from running.
[1] https://clang.llvm.org/docs/AttributeReference.html#optnone [2] http://llvm.org/docs/Passes.html#mem2reg-promote-memory-to-register
On Wed, Feb 12, 2020 at 2:36 AM Priyanka Panigrahi via llvm-dev < llvm-dev at lists.llvm.org> wrote:
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. $clang reg.c -Xclang -disable-O0-optnone -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s* *2. $clang reg.c -Xclang -disable-llvm-passes -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s* *3. $clang reg.c -S -emit-llvm -o reg.ll && opt -mem2reg -S reg.ll -o reg.ll && llc --regalloc=greedy reg.ll -o reg.s* Only 1. gives the spill code but it deletes the dead stores., 2 and 3 give only allocas. Why so?? How -mem2reg works and what it depends on? How to generate the spill code with dead stores? Thank you. Regards, Priyanka
LLVM Developers mailing list llvm-dev at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200212/be967f04/attachment.html>
- Previous message: [llvm-dev] tool options to generate spill code
- Next message: [llvm-dev] tool options to generate spill code
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]