summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetPassConfig.cpp
AgeCommit message (Collapse)Author
2022-03-23Revert "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"Zequan Wu
This reverts commit 22570bac694396514fff18dec926558951643fa6.
2022-03-17Lower `@llvm.global_dtors` using `__cxa_atexit` on MachOJulian Lettner
For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with `__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`. Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this. Enable fallback to the old behavior via Clang driver flag (`-fregister-global-dtors-with-atexit`) or llc / code generation flag (`-lower-global-dtors-via-cxa-atexit`). This escape hatch will be removed in the future. Differential Revision: https://reviews.llvm.org/D121736
2022-03-16[NFC][CodeGen] Remove redundant if clause in TargetPassConfig::addPassShengchen Kan
2022-03-16Cleanup codegen includesserge-sans-paille
This is a (fixed) recommit of https://reviews.llvm.org/D121169 after: 1061034926 before: 1063332844 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121681
2022-03-15Revert rG9c542a5a4e1ba36c24e48185712779df52b7f7a6 "Lower ↵Simon Pilgrim
`@llvm.global_dtors` using `__cxa_atexit` on MachO" Mane of the build bots are complaining: Unknown command line argument '-lower-global-dtors'
2022-03-14Lower `@llvm.global_dtors` using `__cxa_atexit` on MachOJulian Lettner
For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with `__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`. Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this. Enable fallback to the old behavior via Clang driver flag (`-fregister-global-dtors-with-atexit`) or llc / code generation flag (`-lower-global-dtors-via-cxa-atexit`). This escape hatch will be removed in the future. Differential Revision: https://reviews.llvm.org/D121327
2022-03-10Revert "Cleanup codegen includes"Nico Weber
This reverts commit 7f230feeeac8a67b335f52bd2e900a05c6098f20. Breaks CodeGenCUDA/link-device-bitcode.cu in check-clang, and many LLVM tests, see comments on https://reviews.llvm.org/D121169
2022-03-10Cleanup codegen includesserge-sans-paille
after: 1061034926 before: 1063332844 Differential Revision: https://reviews.llvm.org/D121169
2022-03-10TLS loads opimization (hoist)Xiang1 Zhang
Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D120000
2022-03-02Revert "TLS loads opimization (hoist)"Xiang1 Zhang
Revert for more reviews This reverts commit 30e612ebdfb0f243eb63d93487790a53c26ae873.
2022-03-02TLS loads opimization (hoist)Xiang1 Zhang
Reviewed By: Wang Pheobe, Topper Craig Differential Revision: https://reviews.llvm.org/D120000
2022-02-05[SampleFDO] Enable FSAFDO loading passes if --enable-fs-discriminator is enabledRong Xu
FSAFDO profile loader is currently disabled even --enable-fs-discriminator is enabled. They need to be turned on by options which makes it cumbersome for experiments. This patch changes the FSAFDO profile loader enabled by default. Since they are guarded by EnableFSDiscriminator, they will only be turned on if --enable-fs-discriminator is enabled. Note that --enable-fs-discriminator is still disabled by default. Differential Revision: https://reviews.llvm.org/D119033
2022-01-19[MLGO] ML Regalloc Eviction AdvisorMircea Trofin
The bulk of the implementation is common between 'release' mode (==AOT-ed model) and 'development' mode (for training), the main difference is that in development mode, we may also log features (for training logs), inject scoring information (currently after the Virtual Register Rewriter) and then produce the log file. This patch also introduces the score injection pass, 'Register Allocation Pass Scoring', which is trivially just logging the score in development mode. Differential Revision: https://reviews.llvm.org/D117147
2021-12-28[CodeGen] Drop unnecessary const from return types (NFC)Kazu Hirata
Identified with readability-const-return-type.
2021-10-18Remove the verifyAfter mechanism that was replaced by D111397Jay Foad
Differential Revision: https://reviews.llvm.org/D111872
2021-10-08[TargetPassConfig] Remove an obsolete FIXME commentJay Foad
The "coloring with register" functionality it refers to was removed ten years ago in svn r144481 "Remove the -color-ss-with-regs option".
2021-10-07[TargetPassConfig] Enable machine verification after miscellaneous passesJay Foad
In a couple of places machine verification was disabled for no apparent reason, probably just because an "addPass(..., false)" line was cut and pasted from elsewhere. After this patch the only remaining place where machine verification is disabled in the generic TargetPassConfig code, is after addPreEmitPass.
2021-10-07[TwoAddressInstruction] Enable machine verification after this passJay Foad
Differential Revision: https://reviews.llvm.org/D111007
2021-10-07[PHIElimination] Enable machine verification after this passJay Foad
Differential Revision: https://reviews.llvm.org/D111006
2021-10-05[LiveIntervals] Fix verification of early-clobbered segmentsJay Foad
Enable verification of live intervals immediately after computing them (when -early-live-intervals is used) and fix a problem that that provokes: currently the verifier insists that a segment that ends at an early-clobber slot must be followed by another segment starting at the same slot. But before TwoAddressInstruction runs, the equivalent condition is: a segment that ends at an early-clobber slot must have its last use tied to an early-clobber def. That condition is harder to check here, so for now just disable this check until tied operands have been rewritten. Differential Revision: https://reviews.llvm.org/D111065
2021-10-01[MachineLoopInfo] Enable machine verification after this passJay Foad
Enabling this does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110703
2021-10-01[LiveVariables] Skip verification of kills inside bundlesJay Foad
LiveVariables does not examine the contents of bundles, so MachineVerifier should not expect it to know about kill flags on operands of instructions inside a bundle. With this fix we can enable machine verification after running the LiveVariables analysis. Doing this does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110700
2021-10-01[UnreachableMachineBlockElim] Enable machine verification after this passJay Foad
Enabling this does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110697
2021-10-01[ProcessImplicitDefs] Enable machine verification after this passJay Foad
Enabling this does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110695
2021-10-01[DetectDeadLanes] Enable machine verification after this passJay Foad
Machine verification after DetectDeadLanes has been disabled since the pass was first added in D18427, but I guess this was just due to copy- and-paste. Enabling it does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110689
2021-09-29[RemoveRedundantDebugValues] Enable machine verification after this passJay Foad
Machine verification after RemoveRedundantDebugValues has been disabled since the pass was first added in D105279, but I guess this was just due to copy-and-paste. Enabling it does not show any problems in check-llvm in an LLVM_ENABLE_EXPENSIVE_CHECKS build. Differential Revision: https://reviews.llvm.org/D110688
2021-09-22[CSSPGO] Set PseudoProbeInserter as a default pass.Hongtao Yu
Currenlty PseudoProbeInserter is a pass conditioned on a target switch. It works well with a single clang invocation. It doesn't work so well when the backend is called separately (i.e, through the linker or llc), where user has always to pass -pseudo-probe-for-profiling explictly. I'm making the pass a default pass that requires no command line arg to trigger, but will be actually run depending on whether the CU comes with `llvm.pseudo_probe_desc` metadata. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D110209
2021-08-18[SampleFDO] Flow Sensitive Sample FDO (FSAFDO) profile loaderRong Xu
This patch implements Flow Sensitive Sample FDO (FSAFDO) profile loader. We have two profile loaders for FS profile, one before RegAlloc and one before BlockPlacement. To enable it, when -fprofile-sample-use=<profile> is specified, add "-enable-fs-discriminator=true \ -disable-ra-fsprofile-loader=false \ -disable-layout-fsprofile-loader=false" to turn on the FS profile loaders. Differential Revision: https://reviews.llvm.org/D107878
2021-08-11[SampleFDO] Add two passes of MIRAddFSDiscriminatorsPassRong Xu
This patch adds Pass1 of MIRADDFSDiscriminatorsPass before register allocation, and Pass2 of MIRAddFSDiscriminatorsPass before Block-Placement. This is still under --enable-fs-discrmininator option (default false). This would reduce the turn-around time for FSAFDO transition. Differential Revision: https://reviews.llvm.org/D104579
2021-07-14[RemoveRedundantDebugValues] Add a Pass that removes redundant DBG_VALUEsDjordje Todorovic
This new MIR pass removes redundant DBG_VALUEs. After the register allocator is done, more precisely, after the Virtual Register Rewriter, we end up having duplicated DBG_VALUEs, since some virtual registers are being rewritten into the same physical register as some of existing DBG_VALUEs. Each DBG_VALUE should indicate (at least before the LiveDebugValues) variables assignment, but it is being clobbered for function parameters during the SelectionDAG since it generates new DBG_VALUEs after COPY instructions, even though the parameter has no assignment. For example, if we had a DBG_VALUE $regX as an entry debug value representing the parameter, and a COPY and after the COPY, DBG_VALUE $virt_reg, and after the virtregrewrite the $virt_reg gets rewritten into $regX, we'd end up having redundant DBG_VALUE. This breaks the definition of the DBG_VALUE since some analysis passes might be built on top of that premise..., and this patch tries to fix the MIR with the respect to that. This first patch performs bacward scan, by trying to detect a sequence of consecutive DBG_VALUEs, and to remove all DBG_VALUEs describing one variable but the last one: For example: (1) DBG_VALUE $edi, !"var1", ... (2) DBG_VALUE $esi, !"var2", ... (3) DBG_VALUE $edi, !"var1", ... ... in this case, we can remove (1). By combining the forward scan that will be introduced in the next patch (from this stack), by inspecting the statistics, the RemoveRedundantDebugValues removes 15032 instructions by using gdb-7.11 as a testbed. Differential Revision: https://reviews.llvm.org/D105279
2021-07-13RegAlloc: Allow targets to split register allocationMatt Arsenault
AMDGPU normally spills SGPRs to VGPRs. Previously, since all register classes are handled at the same time, this was problematic. We don't know ahead of time how many registers will be needed to be reserved to handle the spilling. If no VGPRs were left for spilling, we would have to try to spill to memory. If the spilled SGPRs were required for exec mask manipulation, it is highly problematic because the lanes active at the point of spill are not necessarily the same as at the restore point. Avoid this problem by fully allocating SGPRs in a separate regalloc run from VGPRs. This way we know the exact number of VGPRs needed, and can reserve them for a second run. This fixes the most serious issues, but it is still possible using inline asm to make all VGPRs unavailable. Start erroring in the case where we ever would require memory for an SGPR spill. This is implemented by giving each regalloc pass a callback which reports if a register class should be handled or not. A few passes need some small changes to deal with leftover virtual registers. In the AMDGPU implementation, a new pass is introduced to take the place of PrologEpilogInserter for SGPR spills emitted during the first run. One disadvantage of this is currently StackSlotColoring is no longer used for SGPR spills. It would need to be run again, which will require more work. Error if the standard -regalloc option is used. Introduce new separate -sgpr-regalloc and -vgpr-regalloc flags, so the two runs can be controlled individually. PBQB is not currently supported, so this also prevents using the unhandled allocator.
2021-07-07[AMDGPU] Disable garbage collection passesStanislav Mekhanoshin
Differential Revision: https://reviews.llvm.org/D105593
2021-06-02[SampleFDO] New hierarchical discriminator for FS SampleFDO (ProfileData part)Rong Xu
This patch was split from https://reviews.llvm.org/D102246 [SampleFDO] New hierarchical discriminator for Flow Sensitive SampleFDO This is mainly for ProfileData part of change. It will load FS Profile when such profile is detected. For an extbinary format profile, create_llvm_prof tool will add a flag to profile summary section. For other format profiles, the users need to use an internal option (-profile-isfs) to tell the compiler that the profile uses FS discriminators. This patch also simplified the bit API used by FS discriminators. Differential Revision: https://reviews.llvm.org/D103041
2021-05-31Remove "Rewrite Symbols" from codegen pipelineArthur Eubanks
It breaks up the function pass manager in the codegen pipeline. With empty parameters, it looks at the -mllvm flag -rewrite-map-file. This is likely not in use. Add a check that we only have one function pass manager in the codegen pipeline. Some tests relied on the fact that we had a module pass somewhere in the codegen pipeline. addr-label.ll crashes on ARM due to this change. This is because a ARMConstantPoolConstant containing a BasicBlock to represent a blockaddress may hold an invalid pointer to a BasicBlock if the blockaddress is invalidated by its BasicBlock getting removed. In that case all referencing blockaddresses are RAUW a constant int. Making ARMConstantPoolConstant::CVal a WeakVH fixes the crash, but I'm not sure that's the right fix. As a workaround, create a barrier right before ISel so that IR optimizations can't happen while a ARMConstantPoolConstant has been created. Reviewed By: rnk, MaskRay, compnerd Differential Revision: https://reviews.llvm.org/D99707
2021-05-18[SampleFDO] New hierarchical discriminator for Flow Sensitive SampleFDORong Xu
This patch implements first part of Flow Sensitive SampleFDO (FSAFDO). It has the following changes: (1) disable current discriminator encoding scheme, (2) new hierarchical discriminator for FSAFDO. For this patch, option "-enable-fs-discriminator=true" turns on the new functionality. Option "-enable-fs-discriminator=false" (the default) keeps the current SampleFDO behavior. When the fs-discriminator is enabled, we insert a flag variable, namely, llvm_fs_discriminator, to the object. This symbol will checked by create_llvm_prof tool, and used to generate a profile with FS-AFDO discriminators enabled. If this happens, for an extbinary format profile, create_llvm_prof tool will add a flag to profile summary section. Differential Revision: https://reviews.llvm.org/D102246
2021-05-08[X86] Support AMX fast register allocationXiang1 Zhang
Differential Revision: https://reviews.llvm.org/D100026
2021-05-08Revert "[X86] Support AMX fast register allocation"Xiang1 Zhang
This reverts commit 77e2e5e07d01fe0b83c39d0c527c0d3d2e659146.
2021-05-08[X86] Support AMX fast register allocationXiang1 Zhang
2021-05-04Recommit "[VP,Integer,#2] ExpandVectorPredication pass"Simon Moll
This reverts the revert 02c5ba8679873e878ae7a76fb26808a47940275b Fix: Pass was registered as DUMMY_FUNCTION_PASS causing the newpm-pass functions to be doubly defined. Triggered in -DLLVM_ENABLE_MODULE=1 builds. Original commit: This patch implements expansion of llvm.vp.* intrinsics (https://llvm.org/docs/LangRef.html#vector-predication-intrinsics). VP expansion is required for targets that do not implement VP code generation. Since expansion is controllable with TTI, targets can switch on the VP intrinsics they do support in their backend offering a smooth transition strategy for VP code generation (VE, RISC-V V, ARM SVE, AVX512, ..). Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D78203
2021-04-30Revert "[VP,Integer,#2] ExpandVectorPredication pass"Adrian Prantl
This reverts commit 43bc584dc05e24c6d44ece8e07d4bff585adaf6d. The commit broke the -DLLVM_ENABLE_MODULES=1 builds. http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/31603/consoleFull#2136199809a1ca8a51-895e-46c6-af87-ce24fa4cd561
2021-04-30[VP,Integer,#2] ExpandVectorPredication passSimon Moll
This patch implements expansion of llvm.vp.* intrinsics (https://llvm.org/docs/LangRef.html#vector-predication-intrinsics). VP expansion is required for targets that do not implement VP code generation. Since expansion is controllable with TTI, targets can switch on the VP intrinsics they do support in their backend offering a smooth transition strategy for VP code generation (VE, RISC-V V, ARM SVE, AVX512, ..). Reviewed By: rogfer01 Differential Revision: https://reviews.llvm.org/D78203
2021-04-29Revert "[X86] Support AMX fast register allocation"Benjamin Kramer
This reverts commit 3b8ec86fd576b9808dc63da620d9a4f7bbe04372. Revert "[X86] Refine AMX fast register allocation" This reverts commit c3f95e9197643b699b891ca416ce7d72cf89f5fc. This pass breaks using LLVM in a multi-threaded environment by introducing global state.
2021-04-25[X86] Support AMX fast register allocationXiang1 Zhang
Differential Revision: https://reviews.llvm.org/D100026
2021-04-10Revert "Remove "Rewrite Symbols" from codegen pipeline"Arthur Eubanks
This reverts commit 6210261ecb21c84c9a440a76c0ccbc8ad211bed3. addr-label.ll crashes on armv7.
2021-04-10Remove "Rewrite Symbols" from codegen pipelineArthur Eubanks
It breaks up the function pass manager in the codegen pipeline. With empty parameters, it looks at the -mllvm flag -rewrite-map-file. This is likely not in use. Add a check that we only have one function pass manager in the codegen pipeline. This required reverting commit 9583a3f2625818b78c0cf6d473cdedb9f23ad82c: "[AsmPrinter] Delete dead takeDeletedSymbsForFunction()". This was not NFC as initially thought. By coalescing two function psas managers, this exposed the reverted code as necessary. addr-label.ll was crashing due to an emitted blockaddress's block being removed but the label not emitted. Some tests relied on the fact that we had a module pass somewhere in the codegen pipeline. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D99707
2021-03-01Move EntryExitInstrumentation pass locationArthur Eubanks
This seems to be more of a Clang thing rather than a generic LLVM thing, so this moves it out of LLVM pipelines and as Clang extension hooks into LLVM pipelines. Move the post-inline EEInstrumentation out of the backend pipeline and into a late pass, similar to other sanitizer passes. It doesn't fit into the codegen pipeline. Also fix up EntryExitInstrumentation not running at -O0 under the new PM. PR49143 Reviewed By: hans Differential Revision: https://reviews.llvm.org/D97608
2021-02-12[CodeGen] New pass: Replace vector intrinsics with call to vector libraryLukas Sommer
This patch adds a pass to replace calls to vector intrinsics (i.e., LLVM intrinsics operating on vector operands) with calls to a vector library. Currently, calls to LLVM intrinsics are only replaced with calls to vector libraries when scalar calls to intrinsics are vectorized by the Loop- or SLP-Vectorizer. With this pass, it is now possible to replace calls to LLVM intrinsics already operating on vector operands, e.g., if such code was generated by MLIR. For the replacement, information from the TargetLibraryInfo, e.g., as specified via -vector-library is used. This is a re-try of the original commit 2303e93e66 that was reverted due to pass manager problems. Other minor changes have also been made. Differential Revision: https://reviews.llvm.org/D95373
2021-02-11[CodeGen] Basic block sections should take precendence over splitting.Snehasish Kumar
The use of basic block sections should take precedence over the machine function splitting pass. Since they use the same underlying mechanism they are kept exclusive. Updated the tests to check that split machine functions is overridden by all flavours of basic block sections. Differential Revision: https://reviews.llvm.org/D96392
2021-02-05Revert "[Codegen][ReplaceWithVecLib] add pass to replace vector intrinsics ↵Sanjay Patel
with calls to vector library" This reverts commit 2303e93e666e13ebf6d24323729c28f520ecca37. Investigating bot failures.
2021-02-05[Codegen][ReplaceWithVecLib] add pass to replace vector intrinsics with ↵Lukas Sommer
calls to vector library This patch adds a pass to replace calls to vector intrinsics (i.e., LLVM intrinsics operating on vector operands) with calls to a vector library. Currently, calls to LLVM intrinsics are only replaced with calls to vector libraries when scalar calls to intrinsics are vectorized by the Loop- or SLP-Vectorizer. With this pass, it is now possible to replace calls to LLVM intrinsics already operating on vector operands, e.g., if such code was generated by MLIR. For the replacement, information from the TargetLibraryInfo, e.g., as specified via -vector-library is used. Differential Revision: https://reviews.llvm.org/D95373