Commit Graph

4164 Commits

Author SHA1 Message Date
Michael Kruse e2d4b02404 [Polly][ScopInliner] Indicate if the IR has changed.
Return true to indicate that the IR has changed if the nested pass
manager has changed it.

Fixes the ScopInliner tests in the LLVM_ENABLE_EXPENSIVE_CHECKS=ON
configuration.

Thanks to Alexandre Ganea for reporting.
2021-06-24 15:44:39 -05:00
Michael Kruse 84046ebd95 [Polly] Fix test after D104732.
The SCEV analysis has been improved to identify a write access as a MustWrite.
2021-06-23 14:59:53 -05:00
patacca 2a629efc74 [Polly][Isl] Refactoring IslAstInfo::getBuild() and IslAstInfo::IslAstUserPayload::Build to use isl++. NFC
Polly uses algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring the method `IslAstInfo::getBuild()`
 - `IslAstInfo::IslAstUserPayload.Build` now uses C++ types instead of C types
 - Removing destructor of `IslAstInfo::IslAstUserPayload`

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D104370
2021-06-18 09:53:51 +02:00
Bjorn Pettersson 6aac2773d8 [polly][GPGPU] Fixup related to overloading exponent type in llvm.powi
Commit 4c7f820b2b changed the llvm.powi intrinsic to support
different 'int' sizes for the exponent. That happened to break
the IntrinsicToLibdeviceFunc mapping in PPCGCodeGeneration, which
obviously should have been updated as part of commit 4c7f820b2b
(https://reviews.llvm.org/D99439).

The shortcoming was found by buildbots that use
   -DPOLLY_ENABLE_GPGPU_CODEGEN=ON

This patch should fixup the problem.
2021-06-18 08:59:06 +02:00
patacca cfe117def7 [Polly][Isl] Replacing isl method `to_str()` with `stringFromIslObj()`. NFC.
This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 - Removing method `to_str()` from all the classes in the isl C++ bindings.
 - Overload method `stringFromIslObj()` so it accepts isl C++ objects.
 - To keep backward compatibility `stringFromIslObj()` now accepts a value that is returned if the isl C object is `null` or doesn't have a string representation (by default it's an empty string). In some cases it's better to have the string "null" instead of an empty string.
 - isl-noexceptions.h has been generated by this d33ec3a3bb

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D104211
2021-06-15 14:22:10 +02:00
patacca 7c7978a122 [Polly][Isl] Removing explicit operator bool() from isl C++ bindings. NFC.
This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 - Removing explicit operator bool() from all the classes in the isl C++ bindings.
 - Replace each call to operator bool() to method `is_null()`.
 - isl-noexceptions.h has been generated by this 27396daac5

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D103976
2021-06-11 14:44:24 +02:00
Michael Kruse a56bd7dec8 [Polly][Matmul] Re-pack A in every iteration.
Packed_A must be copied repeatedly, not just for the first iteration of
the outer tile.

This fixes llvm.org/PR50557
2021-06-09 15:19:52 -05:00
patacca 9b41d0958e [Polly][Isl] Removing nullptr constructor from C++ bindings. NFC.
[Polly][Isl] Removing nullptr constructor from C++ bindings. NFC.

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 - Removed `std::nullptr_t` constructor from all the classes in the isl C++ bindings.
 - `isl-noexceptions.h` has been generated by this a7e00bea38

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D103751
2021-06-08 23:46:28 +02:00
patacca f60ea691a9 Revert "[Polly][Isl] Removing nullptr constructor from C++ bindings. NFC."
This reverts commit be5e2fc7bf.

This introduced a building error for polly. https://lab.llvm.org/buildbot#builders/10/builds/4951
2021-06-08 17:12:10 +02:00
patacca be5e2fc7bf [Polly][Isl] Removing nullptr constructor from C++ bindings. NFC.
[Polly][Isl] Removing nullptr constructor from C++ bindings. NFC.

This is part of an effort to reduce the differences between the custom C++ bindings used right now by polly in `lib/External/isl/include/isl/isl-noxceptions.h` and the official isl C++ interface.

Changes made:
 - Removed `std::nullptr_t` constructor from all the classes in the isl C++ bindings.
 - `isl-noexceptions.h` has been generated by this a7e00bea38

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D103751
2021-06-08 15:28:20 +02:00
Michael Kruse d123e983b3 [Polly] Move MatMul optimization into its own file. NFC.
Functions shared between generalized matrix-multiplication optimization
and other post-reschedule optimizations (tiling, prevect) are moved into
the schedule tree transformation utility ScheduleTreeTransform.
2021-06-04 23:22:30 -05:00
Eli Friedman fd229caa01 [polly] Fix SCEVLoopAddRecRewriter to avoid invalid AddRecs.
When we're remapping an AddRec, the AddRec constructed by a partial
rewrite might not make sense.  This triggers an assertion complaining
it's not loop-invariant.

