- Jun 04, 2021
-
-
William S. Moses authored
Fix bug in MemoryDependence [and thus GVN] for invariant group. Previously MemDep didn't verify that the store was storing into a pointer rather than a store simply using a pointer. Differential Revision: https://reviews.llvm.org/D98267 (cherry picked from commit 875891a1)
-
- May 25, 2021
-
-
serge-sans-paille authored
llvm::Any::TypeId::Id relies on the uniqueness of the address of a static variable defined in a template function. hidden visibility implies vague linkage for that variable, which does not guarantee the uniqueness of the address across a binary and a shared library. This totally breaks the implementation of llvm::Any. Ideally, setting visibility to llvm::Any::TypeId::Id should be enough, unfortunately this doesn't work as expected and we lack time (before 12.0.1 release) to understand why setting the visibility to llvm::Any does work. See https://gcc.gnu.org/wiki/Visibility and https://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html for more information on that topic. Differential Revision: https://reviews.llvm.org/D101972 (cherry picked from commit 3d3abc22)
-
- May 20, 2021
-
-
Roman Lebedev authored
We can not rely on (C+X)-->(X+C) already happening, because we might not have visited that `add` yet. The added testcase would get stuck in an endless combine loop. (cherry-picked from 554b1bce)
-
- May 18, 2021
-
-
Nick Desaulniers authored
GlobalVariables are Constants, yet should not unconditionally be considered true for __builtin_constant_p. Via the LangRef https://llvm.org/docs/LangRef.html#llvm-is-constant-intrinsic: This intrinsic generates no code. If its argument is known to be a manifest compile-time constant value, then the intrinsic will be converted to a constant true value. Otherwise, it will be converted to a constant false value. In particular, note that if the argument is a constant expression which refers to a global (the address of which _is_ a constant, but not manifest during the compile), then the intrinsic evaluates to false. Move isManifestConstant from ConstantFolding to be a method of Constant so that we can reuse the same logic in LowerConstantIntrinsics. pr/41459 Reviewed By: rsmith, george.burgess.iv Differential Revision: https://reviews.llvm.org/D102367 (cherry picked from commit 8c72749b)
-
- May 13, 2021
-
-
Matt Arsenault authored
(cherry picked from commit 2f779e79)
-
- May 12, 2021
-
-
Matt Arsenault authored
This practically only works for the f16 case AMDGPU uses, not wider types. Fixes bug 49710 by failing legalization. (cherry picked from commit 83a25a10)
-
Nikita Popov authored
Instead of using VMap, which may include instructions from the caller as a result of simplification, iterate over the (FirstNewBlock, Caller->end()) range, which will only include new instructions. Fixes https://bugs.llvm.org/show_bug.cgi?id=50270. Differential Revision: https://reviews.llvm.org/D102110 (cherry picked from commit aa9b02ac)
-
Florian Hahn authored
I think currently isImpliedViaMerge can incorrectly return true for phis in a loop/cycle, if the found condition involves the previous value of Consider the case in exit_cond_depends_on_inner_loop. At some point, we call (modulo simplifications) isImpliedViaMerge(<=, %x.lcssa, -1, %call, -1). The existing code tries to prove IncV <= -1 for all incoming values InvV using the found condition (%call <= -1). At the moment this succeeds, but only because it does not compare the same runtime value. The found condition checks the value of the last iteration, but the incoming value is from the *previous* iteration. Hence we incorrectly determine that the *previous* value was <= -1, which may not be true. I think we need to be more careful when looking at the incoming values here. In particular, we need to rule out that a found condition refers to any value that may refer to one of the previous iterations. I'm not sure there's a reliable way to do so (that also works of irreducible control flow). So for now this patch adds an additional requirement that the incoming value must properly dominate the phi block. This should ensure the values do not change in a cycle. I am not entirely sure if will catch all cases and I appreciate a through second look in that regard. Alternatively we could also unconditionally bail out in this case, instead of checking the incoming values Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D101829 (cherry picked from commit 6c99e631)
-
Florian Hahn authored
(cherry picked from commit d65e5f60)
-
Fangrui Song authored
An unfetched lazy symbol (undefined weak) should be considered to have its original versionId which is VER_NDX_GLOBAL, instead of the lazy symbol's versionId. (The original versionId cannot be non-VER_NDX_GLOBAL because a undefined versioned symbol is an error.) The regression was introduced in D77280 when making version scripts work with lazy symbols fetched by LTO calls. Fix PR49915 Differential Revision: https://reviews.llvm.org/D100624 (cherry picked from commit 1c00530b)
-
Tom Stellard authored
This reverts commit b89942c3. There are issues with this patch and also no tracking bug for it.
-
Dimitry Andric authored
When run under valgrind, or with a malloc that poisons freed memory, this can lead to segfaults or other problems. To avoid modifying the AdditionalUsers DenseMap while still iterating, save the instructions to be notified in a separate SmallPtrSet, and use this to later call OperandChangedState on each instruction. Fixes PR49582. Reviewed By: fhahn Differential Revision: https://reviews.llvm.org/D98602 (cherry picked from commit 6abb92f2)
-
Alan Phipps authored
Fix branch coverage merging in FunctionCoverageSummary::get() for instantiation groups. This change corrects the implementation for the branch coverage summary to do the same thing for branches that is done for lines and regions. That is, across function instantiations in an instantiation group, the maximum branch coverage found in any of those instantiations is returned, with the total number of branches being the same across instantiations. Differential Revision: https://reviews.llvm.org/D102193 (cherry picked from commit eccb9251)
-
- May 11, 2021
-
-
Jonas Paulsson authored
Expand 128 bit shifts instead of using a libcall. This patch removes the 128 bit shift libcalls and thereby causes ExpandShiftWithUnknownAmountBit() to be called. Review: Ulrich Weigand Differential Revision: https://reviews.llvm.org/D101993 (cherry picked from commit 1c4cb510)
-
Amara Emerson authored
Fixes PR49904 (cherry picked from commit 40e75caf)
-
Joachim Meyer authored
Only verify that there's no negative indent. Noted by @chapuni in https://reviews.llvm.org/D93494. Reviewed By: chapuni Differential Revision: https://reviews.llvm.org/D102021 (cherry picked from commit d9f2960c)
-
Tom Stellard authored
This test case was added by accident and is failing on the release/12.x branch.
-
- May 08, 2021
-
-
Tom Stellard authored
-
Tom Stellard authored
The compressed dumps are no longer readable, but I'm not sure why.
-
Tom Stellard authored
This should help reduce memory usage of the abi-dumper tool and avoid running out of memory and disk space.
-
- May 07, 2021
-
-
Sanjay Patel authored
This is the sibling fix to c590a988 - as there, we can't subsitute a vector value the equality compare replacement that we are trying requires that the comparison is true for the entire value. Vector select can be partly true/false. (cherry picked from commit e2a0f512)
-
Sanjay Patel authored
We need a sibling fix to c590a988 ( https://llvm.org/PR49832 ) to avoid miscompiling. (cherry picked from commit 78e5cf66)
-
Sanjay Patel authored
As shown in the example based on: https://llvm.org/PR49832 ...and the existing test, we can't substitute a vector value because the equality compare replacement that we are attempting requires that the comparison is true for the entire value. Vector select can be partly true/false. (cherry picked from commit c590a988)
-
Sanjay Patel authored
The new test is reduced from: https://llvm.org/PR49832 ...but we already show a potential miscompile in the existing test too. (cherry picked from commit c0b0da46)
-
Ahsan Saghir authored
This patch prevents argument promotion of types having type size greater than 128 bits. Fixes Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=49952 Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D101188 (cherry picked from commit 670736a9)
-
KAWASHIMA Takahiro authored
Fixes PR47627 This fix suppresses rerolling a loop which has an unrerollable instruction. Sample IR for the explanation below: ``` define void @foo([2 x i32]* nocapture %a) { entry: br label %loop loop: ; base instruction %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %loop ] ; unrerollable instructions %stptrx = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %indvar, i64 0 store i32 999, i32* %stptrx, align 4 ; extra simple arithmetic operations, used by root instructions %plus20 = add nuw nsw i64 %indvar, 20 %plus10 = add nuw nsw i64 %indvar, 10 ; root instruction 0 %ldptr0 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus20, i64 0 %value0 = load i32, i32* %ldptr0, align 4 %stptr0 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus10, i64 0 store i32 %value0, i32* %stptr0, align 4 ; root instruction 1 %ldptr1 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus20, i64 1 %value1 = load i32, i32* %ldptr1, align 4 %stptr1 = getelementptr inbounds [2 x i32], [2 x i32]* %a, i64 %plus10, i64 1 store i32 %value1, i32* %stptr1, align 4 ; loop-increment and latch %indvar.next = add nuw nsw i64 %indvar, 1 %exitcond = icmp eq i64 %indvar.next, 5 br i1 %exitcond, label %exit, label %loop exit: ret void } ``` In the loop rerolling pass, `%indvar` and `%indvar.next` are appended to the `LoopIncs` vector in the `LoopReroll::DAGRootTracker::findRoots` function. Before this fix, two instructions with `unrerollable instructions` comment above are marked as `IL_All` at the end of the `LoopReroll::DAGRootTracker::collectUsedInstructions` function, as well as instructions with `extra simple arithmetic operations` comment and `loop-increment and latch` comment. It is incorrect because `IL_All` means that the instruction should be executed in all iterations of the rerolled loop but the `store` instruction should not. This fix rejects instructions which may have side effects and don't belong to def-use chains of any root instructions and reductions. See https://bugs.llvm.org/show_bug.cgi?id=47627 for more information. (cherry picked from commit d9a9c992) -
Tim Northover authored
The IR stack protector pass must insert stack checks before the call instead of between it and the return. Similarly, SDAG one should recognize that ADJCALLFRAME instructions could be part of the terminal sequence of a tail call. In this case because such call frames cannot be nested in LLVM the stack protection code must skip over the whole sequence (or risk clobbering argument registers). (cherry picked from commit 5e3d9fcc)
-
Brad Smith authored
(cherry picked from commit 3a62d4fd)
-
- May 04, 2021
-
-
Yonghong Song authored
Lorenz Bauer reported that the following code will have compilation error for bpf target: enum e { TWO }; bpf_core_enum_value_exists(enum e, TWO); The clang emitted the following error message: __builtin_preserve_enum_value argument 1 invalid In SemaChecking, an expression like "*(enum NAME)1" will have cast kind CK_IntegralToPointer, but "*(enum NAME)0" will have cast kind CK_NullToPointer. Current implementation only permits CK_IntegralToPointer, missing enum value 0 case. This patch permits CK_NullToPointer cast kind and the above test case can pass now. Differential Revision: https://reviews.llvm.org/D97659 (cherry picked from commit 283db5f0) -
Yonghong Song authored
Andrei Matei reported a llvm11 core dump for his bpf program https://bugs.llvm.org/show_bug.cgi?id=48578 The core dump happens in LiveVariables analysis phase. #4 0x00007fce54356bb0 __restore_rt #5 0x00007fce4d51785e llvm::LiveVariables::HandleVirtRegUse(unsigned int, llvm::MachineBasicBlock*, llvm::MachineInstr&) #6 0x00007fce4d519abe llvm::LiveVariables::runOnInstr(llvm::MachineInstr&, llvm::SmallVectorImpl<unsigned int>&) #7 0x00007fce4d519ec6 llvm::LiveVariables::runOnBlock(llvm::MachineBasicBlock*, unsigned int) #8 0x00007fce4d51a4bf llvm::LiveVariables::runOnMachineFunction(llvm::MachineFunction&) The bug can be reproduced with llvm12 and latest trunk as well. Futher analysis shows that there is a bug in BPF peephole TRUNC elimination optimization, which tries to remove unnecessary TRUNC operations (a <<= 32; a >>= 32). Specifically, the compiler did wrong transformation for the following patterns: %1 = LDW ... %2 = SLL_ri %1, 32 %3 = SRL_ri %2, 32 ... %3 ... %4 = SRA_ri %2, 32 ... %4 ... The current transformation did not check how many uses of %2 and did transformation like %1 = LDW ... ... %1 ... %4 = SRL_ri %2, 32 ... %4 ... and pseudo register %2 is used by not defined and caused LiveVariables analysis core dump. To fix the issue, when traversing back from SRL_ri to SLL_ri, check to ensure SLL_ri has only one use. Otherwise, don't do transformation. Differential Revision: https://reviews.llvm.org/D97792 (cherry picked from commit 51cdb780)
-
Yonghong Song authored
Lorenz Bauer from Cloudflare tried to use "const struct <name>" as the type for __builtin_btf_type_id(*(const struct <name>)0, 1) relocation and hit a llvm BPF fatal error. https://lore.kernel.org/bpf/a3782f71-3f6b-1e75-17a9-1827822c2030@fb.com/ ... fatal error: error in backend: Empty type name for BTF_TYPE_ID_REMOTE reloc Currently, we require the debuginfo type itself must have a name. In this case, the debuginfo type is "const" which points to "struct <name>". The "const" type does not have a name, hence the above fatal error will be triggered. Let us permit "const" and "volatile" type modifiers. We skip modifiers in some other cases as well like structure member type tracing. This can aviod the above fatal error. Differential Revision: https://reviews.llvm.org/D97986 (cherry picked from commit 9c0274cd)
-
Luke Drummond authored
`__translate_sampler_initializer` has a calling convention of `spir_func`, but clang generated calls to it using the default CC. Instruction Combining was lowering these mismatching calling conventions to `store i1* undef` which itself was subsequently lowered to a trap instruction by simplifyCFG resulting in runtime `SIGILL` There are arguably two bugs here: but whether there's any wisdom in converting an obviously invalid call into a runtime crash over aborting with a sensible error message will require further discussion. So for now it's enough to set the right calling convention on the runtime helper. Reviewed By: svenh, bader Differential Revision: https://reviews.llvm.org/D98411 (cherry picked from commit fcfd3fda)
-
ShihPo Hung authored
This patch changes the operand order of masked vmslt[u] from (mask, rs1, scalar, maskedoff, vl) to (maskedoff, rs1, scalar, mask, vl). Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D98839 (cherry picked from commit fca5d63a)
-
Tom Stellard authored
This reverts some of commit dbb01536. The Reporter module was still being used by the ScanView.py module and deleting it caused scan-view to fail. This commit adds back Reporter.py but removes the code the references the AppleScript files which were removed in dbb01536. Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D96367 (cherry picked from commit e3cd3a3c)
-
Michael Kruse authored
external.c defines stub functions that are never used because of how Polly uses PPCG. Unfortunately, they are declared as functions without return values or parameters which does not match their declarations. Since they are never called, this was usually not a problem, but an LTO build gets confused with differently declared functions, or in case of pet_options_args, a global variable declaration that is defined as a function Resolve by including the declaring headers in external.c which forces the declaration and definition to match at compile-time. This fixes llvm.org/50021 (cherry picked from commit 89b59345)
-
Michael Kruse authored
The isl_id_* have been in used without including the correspodning isl/id.h header. According to rules in C, a function is defined implicitly when first used with an assumed int return type (32 bits on 64 bit systems). But the implementation returns a pointer (64 bits on 64 bit systems). Is usually has no consequence because the return value is stored in a registers that is 64 bits (RAX) and the optimizer does not truncate its value before using it again as a pointer value. However, LTO optimizers will be rightfull;y confused. Fix by including <isl/id.h> This fixes llvm.org/PR50021 (cherry picked from commit 90e5ce0b)
-
Yonghong Song authored
Commit 1959ead5 ("BPF: Implement TTI.getCmpSelInstrCost() properly") introduced a dependency on LLVMTransformUtils library. Let us encode this dependency explicitly in CMakefile to avoid build error. (cherry picked from commit 6d102f15)
-
Yonghong Song authored
The Select insn in BPF is expensive as BPF backend needs to resolve with conditionals. This patch set the getCmpSelInstrCost() to SCEVCheapExpansionBudget for Select insn to prevent some Select insn related optimizations. This change is motivated during bcc code review for https://github.com/iovisor/bcc/pull/3270 where IndVarSimplifyPass eventually caused generating the following asm code: ; for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) { 14: 16 05 40 00 00 00 00 00 if w5 == 0 goto +64 <LBB0_6> 15: bc 51 00 00 00 00 00 00 w1 = w5 16: 04 01 00 00 ff ff ff ff w1 += -1 17: 67 05 00 00 20 00 00 00 r5 <<= 32 18: 77 05 00 00 20 00 00 00 r5 >>= 32 19: a6 01 01 00 05 00 00 00 if w1 < 5 goto +1 <LBB0_4> 20: b7 05 00 00 06 00 00 00 r5 = 6 00000000000000a8 <LBB0_4>: 21: b7 02 00 00 00 00 00 00 r2 = 0 22: b7 01 00 00 00 00 00 00 r1 = 0 ; for (i = 0; (i < VIRTIO_MAX_SGS) && (i < num); i++) { 23: 7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1 24: 7b 5a c0 ff 00 00 00 00 *(u64 *)(r10 - 64) = r5 Note that insn #15 has w1 = w5 and w1 is refined later but r5(w5) is eventually saved on stack at insn #24 for later use. This cause later verifier failures. With this change, IndVarSimplifyPass won't do the above transformation any more. Differential Revision: https://reviews.llvm.org/D97479 (cherry picked from commit 1959ead5)
-
Yonghong Song authored
buildbot reported a build error like below: BPFTargetMachine.cpp:(.text._ZN4llvm19TargetTransformInfo5ModelINS_10BPFTTIImplEED2Ev [_ZN4llvm19TargetTransformInfo5ModelINS_10BPFTTIImplEED2Ev]+0x14): undefined reference to `llvm::TargetTransformInfo::Concept::~Concept()' lib/Target/BPF/CMakeFiles/LLVMBPFCodeGen.dir/BPFTargetMachine.cpp.o: In function `llvm::TargetTransformInfo::Model<llvm::BPFTTIImpl>::~Model()': Commit a260ae71 ("BPF: Implement TTI.IntImmCost() properly") added TargetTransformInfo to BPF, which requires LLVMAnalysis dependence. In certain cmake configurations, lacking explicit LLVMAnalysis dependency may cause compilation error. Similar to other targets, this patch added LLVMAnalysis in CMakefile LINK_COMPONENTS explicitly. (cherry picked from commit 74975d35) -
Yonghong Song authored
This patch implemented TTI.IntImmCost() properly. Each BPF insn has 32bit immediate space, so for any immediate which can be represented as 32bit signed int, the cost is technically free. If an int cannot be presented as a 32bit signed int, a ld_imm64 instruction is needed and a TCC_Basic is returned. This change is motivated when we observed that several bpf selftests failed with latest llvm trunk, e.g., #10/16 strobemeta.o:FAIL #10/17 strobemeta_nounroll1.o:FAIL #10/18 strobemeta_nounroll2.o:FAIL #10/19 strobemeta_subprogs.o:FAIL #96 snprintf_btf:FAIL The reason of the failure is due to that SpeculateAroundPHIsPass did aggressive transformation which alters control flow for which currently verifer cannot handle well. In llvm12, SpeculateAroundPHIsPass is not called. SpeculateAroundPHIsPass relied on TTI.getIntImmCost() and TTI.getIntImmCostInst() for profitability analysis. This patch implemented TTI.getIntImmCost() properly for BPF backend which also prevented transformation which caused the above test failures. Differential Revision: https://reviews.llvm.org/D96448 (cherry picked from commit a260ae71)
-