- May 28, 2024
-
-
mingmingl authored
indirect-call-promotion with vtable profiles. Clang's `-fwhole-program-vtables` is required for this optimization to take place. If `-fwhole-program-vtables` is not enabled, this change is no-op. Function-comparison (before): VTable-comparison (after): Key changes: 1. Find out virtual calls and the vtables they come from. - The ICP relies on type intrinsic `llvm.type.test` and `llvm.public.type.test` to find out virtual calls and the compatible vtables, and relies on type metadata to find the address point (offset) for comparison. 2. ICP pass does cost-benefit analysis and compares vtable only when both conditions are met 1) The function addressing and vtable load can sink to indirect fallback, and the indirect fallback is cold block 2) The number of vtables for a function candidate is within (option specified) threshold. 3. Sink the function addressing and vtable load instruction to indirect fallback. - The sink helper functions are simplified versions of `InstCombinerImpl::tryToSinkInstruction`. - The helper functions to handle debug intrinsics are copied from `InstCombinerImpl::tryToSinkInstructionDbgValues` and `InstCombinerImpl::tryToSinkInstructionDbgVariableRecords` into Transforms/Utils/Local.cpp. Ideally only one copy should exist for inst-combine, icp and other passes. 4. Keep value profiles updated 1) Update vtable value profiles after inline 2) For either function-based comparison or vtable-based comparison, update both vtable and indirect call value profiles.
-
- May 20, 2024
-
-
mingmingl authored
-
Kazu Hirata authored
-
Freddy Ye authored
-
Kazu Hirata authored
-
Mingming Liu authored
[CallPromotionUtils]Implement conditional indirect call promotion with vtable-based comparison (#81378) * Given the code sequence ``` bb: %vtable = load ptr, ptr %d, !prof !8 %vfn = getelementptr inbounds ptr, ptr %vtable, i64 1 %1 = load ptr, ptr %vfn %call = tail call i32 %1(ptr %d), !prof !9 ``` The transformation looks like ``` bb: %vtable = load ptr, ptr %d, align 8 %vfn = getelementptr inbounds i8, ptr %vtable, i64 8 <-- Inst 1 %func-addr = load ptr, ptr %vfn, align 8 <-- Inst 2 # compare loaded pointers with address point of vtables %1 = icmp eq ptr %vtable, getelementptr inbounds (i8, ptr @_ZTV<VTable>, i32 16) br i1 %1, label %if.true.direct_targ, label %if.false.orig_indirect, !prof !18 if.true.direct_targ: ; preds = %bb %2 = tail call i32 @<direct-call>(ptr nonnull %d) br label %if.end.icp if.false.orig_indirect: ; preds = %bb %call = tail call i32 %func-addr(ptr nonnull %d) br label %if.end.icp if.end.icp: ; preds = %if.false.orig_indirect, %if.true.direct_targ %4 = phi i32 [ %call, %if.false.orig_indirect ], [ %2, %if.true.direct_targ ] ``` It's intentional that `Inst 1` and `Inst2` remains in `bb` (not in `if.false.orig_indirect`). A follow up patch will implement code to sink them (something like how `instcombine` would [sink](https://github.com/llvm/llvm-project/blob/2fcfc9754a16805b81e541dc8222a8b5cf17a121/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L4293) instructions along with [debug intrinsics](https://github.com/llvm/llvm-project/blob/2fcfc9754a16805b81e541dc8222a8b5cf17a121/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L4356-L4368) if possible) * The parent patch is https://github.com/llvm/llvm-project/pull/81181 -
Kazu Hirata authored
-
Owen Pan authored
Wherever applicable, replace EXPECT_EQ with verifyFormat and std::string with StringRef. Also, change a raw string literal to a regular one.
-
Kazu Hirata authored
-
Ryuichi Watanabe authored
-
Fangrui Song authored
Fix #92702
-
Leon Clark authored
Use LSH to lower ctlz_zero_undef instead of subtracting leading zeros for i8 and i16. Related to [77615](https://github.com/llvm/llvm-project/pull/77615 ). --------- Co-authored-by:
Leon Clark <leoclark@amd.com>
-
Amir Ayupov authored
-
Matt Arsenault authored
Treat undef as unknown, and poison as ignorable.
-
Helena Kotas authored
Add `environment` parameter to Clang availability attribute. The allowed values for this parameter are a subset of values allowed in the `llvm::Triple` environment component. If the `environment` parameters is present, the declared availability attribute applies only to targets with the same platform and environment. This new parameter will be initially used for annotating HLSL functions for the `shadermodel` platform because in HLSL built-in function availability can depend not just on the shader model version (mapped to `llvm::Triple::OSType`) but also on the target shader stage (mapped to `llvm::Triple::EnvironmentType`). See example in #89802 and microsoft/hlsl-specs#204 for more details. The environment parameter is currently supported only for HLSL. Fixes #89802
-
Isaac David authored
-
Helena Kotas authored
Design document for the HLSL availability diagnostic modes Fixes microsoft/hlsl-specs#190 --------- Co-authored-by:Xiang Li <python3kgae@outlook.com>
-
- May 19, 2024
-
-
Florian Hahn authored
Simplify a common pattern generated for masks when folding the tail. PR: https://github.com/llvm/llvm-project/pull/89386
-
Matt Arsenault authored
-
Nhat Nguyen authored
This PR is to address the issue #84640
-
aengelke authored
This saves an extra iteration over the all instructions of the function.
-
aengelke authored
This is a pure optimization to avoid redundant extensions, but iterating over all users is expensive, so don't do this at -O0.
-
Alex Voicu authored
At the moment, Clang is rather liberal in assuming that 0 (and by extension unqualified) is always a safe default. This does not work for targets that actually use a different value for the default / generic AS (for example, the SPIRV that obtains from HIPSPV or SYCL). This patch is a first, fairly safe step towards trying to clear things up by querying a modules' default AS from the target, rather than assuming it's 0, alongside fixing a few places where things break / we encode the 0 == DefaultAS assumption. A bunch of existing tests are extended to check for non-zero default AS usage.
-
Vitaly Buka authored
Issue #92687 This reverts commit 112eadd5.
-
Vitaly Buka authored
Memory leak: https://lab.llvm.org/buildbot/#/builders/5/builds/43403 Issue #92687 This reverts commit 0ec3b972.
-
Vitaly Buka authored
Revert "[Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members" Together with 0ec3b972 breaks https://lab.llvm.org/buildbot/#/builders/5/builds/43403 Issue #92687 This reverts commit cef6387e.
-
Simon Pilgrim authored
No need for this to be vector specific, and its more likely that scalar cases will appear after #92576
-
Simon Pilgrim authored
No need for this to be vector specific, and its more likely that scalar cases will appear after #92096
-
Simon Pilgrim authored
[DAG] canCreateUndefOrPoison - only compute extract/index vector elt index knownbits when not poison We were calling computeKnownBits to determine the bounds of the element index without ensuring that it wasn't poison, meaning if we did freeze the index, isGuaranteedNotToBeUndefOrPoison would then fail as we can't call computeKnownBits through FREEZE for potentially poison values. Fixes #92569
-
Vitaly Buka authored
Fixes build after cfe9deb1 on https://lab.llvm.org/buildbot/#/builders/37/builds/34828
-
Simon Pilgrim authored
The only difference is the operand index for the element index variable.
-
David Green authored
-
Yingwei Zheng authored
This patch supports `G_CONSTANT_FOLD_BARRIER` on RISCV to generate the following inst seq without crash: ``` define i64 @xor_and_i64(i64 %x) { entry: %y = and i64 %x, 16383 %z = xor i64 %y, 16368 ret i64 %z } ``` -
LLVM GN Syncbot authored
-
paperchalice authored
In order to test SelectionDAG for target AMDGPU, we need CodeGenPassBuilder.
-
NAKAMURA Takumi authored
`__sanitizer_siginfo` has been introduced in D142117. (llvmorg-16-init-17950-ged9ef9b4) It is incompatible to -pedantic. `clang_rt.ctx_profile` has been introduced in #92456.
-
NAKAMURA Takumi authored
-
Mingming Liu authored
The smaller class member are more focused and easier to maintain. This also paves the way for partial header forward compatibility in https://github.com/llvm/llvm-project/pull/88212 --------- Co-authored-by:
Kazu Hirata <kazu@google.com>
-
Mingming Liu authored
Add 'sort' here since it's helpful when container type changes (for example, https://github.com/llvm/llvm-project/pull/88024 wants to change container type from `unordered_set` to `DenseMap) @MaskRay points out `std::` doesn't randomize the iteration order of `unordered_{set,map}`, and the iteration order for single build is deterministic.
-
Nicolai Hähnle authored
Labels are matched using a regexp of the form '^(pattern):', which requires the addition of a "suffix" concept to NamelessValue. Aside from that, the key challenge is that block labels are values, and we typically capture values including the prefix '%'. However, when labels appear at the start of a basic block, the prefix '%' is not included, so we must capture block label values *without* the prefix '%'. We don't know ahead of time whether an IR value is a label or not. In most cases, they are prefixed by the word "label" (their type), but this isn't the case in phi nodes. We solve this issue by leveraging the two-phase nature of variable generalization: the first pass finds all occurences of a variable and determines whether the '%' prefix can be included or not. The second pass does the actual substitution. This change also unifies the generalization path for assembly with that for IR and analysis, in the hope that any future changes avoid diverging those cases future. I also considered the alternative of trying to detect the phi node case using more regular expression special cases but ultimately decided against that because it seemed more fragile, and perhaps the approach of keeping a tentative prefix that may later be discarded could also be eventually applied to some metadata and attribute cases. Note that an early version of this change was reviewed as https://reviews.llvm.org/D142452, before version numbers were introduced. This is a substantially updated version of that change.
-