Sumanth Gundapaneni via llvm-dev
2017-Jan-05 00:03 UTC
[llvm-dev] LLVMTargetMachine with optimization level passed from clang.
I see the BackendUtil.cpp of Clang creates the TargetMachine with the optimization level based on below mentioned logic CodeGenOpt::Level OptLevel = CodeGenOpt::Default; switch (CodeGenOpts.OptimizationLevel) { default: break; case 0: OptLevel = CodeGenOpt::None; break; case 3: OptLevel = CodeGenOpt::Aggressive; break; } As per my understanding, the correspondence between optimization level and CodeGenOpt is as below O0 - none O1 - less O2 - default O3 - aggressive My goal is to turn on a target dependent codegen optimization at -O1(less). The TargetMachine is constructed with "CodeGenOpt::Default". Is there a way I could do this in LLVM ? What is the standard way of doing this ? Also, the code in BackendUtil.cpp seem somewhat offbeat to me. --Sumanth G -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170104/aaa1a836/attachment.html>
Ryan Taylor via llvm-dev
2017-Jan-05 00:05 UTC
[llvm-dev] LLVMTargetMachine with optimization level passed from clang.
If I understand you correctly, you should look at putting your pass in the pass manager at the opt level u want. Ryan On Jan 4, 2017 7:03 PM, "Sumanth Gundapaneni via llvm-dev" < llvm-dev at lists.llvm.org> wrote:> I see the BackendUtil.cpp of Clang creates the TargetMachine with the > optimization level based on below mentioned logic > > > > CodeGenOpt::Level OptLevel = CodeGenOpt::Default; > > switch (CodeGenOpts.OptimizationLevel) { > > default: break; > > case 0: OptLevel = CodeGenOpt::None; break; > > case 3: OptLevel = CodeGenOpt::Aggressive; break; > > } > > > > As per my understanding, the correspondence between optimization level and > CodeGenOpt is as below > > O0 - none > > O1 - less > > O2 - default > > O3 - aggressive > > > > My goal is to turn on a target dependent codegen optimization at > –O1(less). The TargetMachine is constructed with “CodeGenOpt::Default”. Is > there a way I could do this in LLVM ? What is the standard way of doing > this ? Also, the code in BackendUtil.cpp seem somewhat offbeat to me. > > > > --Sumanth G > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://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/20170104/6ebb4073/attachment.html>
Mehdi Amini via llvm-dev
2017-Jan-05 00:10 UTC
[llvm-dev] LLVMTargetMachine with optimization level passed from clang.
> On Jan 4, 2017, at 4:03 PM, Sumanth Gundapaneni via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > I see the BackendUtil.cpp of Clang creates the TargetMachine with the optimization level based on below mentioned logic > > CodeGenOpt::Level OptLevel = CodeGenOpt::Default; > switch (CodeGenOpts.OptimizationLevel) { > default: break; > case 0: OptLevel = CodeGenOpt::None; break; > case 3: OptLevel = CodeGenOpt::Aggressive; break; > } > > As per my understanding, the correspondence between optimization level and CodeGenOpt is as below > O0 - none > O1 - less > O2 - default > O3 - aggressive > > My goal is to turn on a target dependent codegen optimization at –O1(less).Apparently “less” is not used by clang, do you want your optimization to be turned on for O1 *and above* or just for O1 specifically? Also what kind of optimization is this? A SelectionDAG combine or a specific pass? If it is a pass, is it IR or MIR? — Mehdi> The TargetMachine is constructed with “CodeGenOpt::Default”. Is there a way I could do this in LLVM ? What is the standard way of doing this ? Also, the code in BackendUtil.cpp seem somewhat offbeat to me. > > --Sumanth G > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://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/20170104/7aa9485f/attachment.html>
Ryan Taylor via llvm-dev
2017-Jan-05 00:12 UTC
[llvm-dev] LLVMTargetMachine with optimization level passed from clang.
My mistake, u want a code gen opt, not IR, so a backend pass? On Jan 4, 2017 7:05 PM, "Ryan Taylor" <ryta1203 at gmail.com> wrote:> If I understand you correctly, you should look at putting your pass in the > pass manager at the opt level u want. > > Ryan > > On Jan 4, 2017 7:03 PM, "Sumanth Gundapaneni via llvm-dev" < > llvm-dev at lists.llvm.org> wrote: > >> I see the BackendUtil.cpp of Clang creates the TargetMachine with the >> optimization level based on below mentioned logic >> >> >> >> CodeGenOpt::Level OptLevel = CodeGenOpt::Default; >> >> switch (CodeGenOpts.OptimizationLevel) { >> >> default: break; >> >> case 0: OptLevel = CodeGenOpt::None; break; >> >> case 3: OptLevel = CodeGenOpt::Aggressive; break; >> >> } >> >> >> >> As per my understanding, the correspondence between optimization level >> and CodeGenOpt is as below >> >> O0 - none >> >> O1 - less >> >> O2 - default >> >> O3 - aggressive >> >> >> >> My goal is to turn on a target dependent codegen optimization at >> –O1(less). The TargetMachine is constructed with “CodeGenOpt::Default”. Is >> there a way I could do this in LLVM ? What is the standard way of doing >> this ? Also, the code in BackendUtil.cpp seem somewhat offbeat to me. >> >> >> >> --Sumanth G >> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://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/20170104/f3b010eb/attachment.html>
via llvm-dev
2017-Jan-05 16:12 UTC
[llvm-dev] LLVMTargetMachine with optimization level passed from clang.
I want the optimization to be turned on at -O1 and above. In my case, it is a target independent back-end pass. (Eg: MachinePipeliner) On 2017-01-04 18:10, Mehdi Amini wrote:>> On Jan 4, 2017, at 4:03 PM, Sumanth Gundapaneni via llvm-dev >> <llvm-dev at lists.llvm.org> wrote: >> >> I see the BackendUtil.cpp of Clang creates the TargetMachine with >> the optimization level based on below mentioned logic >> >> CodeGenOpt::Level OptLevel = CodeGenOpt::Default; >> switch (CodeGenOpts.OptimizationLevel) { >> default: break; >> case 0: OptLevel = CodeGenOpt::None; break; >> case 3: OptLevel = CodeGenOpt::Aggressive; break; >> } >> >> As per my understanding, the correspondence between optimization >> level and CodeGenOpt is as below >> O0 - none >> O1 - less >> O2 - default >> O3 - aggressive >> >> My goal is to turn on a target dependent codegen optimization at >> –O1(less). > > Apparently “less” is not used by clang, do you want your > optimization to be turned on for O1 *and above* or just for O1 > specifically? > > Also what kind of optimization is this? A SelectionDAG combine or a > specific pass? If it is a pass, is it IR or MIR? > — > Mehdi > >> The TargetMachine is constructed with “CodeGenOpt::Default”. Is >> there a way I could do this in LLVM ? What is the standard way of >> doing this ? Also, the code in BackendUtil.cpp seem somewhat offbeat >> to me. >> >> --Sumanth G >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev