-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR] Make CIR-to-LLVM a one shot conversion #171083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/xlauko/cir-personality-functions
Are you sure you want to change the base?
[CIR] Make CIR-to-LLVM a one shot conversion #171083
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp -- clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp --diff_from_common_commit
View the diff from clang-format here.diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 8e2b47dbe..52455fdc4 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -1129,7 +1129,6 @@ mlir::LogicalResult CIRToLLVMBrCondOpLowering::matchAndRewrite(
// ZExtOp and if so, delete it if it has a single use.
assert(!cir::MissingFeatures::zextOp());
-
rewriter.replaceOpWithNewOp<mlir::LLVM::CondBrOp>(
brOp, adaptor.getCond(), brOp.getDestTrue(),
adaptor.getDestOperandsTrue(), brOp.getDestFalse(),
@@ -3781,7 +3780,7 @@ mlir::LogicalResult CIRToLLVMComplexRealOpLowering::matchAndRewrite(
rewriter, op.getLoc(), resultLLVMTy, operand,
llvm::ArrayRef<std::int64_t>{0});
}
-
+
rewriter.replaceOp(op, operand);
return mlir::success();
}
|
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) ClangClang.CIR/CodeGen/complex-compound-assignment.cppClang.CIR/CodeGen/complex-compound-assignment.cppIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
This had to fix memory and conversion bugs due to now immediate conversion patterns and no longer present original MLIR.
68ca1b8 to
4beab30
Compare
b93a2e6 to
e3fda2a
Compare
| // FIXME: | ||
| // Check if we're extracting from a ComplexCreate that was already lowered | ||
| // Pattern: insertvalue(insertvalue(undef, real, 0), imag, 1) -> just use | ||
| // 'real' | ||
| if (auto secondInsert = operand.getDefiningOp<mlir::LLVM::InsertValueOp>()) { | ||
| if (secondInsert.getPosition() == llvm::ArrayRef<int64_t>{1}) { | ||
| if (auto firstInsert = secondInsert.getContainer() | ||
| .getDefiningOp<mlir::LLVM::InsertValueOp>()) { | ||
| if (firstInsert.getPosition() == llvm::ArrayRef<int64_t>{0}) { | ||
| // This is the pattern we're looking for - return the real component | ||
| // directly | ||
| rewriter.replaceOp(op, firstInsert.getValue()); | ||
| return mlir::success(); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andykaylor @AmrDeveloper I am trying to make this work with one-shot conversion. Though our previous conversion "accidently" made this canonicalization as it queried both nontraslated and translated CIR.
And our lit tests expects this to by applied.
I don't really like to have this kind of folding int CIR-to-LLVM translation, but I am not sure whether we want to skip it completely and let LLVM optimize it, or optimize on CIR level somewhere before, e.g., apply already present fold cir.real(cir.complex.create real imag) -> real.
In fact now I am not sure why it is not applied before.
Same holds for imag.

This had to fix memory and conversion bugs due to now immediate
conversion patterns and no longer present original MLIR.