184 Commits

Author SHA1 Message Date
Matt Arsenault
c91cbafad2
TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (#145826)
It should not be possible to construct one without a triple. It would
also be nice to delete TargetLibraryInfoWrapperPass, but that is more
difficult.
2025-06-26 16:12:36 +09:00
Eli Friedman
9f82ac5738
Remove GlobalObject::getAlign/setAlignment (#143188)
Currently, GlobalObject has an "alignment" property... but it's
basically nonsense: alignment doesn't mean the same thing for variables
and functions, and it's completely meaningless for ifuncs.

This "removes" (actually marking protected) the methods from
GlobalObject, adds the relevant methods to Function and GlobalVariable,
and adjusts the code appropriately.

This should make future alignment-related cleanups easier.
2025-06-09 13:51:03 -07:00
Walter Lee
1d338a0b9a
Wrap ifndef NDEBUG around assertion-only code (#142227)
Otherwise we get unused variable warnings.
2025-05-30 19:48:20 -04:00
vporpo
a2b5fd7f6e
[SandboxIR][Region] Auxiliary vector metadata now requires a region (#137443)
The auxiliary vector is represented by the !sandboxaux metadata. But
until now adding an instruction to the aux vector would not
automatically add it to the region (i.e., it would not mark it with
!sandboxvec). This behavior was problematic when generating regions from
metadata, because you wouldn't know which region owns the auxiliary
vector.

This patch fixes this issue: We now require that an instruction with
!sandboxaux also defines its region with !sandboxvec.
2025-05-27 16:11:13 -07:00
vporpo
b81947e589
[SandboxIR] Implement ConstantDataVector member functions (#136200)
Mirroring LLVM IR.
2025-04-25 21:09:07 -07:00
vporpo
a0b2a95226
[SandboxIR] Implement ConstantDataArray functions (#134729)
Mirrors LLVM IR.
2025-04-17 14:03:49 -07:00
Yingwei Zheng
dffef041d5
[IR][ADT] Remove APFloat/Type::isIEEE (#130496)
Address comment
https://github.com/llvm/llvm-project/pull/130477#issuecomment-2708801892.
2025-04-14 17:03:39 +08:00
vporpo
3756ba3c87
[SandboxIR] Implement ConstantDataSequential and subclasses (#133547)
This patch implements sandboxir::ConstantDataSequential mirroring LLVM
IR.
2025-04-07 13:48:30 -07:00
Yingwei Zheng
b6c0ce0bb6
[IR][NFC] Use SwitchInst::defaultDestUnreachable (#134199) 2025-04-03 14:47:47 +08:00
vporpo
bb047b9ea3
[SandboxIR] Implement missing ConstantVector member functions (#131390)
This patch implements get(), getSplat(), getSplatValue() and getType(),
mirroring LLVM IR.
2025-03-28 17:23:18 -07:00
Vasileios Porpodas
214d47af9b [SandboxVec][PassManager][NFC] Fix PM printing
It currently prints '(' instead of '<'. This patch fixes it.
2025-03-13 17:09:13 -07:00
vporpo
d2cbd5fe6b
[SandboxIR][Region][NFC] Change visibility of Region::add()/remove() (#129277)
The vectorizer's passes should not be allowed to manually add/remove
elements. This should only be done automatically by the callbacks.
2025-02-28 14:03:23 -08:00
vporpo
1987f93d03
[SandboxIR] OpaqueValue (#127699)
This patch implements a new subclass of the Value class used for Sandbox
IR Values that we don't support, like metadata or inline asm. The goal
is to never have null sandboxir::Value objects, because this is not the
expected behavior.
2025-02-19 11:54:44 -08:00
vporpo
5ecce45ea2
[SandboxVec] Move seed collection into its own separate pass (#127132)
This patch moves the seed collection logic from the BottomUpVec pass
into a new Sandbox IR Function pass. The new "seed-collection" pass
collects the seeds, builds a region and runs the region pass pipeline.
2025-02-18 11:11:07 -08:00
vporpo
0931a2a5a2
[SandboxIR] SetUse callback (#126985)
This patch implements a callback mechanism similar to the existing ones,
but for getting notified whenever a Use edge gets updated. This is going
to be used in a follow up patch by the Dependency Graph.
2025-02-14 11:26:21 -08:00
NAKAMURA Takumi
0ec1693359 SandboxIRTests: Use EXPECT_DEBUG_DEATH (for #126376) 2025-02-14 04:12:11 +00:00
vporpo
c9ba2b08d5
[SandboxIR][Region] Implement an auxiliary vector in Region (#126376)
This patch adds additional functionality to the sandboxir Region. The
Region is used as a way of passing a set of Instructions across region
passes in a way that can be represented in the IR with metadata. This is
a design choice that allows us to test region passes in isolation with
lit tests.

Up until now the region was only used to tag the instructions generated
by the passes. There is a need to represent an ordered set of
instructions, which can be used as a way to represent the initial seeds
to the first vectorization pass. This patch implements this auxiliary
vector that can be used to convey such information.
2025-02-13 13:51:55 -08:00
vporpo
69b8cf4f06
[SandboxVec][BottomUpVec] Add cost estimation and tr-accept-or-revert pass (#126325)
The TransactionAcceptOrRevert pass is the final pass in the Sandbox
Vectorizer's default pass pipeline. It's job is to check the cost
before/after vectorization and accept or revert the IR to its original
state.

Since we are now starting the transaction in BottomUpVec, tests that run
a custom pipeline need to accept the transaction. This is done with the
help of the TransactionAlwaysAccept pass (tr-accept).
2025-02-08 08:34:18 -08:00
vporpo
334a1cdbfa
[SandboxIR] createFunction() should always create a function (#124665)
This patch removes the assertion that checks for an existing function.
If one exists it will remove it and create a new one. This helps remove
a crash when a function declaration object already exists and we are
about to create a SandboxIR object for the definition.
2025-01-27 20:16:30 -08:00
vporpo
4b209c5d87
[SandboxIR][Region] Add cost modeling to the region (#124354)
This patch implements cost modeling for Region. All instructions that
are added or removed get their cost counted in the Scoreboard. This is
used for checking if the region before or after a transformation is more
profitable.
2025-01-24 14:28:55 -08:00
Mats Jun Larsen
830bd0e8f2
[SandboxIR] Remove sandboxir::PointerType::get(Type) (#123885)
This was just an alias for getting the LLVM Context from the type.

We are in the process of removing the same function for the regular LLVM
type in https://github.com/llvm/llvm-project/issues/123569
2025-01-22 16:19:33 +09:00
vporpo
22d4ff155a
[SandboxIR] Fix CmpInst::create() when it gets folded (#123408)
If the operands of a CmpInst are constants then it gets folded into a
constant. Therefore CmpInst::create() should return a Value*, not a
Constant* and should handle the creation of the constant correctly.
2025-01-17 14:37:29 -08:00
Jorge Gorbe Moya
b22c3c1e88
Register callbacks in Region for instruction creation/deletion. (#117088)
This will keep the current Region updated when region passes add/delete
instructions.
2024-11-21 09:58:51 -08:00
Jorge Gorbe Moya
3b8606be54
Re-land "[SandboxIR] Add debug checker to compare IR before/after a revert (#115968)" (#116671)
This PR re-lands https://github.com/llvm/llvm-project/pull/115968 with a
fix for a buildbot failure.

The `IRSnapshotChecker` class is only defined in debug mode, so its unit
tests must also be inside `#ifndef NDEBUG`.
2024-11-18 11:07:15 -08:00
Jorge Gorbe Moya
0ae58c4533
Revert "[SandboxIR] Add debug checker to compare IR before/after a revert" (#116666)
Reverts llvm/llvm-project#115968. It caused buildbot failures.
2024-11-18 09:54:43 -08:00
Jorge Gorbe Moya
9161e6ab74
[SandboxIR] Add debug checker to compare IR before/after a revert (#115968)
This will help us catch mistakes in change tracking. It's only enabled
when EXPENSIVE_CHECKS are enabled.
2024-11-18 09:39:13 -08:00
Jorge Gorbe Moya
9d85ba5724
[SandboxIR] Preserve the order of switch cases after revert. (#115577)
Preserving the case order is not strictly necessary to preserve
semantics (for example, operations like SwitchInst::removeCase will
happily swap cases around). However, I'm planning to introduce an
optional verification step for SandboxIR that will use StructuralHash to
compare IR after a revert to the original IR to help catch tracker bugs,
and the order difference triggers a difference there.
2024-11-12 14:10:46 -08:00
Jorge Gorbe Moya
12a8f504cf [SandboxIR] Use the proper gmock public header in unit tests.
This should fix the BuildKite bazel build.
2024-10-29 09:59:03 -07:00
Jorge Gorbe Moya
4df71ab78e
[SandboxIR] Add callbacks for instruction insert/remove/move ops (#112965) 2024-10-29 09:25:51 -07:00
vporpo
a461869db3
[SandboxIR][Pass] Implement Analyses class (#113962)
The Analyses class provides a way to pass around commonly used Analyses
to SandboxIR passes throught `runOnFunction()` and `runOnRegion()`
functions.
2024-10-28 18:00:52 -07:00
vporpo
a24a420c2b
[SandboxIR] Implement FPMathOperator (#112921)
This patch implements sandboxir::FPMathOperator mirroring
llvm::FPMathOperator
2024-10-18 10:02:16 -07:00
vporpo
54566ba523
[SandboxIR] Implement Operator (#112805)
This patch implements sandboxir::Operator mirroring llvm::Operator.
2024-10-18 08:14:14 -07:00
Jorge Gorbe Moya
2e8ad49e7c
[SandboxVec] Add pass to create Regions from metadata. Generalize SandboxVec pass pipelines. (#112288)
My previous attempt (#111904) hacked creation of Regions from metadata
into the bottom-up vectorizer. I got some feedback that it should be its
own pass. So now we have two SandboxIR function passes (`BottomUpVec`
and `RegionsFromMetadata`) that are interchangeable, and we could have
other SandboxIR function passes doing other kinds of transforms, so this
commit revamps pipeline creation and parsing.

First, `sandboxir::PassManager::setPassPipeline` now accepts pass
arguments in angle brackets. Pass arguments are arbitrary strings that
must be parsed by each pass, the only requirement is that nested angle
bracket pairs must be balanced, to allow for nested pipelines with more
arguments. For example:
```
    bottom-up-vec<region-pass-1,region-pass-2<arg>,region-pass-3>
```
This has complicated the parser a little bit (the loop over pipeline
characters now contains a small state machine), and we now have some new
test cases to exercise the new features.

The main SandboxVectorizerPass now contains a customizable pipeline of
SandboxIR function passes, defined by the `sbvec-passes` flag. Region
passes for the bottom-up vectorizer pass are now in pass arguments (like
in the example above).

Because we have now several classes that can build sub-pass pipelines,
I've moved the logic that interacts with PassRegistry.def into its own
files (PassBuilder.{h,cpp} so it can be easily reused.

Finally, I've added a `RegionsFromMetadata` function pass, which will
allow us to run region passes in isolation from lit tests without
relying on the bottom-up vectorizer, and a new lit test that does
exactly this.

Note that the new pipeline parser now allows empty pipelines. This is
useful for testing. For example, if we use
```
  -sbvec-passes="bottom-up-vec<>"
```
SandboxVectorizer converts LLVM IR to SandboxIR and runs the bottom-up
vectorizer, but no region passes afterwards.
```
  -sbvec-passes=""
```
SandboxVectorizer converts LLVM IR to SandboxIR and runs no passes on
it. This is useful to exercise SandboxIR conversion on its own.
2024-10-15 14:51:31 -07:00
Sterling-Augustine
f0909e3a99
[SandboxIR] Add utility function to find the base Value for Mem instructions (#112030) 2024-10-11 11:19:59 -07:00
Jorge Gorbe Moya
2aa1dbf9c9
[SandboxIR] Add a test for creating non-contiguous Regions. (#112027)
It checks that a Region can have non-contiguous instructions, and that
when iterating through it you don't get the instructions in-between that
aren't part of the Region.
2024-10-11 11:01:52 -07:00
Jorge Gorbe Moya
756ec99c36
[SandboxVec] Re-land "Use sbvec-passes flag to create a pipeline of Region passes after BottomUpVec. (#111223)" (#111772)
https://github.com/llvm/llvm-project/pull/111223 was reverted because of
a build failure with `-DBUILD_SHARED_LIBS=on`.

The Passes component depends on Vectorizer (because PassBuilder needs to
be able to instantiate SandboxVectorizerPass). This resulted in CMake
doing this

1. when it builds lib/libLLVMVectorize.so.20.0git it adds
lib/libLLVMSandboxIR.so.20.0git to the command line, because it's listed
as a dependency (as expected)
2. when it's trying to build lib/libLLVMPasses.so.20.0git it adds
lib/libLLVMVectorize.so.20.0git to the command line, because it's listed
as a dependency (also as expected). But not libLLVMSandboxIR.so.

When SandboxVectorizerPass has its ctors/dtors defined inline, this
caused "undefined reference to vtable" linker errors. This change works
around that by moving ctors/dtors out of line.

Also fix a bazel build problem by adding the new
`llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/PassRegistry.def`
as a textual header in the Vectorizer target.
2024-10-09 18:00:17 -07:00
Jorge Gorbe Moya
102c384b57
Revert "[SandboxVectorizer] Use sbvec-passes flag to create a pipeline of Region passes after BottomUpVec." (#111727)
Reverts llvm/llvm-project#111223

It broke one of the build bots:

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx
running on linaro-flang-aarch64-libcxx while building llvm at step 5
"build-unified-tree".

Full details are available at:
https://lab.llvm.org/buildbot/#/builders/89/builds/8127
2024-10-09 10:45:23 -07:00
Jorge Gorbe Moya
10ada4ae73
[SandboxVectorizer] Use sbvec-passes flag to create a pipeline of Region passes after BottomUpVec. (#111223)
The main change is that the main SandboxVectorizer pass no longer has a
pipeline of function passes. Now it is a wrapper that creates sandbox IR
from functions before calling BottomUpVec.

BottomUpVec now builds its own RegionPassManager from the `sbvec-passes`
flag, using a PassRegistry.def file. For now, these region passes are
not run (BottomUpVec doesn't create Regions yet), and only a null pass
for testing exists.

This commit also changes the ownership model for sandboxir::PassManager:
instead of having a PassRegistry that owns passes, and PassManagers that
contain non-owning pointers to the passes, now PassManager owns (via
unique pointers) the passes it contains.

PassRegistry is now deleted, and the logic to parse and create a pass
pipeline is now in PassManager::setPassPipeline.
2024-10-09 10:37:05 -07:00
Sterling-Augustine
376b5c0cb6
[SandboxIR][NFC] Use accessor for DataLayout rather than passing it down (#111447) 2024-10-07 15:34:33 -07:00
vporpo
ed5088a271
[SandboxIR] Switch more Instruction::create() to InsertPosition (#111213)
Also moves CmpInst definitions from Context.cpp to Instruction.cpp
2024-10-04 15:06:55 -07:00
vporpo
c029702f82
[SandboxIR] Switch more Instruction::create() to InsertPosition (#111208) 2024-10-04 14:26:22 -07:00
vporpo
4f3a0959d6
[SandboxIR] Switch more Instruction::create() to InsertPosition (#111187) 2024-10-04 13:30:53 -07:00
vporpo
3a47bf633c
[SandboxIR] Switch more Instruction::create() to InsertPosition (#111080) 2024-10-04 10:54:20 -07:00
vporpo
e1434a8764
[SandboxIR] Switch more Instruction::create() functions to InsertPosition (#111075) 2024-10-03 17:47:36 -07:00
vporpo
635db5ee97
[SandboxIR] Implement InsertPosition (#110730)
This patch implements the InsertPosition class that is used to specify
where an instruction should be placed.

It also switches a couple of create() functions from the old API to the
new one that uses InsertPosition.
2024-10-03 16:23:23 -07:00
vporpo
7b9c6a7c3c
[SandboxVec][DAG][NFC] Move functions from Utils to DependencyGraph (#111031)
This patch moves:
- Utils::isStackSaveOrRestoreIntrinsic()
- Utils::isMemIntrinsic()
- Utils::isMemDepCandidate()

to DGNode because they no longer require LLVM IR access and are used
only by the DAG.
2024-10-03 15:28:08 -07:00
vporpo
a1ff427558
[SandboxIR][NFC] Move intrinsic code to Utils::isMemIntrinsic() (#111019)
This patch moves the intrinsic specific code from
Utils::isMemDepCandidate() to a new function: Utils::isMemIntrinsic().
2024-10-03 10:40:33 -07:00
vporpo
43d51d63af
[SandboxIR] Implement IntrinsicInst (#110900)
This patch implements sandboxir::IntrinsicInst mirroring
llvm::IntrinsicInst.
2024-10-03 09:41:07 -07:00
Jorge Gorbe Moya
f35c213c81
[SandboxIR] Add RegionPass/RegionPassManager (#110933)
These classes mirror the existing FunctionPass/FunctionPassManager, and
will be used by the sandbox vectorizer to run a pipeline of region
passes.
2024-10-02 16:32:02 -07:00
Sterling-Augustine
906ffc4b4a
[SandboxIR][NFC] Move Utils test to proper file (#110763) 2024-10-02 13:21:19 -07:00