Instead of constructing the partially rewritten AddRec, just skip
straight to calling evaluateAtIteration.

Testcase was automatically reduced using llvm-reduce, so it's a little
messy, but hopefully makes sense.

Differential Revision: https://reviews.llvm.org/D102959
2021-06-01 09:51:05 -07:00
serge-sans-paille 4ab3041acb Revert "[NFC] remove explicit default value for strboolattr attribute in tests"
This reverts commit bda6e5bee0.

See https://lab.llvm.org/buildbot/#/builders/109/builds/15424 for instance
2021-05-24 19:43:40 +02:00
serge-sans-paille bda6e5bee0 [NFC] remove explicit default value for strboolattr attribute in tests
Since d6de1e1a71, no attributes is quivalent to
setting attribute to false.

This is a preliminary commit for https://reviews.llvm.org/D99080
2021-05-24 19:31:04 +02:00
Michael Kruse 86008477a4 [Polly] Avoid compiler warning. NFC.
Avoid the warning

    /polly/lib/Support/RegisterPasses.cpp:833:3: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
      default:
      ^

since all cases are now handled.

Thanks to Luke Benes for reporting.
2021-05-22 00:21:20 -05:00
Michael Kruse ad568f4286 [Polly] Add support for -polly-dump-after(-file) with the NPM.
For the same reason as with -polly-dump-before, it is only supported
with -polly-position=early.
2021-05-17 22:20:47 -05:00
Michael Kruse 29bef8e4e3 [Polly] Add support for -polly-dump-before(-file) with the NPM.
Only supported with -polly-position=early. Unfortunately, the
extension point callpack for VectorizerStart only passes a
FunctionPassManager, making it impossible to add a module pass.
2021-05-17 20:58:37 -05:00
Michael Kruse fb01b1461a [Polly] Run polly-update-format. NFC.
Thanks to Leonard Chan for reporting.
2021-05-14 16:23:36 -05:00
Michael Kruse 5aafcb2b44 [Polly] Add support for -polly-position=early with the NPM.
This required support for the canonicalization passes, inlcuding
porting RewriteByReferenceParams to the NPM.

For some reason, the legacy pass pipeline with -polly-position=early did
not run the CodePreparation pass. This was fixed as well.
2021-05-14 12:55:03 -05:00
Arthur Eubanks 34a8a437bf [NewPM] Hide pass manager debug logging behind -debug-pass-manager-verbose
Printing pass manager invocations is fairly verbose and not super
useful.

This allows us to remove DebugLogging from pass managers and PassBuilder
since all logging (aside from analysis managers) goes through
instrumentation now.

This has the downside of never being able to print the top level pass
manager via instrumentation, but that seems like a minor downside.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D101797
2021-05-07 21:51:47 -07:00
Fangrui Song d8aba75a76 Internalize some cl::opt global variables or move them under namespace llvm 2021-05-07 11:15:43 -07:00
Bjorn Pettersson 3ee826594a Make dependency between certain analysis passes transitive (reapply)
LazyBlockFrequenceInfoPass, LazyBranchProbabilityInfoPass and
LoopAccessLegacyAnalysis all cache pointers to their nestled required
analysis passes. One need to use addRequiredTransitive to describe
that the nestled passes can't be freed until those analysis passes
no longer are used themselves.

There is still a bit of a mess considering the getLazyBPIAnalysisUsage
and getLazyBFIAnalysisUsage functions. Those functions are used from
both Transform, CodeGen and Analysis passes. I figure it is OK to
use addRequiredTransitive also when being used from Transform and
CodeGen passes. On the other hand, I figure we must do it when
used from other Analysis passes. So using addRequiredTransitive should
be more correct here. An alternative solution would be to add a
bool option in those functions to let the user tell if it is a
analysis pass or not. Since those lazy passes will be obsolete when
new PM has conquered the world I figure we can leave it like this
right now.

Intention with the patch is to fix PR49950. It at least solves the
problem for the reproducer in PR49950. However, that reproducer
need five passes in a specific order, so there are lots of various
"solutions" that could avoid the crash without actually fixing the
root cause.

This is a reapply of commit 3655f0757f, that was reverted in
33ff3c2049 due to problems with assertions in the polly
lit tests. That problem is supposed to be solved by also adjusting
ScopPass to explicitly preserve LazyBlockFrequencyInfo and
LazyBranchProbabilityInfo (it already preserved
OptimizationRemarkEmitter which depends on those lazy passes).

