From: Martin Sebor Date: Wed, 29 Jun 2022 16:46:43 +0000 (-0600) Subject: [InstCombine] Relax test to avoid Darwin failure. X-Git-Tag: upstream/15.0.7~3143 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d515211a0ce184e967310ec8b9541c77ef776dda;p=platform%2Fupstream%2Fllvm.git [InstCombine] Relax test to avoid Darwin failure. Avoid testing folding of atoi calls with out-of-bounds pointers. --- diff --git a/llvm/test/Transforms/InstCombine/str-int-3.ll b/llvm/test/Transforms/InstCombine/str-int-3.ll index 916d3fe..0ebbc82 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 differentiate 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