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

[Codegen_LLVM] Annotate LLVM IR functions with nounwind/mustprogress attributes #6897

Merged
merged 1 commit into from
Aug 1, 2022
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
10 changes: 10 additions & 0 deletions src/CodeGen_Internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,16 @@ void set_function_attributes_from_halide_target_options(llvm::Function &fn) {
fn.addFnAttr("tune-cpu", mcpu_tune);
fn.addFnAttr("target-features", mattrs);

// Halide-generated IR is not exception-safe.
// No exception should unwind out of Halide functions.
// No exception should be thrown within Halide functions.
// All functions called by the Halide function must not unwind.
fn.setDoesNotThrow();

// Side-effect-free loops are undefined.
// But asserts and external calls *might* abort.
fn.setMustProgress();

// Turn off approximate reciprocals for division. It's too
// inaccurate even for us.
fn.addFnAttr("reciprocal-estimates", "none");
Expand Down
2 changes: 0 additions & 2 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3377,7 +3377,6 @@ void CodeGen_LLVM::visit(const Call *op) {
if (op->is_pure()) {
call->setDoesNotAccessMemory();
}
call->setDoesNotThrow();
value = call;
} else {

Expand Down Expand Up @@ -3410,7 +3409,6 @@ void CodeGen_LLVM::visit(const Call *op) {
if (op->is_pure()) {
call->setDoesNotAccessMemory();
}
call->setDoesNotThrow();
if (!call->getType()->isVoidTy()) {
value = builder->CreateInsertElement(value, call, idx);
} // otherwise leave it as undef.
Expand Down