-
Notifications
You must be signed in to change notification settings - Fork 100
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
[CIR][CIRGen][Builtin][Neon] Lower neon_vrshl_v and neon_vrshlq_v #1151
base: main
Are you sure you want to change the base?
Commits on Nov 21, 2024
-
Configuration menu - View commit details
-
Copy full SHA for cb5f8b7 - Browse repository at this point
Copy the full SHA cb5f8b7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 50aef5d - Browse repository at this point
Copy the full SHA 50aef5dView commit details -
[CIR][LowerToLLVM][NFC] Exceptions: use getOrCreateLLVMFuncOp to crea…
…te personality functions While here, cleanup getOrCreateLLVMFuncOp usaga a bit.
Configuration menu - View commit details
-
Copy full SHA for 92a2de6 - Browse repository at this point
Copy the full SHA 92a2de6View commit details -
[CIR][Lowering] Erase op through rewriter instead of directly (llvm#853)
Directly erasing the op causes a use after free later on, presumably because the lowering framework isn't aware of the op being deleted. This fixes `clang/test/CIR/CodeGen/pointer-arith-ext.c` with ASAN.
Configuration menu - View commit details
-
Copy full SHA for e74f83d - Browse repository at this point
Copy the full SHA e74f83dView commit details -
Configuration menu - View commit details
-
Copy full SHA for f0c9ec7 - Browse repository at this point
Copy the full SHA f0c9ec7View commit details -
[CIR][ABI] Fix use after free from erasing while iterating (llvm#854)
The loop was erasing the user of a value while iterating on the value's users, which results in a use after free. We're already assuming (and asserting) that there's only one user, so we can just access it directly instead. CIR/Transforms/Target/x86_64/x86_64-call-conv-lowering-pass.cpp was failing with ASAN before this change. We're now ASAN-clean except for llvm#829 (which is also in progress).
Configuration menu - View commit details
-
Copy full SHA for c6325bf - Browse repository at this point
Copy the full SHA c6325bfView commit details -
Recommit [CIR][Pipeline] Support -fclangir-analysis-only (llvm#832)
Reland llvm#638 This was reverted due to llvm#655. I tried to address the problem in the newest commit. The changes of the PR since the last landed one includes: - Move the definition of `cir::CIRGenConsumer` to `clang/include/clang/CIRFrontendAction/CIRGenConsumer.h`, and leave its `HandleTranslationUnit` interface is left empty. So that `cir::CIRGenConsumer` won't need to depend on CodeGen any more. - Change the old definition of `cir::CIRGenConsumer` in `clang/lib/CIR/FrontendAction/CIRGenAction.cpp` and to `CIRLoweringConsumer`, inherited from `cir::CIRGenConsumer`, which implements the original `HandleTranslationUnit` interface. I feel this may improve the readability more even without my original patch.
Configuration menu - View commit details
-
Copy full SHA for 8e7d093 - Browse repository at this point
Copy the full SHA 8e7d093View commit details -
[CIR][Lowering] Fix lowering for multi dimensional array (llvm#851)
This PR fixes the lowering for multi dimensional arrays. Consider the following code snippet `test.c`: ``` void foo() { char arr[4][1] = {"a", "b", "c", "d"}; } ``` When ran with `bin/clang test.c -Xclang -fclangir -Xclang -emit-llvm -S -o -`, It produces the following error: ``` ~/clangir/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = mlir::ArrayAttr; From = mlir::Attribute]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed. ``` The bug can be traced back to `LoweringHelpers.cpp`. It considers the values in the array as integer types, and this causes an error in this case. This PR updates `convertToDenseElementsAttrImpl` when the array contains string attributes. I have also added one more similar test. Note that in the tests I used a **literal match** to avoid matching as regex, so `!dbg` is useful.
Configuration menu - View commit details
-
Copy full SHA for d8a4905 - Browse repository at this point
Copy the full SHA d8a4905View commit details -
[CIR][CodeGen] Support global temporaries
Support expressions at the top level such as const unsigned int n = 1234; const int &r = (const int&)n; Reviewers: bcardosolopes Pull Request: llvm#857
Configuration menu - View commit details
-
Copy full SHA for 74eb038 - Browse repository at this point
Copy the full SHA 74eb038View commit details -
[CIR][CodeGen][NFC] Move GetUndefRValue to the right file
This is to match clang CodeGen
Configuration menu - View commit details
-
Copy full SHA for fa7cab8 - Browse repository at this point
Copy the full SHA fa7cab8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 85422c5 - Browse repository at this point
Copy the full SHA 85422c5View commit details -
[CIR][CIRGen][Builtin][Neon] Lower __builtin_neon_vrndns_f32 (llvm#858)
As title. Also introduced buildAArch64NeonCall skeleton, which is partially the counterpart of OG's EmitNeonCall. And this could be use for many other neon intrinsics. --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for eed49f6 - Browse repository at this point
Copy the full SHA eed49f6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7137b9c - Browse repository at this point
Copy the full SHA 7137b9cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 44852a2 - Browse repository at this point
Copy the full SHA 44852a2View commit details -
[CIR][CIRGen] Implement Nullpointer arithmatic extension (llvm#861)
See the test for example.
Configuration menu - View commit details
-
Copy full SHA for 30fbe24 - Browse repository at this point
Copy the full SHA 30fbe24View commit details -
[CIR][Codegen] supports aarch64_be (llvm#864)
This PR adds aarch64 big endian support. Basically the support for aarch64_be itself is expressed only in two extra cases for the switch statement and changes in the `CIRDataLayout` are needed to prove that we really support big endian. Hence the idea for the test - I think the best way for proof is something connected with bit-fields, so we compare the results of the original codegen and ours.
Configuration menu - View commit details
-
Copy full SHA for e416e10 - Browse repository at this point
Copy the full SHA e416e10View commit details -
[CIR] Split cir-simplify into two passes (llvm#868)
This PR splits the old `cir-simplify` pass into two new passes, namely `cir-canonicalize` and `cir-simplify` (the new `cir-simplify`). The `cir-canonicalize` pass runs transformations that do not affect CIR-to-source fidelity much, such as operation folding and redundant operation elimination. On the other hand, the new `cir-simplify` pass runs transformations that may significantly change the code and break high-level code analysis passes, such as more aggresive code optimizations. This PR also updates the CIR-to-CIR pipeline to fit these two new passes. The `cir-canonicalize` pass is moved to the very front of the pipeline, while the new `cir-simplify` pass is moved to the back of the pipeline (but still before lowering prepare of course). Additionally, the new `cir-simplify` now only runs when the user specifies a non-zero optimization level on the frontend. Also fixed some typos and resolved some `clang-tidy` complaints along the way. Resolves llvm#827 .
Configuration menu - View commit details
-
Copy full SHA for e9282c5 - Browse repository at this point
Copy the full SHA e9282c5View commit details -
[CIR][CodeGen] Implement union cast (llvm#867)
Currently the C style cast is not implemented/supported for unions. This PR adds support for union casts as done in `CGExprAgg.cpp`. I have also added an extra test in `union-init.c`.
Configuration menu - View commit details
-
Copy full SHA for c4287aa - Browse repository at this point
Copy the full SHA c4287aaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 69c43b5 - Browse repository at this point
Copy the full SHA 69c43b5View commit details -
[CIR][CodeGen] Fix array initialization in CIRGenExprAgg (llvm#852)
Mistakenly closed llvm#850 llvm#850 (review) This PR fixes array initialization for expression arguments. Consider the following code snippet `test.c`: ``` typedef struct { int a; int b[2]; } A; int bar() { return 42; } void foo() { A a = {bar(), {}}; } ``` When ran with `bin/clang test.c -Xclang -fclangir -Xclang -emit-cir -S -o -`, It produces the following error: ``` ~/clangir/clang/lib/CIR/CodeGen/CIRGenExprAgg.cpp:483: void {anonymous}::AggExprEmitter::buildArrayInit(cir::Address, mlir::cir::ArrayType, clang::QualType, clang::Expr*, llvm::ArrayRef<clang::Expr*>, clang::Expr*): Assertion `NumInitElements != 0' failed. ``` The error can be traced back to `CIRGenExprAgg.cpp`, and the fix is simple. It is possible to have an empty array initialization as an expression argument!
Configuration menu - View commit details
-
Copy full SHA for cb53381 - Browse repository at this point
Copy the full SHA cb53381View commit details -
[CIR][CIRGen] Correct isSized predicate for vector type (llvm#869)
As title, if element type of vector type is sized, then the vector type should be deemed sized. This would enable us generate code for neon without triggering assertion
Configuration menu - View commit details
-
Copy full SHA for 174a82a - Browse repository at this point
Copy the full SHA 174a82aView commit details -
[CIR][CIRGen][Builtin][Neon] Lower builtin_neon_vrnda_v and builtin_n…
…eon_vrndaq_v (llvm#871) as title. This also added NeonType support for Float32 Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e5795cf - Browse repository at this point
Copy the full SHA e5795cfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5b41047 - Browse repository at this point
Copy the full SHA 5b41047View commit details -
[CIR][CIRGen][NFC] Cleanups: add skeleton for DominatingValue<RValue>…
…::saved_type::save
Configuration menu - View commit details
-
Copy full SHA for e140ca1 - Browse repository at this point
Copy the full SHA e140ca1View commit details -
Configuration menu - View commit details
-
Copy full SHA for ae236b5 - Browse repository at this point
Copy the full SHA ae236b5View commit details -
[CIR][CIRGen][NFC] Cleanups: add more skeleton to pushFullExprCleanup
It will hit another assert when calling initFullExprCleanup.
Configuration menu - View commit details
-
Copy full SHA for a021d11 - Browse repository at this point
Copy the full SHA a021d11View commit details -
[CIR][CodeGen][BugFix] don't place alloca before the label (llvm#875)
This PR fixes the case, when a temporary var is used, and `alloca` operation is inserted in the block start before the `label` operation. Implementation: when we search for the `alloca` place in a block, we take label operations into account as well. Fix llvm#870 --------- Co-authored-by: Bruno Cardoso Lopes <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f370265 - Browse repository at this point
Copy the full SHA f370265View commit details -
[CIR][CIRGen] Allow constant evaluation of int annotation (llvm#874)
__attribute__((annotate()) was only accepting integer literals, preventing some meta-programming usage for example. This should be extended to some other kinds of types. --------- Co-authored-by: Bruno Cardoso Lopes <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ed18860 - Browse repository at this point
Copy the full SHA ed18860View commit details -
[CIR][CIRGen] Cleanups: handle conditional cleanups
Just as the title says, but only covers non-exception path, that's coming next.
Configuration menu - View commit details
-
Copy full SHA for 24e3311 - Browse repository at this point
Copy the full SHA 24e3311View commit details -
[CIR][CIRGen][NFC] Cleanups: Prepare for conditional cleanup
Nothing unblocked yet, just hit next assert in the same path.
Configuration menu - View commit details
-
Copy full SHA for 2664ee2 - Browse repository at this point
Copy the full SHA 2664ee2View commit details -
[CIR][CIRGen][NFC] Cleanups: more boilerplate work for conditional on…
… exceptions Code path still hits an assert sooner, incremental NFC step.
Configuration menu - View commit details
-
Copy full SHA for ab59ec0 - Browse repository at this point
Copy the full SHA ab59ec0View commit details -
[CIR][CodeGen] Handling multiple stmt followed after a switch case (l…
…lvm#878) Close llvm#876 We've already considered the case that there are random stmt after a switch case: ``` for (auto *c : compoundStmt->body()) { if (auto *switchCase = dyn_cast<SwitchCase>(c)) { res = buildSwitchCase(*switchCase, condType, caseAttrs); } else if (lastCaseBlock) { // This means it's a random stmt following up a case, just // emit it as part of previous known case. mlir::OpBuilder::InsertionGuard guardCase(builder); builder.setInsertionPointToEnd(lastCaseBlock); res = buildStmt(c, /*useCurrentScope=*/!isa<CompoundStmt>(c)); } else { llvm_unreachable("statement doesn't belong to any case region, NYI"); } lastCaseBlock = builder.getBlock(); if (res.failed()) break; } ``` However, maybe this is an oversight, in the branch of ` if (lastCaseBlock)`, the insertion point will be updated automatically when the RAII object `guardCase` destroys, then we can assign the correct value for `lastCaseBlock` later. So we will see the weird code pattern in the issue side. BTW, I found the codes in CIRGenStmt.cpp are far more less similar with the ones other code gen places. Is this intentional? And what is the motivation and guide lines here?
Configuration menu - View commit details
-
Copy full SHA for 27cbc49 - Browse repository at this point
Copy the full SHA 27cbc49View commit details -
Configuration menu - View commit details
-
Copy full SHA for e6f7025 - Browse repository at this point
Copy the full SHA e6f7025View commit details -
[CIR][CIRGen] Generate CIR for vset_lane and vsetq_lane intrinsics (l…
…lvm#882) As title. Notice that for those intrinsics, just like OG, we do not lower to llvm intrinsics, instead, do vector insert. The test case is partially from OG [aarch64-neon-vget.c](https://github.com/llvm/clangir/blob/85bc6407f559221afebe08a60ed2b50bf1edf7fa/clang/test/CodeGen/aarch64-neon-vget.c) But, I did not do all signed and unsigned int tests because unsigned and signed of the same width essentially just use the same intrinsic ID thus exactly same code path as far as this PR concerns. --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 23ce0cf - Browse repository at this point
Copy the full SHA 23ce0cfView commit details -
Reviewers: bcardosolopes Reviewed By: bcardosolopes Pull Request: llvm#881
Configuration menu - View commit details
-
Copy full SHA for 7a4cf9e - Browse repository at this point
Copy the full SHA 7a4cf9eView commit details -
[CIR][Dialect][CodeGen] Add a unit attribute for OpenCL kernels (llvm…
…#877) We need a target-independent way to distinguish OpenCL kernels in ClangIR. This PR adds a unit attribute `OpenCLKernelAttr` similar to the one in Clang AST. This attribute is attached to the extra attribute dictionary of `cir.func` operations only. (Not for `cir.call`.)
Configuration menu - View commit details
-
Copy full SHA for 510c147 - Browse repository at this point
Copy the full SHA 510c147View commit details -
[CIR][CodeGen] Handle the case of 'case' after label statement after …
…'case' (llvm#879) Motivation example: ``` extern "C" void action1(); extern "C" void action2(); extern "C" void case_follow_label(int v) { switch (v) { case 1: label: case 2: action1(); break; default: action2(); goto label; } } ``` When we compile it, we will meet: ``` case Stmt::CaseStmtClass: case Stmt::DefaultStmtClass: assert(0 && "Should not get here, currently handled directly from SwitchStmt"); break; ``` in `buildStmt`. The cause is clear. We call `buildStmt` when we build the label stmt. To solve this, I think we should be able to build case stmt in buildStmt. But the new problem is, we need to pass the information like caseAttr and condType. So I tried to add such informations in CIRGenFunction as data member.
Configuration menu - View commit details
-
Copy full SHA for 4e6a07c - Browse repository at this point
Copy the full SHA 4e6a07cView commit details -
[CIR][CIRGen] Generate CIR for neon_vget and neon_vdup lane intrinsics (
llvm#884) as title. This PR has simliar test case organization as to [PR882](llvm#882) Notice that comparing to OG, this PR combines cases for some pairs of intrinsics such as BI__builtin_neon_vget_lane_f32 and BI__builtin_neon_vdups_lane_f32. They have the same code generated in OG and CIRGen OG separate them into different case handling because it passes mnemonics which are different. CIRGen doesn't pass that so why not combine them. Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for aaca26b - Browse repository at this point
Copy the full SHA aaca26bView commit details -
[CIR][CIRGen] Allow maybeSetTrivialComdat for GlobalOp (llvm#885)
as title, this would complete solution to fix issue [LLVM lowering missing comdat and constant attributes](llvm#801)
Configuration menu - View commit details
-
Copy full SHA for 842963c - Browse repository at this point
Copy the full SHA 842963cView commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon vqadd_v (llvm#890)
as title. Also add function buildCommonNeonBuiltinExpr just like OG's emitCommonNeonBuiltinExpr. This might help consolidate neon cases and share common code. Notice: - I pretty much keep the skeleton of OG's emitCommonNeonBuiltinExpr at the cost of that we didn't use a few variables they calculate. They might help in the future. - The purpose of having CommonNeonBuiltinExpr is to reduce implementation code duplication. So far, we only have one type implemented, and it's hard for CIR to be more generic. But we should see if in future we can have different types of intrinsics share more generic code path. --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 49067d3 - Browse repository at this point
Copy the full SHA 49067d3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d683dd8 - Browse repository at this point
Copy the full SHA d683dd8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9bce165 - Browse repository at this point
Copy the full SHA 9bce165View commit details -
[CIR][CIRGen][Builtin] Allow CIRGen for builtin calls with math error…
…no override (llvm#893) As title. The test case used is abort(), but it is from the real code. Notice: Since CIR implementation for NoReturn Call is pending to implement, the generated llvm code is like: `define dso_local void @test() llvm#1 { call void @abort(), !dbg !8 ret void }` which is not right, right code should be like, ` `define dso_local void @test() llvm#1 { call void @abort(), !dbg !8 unreachable }` ` Still send this PR as Noreturn implementation is a separate issue.
Configuration menu - View commit details
-
Copy full SHA for 0d17581 - Browse repository at this point
Copy the full SHA 0d17581View commit details -
[CIR][CIRGen] Support __builtin_huge_val for float type (llvm#889)
as title. The test cases are from [clang codegen test case](https://github.com/llvm/clangir/blob/52323c17c6a3708b3eb72651465f7d4b82f057e7/clang/test/CodeGen/builtins.c#L37)
Configuration menu - View commit details
-
Copy full SHA for ee84edb - Browse repository at this point
Copy the full SHA ee84edbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 80bd527 - Browse repository at this point
Copy the full SHA 80bd527View commit details -
[CIR][ABI] Apply CC lowering pass by default (llvm#842)
Before this patch, the CC lowering pass was applied only when explicitly requested by the user. This update changes the default behavior to always apply the CC lowering pass, with an option to disable it using the `-fno-clangir-call-conv-lowering` flag if necessary. The primary objective is to make this pass a mandatory step in the compilation pipeline. This ensures that future contributions correctly implement the CC lowering for both existing and new targets, resulting in more consistent and accurate code generation. From an implementation perspective, several `llvm_unreachable` statements have been substituted with a new `assert_or_abort` macro. This macro can be configured to either trigger a non-blocking assertion or a blocking unreachable statement. This facilitates a test-by-testa incremental development as it does not required you to know which code path a test will trigger an just cause a crash if it does. A few notable changes: - Support multi-block function in CC lowering - Ignore pointer-related CC lowering - Ignore no-proto functions CC lowering - Handle missing type evaluation kinds - Fix CC lowering for function declarations - Unblock indirect function calls - Disable CC lowering pass on several tests
Configuration menu - View commit details
-
Copy full SHA for 5a77095 - Browse repository at this point
Copy the full SHA 5a77095View commit details -
[CIR][CIRGen][Builtin][Neon] Lower vqrshrun_n and add getAArch64SIMDI…
…ntrinsicString (llvm#899) as title. In addition, this PR has 2 extra changes. 1. change return type of GetNeonType into mlir::cir::VectorType so we don't have to do cast all the time, this is consistent with [OG](https://github.com/llvm/clangir/blob/db6b7c07c076cb738d0acae248d7c3c199b2b952/clang/lib/CodeGen/CGBuiltin.cpp#L6234) as well. 2. add getAArch64SIMDIntrinsicString helper function so we have better debug info when hitting NYI in buildCommonNeonBuiltinExpr --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d3f26d8 - Browse repository at this point
Copy the full SHA d3f26d8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 85ba26f - Browse repository at this point
Copy the full SHA 85ba26fView commit details -
Revert "[CIR][ABI] Apply CC lowering pass by default (llvm#842)"
Configuration menu - View commit details
-
Copy full SHA for ef686b2 - Browse repository at this point
Copy the full SHA ef686b2View commit details -
[CIR][CIRGen] Add time trace to several CIRGen pieces (llvm#898)
Then we can observe the time consumed in different part of CIR. This patch is not complete. But I think it is fine given we can always add them easily.
Configuration menu - View commit details
-
Copy full SHA for f3ba587 - Browse repository at this point
Copy the full SHA f3ba587View commit details -
[CIR][Dialect] Support OpenCL work group uniformity attribute (llvm#896)
> To keep information about whether an OpenCL kernel has uniform work > group size or not, clang generates 'uniform-work-group-size' function > attribute for every kernel: > > "uniform-work-group-size"="true" for OpenCL 1.2 and lower, > "uniform-work-group-size"="true" for OpenCL 2.0 and higher if '-cl-uniform-work-group-size' option was specified, > "uniform-work-group-size"="false" for OpenCL 2.0 and higher if no '-cl-uniform-work-group-size' options was specified. > If the function is not an OpenCL kernel, 'uniform-work-group-size' > attribute isn't generated. > > *From [Differential 43570](https://reviews.llvm.org/D43570)* This PR introduces the `OpenCLKernelUniformWorkGroupSizeAttr` attribute to the ClangIR pipeline, towards the completeness in attributes for OpenCL. While this attribute is represented as a unit attribute in MLIR, its absence signifies either non-kernel functions or a `false` value for kernel functions. To match the original LLVM IR behavior, we also consider whether a function is an OpenCL kernel during lowering: * If the function is not a kernel, the attribute is ignored. No LLVM function attribute is set. * If the function is a kernel: * and the `OpenCLKernelUniformWorkGroupSizeAttr` is present, we generate the LLVM function attribute `"uniform-work-group-size"="true"`. * If absent, we generate `"uniform-work-group-size"="false"`.
Configuration menu - View commit details
-
Copy full SHA for 5358f02 - Browse repository at this point
Copy the full SHA 5358f02View commit details -
[CIR][CodeGen][NFC] Rename the confusing
buildGlobal
overload (llvm……#897) `CIRGenModule::buildGlobal` --[rename]--> `CIRGenModule::getOrCreateCIRGlobal` We already have `CIRGenModule::buildGlobal` that corresponds to `CodeGenModule::EmitGlobal`. But there is an overload of `buildGlobal` used by `getAddrOfGlobalVar`. Since this name is confusing, this PR rename it to `getOrCreateCIRGlobal`. Note that `getOrCreateCIRGlobal` already exists. It is intentional to make the renamed function an overload to it. The reason here is that the renamed function is basically a wrapper of the original `getOrCreateCIRGlobal` with more specific parameters: `getOrCreateCIRGlobal(decl, type, isDef)` --[call]--> `getOrCreateCIRGlobal(getMangledName(decl), type, decl->getType()->getAS(), decl, isDef)`
Configuration menu - View commit details
-
Copy full SHA for ff6b5b7 - Browse repository at this point
Copy the full SHA ff6b5b7View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon vld1_lane and vld1q_lane (llv…
…m#901) just as title. --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f09c88d - Browse repository at this point
Copy the full SHA f09c88dView commit details -
[CIR][CodeGen][NFC] Break the missing feature flag for OpenCL into sm…
…aller pieces (llvm#902) The missing feature flag for OpenCL has very few occurrences now. This PR rearranges them into proper pieces to better track them.
Configuration menu - View commit details
-
Copy full SHA for 3754a55 - Browse repository at this point
Copy the full SHA 3754a55View commit details -
[CIR][CodeGen] Add
nothrow
for functions in OpenCL languages (llvm#903Configuration menu - View commit details
-
Copy full SHA for 6f5d387 - Browse repository at this point
Copy the full SHA 6f5d387View commit details -
[CIR][CodeGen] Set constant properly for global variables (llvm#904)
Fix llvm#801 (the remaining `constant` part). Actually the missing stage is CIRGen. There are two places where `GV.setConstant` is called: * `buildGlobalVarDefinition` * `getOrCreateCIRGlobal` Therefore, the primary test `global-constant.c` contains a global definition and a global declaration with use, which should be enough to cover the two paths. A test for OpenCL `constant` qualified global is also added. Some existing testcases need tweaking to avoid failure of missing constant.
Configuration menu - View commit details
-
Copy full SHA for c194a47 - Browse repository at this point
Copy the full SHA c194a47View commit details -
[CIR][Test][NFC] Organize CIR CodeGen AArch64 neon tests (llvm#910)
as title. --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2a6b30e - Browse repository at this point
Copy the full SHA 2a6b30eView commit details -
[CIR][Lowering] Fix Global Attr Lowering (llvm#906)
Consider the following code snippet `tmp.c`: ``` #define N 3200 struct S { double a[N]; double b[N]; } s; double *b = s.b; void foo() { double x = 0; for (int i = 0; i < N; i++) x += b[i]; } int main() { foo(); return 0; } ``` Running `bin/clang tmp.c -fclangir -o tmp && ./tmp` causes a segmentation fault. I compared the LLVM IR with and without CIR and noticed a difference which causes this: `@b = global ptr getelementptr inbounds (%struct.S, ptr @s, i32 0, i32 1)` // no CIR `@b = global ptr getelementptr inbounds (%struct.S, ptr @s, i32 1)` // with CIR It seems there is a missing index when creating global pointers from structs. I have updated `Lowering/DirectToLLVM/LowerToLLVM.cpp`, and added a few tests.
Configuration menu - View commit details
-
Copy full SHA for dd514ef - Browse repository at this point
Copy the full SHA dd514efView commit details -
[CIR][CIRGen][Builtin] Implement builtin __sync_fetch_and_sub (llvm#932)
as title. Notice this is not target specific nor neon intrinsics.
Configuration menu - View commit details
-
Copy full SHA for 68ad989 - Browse repository at this point
Copy the full SHA 68ad989View commit details -
[CIR][CIRGen] Cleanup: enable conditional cleanup with exceptions
Entails several minor changes: - Duplicate resume blocks around. - Disable LP caching, we repeat them as often as necessary. - Update maps accordingly for tracking places to patch up. - Make changes to clean up block handling. - Fix an issue in flatten cfg.
Configuration menu - View commit details
-
Copy full SHA for b9c251b - Browse repository at this point
Copy the full SHA b9c251bView commit details -
[CIR][CIRGen][Builtin][Neon] Lower BI__builtin_neon_vmovn_v (llvm#909)
as title. The current implementation of this PR is use cir::CastOP integral casting to implement vector type truncation. Thus, LLVM lowering code has been change to accommodate it. In addition. Added code into [CIRGenBuiltinAArch64.cpp](https://github.com/llvm/clangir/pull/909/files#diff-6f7700013aa60ed524eb6ddcbab90c4dd288c384f9434547b038357868334932) to make it more similar to OG. ``` mlir::Type ty = vTy; if (!ty) ``` Added test case into neon.c as the file already contains similar vector move test cases such as vmovl --------- Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c45f01c - Browse repository at this point
Copy the full SHA c45f01cView commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon vst1q_lane and vst1_lane (llv…
…m#935) as title. Also changed [neon-ldst.c](https://github.com/llvm/clangir/compare/main...ghehg:clangir-llvm-ghehg:macM3?expand=1#diff-ea4814b6503bff2b7bc4afc6400565e6e89e5785bfcda587dc8401d8de5d3a22) to make it have the same RUN options as OG [clang/test/CodeGen/aarch64-neon-intrinsics.c](https://github.com/llvm/clangir/blob/main/clang/test/CodeGen/aarch64-neon-intrinsics.c) Those options help us to avoid checking load/store pairs thus make the test less verbose and easier to compare against OG. Co-authored-by: Guojin He <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 33b4226 - Browse repository at this point
Copy the full SHA 33b4226View commit details -
[CIR] Derived-to-base conversions (llvm#937)
Implement derived-to-base address conversions for non-virtual base classes. The code gen for this situation was only implemented when the offset was zero, and it simply created a `cir.base_class_addr` op for which no lowering or other transformation existed. Conversion to a virtual base class is not yet implemented. Two new fields are added to the `cir.base_class_addr` operation: the byte offset of the necessary adjustment, and a boolean flag indicating whether the source operand may be null. The offset is easy to compute in the front end while the entire path of intermediate classes is still available. It would be difficult for the back end to recompute the offset. So it is best to store it in the operation. The null-pointer check is best done late in the lowering process. But whether or not the null-pointer check is needed is only known by the front end; the back end can't figure that out. So that flag needs to be stored in the operation. `CIRGenFunction::getAddressOfBaseClass` was largely rewritten. The code path no longer matches the equivalent function in the LLVM IR code gen, because the generated ClangIR is quite different from the generated LLVM IR. `cir.base_class_addr` is lowered to LLVM IR as a `getelementptr` operation. If a null-pointer check is needed, then that is wrapped in a `select` operation. When generating code for a constructor or destructor, an incorrect `cir.ptr_stride` op was used to convert the pointer to a base class. The code was assuming that the operand of `cir.ptr_stride` was measured in bytes; the operand is the number elements, not the number of bytes. So the base class constructor was being called on the wrong chunk of memory. Fix this by using a `cir.base_class_addr` op instead of `cir.ptr_stride` in this scenario. The use of `cir.ptr_stride` in `ApplyNonVirtualAndVirtualOffset` had the same problem. Continue using `cir.ptr_stride` here, but temporarily convert the pointer to type `char*` so the pointer is adjusted correctly. Adjust the expected results of three existing tests in response to these changes. Add two new tests, one code gen and one lowering, to cover the case where a base class is at a non-zero offset.
Configuration menu - View commit details
-
Copy full SHA for d89f4ba - Browse repository at this point
Copy the full SHA d89f4baView commit details -
Configuration menu - View commit details
-
Copy full SHA for 06554a4 - Browse repository at this point
Copy the full SHA 06554a4View commit details -
[CIR][CIRGen] Exceptions: fix agg store for temporaries
Fix llvm#934 While here move scope op codegen outside the builder, so it's easier to dump blocks and operations while debugging.
Configuration menu - View commit details
-
Copy full SHA for 413d4e1 - Browse repository at this point
Copy the full SHA 413d4e1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2fc0967 - Browse repository at this point
Copy the full SHA 2fc0967View commit details -
Configuration menu - View commit details
-
Copy full SHA for d797fc5 - Browse repository at this point
Copy the full SHA d797fc5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5457e49 - Browse repository at this point
Copy the full SHA 5457e49View commit details -
[Lowering][DirectToLLVM] Fix calling variadic functions (llvm#945)
After 5da4310, the LLVM dialect requires the variadic callee type to be present for variadic calls. The op builders take care of this automatically if you pass the function type, so change our lowering logic to do so. Add tests for this as well as a missing test for indirect function call lowering. Fixes llvm#913 Fixes llvm#933
Configuration menu - View commit details
-
Copy full SHA for 8595b15 - Browse repository at this point
Copy the full SHA 8595b15View commit details -
[CIR] [CodeGen] Remove NYI in buildPointerWithAlignment (llvm#949)
See the test for the reproducer. It would crash due the NYI. See https://github.com/llvm/llvm-project/blob/327124ece7d59de56ca0f9faa2cd82af68c011b9/clang/lib/CodeGen/CGExpr.cpp#L1295-L1373, I found we've implemented all the cases in CGExpr.cpp. IIUC, I think we can remove the NYI.
Configuration menu - View commit details
-
Copy full SHA for 861a0ee - Browse repository at this point
Copy the full SHA 861a0eeView commit details -
[CIR][Lowering] Introduce HoistAllocasPass (llvm#887)
Close llvm#883. See the above issue for details
Configuration menu - View commit details
-
Copy full SHA for a72c4a0 - Browse repository at this point
Copy the full SHA a72c4a0View commit details -
[CIR][CodeGen] Enable -fno-PIE (llvm#940)
The title describes the purpose of the PR. The logic was gotten from the original CodeGen, and I added a test to check that `-fno-PIE` is indeed enabled.
Configuration menu - View commit details
-
Copy full SHA for fd13e77 - Browse repository at this point
Copy the full SHA fd13e77View commit details -
[CIR][CIRGen] Add support for __fp16 type (llvm#950)
This PR adds support for the `__fp16` type. CIRGen and LLVM lowering is included. Resolve llvm#900 .
Configuration menu - View commit details
-
Copy full SHA for 49fc4ee - Browse repository at this point
Copy the full SHA 49fc4eeView commit details -
[CIR][CIRGen][Builtin] Support unsigned type for _sync_(bool/val)_com…
…pare_and_swap (llvm#955) as title. Actually just follow the way in `makeBinaryAtomicValue` in the same file which did the right thing by creating SInt or UInt based on first argument's signess.
Configuration menu - View commit details
-
Copy full SHA for e3cb89e - Browse repository at this point
Copy the full SHA e3cb89eView commit details -
[CIR][CIRGen][NFC] Improve buildAutoVarAlloca skeleton and add hooks …
…for buildVarAnnotations
Configuration menu - View commit details
-
Copy full SHA for 6c35fbb - Browse repository at this point
Copy the full SHA 6c35fbbView commit details -
[CIR][CIRGen] Support annotations on local var decl
LLVM lowering support coming next.
Configuration menu - View commit details
-
Copy full SHA for 3d849ab - Browse repository at this point
Copy the full SHA 3d849abView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e890c9 - Browse repository at this point
Copy the full SHA 8e890c9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 48ea4eb - Browse repository at this point
Copy the full SHA 48ea4ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for 71ce3a0 - Browse repository at this point
Copy the full SHA 71ce3a0View commit details -
Reapply and patch "[CIR][ABI] Apply CC lowering pass by default (llvm…
…#842)" (llvm#944) This reverts commit 8f699fd and fixes some issues, namely: - CC lowering pass will no longer fail if the function has no AST information that won't be used. - Fixed CC lowering not disabling when running certain `cc1` compilation commands. - CC lowering can now be disabled when calling `cir-opt` and `cir-translate`. - Compilation commands that generate Object files should now invoke CC lowering by default.
Configuration menu - View commit details
-
Copy full SHA for b0851e9 - Browse repository at this point
Copy the full SHA b0851e9View commit details -
[CIR][CodeGen] kr-style for function arguments (llvm#938)
I tried to run llvm-test-suite and turned out that there are many tests fail with segfault due to old C style (let's remember Kernighan and Ritchie) . This PR fix it by the usual copy-pasta from the original codegen :) So let's take a look at the code: ``` void foo(x) short x; {} int main() { foo(4); return 0; } ``` and CIR for `foo` function is: ``` cir.func @foo(%arg0: !s32i) { %0 = cir.alloca !s16i, !cir.ptr<!s16i>, ["x", init] %1 = cir.cast(bitcast, %0 : !cir.ptr<!s16i>), !cir.ptr<!s32i> cir.store %arg0, %1 : !s32i, !cir.ptr<!s32i> cir.return } ``` We bitcast the **address** (!!!) and store a value of a bigger size there. And now everything looks fine: ``` cir.func no_proto @foo(%arg0: !s32i) { %0 = cir.alloca !s16i, !cir.ptr<!s16i>, ["x", init] %1 = cir.cast(integral, %arg0 : !s32i), !s16i cir.store %1, %0 : !s16i, !cir.ptr<!s16i> cir.return } ``` We truncate an argument and store it. P.S. The `bitcast` that was there before looks a little bit suspicious and dangerous. Are we sure we can do this unconditional cast while we create `StoreOp` ?
Configuration menu - View commit details
-
Copy full SHA for 96912b3 - Browse repository at this point
Copy the full SHA 96912b3View commit details -
[CIR][CIRGen] Add const attribute to alloca operations (llvm#892)
This PR tries to give a simple initial implementation for eliminating redundant loads of constant objects, an idea originally posted by OfekShilon. Specifically, this PR adds a new unit attribute `const` to the `cir.alloca` operation. Presence of this attribute indicates that the alloca-ed object is declared `const` in the input source program. CIRGen is updated accordingly to start emitting this new attribute.
Configuration menu - View commit details
-
Copy full SHA for 3523638 - Browse repository at this point
Copy the full SHA 3523638View commit details -
[CIR][Lowering] VecCreateOp and VecSplatOp lowering choose LLVM:Poiso…
…nOp (llvm#959) They should use PoisonOp (which becomes PoisonValue in LLVMIR) as it is the OG's choice. Proof: We generate VecCreateOp [here ](https://github.com/llvm/clangir/blob/2ca12fe5ec3a1e7279256f069010be2d68200585/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp#L1975) And it's OG counterpart is [here](https://github.com/llvm/clangir/blob/2ca12fe5ec3a1e7279256f069010be2d68200585/clang/lib/CodeGen/CGExprScalar.cpp#L2096) OG uses PoisonValue. As to VecSplatOp, OG unconditionally [chooses PoisonValue ](https://github.com/llvm/clangir/blob/2ca12fe5ec3a1e7279256f069010be2d68200585/llvm/lib/IR/IRBuilder.cpp#L1204) A even more solid proof for this case is that when we use OG to generate code for our test case I changed in this PR , its always using poison instead of undef as far as VecSplat and VecCreate is concerned. The [OG generated code for vectype-ext.cpp ](https://godbolt.org/z/eqx1rns86) here. The [OG generated code for vectype.cpp ](https://godbolt.org/z/frMjbKGeT) here. For reference, generated CIR for the test case vectype-ext.cpp is [here](https://godbolt.org/z/frMjbKGeT) This is to unblock llvm#936 to help it set on the right path. Note: There might be other CIR vec ops that need to choose Poison to be consistent with OG, but I'd limit the scope of this PR, and wait to see issue pop up in the future.
Configuration menu - View commit details
-
Copy full SHA for d7d449b - Browse repository at this point
Copy the full SHA d7d449bView commit details -
[CIR][NFC][Testing] Fix test failure (llvm#963)
as title. Base on my experience of [this type of test(https://github.com/llvm/clangir/blob/a7ac2b4e2055e169d9f556abf5821a1ccab666cd/clang/test/CIR/CodeGen/attribute-annotate-multiple.cpp#L51), The number of characters varies in this line as it's about full file path which changes during environment.
Configuration menu - View commit details
-
Copy full SHA for 2e38800 - Browse repository at this point
Copy the full SHA 2e38800View commit details -
Configuration menu - View commit details
-
Copy full SHA for 26a6eac - Browse repository at this point
Copy the full SHA 26a6eacView commit details -
[CIR][CIRGen] Support CodeGen for vbase constructors
1. Add new `cir.vtt.address_point` op for visiting the element of VTT to initialize the virtual pointer. 2. Implement `getVirtualBaseClassOffset` method which provides a virtual offset to adjust to actual virtual pointers in virtual base. 3. Follows the original clang CodeGen scheme for the implementation of most other parts. @bcardosolopes's note: this is cherry-picked from an older PR from Jing Zhang and slightly modified for updates: applied review, test, doc and operation syntax. It does not yet has LLVM lowering support, I'm going to make incremental changes on top of this. Any necessary CIR modifications to this design should follow up shortly too. Also, to make this work I also added more logic to `addImplicitStructorParam`s` and `buildThisParam`.
Configuration menu - View commit details
-
Copy full SHA for 4766335 - Browse repository at this point
Copy the full SHA 4766335View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vtrn and neon_vtrnq (llvm#942)
as title. The generated code is the same as Clang codeden except in a small discrepancy when GEP: OG generates code like this: `%6 = getelementptr inbounds <4 x i16>, ptr %retval.i, i32 1` CIR generates a bit differently: `%6 = getelementptr <4 x i16>, ptr %retval.i, i64 1` Ptr offest might be trivial because choosing i64 over i32 as index type seems to be LLVM Dialect's choice. The lack of `inbounds` keyword might be an issue as `mlir::cir::PtrStrideOp` is currently not lowering to LLVM:GEPOp with `inbounds` attribute as `mlir::cir::PtrStrideOp` itself has no `inbounds`. It's probably because there was no need for it though we do have an implementation of [`CIRGenFunction::buildCheckedInBoundsGEP` ](https://github.com/llvm/clangir/blob/10d6f4b94da7e0181a070f0265d079419d96cf78/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp#L2762). Anyway, the issue is not in the scope of this PR and should be addressed in a separate PR. If we think this is an issue, I can create another PR and probably add optional attribute to `mlir::cir::PtrStrideOp` to achieve it. In addition to lowering work, a couple of more works: 1. Did a little refactoring on variable name changing into desired CamelBack case. 2. Changed neon-misc RUN Options to be consistent with other neon test files and make test case more concise.
Configuration menu - View commit details
-
Copy full SHA for 2d12627 - Browse repository at this point
Copy the full SHA 2d12627View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vext_v and neon_vextq_v (llvm…
…#951) as title. There are two highlights of the PR 1. The PR introduced a new test file to cover neon intrinsics that move data, which is a big category. This would the 5th neon test file. And we're committed to keep total number of neon test files within 6. This file uses another opt option instcombine, which makes test LLVM code more concise, and our -fclangir generated LLVM code would be identical to OG with this. It looks like OG did some instcombine optimization. 2. `getIntFromMLIRValue` helper function could be substituted by [`mlir::cir::IntAttr getConstOpIntAttr` in CIRGenAtomic.cpp](https://github.com/llvm/clangir/blob/24b24557c98d1c031572a567b658cfb6254f8a89/clang/lib/CIR/CodeGen/CIRGenAtomic.cpp#L337). The function `mlir::cir::IntAttr getConstOpIntAttr` is doing more than `getIntFromMLIRValue`, and there is FIXME in the comment, so not sure if we should just use `mlir::cir::IntAttr getConstOpIntAttr`, either is fine with me.
Configuration menu - View commit details
-
Copy full SHA for 1fdaa56 - Browse repository at this point
Copy the full SHA 1fdaa56View commit details -
[CIR][Lowering] Handling Lowering of multiple dimension array correct…
…ly (llvm#961) Close llvm#957 the previous algorithm to convert a multiple dimension array to a tensor is: fill the value one by one and fill the zero values in conditions. And it has some problems handling the multiple dimension array as above issue shows so that the generated values are not in the same shape with the original array. the new algorithm here is, full fill the values ahead of time with the correct element size and full fill the values to different slots and we only need to maintain the index to write. I feel the new version has better performance (avoid allocation) and better readability slightly.
Configuration menu - View commit details
-
Copy full SHA for c834e88 - Browse repository at this point
Copy the full SHA c834e88View commit details -
Configuration menu - View commit details
-
Copy full SHA for 17e9b10 - Browse repository at this point
Copy the full SHA 17e9b10View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vpadd_v and neon_vpaddq_v int…
…o llvm intrinsic (llvm#960) This PR refactored Neon Built in code in clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp a bit to make it cleaner. Also changed RUNOption of test file clang/test/CIR/CodeGen/AArch64/neon-arith.c to make test more concise, and easy to compare against OG (to compare, just remove -fclangir from llvm gen part of RUN, and the test should still pass)
Configuration menu - View commit details
-
Copy full SHA for 7412547 - Browse repository at this point
Copy the full SHA 7412547View commit details -
[CIR] [Lowering] Fix handling of multiple array for ZeroAttr (llvm#970)
This is the following up fix for the previous fix llvm#961 See the attached new test for the reproducer. Sorry for the initial overlook.
Configuration menu - View commit details
-
Copy full SHA for fed67da - Browse repository at this point
Copy the full SHA fed67daView commit details -
[CIR][Driver] Fix -fclangir-call-conv-lowering behavior
- The flag is the default even for cc1, so make it disable two level deep. - While here, remove the unnecessary flag disable for pure `-emit-cir`.
Configuration menu - View commit details
-
Copy full SHA for 1162102 - Browse repository at this point
Copy the full SHA 1162102View commit details -
Configuration menu - View commit details
-
Copy full SHA for 43e21e0 - Browse repository at this point
Copy the full SHA 43e21e0View commit details -
[CIR] Make the asserts to display suggestion for -fno-clangir-call-co…
…nv-lowering While here, add more unrecheables to cover some of the current errors, so that our users can see a clear message instead of a random cast assert of sorts. This covers at least all crashes seen when removing -fno-clangir-call-conv-lowering from all tests, there are probably other things we'll find as we exercise this path.
Configuration menu - View commit details
-
Copy full SHA for 7806409 - Browse repository at this point
Copy the full SHA 7806409View commit details -
[CIR][NFC] Massively rename workarounds for callconv lowering
These are not meant to be used by any other component, make sure it's very specific.
Configuration menu - View commit details
-
Copy full SHA for 80a2c83 - Browse repository at this point
Copy the full SHA 80a2c83View commit details -
[CIR][CIRGen] Implement CIRGenModule::shouldEmitFunction (llvm#984)
This is the usual copy-paste-modify from CodeGen, though I changed all the variable names to conform to our new style. All these functions should be pulled out as common helpers when we're upstream.
Configuration menu - View commit details
-
Copy full SHA for fabfae9 - Browse repository at this point
Copy the full SHA fabfae9View commit details -
[CIR][CIRGen] Port 1d0bd8e (llvm#983)
llvm/llvm-project@1d0bd8e moves a conditional from CodeGen to AST, and this follows suit for consistency. (Our support for the Microsoft ABI is NYI anyway; this is just to make things simpler to follow when matching up logic between CodeGen and CIRGen.)
Configuration menu - View commit details
-
Copy full SHA for f3b2a57 - Browse repository at this point
Copy the full SHA f3b2a57View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2703cc4 - Browse repository at this point
Copy the full SHA 2703cc4View commit details -
Configuration menu - View commit details
-
Copy full SHA for a2fb31f - Browse repository at this point
Copy the full SHA a2fb31fView commit details -
Configuration menu - View commit details
-
Copy full SHA for d29f2f7 - Browse repository at this point
Copy the full SHA d29f2f7View commit details -
[CIR][CIRGen][NFC] Consolidate RUN lines for builtin tests (llvm#968)
There is no change to testing functionality. This refacot let those files have the same Run options that is easier to maintain and extend.
Configuration menu - View commit details
-
Copy full SHA for 49aba1b - Browse repository at this point
Copy the full SHA 49aba1bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 93c4af7 - Browse repository at this point
Copy the full SHA 93c4af7View commit details -
[CIR] Add support for __int128 type (llvm#980)
This PR adds initial support for the `__int128` type. The `!cir.int` type is extended to support 128-bit integer types. This PR comes with a simple test that verifies the CIRGen and LLVM lowering of `!s128i` and `!u128i` work. Resolve llvm#953 .
Configuration menu - View commit details
-
Copy full SHA for c33a9df - Browse repository at this point
Copy the full SHA c33a9dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 57591cc - Browse repository at this point
Copy the full SHA 57591ccView commit details -
[CIR][CIRGen][Builtin][Neon] Lower vqdmulhq_lane, vqdmulh_lane, vqrdm…
…ulhq_lane and vqrdmulh_lane (llvm#985)
Configuration menu - View commit details
-
Copy full SHA for 9f38e23 - Browse repository at this point
Copy the full SHA 9f38e23View commit details -
[CIR][CIRGen][Builtin][Type] Support for IEEE Quad (long double) adde…
Configuration menu - View commit details
-
Copy full SHA for f5ed512 - Browse repository at this point
Copy the full SHA f5ed512View commit details -
Configuration menu - View commit details
-
Copy full SHA for a390662 - Browse repository at this point
Copy the full SHA a390662View commit details -
[CIR] Disable
-fclangir-call-conv-lowering
from default in the LLVM…… pipeline This is causing lots of churn. `-fclangir-call-conv-lowering` is not mature enough, assumptions are leading to crashes we cannot track with special messages, leading to not great user experience. Turn this off until we have someone dedicated to roll this out.
Configuration menu - View commit details
-
Copy full SHA for 7da2873 - Browse repository at this point
Copy the full SHA 7da2873View commit details -
Configuration menu - View commit details
-
Copy full SHA for 255f0ab - Browse repository at this point
Copy the full SHA 255f0abView commit details -
Configuration menu - View commit details
-
Copy full SHA for e6e835a - Browse repository at this point
Copy the full SHA e6e835aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5a7df72 - Browse repository at this point
Copy the full SHA 5a7df72View commit details -
[CIR][CIRGen][NFC] Add more skeleton for handling inheritance ctors
While here add some bits for ptr auth and match OG.
Configuration menu - View commit details
-
Copy full SHA for daf730d - Browse repository at this point
Copy the full SHA daf730dView commit details -
[CIR][CIRGen] Ensure default visibility for local linkage functions (l…
…lvm#990) LLVM's verifier enforces this, which was previously causing us to fail verification. This is a bit of a band-aid; the overall linkage and visibility setting flow needs some work to match the original.
Configuration menu - View commit details
-
Copy full SHA for 5bee6b3 - Browse repository at this point
Copy the full SHA 5bee6b3View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vshl_n_v and neon_vshlq_n_v (l…
…lvm#965) As title, but important step in this PR is to allow CIR ShiftOp to take vector of int type as input type. As result, I added a verifier to ShiftOp with 2 constraints 1. Input type either all vector or int type. This is consistent with LLVM::ShlOp, vector shift amount is expected. 2. In the spirit of C99 6.5.7.3, shift amount type must be the same as result type, the if vector type is used. (This is enforced in LLVM lowering for scalar int type).
Configuration menu - View commit details
-
Copy full SHA for 52fc064 - Browse repository at this point
Copy the full SHA 52fc064View commit details -
[CIR][CIRGen] Use Clang Codegen's skeleton in CIRGenFunction::buildBu…
…iltinExpr (llvm#967) This PR helps us to triage unimplemented builtins (that are target independent). There are unhandled builtins in CIR Codegen `[CIRGenFunction::buildBuiltinExpr](https://github.com/llvm/clangir/blob/4c446b3287895879da598e23164d338d04bced3e/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp#L305)`. And those builtins have implementation in [OG](https://github.com/llvm/clangir/blob/4c446b3287895879da598e23164d338d04bced3e/clang/lib/CodeGen/CGBuiltin.cpp#L2573). Currently, those builtins just are treated as LibraryCall or some other ways which eventually get failure, and failure messages are confusing. This PR address this problem by refactoring `CIRGenFunction::buildBuiltinExpr` to keep the same skeleton as OG counterpart `CodeGenFunction::EmitBuiltinExpr`, and add builtin name to NYI message
Configuration menu - View commit details
-
Copy full SHA for a4367bf - Browse repository at this point
Copy the full SHA a4367bfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5c18bcb - Browse repository at this point
Copy the full SHA 5c18bcbView commit details -
Configuration menu - View commit details
-
Copy full SHA for a1aff8a - Browse repository at this point
Copy the full SHA a1aff8aView commit details -
[CIR][CIRGen] Support initial cases of inheritance ctor/dtor
Add more NFC skeleton while here.
Configuration menu - View commit details
-
Copy full SHA for 0b9b0a4 - Browse repository at this point
Copy the full SHA 0b9b0a4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 470a163 - Browse repository at this point
Copy the full SHA 470a163View commit details -
Configuration menu - View commit details
-
Copy full SHA for c481b17 - Browse repository at this point
Copy the full SHA c481b17View commit details -
[CIR][CIRGen] Add missing testcase for null base class
Forgot to git add in cb0cb34
Configuration menu - View commit details
-
Copy full SHA for b739bc2 - Browse repository at this point
Copy the full SHA b739bc2View commit details -
[CIR] [CodeGen] Introduce IsFPClassOp to support builtin_isfpclass (l…
…lvm#971) The llvm's intrinsic `llvm.is.fpclass` is used to support multiple float point builtins: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-isfpclass > The `__builtin_isfpclass()` builtin is a generalization of functions > isnan, isinf, isfinite and some others defined by the C standard. It tests > if the floating-point value, specified by the first argument, falls into > any of data classes, specified by the second argument. I meant to support this by creating IntrinsicCallOp directly. But I can't make it due to llvm#480 since the return type of the intrinsic will mismatch. So I have to create a new Op for it. But I feel it might not be too bad. At least it is more explicit and more expressive.
Configuration menu - View commit details
-
Copy full SHA for 1810bc0 - Browse repository at this point
Copy the full SHA 1810bc0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b4a9b1 - Browse repository at this point
Copy the full SHA 4b4a9b1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3405a67 - Browse repository at this point
Copy the full SHA 3405a67View commit details -
Configuration menu - View commit details
-
Copy full SHA for 824eda3 - Browse repository at this point
Copy the full SHA 824eda3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 12d00bd - Browse repository at this point
Copy the full SHA 12d00bdView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8676652 - Browse repository at this point
Copy the full SHA 8676652View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5362a4f - Browse repository at this point
Copy the full SHA 5362a4fView commit details -
[CIR][Transforms] Fix CallConv Function Lowering (llvm#979)
Re llvm#958 > Consider the following code snippet `tmp.c`: > ``` > typedef struct { > int a, b; > } S; > > void foo(S s) {} > ``` > Running `bin/clang tmp.c -fclangir -Xclang -emit-llvm -Xclang -fclangir-call-conv-lowering -S -o -`, we get: > ``` > loc(fused["tmp.c":5:1, "tmp.c":5:16]): error: 'llvm.bitcast' op result #0 must be LLVM-compatible non-aggregate type, but got '!llvm.struct<"struct.S", (i32, i32)>' > ``` > We can also produce a similar error from this: > ``` > typedef struct { > int a, b; > } S; > > S init() { S s; return s; } > ``` > gives: > ``` > loc(fused["tmp.c":5:17, "tmp.c":5:24]): error: 'llvm.bitcast' op operand #0 must be LLVM-compatible non-aggregate type, but got '!llvm.struct<"struct.S", (i32, i32)>' > ``` > I've traced the errors back to `lib/CIR/Dialect/Transforms/TargetLowering/LowerFunction.cpp` in `LowerFunction::buildAggregateStore`, `castReturnValue`, and `buildAggregateBitcast`. > > `withElementType(SrcTy)` is currently commented out/ignored in `LowerFunction.cpp`, but it is important. > > This PR adds/fixes this and updates one test. I thought [about it](llvm#958 (comment)) and I understand adding `cir.bitcast` to circumvent the CIR checks, but I am not sure how we can ignore/drop the bitcast while lowering. I think we can just make the CIR casts correct. I have added a number of lowering tests to verify that the CIR is lowered properly. cc: @sitio-couto @bcardosolopes.
Configuration menu - View commit details
-
Copy full SHA for e92884b - Browse repository at this point
Copy the full SHA e92884bView commit details -
[CIR][CIRGen][Lowering] Use same set of annotation-related global var…
…s for source code global and local vars (llvm#1001) Now CIR supports annotations for both globals and locals. They all should just use the same set of annotation related globals including file name string, annotation name string, and arguments. This PR makes sure this is the case. FYI: for the test case we have, OG generates [ code ](https://godbolt.org/z/Ev5Ycoqj1), pretty much the same code except annotation variable names. This would fix the crash like > error: redefinition of symbol named '.str.annotation' > fatal error: error in backend: The pass manager failed to lower CIR to LLVMIR dialect!
Configuration menu - View commit details
-
Copy full SHA for 274dd71 - Browse repository at this point
Copy the full SHA 274dd71View commit details -
Configuration menu - View commit details
-
Copy full SHA for ac0a2b7 - Browse repository at this point
Copy the full SHA ac0a2b7View commit details -
[ClangIR][Lowering] Handle lowered array index (llvm#1008)
Previously we didn't generate the index for array correct. The previous test is incorrect already: globals-neg-index-array.c ``` // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-cir %s -o %t.cir // RUN: FileCheck --input-file=%t.cir %s // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -emit-cir %s -o %t.cir // RUN: FileCheck --input-file=%t.cir %s // RUN: %clang_cc1 -x c++ -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll // RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s struct __attribute__((packed)) PackedStruct { char a1; char a2; char a3; }; struct PackedStruct packed[10]; char *packed_element = &(packed[-2].a3); // CHECK: cir.global external @PACKED = #cir.zero : !cir.array<!ty_PackedStruct x 10> {alignment = 16 : i64} loc(#loc5) // CHECK: cir.global external @packed_element = #cir.global_view<@PACKED, [-2 : i32, 2 : i32]> // LLVM: @PACKED = global [10 x %struct.PackedStruct] zeroinitializer + // LLVM: @packed_element = global ptr getelementptr inbounds ([10 x %struct.PackedStruct], ptr @PACKED, i32 0, i32 -2, i32 2) - // LLVM: @packed_element = global ptr getelementptr inbounds ([10 x %struct.PackedStruct], ptr @PACKED, i32 -2, i32 2) ``` Compile it with `-fclangir -S`, we got: ``` packed: .zero 30 packed_element: .quad packed-54 ``` but the traditional pipeline shows (https://godbolt.org/z/eTj96EP1E): ``` packed: .zero 30 packed_element: .quad packed-4 ``` this may be a simple mismatch.
Configuration menu - View commit details
-
Copy full SHA for bb50940 - Browse repository at this point
Copy the full SHA bb50940View commit details -
[CIR][CIRGen] Removed extra space in "cir.shift( right)" (llvm#997) (l…
…lvm#1009) The MLIR docs at https://mlir.llvm.org/docs/DefiningDialects/Operations/#literals specify that "An empty literal `` may be used to remove a space that is inserted implicitly after certain literal elements", so I inserted one before the `right` literal to remove the extra space that was being printed. Oddly, the bug is also fixed by inserting an empty literal _after_ the `left` literal, which leads me to believe that tablegen is inserting an implicit space after the `left` literal.
Configuration menu - View commit details
-
Copy full SHA for f05175f - Browse repository at this point
Copy the full SHA f05175fView commit details -
Configuration menu - View commit details
-
Copy full SHA for c8fa3f6 - Browse repository at this point
Copy the full SHA c8fa3f6View commit details -
[ClangIR][CIRGen] Introduce CaseOp and refactor SwitchOp (llvm#1006)
Close llvm#522 This solves the issue we can't handle `case` in nested scopes and we can't handle if the switch body is not a compound statement. The core idea of the patch is to introduce the `cir.case` operation to the language. Then we can get the cases by traversing the body of the `cir.switch` operation easily instead of counting the regions and the attributes. Every `cir.case` operation has a region and now the `cir.switch` has only one region too. But to make the analysis and optimizations easier, I add a new concept `simple form` here. That a simple `cir.switch` operation is: all the `cir.case` operation owned by the `cir.switch` lives in the top level blocks of the `cir.switch` region and there is no other operations except the ending `cir.yield`. This solves the previous `simplified for common-case` vs `general solution` discussion in llvm#522. After implemented this, I feel the correct answer to it is, we want a general solution for constructing and lowering the operations but we like simple and common case for analysis and optimizations. We just mixed the different phases. For other semantics, see `CIROps.td`. For lowering, we can make it generally by lower the cases one by one and finally lower the switch itself. Although this patch has 1000+ lines of changes, I feel it is relatively neat especially it erases some odd behaviors before. Tested with Spec2017's C benchmarks except 500.perlbench_r.
Configuration menu - View commit details
-
Copy full SHA for 45f49ba - Browse repository at this point
Copy the full SHA 45f49baView commit details -
[CIR][ABI][AArch64][Lowering] Initial support for return of struct ty…
…pes (llvm#1004) This PR adds a support for return values of a struct type. There are two cases that are not covered by this PR and will be added later.
Configuration menu - View commit details
-
Copy full SHA for c6a17f8 - Browse repository at this point
Copy the full SHA c6a17f8View commit details -
[CIR][Lowering] Supports varargs in the CallingConvention pass (llvm#…
…1005) This PR adds several copy-pasted lines and a small test and now var args seems to work in the calling convention pass
Configuration menu - View commit details
-
Copy full SHA for 7af5e8a - Browse repository at this point
Copy the full SHA 7af5e8aView commit details -
[CIR][CodeGen][NFC] Add some missing guards for unreachable
Reviewers: smeenai Reviewed By: smeenai Pull Request: llvm#1022
Configuration menu - View commit details
-
Copy full SHA for f90e3b9 - Browse repository at this point
Copy the full SHA f90e3b9View commit details -
[CIR][CodeGen] Store the old CIRGenFunction when popping to a new one
We diverge from CodeGen here by delaying the function emission that happens for a global variable. However, due to situations where a global can be emitted while building out a function the old CGF might not be invalid. So we need to store it here just in case. Reviewers: bcardosolopes, smeenai Reviewed By: smeenai Pull Request: llvm#1023
Configuration menu - View commit details
-
Copy full SHA for 9b7427f - Browse repository at this point
Copy the full SHA 9b7427fView commit details -
[CIR][CodeGen][NFC] Implement a missing function
This was declared but never implemented. Upon first usage in a later commit this fails to link. Reviewers: bcardosolopes, smeenai Reviewed By: smeenai Pull Request: llvm#1024
Configuration menu - View commit details
-
Copy full SHA for 88152b8 - Browse repository at this point
Copy the full SHA 88152b8View commit details -
[CIR][ABI][Lowering] Supports function pointers in the calling conven…
…tion lowering pass (llvm#1003) This PR adds initial function pointers support for the calling convention lowering pass. This is a suggestion, so any other ideas are welcome. Several ideas was described in the llvm#995 and basically what I'm trying to do is to generate a clean CIR code without additional `bitcast` operations for function pointers and without mix of lowered and initial function types. #### Problem Looks like we can not just lower the function type and cast the value since too many operations are involved. For instance, for the next simple code: ``` typedef struct { int a; } S; typedef int (*myfptr)(S); int foo(S s) { return 42 + s.a; } void bar() { myfptr a = foo; } ``` we get the next CIR for the function `bar` , before the calling convention lowering pass: ``` cir.func no_proto @bar() extra(#fn_attr) { %0 = cir.alloca !cir.ptr<!cir.func<!s32i (!ty_S)>>, !cir.ptr<!cir.ptr<!cir.func<!s32i (!ty_S)>>>, ["a", init] %1 = cir.get_global @foo : !cir.ptr<!cir.func<!s32i (!ty_S)>> cir.store %1, %0 : !cir.ptr<!cir.func<!s32i (!ty_S)>>, !cir.ptr<!cir.ptr<!cir.func<!s32i (!ty_S)>>> cir.return } ``` As one can see, first three operations depend on the function type. Once `foo` is lowered, we need to fix `GetGlobalOp`: otherwise the code will fail with the verification error since actual `foo` type (lowered) differs from the one currently expected by the `GetGlobalOp`. First idea would just rewrite only the `GetGlobalOp` and insert a bitcast after, so both `AllocaOp` and `StoreOp` would work witth proper types. Once the code will be more complex, we will need to take care about possible use cases, e.g. if we use arrays, we will need to track array accesses to it as well in order to insert this bitcast every time the array element is needed. One workaround I can think of: we fix the `GetGlobalOp` type and cast from the lowered type to the initial, and cast back before the actual call happens - but it doesn't sound as a good and clean approach (from my point of view, of course). So I suggest to use type converter and rewrite any operation that may deal with function pointers and make sure it has a proper type, and we don't have any unlowered function type in the program after the calling convention lowering pass. #### Implementation I added lowering for `AllocaOp`, `GetGlobalOp`, and split the lowering for `FuncOp` (former `CallConvLoweringPattern`) and lower `CallOp` separately. Frankly speaking, I tried to implement a pattern for each operation, but for some reasons the tests are not passed for windows and macOs in this case - something weird happens inside `applyPatternsAndFold` function. I suspect it's due to two different rewriters used - one in the `LoweringModule` and one in the mentioned function. So I decided to follow the same approach as it's done for the `LoweringPrepare` pass and don't involve this complex rewriting framework. Next I will add a type converter for the struct type, patterns for `ConstantOp` (for const arrays and `GlobalViewAttr`) In the end of the day we'll have (at least I hope so) a clean CIR code without any bitcasts for function pointers. cc @sitio-couto @bcardosolopes
Configuration menu - View commit details
-
Copy full SHA for b47fd6e - Browse repository at this point
Copy the full SHA b47fd6eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 084419a - Browse repository at this point
Copy the full SHA 084419aView commit details -
Configuration menu - View commit details
-
Copy full SHA for ed48e54 - Browse repository at this point
Copy the full SHA ed48e54View commit details -
[CIR][CIRGen] Fix "definition with same mangled name" error (llvm#1016)
We had some incorrect logic when creating functions and getting their address which resulted in spurious "definition with the same mangled name" errors. Fix that logic to match original CodeGen, which also fixes these errors. It's expected that decls can appear in the deferred decl list multiple times, and CodeGen has to guard against that. In the case that triggered the error, both `CIRGenerator::HandleInlineFunctionDefinition` and CIRGenModule were deferring the declaration. Something else I discovered here is that we emit these functions in the opposite order as regular CodeGen: https://godbolt.org/z/4PrKG7h9b. That might be a meaningful difference worth investigating further. Fixes llvm#991
Configuration menu - View commit details
-
Copy full SHA for b25af59 - Browse repository at this point
Copy the full SHA b25af59View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vrshr_n and vrshrq_n to llvm …
…intrinsics (llvm#1020) In this PR, also changed `buildNeonShiftVector` to allow it generates negative shift values. When the shift value is negative, the shift amount vector is not used in any ShiftOp of IR (as they don't need sign to know shift direction), instead, it is just input argument to shift intrinsic function call.
Configuration menu - View commit details
-
Copy full SHA for de2cce1 - Browse repository at this point
Copy the full SHA de2cce1View commit details -
[CIR][Dialect][NFC] Fix double whitespaces in
cir.func
assembly (ll……vm#1028) This PR fixes the notorious double whitespaces introduced by visibility attribute, for `cir.func` only. It uses "leading whitespace" for every print. And the printing of visibility attr is properly guarded by a check of `!isDefault()`. Double whitespaces in test files are removed.
Configuration menu - View commit details
-
Copy full SHA for ac501a2 - Browse repository at this point
Copy the full SHA ac501a2View commit details -
[CIR][CIRGen] Add support for abs (llvm#1011)
This patch introduces support for the abs family of built-in functions (abs, labs, llabs).
Configuration menu - View commit details
-
Copy full SHA for a62daa0 - Browse repository at this point
Copy the full SHA a62daa0View commit details -
[CIR][Lowering] Transform cir.store of const arrays into cir.copy
Add lowering prepare logic to lower stores to cir.copy. This bring LLVM lowering closer to OG and turns out the rest of the compiler understands memcpys better and generate better assembly code for at least arm64 and x86_64. Note that current lowering to memcpy is only using i32 intrinsic version, this PR does not touch that code and that will be addressed in another PR.
Configuration menu - View commit details
-
Copy full SHA for 89aa90c - Browse repository at this point
Copy the full SHA 89aa90cView commit details -
Configuration menu - View commit details
-
Copy full SHA for b07cb33 - Browse repository at this point
Copy the full SHA b07cb33View commit details -
[CIR][CIRGen] Fix swapped parameters in test
Clang recognizes the function anyway, but this is an obvious error.
Configuration menu - View commit details
-
Copy full SHA for bb2a2fc - Browse repository at this point
Copy the full SHA bb2a2fcView commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vtst_v and neon_vtstq_v (llvm…
…#1013) In addition, this PR enables ZeroAttr of vector type so that CIR can generate a vector initialized with all zero values.
Configuration menu - View commit details
-
Copy full SHA for edf1eda - Browse repository at this point
Copy the full SHA edf1edaView commit details -
[CIR][CIRGen] Add support for memmove (llvm#1019)
due to the issue described in llvm#1018, the MLIR lowering for `memmove` has been excluded in this patch.
Configuration menu - View commit details
-
Copy full SHA for 917c431 - Browse repository at this point
Copy the full SHA 917c431View commit details -
[CIR][ABI][AArch64] support for return struct types greater than 128 …
…bits (llvm#1027) This PR adds a support for the return values of struct types > 128 bits in size. As usually, lot's of copy-pasted lines from the original codegen, except the `AllocaOp` replacement for the return value.
Configuration menu - View commit details
-
Copy full SHA for f024214 - Browse repository at this point
Copy the full SHA f024214View commit details -
[CIR][ABI][Lowering] Supports call by function pointer in the calling…
… convention lowering pass (llvm#1034) This PR adds a support for calls by function pointers. @sitio-couto I think would be great if you'll also take a look
Configuration menu - View commit details
-
Copy full SHA for 849c2af - Browse repository at this point
Copy the full SHA 849c2afView commit details -
[CIR][CIRGen][Builtin] Support BI__builtin_operator_new and BI__built…
…in_operator_delete (llvm#1035) The added test cases are from [OG's counterpart](https://github.com/llvm/clangir/blob/f9c5477ee10c9bc005ffbfe698691cc02193ea81/clang/test/CodeGenCXX/builtin-operator-new-delete.cpp#L7). I changed run option to -std=c++17 to support [std::align_val_t](https://en.cppreference.com/w/cpp/memory/new/align_val_t)
Configuration menu - View commit details
-
Copy full SHA for fa7a1b8 - Browse repository at this point
Copy the full SHA fa7a1b8View commit details -
[CIR][ABI][Lowering] Add CCLower support for int128 on x86_64 (llvm#1036
) This PR adds calling convention lowering support for the int128 type on x86_64. This is a follow up on llvm#953 .
Configuration menu - View commit details
-
Copy full SHA for 31d37e1 - Browse repository at this point
Copy the full SHA 31d37e1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1a28ad4 - Browse repository at this point
Copy the full SHA 1a28ad4View commit details -
Configuration menu - View commit details
-
Copy full SHA for a7c9deb - Browse repository at this point
Copy the full SHA a7c9debView commit details -
[Driver] Bring back -emit-cir as a frontend option
Upstream accepted this being a ClangOption but it got lost in the rebase. Bring it back here.
Configuration menu - View commit details
-
Copy full SHA for 734507c - Browse repository at this point
Copy the full SHA 734507cView commit details -
CodeGen sometimes emits undef constants directly, e.g. when initializing an empty struct (https://godbolt.org/z/68od33aa8). We want to match this behavior, so we need a cir.undef attr to represent the constant. This change implements the lowering for the new op, which matches how cir.zero is lowered. A follow-up will change CIRGen to use it. It also replaces UndefOf with a ConstantOp of UndefAttr to avoid redundancy. Pull Request resolved: llvm#993
Configuration menu - View commit details
-
Copy full SHA for 4c8914f - Browse repository at this point
Copy the full SHA 4c8914fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e4370c - Browse repository at this point
Copy the full SHA 8e4370cView commit details -
[CIR][CIRGen] Fix const codegen for empty struct
If an empty struct has a non-trivial constexpr constructor, CodeGen emits an undef constant. CIRGen was previously emitting an empty attribute, which got interpreted as constant evaluation failing, resulting in a global variable initializer being emitted. Change to undef to match CodeGen. https://godbolt.org/z/7M9EnEddx has the comparison between current CIRGen vs. original CodeGen; it should match after this lands. Pull Request resolved: llvm#994
Configuration menu - View commit details
-
Copy full SHA for 417d6d3 - Browse repository at this point
Copy the full SHA 417d6d3View commit details -
Configuration menu - View commit details
-
Copy full SHA for b470cf7 - Browse repository at this point
Copy the full SHA b470cf7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 850bd83 - Browse repository at this point
Copy the full SHA 850bd83View commit details -
Configuration menu - View commit details
-
Copy full SHA for 85567c8 - Browse repository at this point
Copy the full SHA 85567c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 74f2c37 - Browse repository at this point
Copy the full SHA 74f2c37View commit details -
Configuration menu - View commit details
-
Copy full SHA for 48a16fc - Browse repository at this point
Copy the full SHA 48a16fcView commit details -
Configuration menu - View commit details
-
Copy full SHA for c8faebe - Browse repository at this point
Copy the full SHA c8faebeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0ad8020 - Browse repository at this point
Copy the full SHA 0ad8020View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vshr_n_v and neon_vshrq_n_v (l…
…lvm#1045) Note in the test file, `test_vshrq_n_s32_32` and `test_vshr_n_u16_16` are addition to what traditional clang code gen already has. They tested the case where shift amount is the same as element size ( compiler errors if shift amount is greater than elem size). OG didn't test that case here, but [has somewhat tested elsewhere](https://github.com/llvm/clangir/blob/3d16a0f8499c43497a18a46d838313ab4deeadea/clang/test/CodeGen/aarch64-neon-shifts.c#L23)
Configuration menu - View commit details
-
Copy full SHA for f7df2dd - Browse repository at this point
Copy the full SHA f7df2ddView commit details -
[ClangIR][CIRGen] Handle nested union in arrays of struct (llvm#1007)
Reproducer: ``` struct nested { union { const char *single; const char *const *multi; } output; }; static const char * const test[] = { "test", }; const struct nested data[] = { { { .multi = test, }, }, { { .single = "hello", }, }, }; ``` ClangIR now failed to recognize `data` as an array since it failed to recognize the initializer for union. This comes from a fundamental difference between CIR and LLVM IR. In LLVM IR, the union is simply a struct with the largest member. So it is fine to have only one init element. But in CIR, the union has the information for all members. So if we only pass a single init element, we may be in trouble. We solve the problem by appending placeholder attribute for the uninitialized fields.
Configuration menu - View commit details
-
Copy full SHA for 781a0c0 - Browse repository at this point
Copy the full SHA 781a0c0View commit details -
Configuration menu - View commit details
-
Copy full SHA for e19d2ad - Browse repository at this point
Copy the full SHA e19d2adView commit details -
[CIR][CIRGen] Support __builtin___memcpy_chk (llvm#1032)
This is just the usual adaption from CodeGen.
Configuration menu - View commit details
-
Copy full SHA for 9dcb512 - Browse repository at this point
Copy the full SHA 9dcb512View commit details -
[CIR][CIRGen] Support __builtin___memset_chk (llvm#1053)
This follows the same implementation as CodeGen. llvm#1051 tracks potentially switching to a different strategy in the future.
Configuration menu - View commit details
-
Copy full SHA for 60c8d68 - Browse repository at this point
Copy the full SHA 60c8d68View commit details -
[CIR][CIRGen] Emit required vtables (llvm#1054)
We were missing an override for this previously and thus not emitting vtables when key functions were defined.
Configuration menu - View commit details
-
Copy full SHA for ddc3e89 - Browse repository at this point
Copy the full SHA ddc3e89View commit details -
[CIR][CodeGen][NFC] Add
getMLIRContext
to CIRGenModuleUpstream review of a PR requested that we be more explicit with differentiating things from MLIR to similarly named things from clang AST/LLVM/etc. So add an MLIRContext getter that we should start using. Reviewers: bcardosolopes Reviewed By: bcardosolopes Pull Request: llvm#1047
Configuration menu - View commit details
-
Copy full SHA for 78af26c - Browse repository at this point
Copy the full SHA 78af26cView commit details -
[CIR][Dialect][NFC] Add some helpers to LoadOp
These are just missing getters/setters that should be there already. They are in use in a patch coming up. I'm splitting them out here for reviewability. Reviewers: bcardosolopes Pull Request: llvm#1021
Configuration menu - View commit details
-
Copy full SHA for 6d10568 - Browse repository at this point
Copy the full SHA 6d10568View commit details -
[CIR][ABI][AArch64][Lowering] Initial support for passing struct types (
llvm#1041) This PR adds a support for some basic cases for struct types passed by value. The hardest part probably is `createCoercedStore` function, which I rewrote significantly in order to make it closer to the orignal codegen.
Configuration menu - View commit details
-
Copy full SHA for 11feef3 - Browse repository at this point
Copy the full SHA 11feef3View commit details -
[CIR][ABI][AArch64] convers aarch64_be return struct case (llvm#1049)
This PR adds a support return struct as a value for one missed case for AArch64 big endian arch
Configuration menu - View commit details
-
Copy full SHA for 79afcd0 - Browse repository at this point
Copy the full SHA 79afcd0View commit details -
[CIR][CIRGen][Builtin][NFC] Refactor IntrinsicCallOp (llvm#1056)
`IntrinsicCallOp` is now named `LLVMIntrinsicCallOp` to better reflect its purpose. And now In CIR, we do not have "llvm" prefix which will be added later during LLVMLowering.
Configuration menu - View commit details
-
Copy full SHA for 304f1ed - Browse repository at this point
Copy the full SHA 304f1edView commit details -
[CIR][CIRGen][Builtin] Support __builtin_char_memchr (llvm#1050)
This should fix NYI like `BI__builtin_char_memchr NYI UNREACHABLE executed at clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp:1402` The test is from [OG](https://github.com/llvm/clangir/blob/3ef67c19917ad26ed8b19d4d13a43458a952fddb/clang/test/CodeGenCXX/builtins.cpp#L64) see builtin's prototype [char *__builtin_char_memchr(const char *haystack, int needle, size_t size); ](https://clang.llvm.org/docs/LanguageExtensions.html#string-builtins)
Configuration menu - View commit details
-
Copy full SHA for b4ef453 - Browse repository at this point
Copy the full SHA b4ef453View commit details -
[CIR] fix getTypeSizeInBits with fp80 and fp128 (llvm#1058)
fix llvm#1057 --------- Co-authored-by: Bruno Cardoso Lopes <[email protected]> Co-authored-by: Sirui Mu <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 67121cb - Browse repository at this point
Copy the full SHA 67121cbView commit details -
[CIR][ABI][Lowering] covers return struct case with coercion through …
…memory (llvm#1059) This PR covers one more case for return values of struct type, where `memcpy` is emitted.
Configuration menu - View commit details
-
Copy full SHA for 2a5b70d - Browse repository at this point
Copy the full SHA 2a5b70dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ff5074b - Browse repository at this point
Copy the full SHA ff5074bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0249cac - Browse repository at this point
Copy the full SHA 0249cacView commit details -
[CIR][Lowering] Add LLVM lowering support for cir.assume (llvm#1066)
This PR adds LLVMIR lowering support for `cir.assume`, `cir.assume.aligned`, and `cir.assume.separate_storage`.
Configuration menu - View commit details
-
Copy full SHA for 2404d8b - Browse repository at this point
Copy the full SHA 2404d8bView commit details -
[CIR][CodeGen] Fix the default linkage of string literals (llvm#1067)
In OG CodeGen, string literals has `private` linkage as default (marked by `cir_private` in CIR assembly). But CIR uses `internal`, which is probably an ancient typo. This PR keeps align with it and thus modifies the existing test files.
Configuration menu - View commit details
-
Copy full SHA for 1e5c1bd - Browse repository at this point
Copy the full SHA 1e5c1bdView commit details -
[CIR][ABI][AArch64][Lowering] support for passing struct types > 128 …
…bits (llvm#1068) This PR adds a partial support for so-called indirect function arguments for struct types with size > 128 bits for aarch64. #### Couple words about the implementation The hard part is that it's not one-to-one copy from the original codegen, but the code is inspired by it of course. In the original codegen there is no much job is done for the indirect arguments inside the loop in the `EmitFunctionProlog`, and additional alloca is added in the end, in the call for `EmitParamDecl` function. In our case, for the indirect argument (which is a pointer) we replace the original alloca with a new one, and store the pointer in there. And replace all the uses of the old alloca with the load from the new one, i.e. in both cases users works with the pointer to a structure. Also, I added several missed features in the `constructAttributeList` for indirect arguments, but didn't preserve the original code structure, so let me know if I need to do it.
Configuration menu - View commit details
-
Copy full SHA for 7c3bdfc - Browse repository at this point
Copy the full SHA 7c3bdfcView commit details -
[CIR][CIRGen] Add aliases for virtual dtors calls
Note that we lack two pieces of support for aliases in LLVM IR dialect globals: the `alias` keyword and function types `void (ptr)`, this needs to be done before we can nail this for good, but it's outside the scope of this commit. The behavior is slightly different under -O1, which will be addressed next.
Configuration menu - View commit details
-
Copy full SHA for b53d5ee - Browse repository at this point
Copy the full SHA b53d5eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 902c13a - Browse repository at this point
Copy the full SHA 902c13aView commit details -
[CIR][CodeGen] Use the same SSA name as OG's for string literals (llv…
…m#1073) This PR changes the naming format of string literals from `.str1` to `.str.1`, making it easier to reuse the existing testcases of OG CodeGen.
Configuration menu - View commit details
-
Copy full SHA for 6f5d545 - Browse repository at this point
Copy the full SHA 6f5d545View commit details -
[CIR] Make X86ArgClass an
enum class
(llvm#1080)It's currently polluting the `cir` namespace with very generic symbols like `Integer` and `Memory`, which is pretty confusing. `X86_64ABIInfo` already has `Class` alias for `X86ArgClass`, so we can use that alias to qualify all uses.
Configuration menu - View commit details
-
Copy full SHA for 4f54597 - Browse repository at this point
Copy the full SHA 4f54597View commit details -
[CIR][CIRGen] Fix some alias issues under -O1 and above
Note that there are still missing pieces, which will be incrementally addressed.
Configuration menu - View commit details
-
Copy full SHA for 84afe61 - Browse repository at this point
Copy the full SHA 84afe61View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2824576 - Browse repository at this point
Copy the full SHA 2824576View commit details -
[CIR][NFC] Update test comment
Just verified this is actually done by some LLVM optimization, not by the frontend emitting directly, so this is a non-goal now, since CIR can also use LLVM opts to do the same once we have real global alias.
Configuration menu - View commit details
-
Copy full SHA for e507d92 - Browse repository at this point
Copy the full SHA e507d92View commit details -
[CIR][NFC] More comments removed for ir differences
Also verified this does not apply anymore, we match -O0. The only remaing part is to lower to proper LLVM globals once LLVM IR dialect gets the global alias support.
Configuration menu - View commit details
-
Copy full SHA for cc176b7 - Browse repository at this point
Copy the full SHA cc176b7View commit details -
Configuration menu - View commit details
-
Copy full SHA for fdadaf4 - Browse repository at this point
Copy the full SHA fdadaf4View commit details -
[CIR][CIRGen][Builtin] Support __builtin_return_address (llvm#1046)
test case is from [Traditional Clang CodeGen test file](https://github.com/llvm/clangir/blob/723e78afb5ae4fbd000269a057410913ade3ef44/clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c#L5)
Configuration menu - View commit details
-
Copy full SHA for 0960f32 - Browse repository at this point
Copy the full SHA 0960f32View commit details -
[CIR] Extend support for floating point attributes (llvm#572)
This commit extends the support for floating point attributes parsing by using the new `AsmParser::parseFloat(fltSemnatics, APFloat&)` interface. As a drive-by, this commit also harmonizes the cir.fp print/parse namespace usage, and adds the constraint of supporting only "CIRFPType"s for cir.fp in tablegen instead of verifying it manually in the parsing logic. --- This commit is based on top of a to-be-upstreamed commit which extends the upstream MLIR float type parsing. Upstream parsing of float type has full capability only through parsing the Builtin Dialect's `FloatAttr`. Thos commit exposes the same capabilities to downstream users. --- This PR should resolve (at least) `GCC-C-execute-ieee-fp-cmp-2` and `GCC-C-execute-ieee-fp-cmp-4`, paving the way to other `GCC-C-execute-ieee-*` tests passing from the SingleSource suite. It resolves llvm#559 .
Configuration menu - View commit details
-
Copy full SHA for f105395 - Browse repository at this point
Copy the full SHA f105395View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7f2732b - Browse repository at this point
Copy the full SHA 7f2732bView commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_vaesmcq_u8 (llvm#1072)
The test case is from [clang/test/CodeGen/neon-crypto.c](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/test/CodeGen/neon-crypto.c#L28) Need a dedicated test file as RunOptions has crypto related target features.
Configuration menu - View commit details
-
Copy full SHA for 313a733 - Browse repository at this point
Copy the full SHA 313a733View commit details -
[CIR][CIRGen] Move CIRGen types into clang::CIRGen (llvm#1082)
llvm#1025 explains why we want to move the CIR dialect from the `mlir::cir` to the `cir` namespace. To avoid overloading the `cir` namespace too much afterwards, move all symbols whose equivalents live inside the `clang::CodeGen` namespace to a new `clang::CIRGen` namespace, so that we match the original CodeGen's structure more closely. There's some symbols that live under `clang/include/clang/CIR` whose equivalents live in `clang/lib/CodeGen` and are in the `clang::CodeGen` namespace. We have these symbols in a common location since they're also used by lowering, so I've also left them in the `cir` namespace. Those symbols are: - AArch64ABIKind - ABIArgInfo - FnInfoOpts - TypeEvaluationKind - X86AVXABILevel This is a pretty large PR out of necessity. To make it slightly more reviewable, I've split it out into three commits (which will be squashed together when the PR lands): - The first commit manually switches places to the `clang::CIRGen` namespace. This has to be manual because we only want to move things selectively. - The second commit adjusts namespace prefixes to make builds work. I ran https://gist.github.com/smeenai/f4dd441fb61c53e835c4e6057f8c322f to make this change. The script is idempotent, and I added substitutions one at a time and reviewed each one afterwards (using `git diff --color-words=.`) to ensure only intended changes were being made. - The third commit runs `git clang-format`. Because I went one-by-one with all my substitutions and checked each one afterwards, I'm pretty confident in the validity of all the changes (despite the size of the PR).
Configuration menu - View commit details
-
Copy full SHA for ccf07f6 - Browse repository at this point
Copy the full SHA ccf07f6View commit details -
[CIR][ABI][AArch64][Lowering] Support unions (llvm#1075)
As the title says, this PR adds support for unions for AArch64 lowering. The idea is basically the same as the [original](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/lib/AST/RecordLayoutBuilder.cpp#L2111) codegen, and I added a couple of tests.
Configuration menu - View commit details
-
Copy full SHA for 2333bfa - Browse repository at this point
Copy the full SHA 2333bfaView commit details -
[CIR] Merge the mlir::cir namespace into cir (llvm#1084)
llvm#1025 explains why we want to move the CIR dialect from the `mlir::cir` to the `cir` namespace. This is a large PR, and I've split it out into four commits (that'll be squashed when landing). The first commit changes `mlir::cir` to `cir` everywhere. This was originally done mechanically with: ``` find clang \( -name '*.h' -o -name '*.cpp' -o -name '*.td' \) -print0 | xargs -0 perl -pi -e 's/mlir::cir/cir/g' find clang \( -name '*.h' -o -name '*.cpp' \) -print0 | xargs -0 perl -pi -e 's/::cir/cir/g' find clang \( -name '*.h' -o -name '*.cpp' \) -print0 | xargs -0 perl -0777 -pi -e 's/namespace mlir \{\nnamespace cir \{/namespace cir {/g' find clang \( -name '*.h' -o -name '*.cpp' \) -print0 | xargs -0 perl -0777 -pi -e 's!\} // namespace cir\n\} // namespace mlir!} // namespace cir!g' ``` It then required some manual fixups to address edge cases. Code that lived under `mlir::cir` could refer to the `mlir` namespace without qualification, but after the namespace change, we need to explicitly qualify all our usages. This is done in the second commit via https://gist.github.com/smeenai/996200fd45ad123bbf22b412d59479b6, which is an idempotent script to add all qualifications. I added cases to the script one at a time and reviewed each change afterwards to ensure we were only making the intended modifications, so I feel pretty confident in the end result. I also removed `using namespace llvm` from some headers to avoid conflicts, which in turn required adding some `llvm::` qualifiers as well. The third commit fixes a test, since an error message now contains the mlir namespace. Similar tests in flang also have the namespace in their error messages, so this is an expected change. The fourth change runs `git clang-format`. Unfortunately, that doesn't work for TableGen files, so we'll have a few instances of undesirable formatting left there. I'll look into fixing that as a follow-up. I validated the end result by examining the symbols in the built Clang binary. There's nothing in the `mlir::cir` namespace anymore. https://gist.github.com/smeenai/8438fd01588109fcdbde5c8652781dc0 had the symbols which lived in `cir` and should have moved to `clang::CIRGen`, and I validated that all the symbols were moved, with the exceptions noted in llvm#1082 and the duplicated symbols noted in llvm#1025.
Configuration menu - View commit details
-
Copy full SHA for a12bfcd - Browse repository at this point
Copy the full SHA a12bfcdView commit details -
[CIR] Merge two copies of CIRGenAction.h (llvm#1085)
We have both clang/include/clang/CIRFrontendAction/CIRGenAction.h and clang/include/clang/cir/FrontendAction/CIRGenAction.h, which is a historical artifact. The latter is what's being upstreamed, so merge the former into it to avoid any confusion.
Configuration menu - View commit details
-
Copy full SHA for a8f135d - Browse repository at this point
Copy the full SHA a8f135dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8330f30 - Browse repository at this point
Copy the full SHA 8330f30View commit details -
Configuration menu - View commit details
-
Copy full SHA for d4bece8 - Browse repository at this point
Copy the full SHA d4bece8View commit details -
[CIR][CIRGen] Change buildX functions to emitX (llvm#1093)
The buildX naming convention originated when the CIRGen implementation was planned to be substantially different from original CodeGen. CIRGen is now a much closer adaption of CodeGen, and the emitX to buildX renaming just makes things more confusing, since CodeGen also has some helper functions whose names start with build or Build, so it's not immediately clear which CodeGen function corresponds to a CIRGen buildX function. Rename the buildX functions back to emitX to fix this. This diff was generated mostly mechanically. I searched for all buildX functions in CIRGen and all emitX or buildX functions in CodeGen: ``` rg '\b[Bb]uild[A-Z][A-Za-z0-9_]*\b' clang/lib/CIR/CodeGen -Io | sort -u -o /tmp/buildfuncs rg '\b([Ee]mit|[Bb]uild)[A-Z][A-Za-z0-9_]*\b' clang/lib/CodeGen -Io | sort -u -o /tmp/emitfuncs ``` I used a simple Python script to find corresponding functions: https://gist.github.com/smeenai/02be7ced8564cef5518df72606ec7b19. https://gist.github.com/smeenai/6ffd67be4249c8cebdd7fa99cfa4f13c is the resulting list of correspondences. This isn't 100% accurate because it's not accounting for the files that the functions are present in, but that's pretty unlikely to matter here, so I kept it simple. The buildX functions in CIRGen which correspond to an emitX function in CodeGen should be changed, and the ones which correspond to a BuildX function in CodeGen should not be changed. That leaves some functions without any correspondences, which required a judgement call. I scanned through all those functions, and buildVirtualMethodAttr was the only one that seemed like it shouldn't be changed to emit. I performed the replacement as follows: ``` funcs="$(awk '(/-> [Ee]/ || !/->/) && !/buildVirtualMethodAttr/ { print substr($1, 6) }' /tmp/corrfuncs | paste -sd '|')" find clang/include/clang/CIR clang/lib/CIR/{CodeGen,FrontendAction} \( -name '*.h' -o -name '*.cpp' \) -print0 | \ xargs -0 perl -pi -e "s/\bbuild($funcs)\\b/emit\\1/g" ``` The mechanical changes are in the first commit of this PR. There was a manual fixup required for a token pasting macro in CIRGenExprScalar.cpp, which is the second commit. I then ran `git clang-format`, which is the third commit. (They'll be squashed together when the PR is committed.)
Configuration menu - View commit details
-
Copy full SHA for efacbbd - Browse repository at this point
Copy the full SHA efacbbdView commit details -
[CIR][NFC] Move LoweringPrepare into CIRGen (llvm#1092)
Move LP into CIRGen and give it a handle on the CIRGenModule. A lot of code has been duplicated from CIRGen into cir/Dialect/Transforms in order to let LP live there, but with more necessary CIRGen features (e.g. EH scope and cleanups) going to be used in LP it doesn't make sense to keep it separate. Add this patch that just refactors LoweringPrepare into the CIRGen directory and give it a handle on the CGM.
Configuration menu - View commit details
-
Copy full SHA for 6ce2aaf - Browse repository at this point
Copy the full SHA 6ce2aafView commit details -
[CIR][CodeGen][LowerToLLVM] String literals for OpenCL (llvm#1091)
This PR supports string literals in OpenCL end to end, making it possible to use `printf`. This involves two changes: * In CIRGen, ensure we create the global symbol for string literals with correct `constant` address space. * In LowerToLLVM, make the lowering of `GlobalViewAttr` aware of the upstream address space. Other proper refactors are also applied. Two test cases from OG CodeGen are reused. `str_literals.cl` is the primary test, while `printf.cl` is the bonus one.
Configuration menu - View commit details
-
Copy full SHA for 09299e7 - Browse repository at this point
Copy the full SHA 09299e7View commit details -
Revert "[CIR][NFC] Move LoweringPrepare into CIRGen (llvm#1092)"
This reverts commit 4463352.
Configuration menu - View commit details
-
Copy full SHA for 8043f18 - Browse repository at this point
Copy the full SHA 8043f18View commit details -
[CIR][CIRGen] support builtin signbit (llvm#1033)
This patch adds support for the `__builtin_signbit` intrinsic. The intrinsic requires special handling for PowerPC; however, since ClangIR does not currently support PowerPC, this handling is omitted in this implementation.
Configuration menu - View commit details
-
Copy full SHA for 439ed75 - Browse repository at this point
Copy the full SHA 439ed75View commit details -
[CIR][CIRGen][Builtin] Support __builtin_memcpy_inline (llvm#1069)
The test code is from [OG's clang/test/CodeGen/builtins-memcpy-inline.c](https://github.com/llvm/clangir/blob/5f1afad625f1292ffcf02c36402d292c46213c86/clang/test/CodeGen/builtins-memcpy-inline.c#L7) Also, a little design choice when introducing MemCpyInlineOp, I chose to let it inherit CIR_MemCpyOp, so in future when we optimize MemCpy like Ops, we'd have cleaner and more unified code. However, the cost is that during LLVM lowering I'd have to convert the length from ConstOp into IntegerAttr as that's [what LLVM dialect is expecting](https://mlir.llvm.org/docs/Dialects/LLVM/#llvmintrmemcpyinline-llvmmemcpyinlineop)
Configuration menu - View commit details
-
Copy full SHA for f9ac647 - Browse repository at this point
Copy the full SHA f9ac647View commit details -
[CIR][CIRGen][Builtin] Support __sync_add_and_fetch (llvm#1077)
Notable change is to introduce helper function `buildBinaryAtomicPost` which models on [OG's `EmitBinaryAtomicPost`](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/lib/CodeGen/CGBuiltin.cpp#L340C15-L340C35). Comparing to `EmitBinaryAtomicPost`, `buildBinaryAtomicPost` is more concise as OG's ``EmitBinaryAtomicPost`` duplicates quite a bit of code from [MakeBinaryAtomicValue](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/lib/CodeGen/CGBuiltin.cpp#L340) Also, didn't implement invert as __sync_add_and_fetch does not need it, but will add it (which is a trivial work) when we implement a builtin that needs it. Test cases are from [OG](https://github.com/llvm/clangir/blob/dbf320e5c3db0410566ae561067c595308870bad/clang/test/CodeGen/Atomics.c#L134)
Configuration menu - View commit details
-
Copy full SHA for 557a21b - Browse repository at this point
Copy the full SHA 557a21bView commit details -
[CIR][CodeGen][NFC] Simplify replacing initializer of static decls (l…
…lvm#1095) When emitting initializers for static declarations, it's essential to ensure that the `cir.global` operation aligns its type with that of the initializer. The original approach creates a new global op and copies every attribute from the old one. But just `setSymType` should work well. This also removes missing feature flags there.
Configuration menu - View commit details
-
Copy full SHA for a3bf7b6 - Browse repository at this point
Copy the full SHA a3bf7b6View commit details -
[CIR][Dialect][NFC] Fix double white spaces in
cir.global
assembly (l……lvm#1096) Following llvm#1009 and llvm#1028, this PR removes the double white spaces in the assembly format of `cir.global` op. It's basically some `mlir-tablegen`-builtin magic: With `constBuilderCall` specified, we can apply `DefaultValuedAttr` with any default value we can construct from constant values. Then we can easily omit the default in assembly. Hence, we don't need to compromise anything for the wrapper attribute `cir::VisibilityAttr`. Similarly to llvm#1009, an empty literal ``` `` ``` is used to omit the leading space emitted by inner attribute. The test case `visibility-attribute.c` is modified to save the intermediate CIR to disk and reflect the effects. Double whitespaces in other test files are removed.
Configuration menu - View commit details
-
Copy full SHA for b654538 - Browse repository at this point
Copy the full SHA b654538View commit details -
[CIR] Properly ensure terminating IfOp and ScopeOp regions (llvm#1097)
The code changes modify the `cir.if` and `cir.scope` operations to ensure that their code regions are properly terminated. Previously, the if/else and scope regions could be left completely empty which is non-trivially expected in most code inspecting these ops. This led, for example, to a crash when and if clause was left empty in the source code. Now, the child regions must be terminated, either explicitly or implicitly by the default builder and assembly parser. This change improves the clarity and correctness of the code.
Configuration menu - View commit details
-
Copy full SHA for 851abf8 - Browse repository at this point
Copy the full SHA 851abf8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8fdb5be - Browse repository at this point
Copy the full SHA 8fdb5beView commit details -
[CIR][NFC] Fix formatting (llvm#1105)
This got misaligned after the namespace changes.
Configuration menu - View commit details
-
Copy full SHA for def8476 - Browse repository at this point
Copy the full SHA def8476View commit details -
[CIR][NFC] Conform if/else lowering order to match clang's output (ll…
…vm#1107) Before the commit, when flattening if/else clauses - the else body came before the "then" body, as opposed to clang's output order. This commit reverses this and hopefully allows easier comparisson between clang's output and cir's.
Configuration menu - View commit details
-
Copy full SHA for 9b678fa - Browse repository at this point
Copy the full SHA 9b678faView commit details -
[CIR] [Lowering] [X86_64] Support VAArg in shape (llvm#1100)
This patch implements transformations for VAArg in X86_64 ABI **in shape**. `In shape` means it can't work properly due to the dependent X86_64 ABI is not robust. e.g., when we want to use VAArg with `long double`, we need llvm#1087. This patch literally implement https://github.com/llvm/llvm-project/blob/d233fedfb0de882353c348cd1ac57dab619efa6d/clang/lib/CodeGen/Targets/X86.cpp#L3015-L3240 in CIR. There some differences due to the traditional pipeline are converting AST to LLVM and we're transforming CIR to CIR. And also to get the ABI Info, I moved `X86_64ABIInfo` to the header.
Configuration menu - View commit details
-
Copy full SHA for 8aa1099 - Browse repository at this point
Copy the full SHA 8aa1099View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6495df4 - Browse repository at this point
Copy the full SHA 6495df4View commit details -
[CIR][ABI][AArch64] Support struct passing with coercion through memo…
…ry (llvm#1111) This PR adds a support for one more case of passing structs by value, with `memcpy` emitted. First of all, don't worry - despite the PR seems big, it's basically consist of helpers + refactoring. Also, there is a minor change in the `CIRBaseBuilder` - I made static the `getBestAllocaInsertPoint` method in order to call it from lowering - we discussed once - and I here we just need it (or copy-paste the code, which doesn't seem good). I will add several comments in order to simplify review.
Configuration menu - View commit details
-
Copy full SHA for b9247df - Browse repository at this point
Copy the full SHA b9247dfView commit details -
Configuration menu - View commit details
-
Copy full SHA for df950d8 - Browse repository at this point
Copy the full SHA df950d8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0040a0a - Browse repository at this point
Copy the full SHA 0040a0aView commit details -
[CIR][CIRGen] Support __builtin_signbitl (llvm#1117)
follow llvm#1033 handle `LongDoubleType` with `FP80Type`.
Configuration menu - View commit details
-
Copy full SHA for 9e3a476 - Browse repository at this point
Copy the full SHA 9e3a476View commit details -
[CIR][Dialect][NFC] Refactor hardcoded attribute name strings (llvm#1122
Configuration menu - View commit details
-
Copy full SHA for 0a09c3b - Browse repository at this point
Copy the full SHA 0a09c3bView commit details -
[CIR][ABI][Lowering] Fixes calls with union type (llvm#1119)
This PR handles calls with unions passed by value in the calling convention pass. #### Implementation As one may know, data layout for unions in CIR and in LLVM differ one from another. In CIR we track all the union members, while in LLVM IR only the largest one. And here we need to take this difference into account: we need to find a type of the largest member and treat it as the first (and only) union member in order to preserve all the logic from the original codegen. There is a method `StructType::getLargestMember` - but looks like it produces different results (with the one I implemented or better to say copy-pasted). Maybe it's done intentionally, I don't know. The LLVM IR produced has also some difference from the original one. In the original IR `gep` is emitted - and we can not do the same. If we create `getMemberOp` we may fail on type checking for unions - since the first member type may differ from the largest type. This is why we create `bitcast` instead. Relates to the issue llvm#1061
Configuration menu - View commit details
-
Copy full SHA for 9d90efd - Browse repository at this point
Copy the full SHA 9d90efdView commit details -
[CIR][Builtin][NFC] More informative llvm_unreachable message in CIRG…
…enBuiltinAArch64.cpp (llvm#1124) We are still seeing crash message like `NYI UNREACHABLE executed at clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp:3304`, which is not convenient for triaging as our code base changes so fast, line number doesn't help much. So, here we replaced most of `llvm_unreachable("NYI")` with more informative message.
Configuration menu - View commit details
-
Copy full SHA for 98dc94a - Browse repository at this point
Copy the full SHA 98dc94aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ca33eb - Browse repository at this point
Copy the full SHA 6ca33ebView commit details -
[CIR][LowerToLLVM] Lowering triple from
cir.triple
attribute (llvm#……1125) Currently, the final `target triple` in LLVM IR is set in `CIRGenAction`, which is not executed by cir tools like `cir-translate`. This PR delay its assignment to LLVM lowering, enabling sharing the emitting of `target triple` between different invoking paths.
Configuration menu - View commit details
-
Copy full SHA for 09d82e7 - Browse repository at this point
Copy the full SHA 09d82e7View commit details -
[CIR][ABI][AArch64][Lowering] Support calls for struct types > 128 bi…
Configuration menu - View commit details
-
Copy full SHA for 0cc449f - Browse repository at this point
Copy the full SHA 0cc449fView commit details -
[CIR][CIRGen][Builtin] Support __builtin_elementwise_abs and extend A…
…bsOp to take vector input (llvm#1099) Extend AbsOp to take vector of int input. With it, we can support __builtin_elementwise_abs. We should in the next PR extend FpUnaryOps to support vector type input so we won't have blocker to implement all elementwise builtins completely. Now just temporarily have missingFeature `fpUnaryOPsSupportVectorType`. Currently, int type UnaryOp support vector type. FYI: [clang's documentation about elementwise builtins](https://clang.llvm.org/docs/LanguageExtensions.html#vector-builtins)
Configuration menu - View commit details
-
Copy full SHA for 8d4b850 - Browse repository at this point
Copy the full SHA 8d4b850View commit details -
[ClangIR][Lowering][NFC] Split LowerToLLVM.h from LowerToLLVM.cpp (ll…
…vm#1102) This is a NFC patch that moves declaration from LowerToLLVM.cpp. The motivation of the patch is, we hope we can use the abilities from MLIR's standard dialects without lowering **ALL** clangir operation to MLIR's standard dialects. For example, currently we have 86 operations in LowerToLLVM.cpp but only 45 operations under though MLIR. It won't be easy to add proper lowering for all operation to **different** dialects. I think the solution may be to allow **mixed** IR. So that we can lowering CIR to MLIR's standard dialects partially and we can use some existing analysis and optimizations in MLIR and then we can lower all of them (the MLIR dialects and unlowered clangir) to LLVM IR. The hybrid IR is one of the goals of MLIR as far as I know. NOTE: I completely understand that the DirectlyLLVM pipeline is the tier-1 pipeline that we want to support. The idea above won't change this. I just want to offer some oppotunities for the downstream projects and finally some chances to improve the overall ecosystem.
Configuration menu - View commit details
-
Copy full SHA for 9181e89 - Browse repository at this point
Copy the full SHA 9181e89View commit details -
[CIR][CIRGen][Builtin][Neon] Lower neon_splat_lane, neon_splat_laneq…
…, neon_splatq_lane and neon_splatq_laneq (llvm#1126)
Configuration menu - View commit details
-
Copy full SHA for 937fc31 - Browse repository at this point
Copy the full SHA 937fc31View commit details -
Configuration menu - View commit details
-
Copy full SHA for 333fa63 - Browse repository at this point
Copy the full SHA 333fa63View commit details -
[CIR][CIRGen] Support for visual bases in getAddressOfBaseClass
This is going to be raised in follow up work, which is hard to do in one go because createBaseClassAddr goes of the OG skeleton and ideally we want ApplyNonVirtualAndVirtualOffset to work naturally. This also doesn't handle null checks, coming next.
Configuration menu - View commit details
-
Copy full SHA for c0af341 - Browse repository at this point
Copy the full SHA c0af341View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b2d8ec - Browse repository at this point
Copy the full SHA 6b2d8ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8460d8a - Browse repository at this point
Copy the full SHA 8460d8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for ab13883 - Browse repository at this point
Copy the full SHA ab13883View commit details -
[CIR][CIRGen][NFC] More skeleton conformance
Now that we fixed the dep on VBase, clean up the rest of the function.
Configuration menu - View commit details
-
Copy full SHA for 3ec7fad - Browse repository at this point
Copy the full SHA 3ec7fadView commit details -
[CIR][CIRGen] Teach all uses of ApplyNonVirtualAndVirtualOffset to us…
…e BaseClassAddrOp
Configuration menu - View commit details
-
Copy full SHA for a837cf9 - Browse repository at this point
Copy the full SHA a837cf9View commit details -
[CIR] Force cir.cmp to always return bool (llvm#1110)
It was always the intention for `cir.cmp` operations to return bool result. Due to missing constraints, a bug in codegen has slipped in which created `cir.cmp` operations with result type that matches the original AST expression type. In C, as opposed to C++, boolean expression types are "int". This resulted with extra operations being codegened around boolean expressions and their usage. This commit both enforces `cir.cmp` in the op definition and fixes the mentioned bug.
Configuration menu - View commit details
-
Copy full SHA for 52f27a9 - Browse repository at this point
Copy the full SHA 52f27a9View commit details -
Configuration menu - View commit details
-
Copy full SHA for fcc722d - Browse repository at this point
Copy the full SHA fcc722dView commit details -
[CIR][CIRGen][TBAA] Initial TBAA support (llvm#1116)
This is the first patch to support TBAA, following the discussion at llvm#1076 (comment) - add skeleton for CIRGen, utilizing `decorateOperationWithTBAA` - add empty implementation in `CIRGenTBAA` - introduce `CIR_TBAAAttr` with empty body - attach `CIR_TBAAAttr` to `LoadOp` and `StoreOp` - no handling of vtable pointer - no LLVM lowering
Configuration menu - View commit details
-
Copy full SHA for f622726 - Browse repository at this point
Copy the full SHA f622726View commit details -
[CIR][ABI][AArch64][Lowering] Support structures with padding (llvm#1118
) The title describes the purpose of the PR. It adds initial support for structures with padding to the call convention lowering for AArch64. I have also _initial support_ for the missing feature [FinishLayout](https://github.com/llvm/clangir/blob/5c5d58402bebdb1e851fb055f746662d4e7eb586/clang/lib/AST/RecordLayoutBuilder.cpp#L786) for records, and the logic is gotten from the original codegen. Finally, I added a test for verification.
Configuration menu - View commit details
-
Copy full SHA for 7a3ee3f - Browse repository at this point
Copy the full SHA 7a3ee3fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2f281fc - Browse repository at this point
Copy the full SHA 2f281fcView commit details
Commits on Nov 22, 2024
-
[CIR][NFC] Refactor code for populating LLVM conversion patterns (llv…
…m#1152) The function `populateCIRToLLVMConversionPatterns` contains a spaghetti of LLVM dialect conversion patterns, which results in merge conflicts very easily. Besides, a few patterns are even registered for more than once, possibly due to careless resolution of merge conflicts. This PR attempts to mitigate this problem. Pattern names now are sorted in alphabetical order, and each source code line now only lists exactly one pattern name to reduce potential merge conflicts.
Configuration menu - View commit details
-
Copy full SHA for 8176d88 - Browse repository at this point
Copy the full SHA 8176d88View commit details -
Configuration menu - View commit details
-
Copy full SHA for ce06361 - Browse repository at this point
Copy the full SHA ce06361View commit details