- Aug 04, 2021
-
-
Serge Pavlov authored
Clang has builtin function '__builtin_isnan', which implements C library function 'isnan'. This function now is implemented entirely in clang codegen, which expands the function into set of IR operations. There are three mechanisms by which the expansion can be made. * The most common mechanism is using an unordered comparison made by instruction 'fcmp uno'. This simple solution is target-independent and works well in most cases. It however is not suitable if floating point exceptions are tracked. Corresponding IEEE 754 operation and C function must never raise FP exception, even if the argument is a signaling NaN. Compare instructions usually does not have such property, they raise 'invalid' exception in such case. So this mechanism is unsuitable when exception behavior is strict. In particular it could result in unexpected trapping if argument is SNaN. * Another solution was implemented in https://reviews.llvm.org/D95948. It is used in the cases when raising FP exceptions by 'isnan' is not allowed. This solution implements 'isnan' using integer operations. It solves the problem of exceptions, but offers one solution for all targets, however some can do the check in more efficient way. * Solution implemented by https://reviews.llvm.org/D96568 introduced a hook 'clang::TargetCodeGenInfo::testFPKind', which injects target specific code into IR. Now only SystemZ implements this hook and it generates a call to target specific intrinsic function. Although these mechanisms allow to implement 'isnan' with enough efficiency, expanding 'isnan' in clang has drawbacks: * The operation 'isnan' is hidden behind generic integer operations or target-specific intrinsics. It complicates analysis and can prevent some optimizations. * IR can be created by tools other than clang, in this case treatment of 'isnan' has to be duplicated in that tool. Another issue with the current implementation of 'isnan' comes from the use of options '-ffast-math' or '-fno-honor-nans'. If such option is specified, 'fcmp uno' may be optimized to 'false'. It is valid optimization in general, but it results in 'isnan' always returning 'false'. For example, in some libc++ implementations the following code returns 'false': std::isnan(std::numeric_limits<float>::quiet_NaN()) The options '-ffast-math' and '-fno-honor-nans' imply that FP operation operands are never NaNs. This assumption however should not be applied to the functions that check FP number properties, including 'isnan'. If such function returns expected result instead of actually making checks, it becomes useless in many cases. The option '-ffast-math' is often used for performance critical code, as it can speed up execution by the expense of manual treatment of corner cases. If 'isnan' returns assumed result, a user cannot use it in the manual treatment of NaNs and has to invent replacements, like making the check using integer operations. There is a discussion in https://reviews.llvm.org/D18513#387418, which also expresses the opinion, that limitations imposed by '-ffast-math' should be applied only to 'math' functions but not to 'tests'. To overcome these drawbacks, this change introduces a new IR intrinsic function 'llvm.isnan', which realizes the check as specified by IEEE-754 and C standards in target-agnostic way. During IR transformations it does not undergo undesirable optimizations. It reaches instruction selection, where is lowered in target-dependent way. The lowering can vary depending on options like '-ffast-math' or '-ffp-model' so the resulting code satisfies requested semantics. Differential Revision: https://reviews.llvm.org/D104854
-
Andre Vieira authored
Differential Revision: https://reviews.llvm.org/D107376
-
Sjoerd Meijer authored
This adds support for specialising recursive functions. For example: int Global = 1; void recursiveFunc(int *arg) { if (*arg < 4) { print(*arg); recursiveFunc(*arg + 1); } } void main() { recursiveFunc(&Global); } After 3 iterations of function specialisation, followed by inlining of the specialised versions of recursiveFunc, the main function looks like this: void main() { print(1); print(2); print(3); } To support this, the following has been added: - Update the solver and state of the new specialised functions, - An optimisation to propagate constant stack values after each iteration of function specialisation, which is necessary for the next iteration to recognise the constant values and trigger. Specialising recursive functions is (at the moment) controlled by option -func-specialization-max-iters and is opt-in for compile-time reasons. I.e., the default is -func-specialization-max-iters=1, but for the example above we would need to use -func-specialization-max-iters=3. Future work is to see if we can increase the default, or improve the cost-model/heuristics to control compile-times. Differential Revision: https://reviews.llvm.org/D106426 -
Senran Zhang authored
This allows users accessing options in libSupport before invoking `cl::ParseCommandLineOptions`, and also matches the behavior before D105959. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D106334
-
Adrian Kuegel authored
The dependency is needed after 1b00b94f Differential Revision: https://reviews.llvm.org/D107426
-
Esme-Yi authored
-
Stephen Neuendorffer authored
The existing vector transforms reduce the dimension of transfer_read ops. However, beyond a certain point, the vector op actually has to be reduced to a scalar load, since we can't load a zero-dimension vector. This handles this case. Note that in the longer term, it may be preferaby to support zero-dimension vectors. see https://llvm.discourse.group/t/should-we-have-0-d-vectors/3097. Differential Revision: https://reviews.llvm.org/D103432
-
hsmahesha authored
While collecting reachable callees (from kernels), ignore call graph node which does not have associated function or associated function is not a definition. Reviewed By: rampitec Differential Revision: https://reviews.llvm.org/D107329
-
Senran Zhang authored
Constant::getSplatValue has O(N) time complexity in the worst case, where N is the # of elements in a vector. So we call Constant::getAggregateElement first and return earlier if possible to avoid unnecessary getSplatValue calls. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D107252
-
Matthias Springer authored
This test ensures that an error is generated from the Python side when running a module pass on a function. The test used to instantiate ViewOpGraph, however, this pass was changed into a general "any op" pass in D106253. Therefore, a different pass must be used in this test. Differential Revision: https://reviews.llvm.org/D107424
-
Heejin Ahn authored
- Rename `wasm.catch` intrinsic to `wasm.catch.exn`, because we are planning to add a separate `wasm.catch.longjmp` intrinsic which returns two values. - Rename several variables - Remove an unnecessary parameter from `canLongjmp` and `isEmAsmCall` from LowerEmscriptenEHSjLj pass - Add `-verify-machineinstrs` in a test for a safety measure - Add more comments + fix some errors in comments - Replace `std::vector` with `SmallVector` for cases likely with small number of elements - Renamed `EnableEH`/`EnableSjLj` to `EnableEmEH`/`EnableEmSjLj`: We are soon going to add `EnableWasmSjLj`, so this makes the distincion clearer Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D107405
-
Arthur Eubanks authored
Previously we would emit constant pool entries for ldr inline asm at the very end of AsmPrinter::doFinalization(). However, if we're emitting dwarf aranges, that would end all sections with aranges. Then if we have constant pool entries to be emitted in those same sections, we'd hit an assert that the section has already been ended. We want to emit constant pool entries before emitting dwarf aranges. This patch splits out arm32/64's constant pool entry emission into its own MCTargetStreamer virtual method. Fixes PR51208 Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D107314
-
Matthias Springer authored
* New pass option `max-label-len`: Truncate attributes/result types that have more #chars. * New pass option `print-attrs`: Activate/deactivate rendering of attributes. * New pass option `printResultTypes`: Activate/deactivate rendering of result types. Differential Revision: https://reviews.llvm.org/D106337
-
Vitaly Buka authored
Followup for D105522 Differential Revision: https://reviews.llvm.org/D107398
-
Jacob Hegna authored
-
Matthias Springer authored
* Visualize blocks and regions as subgraphs. * Generate DOT file directly instead of using `GraphTraits`. `GraphTraits` does not support subgraphs. Differential Revision: https://reviews.llvm.org/D106253
-
Christian Kandeler authored
This is needed for clients that want to highlight virtual functions differently. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D107145
-
Aart Bik authored
Also makes style consistent with the "surrounding" text that appears on one webpage in MLIR doc Reviewed By: grosul1 Differential Revision: https://reviews.llvm.org/D107418
-
Vitaly Buka authored
Similar to qsort, bsearch can be called from non-instrumented code of glibc. When it happends tls for arguments can be in uninitialized state. Unlike to qsort, bsearch does not move data, so we don't need to check or initialize searched memory or key. Intrumented comparator will do that on it's own. Differential Revision: https://reviews.llvm.org/D107387
-
Jessica Paquette authored
This allows us to handle the s88 G_SELECTS: https://godbolt.org/z/5s18M4erY Weird types like this can result in weird merges. Widening to s128 first and then clamping down avoids that situation. Differential Revision: https://reviews.llvm.org/D107415
-
Matthias Springer authored
Insertion point should be set before creating new operations. Differential Revision: https://reviews.llvm.org/D107326
-
wlei authored
This change tried to integrate a new count based aggregated type of perf script. The only difference of the format is that an aggregated count is added at the head of the original sample which means the same samples are repeated to the given count times. This is used to reduce the perf script size. e.g. ``` 2 4005dc 400634 400684 7f68c5788793 0x4005c8/0x4005dc/P/-/-/0 .... ``` Implemented by a dedicated PerfReader `AggregatedHybridPerfReader`. Differential Revision: https://reviews.llvm.org/D107192
-
Rob Suderman authored
We can propagate the shape from tosa.cond_if operands into the true/false regions then through the connected blocks. Then, using the tosa.yield ops we can determine what all possible return types are. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D105940
-
Dan Liew authored
On macOS the unit tests currently rely on libmalloc being used for allocations (due to no functioning interceptors) but also having the ASan/TSan allocator initialized in the same process. This leads to crashes with the macOS 12.0 libmalloc nano allocator so disable use of the allocator while running unit tests as a workaround. rdar://80086125 Differential Revision: https://reviews.llvm.org/D107412
-
Rob Suderman authored
Handles shape inference for identity, cast, and rescale. These were missed during the initialy elementwise work. This includes resize shape propagation which includes both attribute and input type based propagation. Reviewed By: jpienaar Differential Revision: https://reviews.llvm.org/D105845
-
Shimin Cui authored
Currently, in OptimizeGlobalAddressOfMalloc, the transformation for global loads assumes that they have the same Type. With the support of ConstantExpr (https://reviews.llvm.org/D106589), this may not be true any more (as seen in the test case), and we miss the code to handle this, This is to fix that. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D107397
-
Michael Kruse authored
-
Aart Bik authored
Indentation seems to have an impact on website layout. Reviewed By: grosul1 Differential Revision: https://reviews.llvm.org/D107403
-
Roman Lebedev authored
-
Roman Lebedev authored
-
Craig Topper authored
This transform has been restricted to legal types since https://reviews.llvm.org/rG65df808f6254617b9eee931d00e95d900610b660 in 2012. This is particularly restrictive on RISCV64 which only has i64 as a legal integer type. i32 is a very common type in code generated from C, but we won't form a lookup table with it. This also effects other common types like i8/i16 types on ARM, AArch64, RISCV, etc. This patch proposes to allow power of 2 types larger than 8 bit, if they will fit in the largest legal integer type in DataLayout. These types are common in C code so generally well handled in the backends. We could probably do this for other types like i24 and rely on alignment and padding to allow the backend to use a single wider load. This isn't my main concern right now and it will need more tests. We could also allow larger types up to some limit and let the backend split into multiple loads, but we need to define that limit. It's also not my main concern right now. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D107233
-
Jeffrey Tan authored
VScode now sends a "scopes" DAP request immediately after any expression evaluation. This scopes request would clear and invalidate any non-scoped expandable variables in g_vsc.variables, causing later "variables" request to return empty result. The symptom is that any expandable variables in VScode watch window/debug console UI to return empty content. This diff fixes this issue by only clearing the expandable variables at process continue time. To achieve this, we have to repopulate all scoped variables during context switch for each "scopes" request without clearing global expandable variables. So the PR puts the scoped variables into its own locals/globals/registers; and all expandable variables into separate "expandableVariables" list. Also, instead of using the variable index for "variableReference", it generates a new variableReference id each time as the key of "expandableVariables". As a further new feature, this PR adds a new "expandablePermanentVariables" which has the lifetime of debug session. Any expandable variables from debug console are added into this list. This enables users to snapshot expanable old variable in debug console and compare with new variables if desire. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D105166
-
River Riddle authored
This prevents an explosion of threads, given that each file gets its own context and thus its own thread pool. We don't really need a thread pool for the LSP contexts anyways, so it's better to just disable threading.
-
Aart Bik authored
Reviewed By: bixia Differential Revision: https://reviews.llvm.org/D107379
-
Matheus Izvekov authored
See PR48656. The implementation of the template instantiation of requires expressions was incorrectly trying to get the expression from an 'ExprRequirement' before checking if it was an error state. Signed-off-by:
Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D107399
-
Evandro Menezes authored
Add the scheduling resources for the V extension instructions. Differential Revision: https://reviews.llvm.org/D98002
-
Matheus Izvekov authored
See PR47174. When canonicalizing nested name specifiers of the type kind, the prefix for 'DependentTemplateSpecialization' types was being dropped, leading to malformed types which would cause failures when rebuilding template names. Signed-off-by:
Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D107311
-
modimo authored
Results from Clang self-build: {F17435948} Testing: ninja check-all Reviewed By: anton-afanasyev Differential Revision: https://reviews.llvm.org/D104428 -
Alexey Bataev authored
If the vectorized insertelements instructions form indentity subvector (the subvector at the beginning of the long vector), it is just enough to extend the vector itself, no need to generate inserting subvector shuffle. Differential Revision: https://reviews.llvm.org/D107344
-
Nico Weber authored
LLVM includes this header unconditionally on all platforms (including Windows), so this define should no longer be necessary. No behavior change. Differential Revision: https://reviews.llvm.org/D107338
-