Differential Revision: https://reviews.llvm.org/D100958
2021-05-05 15:17:55 +02:00
Jennifer Chukwu c5c7a493ef Fixed Typos
Fixed typo errors in release notes of Polly 13

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D100588
2021-04-28 08:55:03 +05:30
Michael Kruse 286677870b [Polly][ManualOpt] Match interpretation of unroll metadata to LoopUnrolls's.
We previously had a different interpretation of unroll transformation
attributes than how LoopUnroll interpreted it. In particular,
llvm.loop.unroll.enable was needed explicitly to enable it and disabling
metadata was ignored.
Additionally, it required that either full unrolling or an unroll factor
to be specified or fail otherwise. An unroll factor is still required,
but the transformation is ignored with the hope that LoopUnroll is going
to apply the unrolling, since Polly currently does not implement an
heuristic.

Fixes llvm.org/PR50109
2021-04-24 04:30:19 -05:00
Fangrui Song a7b7e7b187 [Polly] Fix stage 2 clang -Wdeprecated-copy after D79714 2021-04-24 00:56:23 -07:00
Krzysztof Parzyszek a7f33d720b [Polly] Explicitly include all std headers
There were some recent header changes, and now some std classes
are no longer available in ScopDetection.cpp with the pre-existing
includes.
2021-04-21 12:52:11 -05:00
Michael Kruse 89b59345ee [PollyACC] Fix declaration/stub definition mismatch. NFC.
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
2021-04-21 11:52:43 -05:00
Michael Kruse 6048d1d19c [PollyACC] Configure PollyPPCG only if needed.
The PollyPPCG library is only needed when POLLY_ENABLE_GPGPU_CODEGEN=ON.
If disabled, the library target is still created, but not linked against
anything.

This change does not add create the PollyPPCG build target if not
needed.

Motivated by llvm.org/PR50021
2021-04-21 01:08:01 -05:00
Michael Kruse 90e5ce0b0d [PollyACC] Fix implicit function definitions. NFC.
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
2021-04-21 01:08:00 -05:00
Roman Lebedev 2aff4f7f57
[polly] Fix check-polly after SCEVExpander PtrToInt fixes 2021-04-19 19:10:55 +03:00
patacca 4170d6cdd5 [Polly][Ast] Partial refactoring of IslAst and IslAstInfo to use isl++. NFC.
Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring the following methods of class `IslAst`
  - `getAst()` `getRunCondition()` `buildRunCondition()`
  - Removed the destructor in favor of the default one
 - Change the type of the attribute `IslAst.RunCondition` to `isl::ast_expr`
 - Change the type of the attribute `IslAst.Root` to `isl::ast_node`
 - Change the order of attributes in class `IslAst` to reflect the data dependencies so that the destructor won't complain
 - Refactoring the following methods of class `IslAstInfo`
  - `getAst()` `getRunCondition()`

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D100265
2021-04-16 00:40:26 -05:00
Fangrui Song acf7e55783 [Polly] Fix PM invalidate usage after D100519 2021-04-15 18:41:20 -07:00
Hamza Sood 0a92aff721 Replace uses of std::iterator with explicit using
This patch removes all uses of `std::iterator`, which was deprecated in C++17.
While this isn't currently an issue while compiling LLVM, it's useful for those using LLVM as a library.

