Skip to content
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] Allow CIRGen for builtin calls with math errorno override #893

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ RValue CIRGenFunction::buildBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
// '#pragma float_control(precise, on)'. This pragma disables fast-math,
// which implies math-errno.
if (E->hasStoredFPFeatures()) {
llvm_unreachable("NYI");
FPOptionsOverride OP = E->getFPFeatures();
if (OP.hasMathErrnoOverride())
ErrnoOverriden = OP.getMathErrnoOverride();
}
// True if 'atttibute__((optnone)) is used. This attibute overrides
// fast-math which implies math-errno.
Expand Down Expand Up @@ -1627,4 +1629,4 @@ mlir::cir::FuncOp CIRGenModule::getBuiltinLibFunction(const FunctionDecl *FD,

auto Ty = getTypes().ConvertType(FD->getType());
return GetOrCreateCIRFunction(Name, Ty, D, /*ForVTable=*/false);
}
}
15 changes: 15 additions & 0 deletions clang/test/CIR/CodeGen/builtin-abort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -fclangir -emit-llvm %s -o %t.ll
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM

void abort();
void test() { abort(); }

// TODO: Add test to test unreachable when CIR support for NORETURN is added.

// CIR-LABEL: test
// CIR: cir.call @abort() : () -> ()

// LLVM-LABEL: test
// LLVM: call void @abort()