[llvm] d515211 - [InstCombine] Relax test to avoid Darwin failure.
Martin Sebor via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 09:52:20 PDT 2022
Author: Martin Sebor
Date: 2022-06-29T10:51:27-06:00
New Revision: d515211a0ce184e967310ec8b9541c77ef776dda
URL: https://github.com/llvm/llvm-project/commit/d515211a0ce184e967310ec8b9541c77ef776dda
DIFF: https://github.com/llvm/llvm-project/commit/d515211a0ce184e967310ec8b9541c77ef776dda.diff
LOG: [InstCombine] Relax test to avoid Darwin failure.
Avoid testing folding of atoi calls with out-of-bounds pointers.
Added:
Modified:
llvm/test/Transforms/InstCombine/str-int-3.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/str-int-3.ll b/llvm/test/Transforms/InstCombine/str-int-3.ll
index 916d3fed5b45..0ebbc8299450 100644
--- a/llvm/test/Transforms/InstCombine/str-int-3.ll
+++ b/llvm/test/Transforms/InstCombine/str-int-3.ll
@@ -57,20 +57,21 @@ define void @fold_atoi_member(i32* %pi) {
}
-; Fold atoi with an excessive offset. It's undefined so folding it to zero
-; is valid and might prevent crashes or returning a bogus value, even though
-; it prevents detecting the bug by sanitizers.
-
-define void @call_atoi_offset_out_of_bounds(i32* %pi) {
-; CHECK-LABEL: @call_atoi_offset_out_of_bounds(
-; CHECK-NEXT: store i32 0, i32* [[PI:%.*]], align 4
-; CHECK-NEXT: [[IA_0_0_33:%.*]] = call i32 @atoi(i8* getelementptr ([2 x %struct.A], [2 x %struct.A]* @a, i64 1, i64 0, i32 0, i64 1))
-; CHECK-NEXT: store i32 [[IA_0_0_33]], i32* [[PI]], align 4
-; CHECK-NEXT: ret void
+; TODO: Fold atoi with an excessive offset. It's undefined so folding it
+; to zero is valid and might prevent crashes or returning a bogus value,
+; even though it prevents detecting the bug by sanitizers.
+; This is not fully implemented because the out-of-bounds offset results
+; in the empty string which atoi (via strtol) is required to interpret as
+; a zero but for which it may set errno to EINVAL. To fold only
+; the undefined calls the folder would have to
diff erentiate between
+; the empty string an out-of-bounds pointer.
+
+define void @fold_atoi_offset_out_of_bounds(i32* %pi) {
+; CHECK-LABEL: @fold_atoi_offset_out_of_bounds(
+; TODO: Check folding.
;
; Fold atoi((const char*)a + sizeof a) to zero.
- %pa_0_0_32 = getelementptr [2 x %struct.A], [2 x %struct.A]* @a, i64 0, i64 0, i32 0, i64 32
- %ia_0_0_32 = call i32 @atoi(i8* %pa_0_0_32)
+ %ia_0_0_32 = call i32 @atoi(i8* getelementptr inbounds ([2 x %struct.A], [2 x %struct.A]* @a, i64 1, i64 0, i32 0, i64 0))
%pia_0_0_32 = getelementptr i32, i32* %pi, i32 0
store i32 %ia_0_0_32, i32* %pia_0_0_32
More information about the llvm-commits
mailing list