For some reason there're a few places that were seemingly able to use `std` functions unqualified, which no longer works after this patch. I've updated those places, but I'm not really sure why it worked in the first place.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D67586
2021-04-12 10:47:14 -07:00
patacca 82fbc5d45b [Polly] Partially refactoring of IslAstInfo and IslNodeBuilder to use isl++. NFC.
Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring the following methods of class IslAstInfo
   - isParallel() isExecutedInParallel() isReductionParallel() getSchedule() getMinimalDependenceDistance() getBrokenReductions()
 - Refactoring the following methods of class IslNodeBuilder
   - getReferencesInSubtree() getScheduleForAstNode()
 - Refactoring function getBrokenReductionsStr()
 - Fixed the mismatching function declaration for getScheduleForAstNode()

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D99971
2021-04-10 21:28:02 -05:00
Abhina Sreeskantharajan 82b3e28e83 [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text
Problem:
On SystemZ we need to open text files in text mode. On Windows, files opened in text mode adds a CRLF '\r\n' which may not be desirable.

Solution:
This patch adds two new flags

  - OF_CRLF which indicates that CRLF translation is used.
  - OF_TextWithCRLF = OF_Text | OF_CRLF indicates that the file is text and uses CRLF translation.

Developers should now use either the OF_Text or OF_TextWithCRLF for text files and OF_None for binary files. If the developer doesn't want carriage returns on Windows, they should use OF_Text, if they do want carriage returns on Windows, they should use OF_TextWithCRLF.

So this is the behaviour per platform with my patch:

z/OS:
OF_None: open in binary mode
OF_Text : open in text mode
OF_TextWithCRLF: open in text mode

Windows:
OF_None: open file with no carriage return
OF_Text: open file with no carriage return
OF_TextWithCRLF: open file with carriage return

The Major change is in llvm/lib/Support/Windows/Path.inc to only set text mode if the OF_CRLF is set.
```
  if (Flags & OF_CRLF)
    CrtOpenFlags |= _O_TEXT;
```

These following files are the ones that still use OF_Text which I left unchanged. I modified all these except raw_ostream.cpp in recent patches so I know these were previously in Binary mode on Windows.
./llvm/lib/Support/raw_ostream.cpp
./llvm/lib/TableGen/Main.cpp
./llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
./llvm/unittests/Support/Path.cpp
./clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
./clang/lib/Frontend/CompilerInstance.cpp
./clang/lib/Driver/Driver.cpp
./clang/lib/Driver/ToolChains/Clang.cpp

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D99426
2021-04-06 07:23:31 -04:00
patacca 812ce7f9be [Polly] Refactoring isInnermost() from isl to use the C++ wrapper
Polly use algorithms from the Integer Set Library (isl), which is a library written in C and which is incompatible with the rest of the LLVM as it is written in C++.

Changes made:
 - Refactoring isInnermost() to take C++ bindings instead of the plain isl C api.
 - Addition of manage_copy() when needed to get the reference for the isl_ast_node object

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D99841
2021-04-05 21:16:52 -05:00
David Blaikie 30df6d5d6a Preprocessor conditionalize some assert-only functions to suppress -Wunused-function 2021-04-03 14:03:43 -07:00
Fangrui Song 927050af53 [Polly] Fix -Wunused-function in -DLLVM_ENABLE_ASSERTIONS=off builds 2021-03-24 19:56:43 -07:00
Nikita Popov 7d91d81c6b [polly] Fix build
This produced a compile error with GCC:

llvm-project/polly/lib/Transform/ScheduleOptimizer.cpp:1220:49: error: cannot convert ‘bool’ to ‘llvm::TargetTransformInfo::RegisterKind’
 1220 |     RegisterBitwidth = TTI->getRegisterBitWidth(true);
2021-03-24 17:46:46 +01:00
Michael Kruse 40653c8bb9 [Polly][DCE] clang-format DeadCodeElimination.h. NFC.
The targets polly-update-format and check-polly-format process new files
only after running cmake again. This is why it was missed in the last
commit.
2021-03-24 09:33:14 -05:00
Michael Kruse 8796451d6e [Polly] Port DeadCodeElim to the NewPM. 2021-03-24 01:01:29 -05:00
Michael Kruse 5f58aae8f3 [Polly][CodeGen] Allow nesting of BandAttr mark without loop.
BandAttr markers are added as parents of schedule tree bands. These also
appear as markers its equivalent AST, but a band does not necessarily
corresponds to a loop in this. Iterations may be peeled or the loop
being unrolled (e.g. if it has just one iteration). In such cases it may
happend that there is not loop between a BandAttr marker and the marker
for a loop nested in the former parent band/loop.

Handle the situation by giving priority to the inner marker over the
outer.

Fixes the polly-x86_64-linux-test-suite buildbot.
2021-03-16 16:17:07 -05:00
Michael Kruse f51427afb5 [Polly][Unroll] Fix unroll_double test.
We enumerated the cross product Domain x Scatter, but sorted only be the
scatter key. In case there are are multiple statement instances per
scatter value, the order between statement instances of the same loop
iteration was undefined.

Propertly enumerate and sort only by the scatter value, and group the
domains using the scatter dimension again.

Thanks to Leonard Chan for the report.
2021-03-16 09:00:42 -05:00
Michael Kruse 9c486eb348 [Polly] Fix deprecation warning. NFC.
IRBuilder::CreateLoad without type parameter was deprecated in 6312c538
to prepare for opaque pointers.
2021-03-15 14:31:16 -05:00
Michael Kruse 3f170eb197 [Polly][Optimizer] Apply user-directed unrolling.
Make Polly look for unrolling metadata (https://llvm.org/docs/TransformMetadata.html#loop-unrolling) that is usually only interpreted by the LoopUnroll pass and apply it to the SCoP's schedule.

While not that useful by itself (there already is an unroll pass), it introduces mechanism to apply arbitrary loop transformation directives in arbitrary order to the schedule. Transformations are applied until no more directives are found. Since ISL's rescheduling would discard the manual transformations and it is assumed that when the user specifies the sequence of transformations, they do not want any other transformations to apply. Applying user-directed transformations can be controlled using the `-polly-pragma-based-opts` switch and is enabled by default.

This does not influence the SCoP detection heuristic. As a consequence, loop that do not fulfill SCoP requirements or the initial profitability heuristic will be ignored. `-polly-process-unprofitable` can be used to disable the latter.

Other than manually editing the IR, there is currently no way for the user to add loop transformations in an order other than the order in the default pipeline, or transformations other than the one supported by clang's LoopHint. See the `unroll_double.ll` test as example that clang currently is unable to emit. My own extension of `#pragma clang loop` allowing an arbitrary order and additional transformations is available here: https://github.com/meinersbur/llvm-project/tree/pragma-clang-loop. An effort to upstream this functionality as `#pragma clang transform` (because `#pragma clang loop` has an implicit transformation order defined by the loop pipeline) is D69088.

Additional transformations from my downstream pragma-clang-loop branch are tiling, interchange, reversal, unroll-and-jam, thread-parallelization and array packing. Unroll was chosen because it uses already-defined metadata and does not require correctness checks.

Reviewed By: sebastiankreutzer

Differential Revision: https://reviews.llvm.org/D97977
2021-03-15 13:05:39 -05:00
Kevin Zhou b7df372cdc [Polly] Refactoring astScheduleDimIsParallel to take the C++ wrapper object. NFC
Polly currently needs to be slowly refactor to use the C++ wrapper objects to handle the reference counters automatically.
I took the function of astScheduleDimIsParallel and refactored it so that it uses the C++ wrapper function as much as possible.

There are some problems with the IsParallel since it expects the C objects, so the C++ wrapper functions must be .release() and .get() first before they are able to be used with IsParallel.

When checking the ReductionDependencies Parallelism with the Build's Schedule, I opted to keep the union map as a C object rather than a C++ object. Eventually, changes will need to be made to IsParallel to refactor it to the C++ wrappers. When this is done, this function will also need to be slightly refactored to not use the C object.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D98455
2021-03-15 12:08:50 -05:00
Roman Lebedev 78b8ce40ef
Reland [SCEV] Improve modelling for (null) pointer constants
This reverts commit 329aeb5db4,
and relands commit 61f006ac65.

This is a continuation of D89456.

As it was suggested there, now that SCEV models `PtrToInt`,
we can try to improve SCEV's pointer handling.
In particular, i believe, i will need this in the future
to further fix `SCEVAddExpr`operation type handling.

This removes special handling of `ConstantPointerNull`
from `ScalarEvolution::createSCEV()`, and add constant folding
into `ScalarEvolution::getPtrToIntExpr()`.
This way, `null` constants stay as such in SCEV's,
but gracefully become zero integers when asked.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D98147
2021-03-13 16:05:34 +03:00
Roman Lebedev 329aeb5db4
Temporairly evert "[SCEV] Improve modelling for (null) pointer constants"
This appears to have broken ubsan bot:
https://lab.llvm.org/buildbot/#/builders/85/builds/3062
https://reviews.llvm.org/D98147#2623549

It looks like LSR needs some kind of a change around insertion point handling.
Reverting until i have a fix.

This reverts commit 61f006ac65.
2021-03-13 09:10:28 +03:00
Nikita Popov 42eb658f65 [OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC)
This removes some (but not all) uses of type-less CreateGEP()
and CreateInBoundsGEP() APIs, which are incompatible with opaque
pointers.

There are a still a number of tricky uses left, as well as many
more variation APIs for CreateGEP.
2021-03-12 21:01:16 +01:00
Roman Lebedev 61f006ac65
[SCEV] Improve modelling for (null) pointer constants
This is a continuation of D89456.

As it was suggested there, now that SCEV models `PtrToInt`,
we can try to improve SCEV's pointer handling.
In particular, i believe, i will need this in the future
to further fix `SCEVAddExpr`operation type handling.

This removes special handling of `ConstantPointerNull`
from `ScalarEvolution::createSCEV()`, and add constant folding
into `ScalarEvolution::getPtrToIntExpr()`.
This way, `null` constants stay as such in SCEV's,
but gracefully become zero integers when asked.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D98147
2021-03-12 22:11:58 +03:00