Tso tawm ntawm LLVM 10.0 compiler suite

Tom qab rau lub hlis ntawm kev loj hlob hais tawm qhov project tso tawm LWM 10.0 - GCC-tshaj cov cuab yeej (compilers, optimizers thiab code generators), compiling cov kev pab cuam rau hauv nruab nrab bitcode ntawm RISC-zoo li cov lus qhia virtual (qib-theem virtual tshuab nrog ntau theem optimization system). Lub generated pseudocode tuaj yeem hloov dua siab tshiab siv JIT compiler rau hauv cov lus qhia tshuab ncaj qha thaum lub sijhawm ua haujlwm.

Cov yam ntxwv tshiab hauv LLVM 10.0 suav nrog kev txhawb nqa rau C ++ Cov Ntsiab Lus, tsis ua haujlwm Clang raws li cov txheej txheem sib cais, kev txhawb nqa rau CFG (control flow guard) checks for Windows, thiab txhawb CPU tshiab.

Kev Txhim Kho Hauv Clang 10.0:

  • Ntxiv kev txhawb nqa rau "tswvyim", C ++ template extension uas yuav suav nrog hauv tus qauv tom ntej, codenamed C ++ 2a (tig los ntawm -std = c ++ 2a chij).
    Cov tswv yim tso cai rau koj los txheeb xyuas cov txheej txheem template uas yuav tsum tau ua, thaum lub sijhawm sib sau, txwv cov txheej txheem sib cav uas tuaj yeem lees txais raws li cov qauv ntsuas. Cov tswv yim tuaj yeem siv los tiv thaiv kev tsis sib haum xeeb ntawm cov khoom ntawm cov ntaub ntawv hom siv nyob rau hauv cov qauv thiab cov ntaub ntawv hom khoom ntawm cov input tsis.

    tus qauv
    tswvyim EqualityComparable = require(T a, T b) {
    { a == b } -> std::boolean;
    {a != b } -> std::boolean;
    };

  • Los ntawm lub neej ntawd, kev tso tawm ntawm cov txheej txheem sib cais ("clang -cc1") nyob rau hauv uas muab tso ua ke tau ua tiav. Kev sau ua ke tam sim no ua tiav hauv cov txheej txheem tseem ceeb, thiab qhov kev xaiv "-fno-integrated-cc1" tuaj yeem siv los kho tus cwj pwm qub.
  • Cov kev kuaj mob tshiab:
    • "-Wc99-designator" thiab "-Wreorder-init-list" ceeb toom tawm tsam kev siv C99 pib hauv C ++ hom nyob rau hauv rooj plaub uas lawv muaj tseeb hauv C99 tab sis tsis nyob hauv C ++ 20.
    • "-Wsizeof-array-div" - ntes cov xwm txheej xws li "int arr[10]; ...sizeof(arr) / sizeof(short)..."(yuav tsum yog "sizeof(arr) / sizeof(int)").
    • "-Wxor-used-as-po" - ceeb toom tawm tsam kev siv cov kev tsim xws li kev siv "^" (xor) tus neeg teb xov tooj hauv kev ua haujlwm uas tuaj yeem tsis meej pem nrog exponentiation (2^16).
    • "-Wfinal-dtor-non-final-class" - ceeb toom txog cov chav kawm uas tsis raug cim nrog "qhov kawg" specifier, tab sis muaj tus destructor nrog "kawg" tus cwj pwm.
    • "-Wtautological-bitwise-piv" yog ib pawg ntawm cov lus ceeb toom rau kev kuaj mob tautological sib piv ntawm kev ua haujlwm me ntsis thiab qhov tsis tu ncua, thiab txhawm rau txheeb xyuas qhov sib piv ib txwm muaj tseeb uas qhov kev ua haujlwm bitwise LOSSIS siv rau tus lej tsis zoo.
    • "-Wbitwise-conditional-parentheses" ceeb toom txog cov teeb meem thaum sib xyaw cov tswv yim sib xyaw THIAB (&) thiab LOS SIS (|) nrog tus neeg teb xov tooj (?:).
    • "-Wmisleading-indentation" yog ib qho piv txwv ntawm daim tshev ntawm tib lub npe los ntawm GCC, uas ceeb toom txog cov kab lus indented xws li yog tias lawv yog ib feem ntawm if / lwm / rau / thaum thaiv, tab sis qhov tseeb lawv tsis suav nrog hauv qhov thaiv no .
    • Thaum qhia meej "-Wextra", "-Wdeprecated-copy" kos yog qhib, ceeb toom txog kev siv cov neeg tsim khoom
      "tsav" thiab "copy" nyob rau hauv cov chav kawm nrog ib tug meej destructor txhais.

    • Cov "-Wtautological-overlap-piv", "-Wsizeof-pointer-div", "-Wtautological-sib piv", "-Wrange-loop-analysis" tau nthuav dav.
    • Cov kev kuaj xyuas "-Wbitwise-op-parentheses" thiab "-Wlogical-op-parentheses" raug cuam tshuam los ntawm lub neej ntawd.
  • Hauv C thiab C ++ code, pointer arithmetic ua haujlwm tsuas yog tso cai hauv arrays. Lub Undefined Cwj Pwm Sanitizer nyob rau hauv "-fsanitize = pointer-overflow" hom tam sim no ntes cov xwm txheej xws li ntxiv qhov tsis yog xoom offset rau tus pointer tsis muaj lossis tsim ib tus pointer null thaum rho tus lej los ntawm tus pointer tsis yog null.
  • Hom "-fsanitize = implicit-conversion" (Implicit Conversion Sanitizer) hom yog yoog los txheeb xyuas cov teeb meem nrog kev nce ntxiv thiab kev ua haujlwm qis rau cov hom me me me dua li ntawm hom "int".
  • Thaum xaiv x86 lub hom phiaj architectures "-march = skylake-avx512", "-march = icelake-client", "-march = icelake-server", "-march = cascadelake" thiab "-march = cooperlake" los ntawm lub neej ntawd hauv vectorized The code tau tso tseg tsis siv 512-ntsis zmm sau npe, tshwj tsis yog rau lawv qhov taw qhia ncaj qha hauv qhov chaws. Qhov laj thawj yog tias CPU zaus txo qis thaum ua haujlwm 512-ntsis, uas tuaj yeem cuam tshuam tsis zoo rau kev ua haujlwm tag nrho. Txhawm rau hloov tus cwj pwm tshiab, qhov kev xaiv "-mprefer-vector-width = 512" yog muab.
  • Tus cwj pwm ntawm tus chij "-flax-vector-conversions" zoo ib yam li GCC: implicit vector me ntsis conversion ntawm integer thiab floating-point vectors raug txwv. Txhawm rau tshem tawm qhov kev txwv no, nws tau thov kom siv tus chij
    "-flax-vector-conversions = tag nrho" uas yog lub neej ntawd.

  • Txhim kho kev txhawb nqa rau MIPS CPUs ntawm Octeon tsev neeg. Ntxiv "octeon+" rau daim ntawv teev cov hom CPU siv tau.
  • Thaum sib sau ua ke rau hauv WebAssembly intermediate code, lub wasm-opt optimizer tau raug hu ua, yog tias muaj nyob hauv qhov system.
  • Rau cov tshuab raws li RISC-V architecture, kev siv cov ntawv sau npe khaws cov ntsiab lus ntab ntab yog tso cai rau hauv cov xwm txheej ntawm cov khoom sib dhos hauv kab.
  • Ntxiv tshiab compiler chij: "-fgnuc-version" los teeb tsa tus nqi version rau "__GNUC__" thiab cov macro zoo sib xws; "-fmacro-prefix-map=OLD=NEW" los hloov cov npe ua ntej OLD nrog NEW hauv macros xws li "__FILE__"; "-fpatchable-function-entry=N[,M]" los tsim kom muaj qee tus lej ntawm NOP cov lus qhia ua ntej thiab tom qab lub ntsiab lus nkag. Rau RISC-V
    ntxiv kev txhawb nqa rau "-ffixed-xX", "-mcmodel=medany" thiab "-mcmodel=medlow" chij.

  • Ntxiv kev txhawb nqa rau '__attribute__((target("branch-tiv thaiv = ... "))) attribute, cov nyhuv uas zoo ib yam li cov kev xaiv -mbranch-kev tiv thaiv.
  • Ntawm lub Windows platform, thaum qhia txog tus chij "-cfguard", kev hloov pauv ntawm kev ua tiav kev kuaj xyuas kev ncaj ncees (Control Flow Guard) rau kev hu xov tooj ncaj qha. Txhawm rau lov tes taw kev hloov pauv, koj tuaj yeem siv tus chij "-cfguard-nochecks" lossis "__declspec(guard(nocf))" hloov.
  • Tus cwj pwm ntawm gnu_inline tus cwj pwm zoo ib yam li GCC thaum nws siv yam tsis muaj lo lus "extern".
  • Lub peev xwm cuam tshuam nrog OpenCL thiab CUDA kev txhawb nqa tau nthuav dav. Ntxiv kev txhawb nqa rau OpenMP 5.0 nta tshiab.
  • Ib qho kev xaiv txheem tau muab ntxiv rau cov khoom siv clang-format, uas tso cai rau koj los txiav txim siab cov qauv ntawm C ++ tus qauv siv thaum parsing thiab formatting code (Last, Auto, c ++ 03, c ++ 11, c ++ 14, c++ 17, c++ 20).
  • Cov tshev tshiab tau muab ntxiv rau qhov ntsuas qhov zoo li qub: alpha.cplusplus.PlacementNew los txiav txim seb puas muaj qhov chaw cia txaus, fuchsia.HandleChecker txhawm rau txheeb xyuas cov xau cuam tshuam nrog Fuchsia handlers, security.insecureAPI.decodeValueOfObjCType txhawm rau txheeb xyuas qhov muaj peev xwm tsis txaus thaum siv [NSCoderbcodeV :ua:].
  • Lub Undefined Cwj Pwm Sanitizer (UBSan) tau nthuav dav nws cov pointer overflow checks kom ntes tau daim ntawv thov ntawm tsis yog xoom offsets rau NULL pointers los yog qhov tshwm sim ntxiv ntawm NULL pointer offset.
  • Hauv linter clang-tidy ntxiv ib feem loj ntawm cov tshev tshiab.

