Commit Graph

93352 Commits

Author SHA1 Message Date
Benjamin Kramer 5d2ce7663b Use llvm::append_range instead of push_back loops where applicable. NFCI. 2022-03-18 01:25:34 +01:00
Paul Kirth 964398ccb1 Revert "Revert "Revert "[misexpect] Re-implement MisExpect Diagnostics"""
This reverts commit 6cf560d69a.
2022-03-18 00:21:33 +00:00
Paul Kirth 6cf560d69a Revert "Revert "[misexpect] Re-implement MisExpect Diagnostics""
I mistakenly reverted my commit, so I'm relanding it.

This reverts commit 10866a1df4.
2022-03-18 00:04:22 +00:00
Paul Kirth 10866a1df4 Revert "[misexpect] Re-implement MisExpect Diagnostics"
This reverts commit e7749d4713.
2022-03-17 23:54:26 +00:00
Paul Kirth e7749d4713 [misexpect] Re-implement MisExpect Diagnostics
Reimplements MisExpect diagnostics from D66324 to reconstruct its
original checking methodology only using MD_prof branch_weights
metadata.

New checks rely on 2 invariants:

1) For frontend instrumentation, MD_prof branch_weights will always be
   populated before llvm.expect intrinsics are lowered.

2) for IR and sample profiling, llvm.expect intrinsics will always be
   lowered before branch_weights are populated from the IR profiles.

These invariants allow the checking to assume how the existing branch
weights are populated depending on the profiling method used, and emit
the correct diagnostics. If these invariants are ever invalidated, the
MisExpect related checks would need to be updated, potentially by
re-introducing MD_misexpect metadata, and ensuring it always will be
transformed the same way as branch_weights in other optimization passes.

Frontend based profiling is now enabled without using LLVM Args, by
introducing a new CodeGen option, and checking if the -Wmisexpect flag
has been passed on the command line.

Differential Revision: https://reviews.llvm.org/D115907
2022-03-17 23:46:23 +00:00
Changpeng Fang dd5895cc39 AMDGPU: Use the implicit kernargs for code object version 5
Summary:
  Specifically, for trap handling, for targets that do not support getDoorbellID,
we load the queue_ptr from the implicit kernarg, and move queue_ptr to s[0:1].
To get aperture bases when targets do not have aperture registers, we load
private_base or shared_base directly from the implicit kernarg. In clang, we use
implicitarg_ptr + offsets to implement __builtin_amdgcn_workgroup_size_{xyz}.

Reviewers: arsenm, sameerds, yaxunl

