[llvm-dev] How to migrate PassManager CodeGenPasses for LLVM v6.x?

Leslie Zhai via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 30 01:51:22 PDT 2017


Hi LLVM developers,

CodeGen had been changed a lot, for example:

* no DataLayoutPass any more  https://reviews.llvm.org/D7992

* no addAnalysisPasses any more

* new MergeFunctions, BBVectorize (but removed after v5.x), RerollLoops 
... for PassManagerBuilder

and I have checked clang-33, clang-39 and clang-svn's EmitAssembly in 
the lib/CodeGen/BackendUtil.cpp, then migrated the CodeGen related code 
from:


PerModulePasses->add(new DataLayoutPass());

TheTarget->addAnalysisPasses(*PerModulePasses);



To:

CodeGenPasses->add(
createTargetTransformInfoWrapperPass(TheTarget->getTargetIRAnalysis()));


DragonEgg (as a testcase of GCC and LLVM, migrated to GCC v8.x and LLVM 
v6.x) is able to generate LLVM IR at present 
http://lists.llvm.org/pipermail/llvm-dev/2017-August/116705.html but 
*failed* to generate Assembly File by addPassesToEmitFile(CodeGenPasses, 
...)  and CodeGenPasses.run(TheModule):


     .file    "hello.c"
     .section    .rodata
     .type    __func__.2269, @object
     .size    __func__.2269, 4
__func__.2269:
     .string    "foo"
     .comm    __gnu_lto_v1,1,1
     .comm    __gnu_lto_slim,1,1
     .section    .note.GNU-stack,"", at progbits

Please give me some hint about why PerFunctionPasses->run(F) failed to 
work, thanks a lot!

PS: I also read CodGen's tutorial about Compiling to Object Code 
https://llvm.org/docs/tutorial/LangImpl08.html  it is able to work by 
addPassesToEmitFile(CodeGenPasses, ...)  and CodeGenPasses.run(TheModule)!

NAKAMURA used PassManager instead of FunctionPassManager in CodeGen 
https://github.com/llvm-mirror/dragonegg/commit/76fc0ed6d68f4b6b8a061dbb03d462385850dd6c 
and clang-33 also use PassManager for CodeGenPasses, I have no idea why 
use FunctionPassManager for it, and FunctionPassManager for 
CodeGenPasses is able to work for GCC v4.8 and LLVM v3.3 to generate 
correct Assembly File.

-- 
Regards,
Leslie Zhai - https://reviews.llvm.org/p/xiangzhai/



More information about the llvm-dev mailing list