ntsiab kev tsim kho tshiab LWM 10.0:

  • Rau lub moj khaum Tus tsim tawm Tshiab interprocedural optimizations thiab analyzers tau ntxiv. Lub xeev ntawm 19 tus cwj pwm sib txawv tau kwv yees, suav nrog 12 tus cwj pwm 12 LLVM IR thiab 7 tus cwj pwm tsis meej xws li kev ua neej nyob.
  • Ntxiv tshiab matrix kev ua lej ua rau hauv lub compiler (Intrinsics), uas yog hloov los ntawm cov lus qhia vector zoo thaum muab tso ua ke.
  • Ntau qhov kev txhim kho tau ua rau backends rau X86, AArch64, ARM, SystemZ, MIPS, AMDGPU thiab PowerPC architectures. Ntxiv CPU txhawb
    Cortex-A65, Cortex-A65AE, Neoverse E1 thiab Neoverse N1. Rau ARMv8.1-M, ​​cov txheej txheem tsim cov cai tau ua kom zoo dua qub (piv txwv li, kev txhawb nqa rau lub voj voog nrog tsawg kawg nkaus nyiaj siv ua haujlwm tau tshwm sim) thiab kev txhawb nqa rau autovectorization tau ntxiv siv MVE txuas ntxiv. Txhim kho CPU MIPS Octeon kev txhawb nqa. Rau PowerPC, vectorization ntawm lej subroutines siv lub tsev qiv ntawv MASSV (Mathematical Acceleration SubSystem) tau qhib, kev tsim cov lej raug txhim kho, thiab kev nkag mus ntawm lub cim xeeb los ntawm cov voj voog tau zoo. Rau x86, kev tuav cov vector hom v2i32, v4i16, v2i16, v8i8, v4i8 thiab v2i8 tau hloov pauv.

  • Txhim kho code generator rau WebAssembly. Ntxiv kev txhawb nqa rau TLS (Thread-Local Storage) thiab cov lus qhia atomic.fence. Kev them nyiaj yug SIMD tau nthuav dav heev. WebAssembly cov ntaub ntawv tam sim no muaj peev xwm siv ntau tus nqi kos npe.
  • Analyzer yog siv thaum ua cov loops MemorySSA, uas tso cai rau koj los txhais cov kev vam meej ntawm kev ua haujlwm nco sib txawv. MemorySSA tuaj yeem txo qhov muab tso ua ke thiab ua tiav lub sijhawm lossis tuaj yeem siv los hloov AliasSetTracker yam tsis muaj kev poob haujlwm.
  • LLDB debugger tau txhim kho kev txhawb nqa rau DWARF v5 hom ntawv. Txhim kho kev txhawb nqa rau kev tsim nrog MinGW
    thiab ntxiv peev xwm pib debug Windows executables rau ARM thiab ARM64 architectures. Ntxiv cov lus piav qhia ntawm cov kev xaiv muaj thaum autocompleting input los ntawm nias tab.

  • Nthuav LLD linker peev xwm. Txhim kho kev txhawb nqa rau ELF hom, suav nrog kev ua kom muaj kev sib raug zoo ntawm lub ntiaj teb templates nrog GNU linker, ntxiv kev txhawb nqa rau compressed debug seem ".zdebug", ntxiv PT_GNU_PROPERTY cov cuab yeej los txhais cov ntu .note.gnu.property (yuav siv tau yav tom ntej Linux kernels),
    Cov qauv "-z noseparate-code", "-z cais-code" thiab "-z cais-loadable-segments" tau siv. Txhim kho kev txhawb nqa rau MinGW thiab WebAssembly.

Tau qhov twg los: opennet.ru

Ntxiv ib saib