Skip to content

Commit 9b1cd96

Browse files
committed
[Clang][CodeGen] Use mustprogress instead of willreturn
1 parent bc3913c commit 9b1cd96

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,8 +3639,8 @@ static void emitCheckHandlerCall(CodeGenFunction &CGF,
36393639
if (CheckHandler != SanitizerHandler::DynamicTypeCacheMiss)
36403640
B.addMemoryAttr(llvm::MemoryEffects::argMemOnly(llvm::ModRefInfo::Ref) |
36413641
llvm::MemoryEffects::inaccessibleMemOnly());
3642-
// If the handler does not return, we must hit a undefined behavior.
3643-
B.addAttribute(llvm::Attribute::WillReturn);
3642+
// If the handler does not return, it must interact with the environment in an observable way.
3643+
B.addAttribute(llvm::Attribute::MustProgress);
36443644
}
36453645

36463646
llvm::FunctionCallee Fn = CGF.CGM.CreateRuntimeFunction(

clang/test/CodeGen/ubsan-attr.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fsanitize=integer-divide-by-zero -O3 %s -o - -fsanitize-recover=integer-divide-by-zero | FileCheck %s --check-prefixes=RECOVER
33
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -fsanitize=integer-divide-by-zero -O3 %s -o - | FileCheck %s --check-prefixes=ABORT
44

5-
// RECOVER: Function Attrs: mustprogress nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: readwrite)
5+
// RECOVER: Function Attrs: mustprogress nounwind memory(read, argmem: readwrite, inaccessiblemem: readwrite)
66
// RECOVER-LABEL: define dso_local noundef range(i32 -32768, 32768) i32 @_Z4testRiRs(
77
// RECOVER-SAME: ptr noundef nonnull align 4 captures(none) dereferenceable(4) [[A:%.*]], ptr noundef nonnull readonly align 2 captures(none) dereferenceable(2) [[C:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
88
// RECOVER-NEXT: [[ENTRY:.*:]]
@@ -44,10 +44,11 @@ int test(int &a, short &c) {
4444
}
4545

4646
// Make sure that we don't eliminate the call to ubsan handler.
47-
// RECOVER: Function Attrs: mustprogress nofree norecurse noreturn nosync nounwind willreturn memory(none)
47+
// RECOVER: Function Attrs: mustprogress noreturn nounwind memory(read, argmem: none, inaccessiblemem: readwrite)
4848
// RECOVER-LABEL: define dso_local noundef i32 @_Z16test_unreachablev(
4949
// RECOVER-SAME: ) local_unnamed_addr #[[ATTR2:[0-9]+]] {
5050
// RECOVER-NEXT: [[ENTRY:.*:]]
51+
// RECOVER-NEXT: tail call void @__ubsan_handle_divrem_overflow(ptr nonnull @{{.+}}, i64 1, i64 0) #[[ATTR3]], !nosanitize [[META9]]
5152
// RECOVER-NEXT: unreachable
5253
//
5354
// ABORT: Function Attrs: mustprogress noreturn nounwind
@@ -65,9 +66,9 @@ int test_unreachable() {
6566
}
6667

6768
//.
68-
// RECOVER: attributes #[[ATTR0]] = { mustprogress nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: readwrite) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
69-
// RECOVER: attributes #[[ATTR1:[0-9]+]] = { mustprogress willreturn memory(argmem: read, inaccessiblemem: readwrite) uwtable }
70-
// RECOVER: attributes #[[ATTR2]] = { mustprogress nofree norecurse noreturn nosync nounwind willreturn memory(none) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
69+
// RECOVER: attributes #[[ATTR0]] = { mustprogress nounwind memory(read, argmem: readwrite, inaccessiblemem: readwrite) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
70+
// RECOVER: attributes #[[ATTR1:[0-9]+]] = { mustprogress memory(argmem: read, inaccessiblemem: readwrite) uwtable }
71+
// RECOVER: attributes #[[ATTR2]] = { mustprogress noreturn nounwind memory(read, argmem: none, inaccessiblemem: readwrite) "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }
7172
// RECOVER: attributes #[[ATTR3]] = { nomerge nounwind }
7273
//.
7374
// ABORT: attributes #[[ATTR0]] = { mustprogress nounwind "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" }

0 commit comments

Comments
 (0)