Differential Revision: https://reviews.llvm.org/D120265
2022-03-17 14:12:36 -07:00
Johannes Doerfert b4cc3b1dd8 [OpenMP][FIX] Make metadata and attribute check lines less detailed
The update_cc script should really do this automatically :(
2022-03-17 14:58:22 -05:00
Johannes Doerfert 052a6c744a [OpenMP][FIX] Relax test check lines 2022-03-17 14:01:47 -05:00
Zahira Ammarguellat bbf0d1932a Currently the control of the eval-method is mixed with fast-math.
FLT_EVAL_METHOD tells the user the precision at which, temporary results
are evaluated but when fast-math is enabled, the numeric values are not
guaranteed to match the source semantics, so the eval-method is
meaningless.
For example, the expression `x + y + z` has as source semantics `(x + y)
+ z`. FLT_EVAL_METHOD is telling the user at which precision `(x + y)`
is evaluated. With fast-math enable the compiler can choose to
evaluate the expression as `(y + z) + x`.
The correct behavior is to set the FLT_EVAL_METHOD to `-1` to tell the
user that the precision of the intermediate values is unknow. This
patch is doing that.

Differential Revision: https://reviews.llvm.org/D121122
2022-03-17 11:48:03 -07:00
Johannes Doerfert f02550bdd9 Reapply "[OpenMP][FIX] Allow device constructors for AMD GPU"
This reverts commit a597d6a780 and
reapplies 07b1766461.

In AMD GPU device code the globals are in AS(1). Before, we crashed if
the global was a structure. Now we simply cast away the AS before we
generate the code to initialize the global.

Differential Revision: https://reviews.llvm.org/D121837

Fixes: https://github.com/llvm/llvm-project/issues/54421
2022-03-17 12:53:47 -05:00
Julian Lettner 22570bac69 Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO
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-17 10:47:13 -07:00
Zixu Wang 54b145d5ca [NFC] Disable clang/SymbolGraph test 2022-03-17 10:14:19 -07:00
Yuanfang Chen 7e80976fdf [PS4] Make __BIGGEST_ALIGNMENT__ 32bytes
So it matches `__STDCPP_DEFAULT_NEW_ALIGNMENT__`.

Reviewed By: probinson, aaron.ballman

Differential Revision: https://reviews.llvm.org/D118850
2022-03-17 10:12:38 -07:00
Stanislav Gatev b000b7705a [clang][dataflow] Model the behavior of non-standard optional assignment
Model nullopt, value, and conversion assignment operators.

Reviewed-by: xazax.hun

Differential Revision: https://reviews.llvm.org/D121863
2022-03-17 17:11:12 +00:00
Craig Topper bbd2ecf9f0 [RISCV] Add +experimental-zvfh extension to cover half types in vectors.
Currently we allow half types in vectors if the scalar Zfh extension
is enabled. This behavior is not inline with the vector spec. For f32
and f64 types, the Zve32f, Zve64f, Zve64d, and V explicitly control
the availablity of floating point types in vectors.

In order to make our compiler compliant, we either need to remove all support
for half in vectors or we need an extension to control it.

Draft spec here https://github.com/riscv/riscv-v-spec/pull/780

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D121345
2022-03-17 10:04:02 -07:00
Matt Devereau a9e08bc7c1 [AArch64][SVE] InstCombine llvm.aarch64.sve.sel to select
InstCombine llvm.aarch64.sve.sel to select. This allows an existing instCombine
added in 20b0fa91c9 to fire.

Differential Revision: https://reviews.llvm.org/D121792
2022-03-17 16:20:48 +00:00
Simon Pilgrim ef865d16ec [clang] AddObjCKeyValueCompletions - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointers are always dereferenced, so assert the cast is correct instead of returning nullptr
2022-03-17 16:16:01 +00:00
Nikita Popov 6e1e99dc07 [CodeGen] Avoid pointer element type access for blocks
Pass the block struct type down to the TargetInfo hooks.
2022-03-17 16:56:31 +01:00
Nikita Popov 6c0af92612 [CodeGen] Avoid some pointer element type accesses 2022-03-17 16:36:14 +01:00
Nikita Popov 2edac9d962 [CodeGen] Avoid some pointer element type accesses 2022-03-17 16:32:45 +01:00
Dávid Bolvanský cb2f2fecc1 [Clang] Added info about noinline/always_inline statement attributes to release notes
Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121896
2022-03-17 16:29:23 +01:00
Nikita Popov bf1a99861c [CodeGen] Avoid some pointer element type accesses 2022-03-17 15:25:55 +01:00
Nikita Popov 799643f7f0 [CGObjCGNU] Remove pointer element type uses 2022-03-17 14:53:34 +01:00
Sanjay Patel ab982eace6 [Sema] add warning for tautological FP compare with literal
If we are equality comparing an FP literal with a value cast from a type
where the literal can't be represented, that's known true or false and
probably a programmer error.

Fixes issue #54222.
https://github.com/llvm/llvm-project/issues/54222

Note - I added the optimizer change with:
9397bdc67e
...and as discussed in the post-commit comments, that transform might be
too dangerous without this warning in place, so it was reverted to allow
this change first.

Differential Revision: https://reviews.llvm.org/D121306
2022-03-17 08:22:30 -04:00
Simon Pilgrim 4e4f839ac2 [X86] Use the unaligned vector typedefs for the lddqu intrinsics pointer arguments (PR20670)
Extension to 4390c721cb - similar to the vanilla load/store intrinsics, _mm_lddqu_si128/_mm256_lddqu_si256 should take an unaligned pointer, but were using the aligned m128i/m256i types which can cause alignment warnings.

The existing sse3-builtins.c and avx-builtins.c tests in llvm-project\clang\test\CodeGen\X86 should cover this.

Differential Revision: https://reviews.llvm.org/D121815
2022-03-17 10:42:29 +00:00
Kazushi (Jam) Marukawa 9df395bb68 [Clang][VE] Add vector mask intrinsics to clang
Add vector mask intrinsics instructions to clang.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D121816
2022-03-17 18:52:28 +09:00
Krystian Kuzniarek 45cb2df678 [clang-format][docs] Regenerate ClangFormatStyleOptions.rst
Misalignment of clang/docs/ClangFormatStyleOptions.rst and
clang/include/clang/Format/Format.h was introduced in c24b3db45.

Regenerated with:
python clang/docs/tools/dump_format_style.py

Reviewed By: sstwcw, curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D121749
2022-03-17 09:45:43 +01:00
Marek Kurdej dc142ea184 [clang-format] Correctly recognize binary operators in template arguments with parenthesized literals.
Fixes https://github.com/llvm/llvm-project/issues/24602.

Before, code like `foo<b & 1>` was formatted correctly but `foo<b & (1)>` wasn't.
This patch fixes this inconsistency.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D121846
2022-03-17 09:36:25 +01:00
Yi Kong e2a1f8ec27 Reland "[clang][driver] Emit a warning if -xc/-xc++ is after the last input file"
This reverts commit ba59476515.
2022-03-17 16:31:01 +08:00
Marek Kurdej 34ce42fe4d [clang-format] Reformat. NFC. 2022-03-17 09:27:31 +01:00
Evgenii Stepanov cb96464f12 Stricter use-after-dtor detection for trivial members.
Poison trivial class members one-by-one in the reverse order of their
construction, instead of all-at-once at the very end.

For example, in the following code access to `x` from `~B` will
produce an undefined value.

struct A {
  struct B b;
  int x;
};

Reviewed By: kda

Differential Revision: https://reviews.llvm.org/D119600
2022-03-16 18:20:27 -07:00
Evgenii Stepanov c5ea8e9138 Use-after-dtor detection for trivial base classes.
-fsanitize-memory-use-after-dtor detects memory access after a
subobject is destroyed but its memory is not yet deallocated.
This is done by poisoning each object memory near the end of its destructor.

Subobjects (members and base classes) do this in their respective
destructors, and the parent class does the same for its members with
trivial destructors.

Inexplicably, base classes with trivial destructors are not handled at
all. This change fixes this oversight by adding the base class poisoning logic
to the parent class destructor.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D119300
2022-03-16 18:20:27 -07:00
Evgeny Shulgin 3587b15abe [Clang] [P2025] More exhaustive tests for NRVO
This is a preliminary patch ahead of D119792 (I'll rebase that one on top of this).
This shows what Clang's _current_ behaviour is for calculating NRVO in various
common cases. Then, in D119792 (and future patches), I'll be able to demostrate
exactly how LLVM IR for each of these cases changes.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D119927
2022-03-17 03:58:40 +03:00
Zixu Wang 3840082ab5 [FIX][NFC] Fix a test case in clang/SymbolGraph
The clang/SymbolGraph/global_record.c test case explicitly diffs the
clang version in use, which causes failures. Fix the issue by normalize
the `generator` field before checking the output.
2022-03-16 17:19:35 -07:00
Eli Friedman 04ba344176 [CodeGen] Inline _byteswap_* builtins.
As discussed in D57915.

Fixes https://github.com/llvm/llvm-project/issues/39999 .

Differential Revision: https://reviews.llvm.org/D121865
2022-03-16 16:18:51 -07:00
Zixu Wang fa331da8fb [FIX][clang-extract-api] Fix scope naming violation 2022-03-16 16:04:44 -07:00
Johannes Doerfert a597d6a780 Revert "[OpenMP][FIX] Allow device constructors for AMD GPU"
This reverts commit 07b1766461 as it broke
the buildbots:
    https://lab.llvm.org/buildbot#builders/193/builds/8594
2022-03-16 17:35:54 -05:00
Zixu Wang 5aab45f430 [clang][extract-api] Add global record support
Add facilities for extract-api:
- Structs/classes to hold collected API information: `APIRecord`, `API`
- Structs/classes for API information:
  - `AvailabilityInfo`: aggregated availbility information
  - `DeclarationFragments`: declaration fragments
    - `DeclarationFragmentsBuilder`: helper class to build declaration
      fragments for various types/declarations
  - `FunctionSignature`: function signature
- Serialization: `Serializer`
- Add output file for `ExtractAPIAction`
- Refactor `clang::RawComment::getFormattedText` to provide an
  additional `getFormattedLines` for a more detailed view of comment lines
  used for the SymbolGraph format

Add support for global records (global variables and functions)
- Add `GlobalRecord` based on `APIRecord` to store global records'
  information
- Implement `VisitVarDecl` and `VisitFunctionDecl` in `ExtractAPIVisitor` to
  collect information
- Implement serialization for global records
- Add test case for global records

Differential Revision: https://reviews.llvm.org/D119479
2022-03-16 15:13:55 -07:00
Johannes Doerfert 07b1766461 [OpenMP][FIX] Allow device constructors for AMD GPU
In AMD GPU device code the globals are in AS(1). Before, we crashed if
the global was a structure. Now we simply cast away the AS before we
generate the code to initialize the global.

Differential Revision: https://reviews.llvm.org/D121837
2022-03-16 17:04:28 -05:00
Mike Rice 79f661edc1 [OpenMP] Initial parsing/sema for the 'omp teams loop' construct
Adds basic parsing/sema/serialization support for the #pragma omp teams loop
directive.

Differential Revision: https://reviews.llvm.org/D121713
2022-03-16 14:39:18 -07:00
Arthur Eubanks 2371c5a0e0 [OpaquePtr][ARM] Use elementtype on ldrex/ldaex/stlex/strex
Includes verifier changes checking the elementtype, clang codegen
changes to emit the elementtype, and ISel changes using the elementtype.

Basically the same as D120527.

Reviewed By: #opaque-pointers, nikic

Differential Revision: https://reviews.llvm.org/D121847
2022-03-16 14:11:53 -07:00
Marek Kurdej dbefb7e86f [clang-format] Reformat. NFC. 2022-03-16 21:54:11 +01:00
Thomas Lively 7e8913d775 [WebAssembly] Fix names of SIMD instructions containing '_zero'
Fix the instruction names to match the WebAssembly spec:

 - `i32x4.trunc_sat_zero_f64x2_{s,u}` => `i32x4.trunc_sat_f64x2_{s,u}_zero`
 - `f32x4.demote_zero_f64x2` => `f32x4.demote_f64x2_zero`

Also rename related things like intrinsics, builtins, and test functions to
match.

Reviewed By: aheejin

Differential Revision: https://reviews.llvm.org/D121661
2022-03-16 13:34:57 -07:00
Yitzhak Mandelbaum e0aefb4f92 [clang][dataflow] Add an API for dataflow "models" -- reusable analysis components.
This patch introduces `DataflowModel`, an abstract base class for dataflow
"models": reusable analysis components that model a particular aspect of program
semantics.

Differential Revision: https://reviews.llvm.org/D121796
2022-03-16 19:47:57 +00:00
Petr Hosek 67f53708b2 Revert "[CMake][Fuchsia] Use correct architecture for iossim"
This reverts commit 1b6ff3f4f8 since
it broke Fuchsia's macOS builders.
2022-03-16 10:10:15 -07:00
David Truby d38c9d3834 [NFC][clang][SVE] Auto-generate SVE operator tests. 2022-03-16 16:39:27 +00:00
Yonghong Song 3251ba2d0f [Attr] Fix a btf_type_tag AST generation
Current ASTContext.getAttributedType() takes attribute kind,
ModifiedType and EquivType as the hash to decide whether an AST node
has been generated or note. But this is not enough for btf_type_tag
as the attribute might have the same ModifiedType and EquivType, but
still have different string associated with attribute.

For example, for a data structure like below,
  struct map_value {
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
        int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b;
  };
The current ASTContext.getAttributedType() will produce
an AST similar to below:
  struct map_value {
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
        int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *b;
  };
and this is incorrect.

It is very difficult to use the current AttributedType as it is hard to
get the tag information. To fix the problem, this patch introduced
BTFTagAttributedType which is similar to AttributedType
in many ways but with an additional BTFTypeTagAttr. The tag itself can
be retrieved with BTFTypeTagAttr.
With the new BTFTagAttributed type, the debuginfo code can be greatly
simplified compared to previous TypeLoc based approach.

Differential Revision: https://reviews.llvm.org/D120296
2022-03-16 08:46:52 -07:00
Kazushi (Jam) Marukawa c2f62ab84b [Clang][VE] Add the rest of intrinsics to clang
Add the rest of intrinsics to clang except intrinsics using vector mask
registers.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D121586
2022-03-17 00:17:21 +09:00
Zhouyi Zhou 30adb9fd27 let EST_Uninstantiated in FunctionProtoType::canThrow return
CT_Dependent

When compile following code without -std=c++17, clang will abort by
llvm_unreachable:

class A {
  public:

  static const char X;

};
const char A::X = 0;

template<typename U> void func() noexcept(U::X);

template<class... B, char x>
void foo(void(B...) noexcept(x)) {}

void bar()
{

  foo(func<A>);

}

So, my solution is to let EST_Uninstantiated in
FunctionProtoType::canThrow return CT_Dependent

Differential Revision: https://reviews.llvm.org/D121498
2022-03-16 07:09:42 -07:00
Jan Svoboda f9096b89dd [clang][deps] NFC: Align path separator conversion in tests
This is the only test in the ClangScanDeps suite that doesn't convert (double) backslashes to forward slashes.
2022-03-16 13:40:09 +01:00