Skip to content

Commit 193ea83

Browse files
committed
[SimplifyLibCalls] Don't infer call-site nocapture on atoi
This is already inferred on the function declaration by BLC, there is no need to also do it at the call-site.
1 parent 87750c9 commit 193ea83

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,8 +3191,6 @@ Value *LibCallSimplifier::optimizeToAscii(CallInst *CI, IRBuilderBase &B) {
31913191

31923192
// Fold calls to atoi, atol, and atoll.
31933193
Value *LibCallSimplifier::optimizeAtoi(CallInst *CI, IRBuilderBase &B) {
3194-
CI->addParamAttr(0, Attribute::NoCapture);
3195-
31963194
StringRef Str;
31973195
if (!getConstantStringInfo(CI->getArgOperand(0), Str))
31983196
return nullptr;

llvm/test/Transforms/InstCombine/str-int-2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ define i64 @strtol_not_const_str(ptr %s) #0 {
8181

8282
define i32 @atoi_not_const_str(ptr %s) #0 {
8383
; CHECK-LABEL: @atoi_not_const_str(
84-
; CHECK-NEXT: [[CALL:%.*]] = call i32 @atoi(ptr nocapture [[S:%.*]])
84+
; CHECK-NEXT: [[CALL:%.*]] = call i32 @atoi(ptr [[S:%.*]])
8585
; CHECK-NEXT: ret i32 [[CALL]]
8686
;
8787
%call = call i32 @atoi(ptr %s) #4

llvm/test/Transforms/InstCombine/str-int-3.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ define void @fold_atoi_member(ptr %pi) {
6666

6767
define void @fold_atoi_offset_out_of_bounds(ptr %pi) {
6868
; CHECK-LABEL: @fold_atoi_offset_out_of_bounds(
69-
; CHECK-NEXT: [[IA_0_0_32:%.*]] = call i32 @atoi(ptr nocapture nonnull getelementptr inbounds nuw (i8, ptr @a, i64 32))
69+
; CHECK-NEXT: [[IA_0_0_32:%.*]] = call i32 @atoi(ptr nonnull getelementptr inbounds nuw (i8, ptr @a, i64 32))
7070
; CHECK-NEXT: store i32 [[IA_0_0_32]], ptr [[PI:%.*]], align 4
71-
; CHECK-NEXT: [[IA_0_0_33:%.*]] = call i32 @atoi(ptr nocapture getelementptr (i8, ptr @a, i64 33))
71+
; CHECK-NEXT: [[IA_0_0_33:%.*]] = call i32 @atoi(ptr getelementptr (i8, ptr @a, i64 33))
7272
; CHECK-NEXT: store i32 [[IA_0_0_33]], ptr [[PI]], align 4
7373
; CHECK-NEXT: ret void
7474
;

llvm/test/Transforms/InstCombine/str-int.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ define i32 @strtol_not_const_str(ptr %s) #0 {
8484

8585
define i32 @atoi_not_const_str(ptr %s) #0 {
8686
; CHECK-LABEL: @atoi_not_const_str(
87-
; CHECK-NEXT: [[CALL:%.*]] = call i32 @atoi(ptr nocapture [[S:%.*]])
87+
; CHECK-NEXT: [[CALL:%.*]] = call i32 @atoi(ptr [[S:%.*]])
8888
; CHECK-NEXT: ret i32 [[CALL]]
8989
;
9090
%call = call i32 @atoi(ptr %s) #4

llvm/test/Transforms/InstCombine/strcall-no-nul.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ define void @fold_strcspn_past_end(ptr %poff) {
268268

269269
define i32 @fold_atoi_past_end() {
270270
; CHECK-LABEL: @fold_atoi_past_end(
271-
; CHECK-NEXT: [[I:%.*]] = call i32 @atoi(ptr nocapture nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
271+
; CHECK-NEXT: [[I:%.*]] = call i32 @atoi(ptr nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
272272
; CHECK-NEXT: ret i32 [[I]]
273273
;
274274
%p5 = getelementptr [5 x i8], ptr @a5, i32 0, i32 5
@@ -282,9 +282,9 @@ define i32 @fold_atoi_past_end() {
282282

283283
define void @fold_atol_strtol_past_end(ptr %ps) {
284284
; CHECK-LABEL: @fold_atol_strtol_past_end(
285-
; CHECK-NEXT: [[I0:%.*]] = call i64 @atol(ptr nocapture nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
285+
; CHECK-NEXT: [[I0:%.*]] = call i64 @atol(ptr nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
286286
; CHECK-NEXT: store i64 [[I0]], ptr [[PS:%.*]], align 4
287-
; CHECK-NEXT: [[I1:%.*]] = call i64 @atoll(ptr nocapture nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
287+
; CHECK-NEXT: [[I1:%.*]] = call i64 @atoll(ptr nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5))
288288
; CHECK-NEXT: [[P1:%.*]] = getelementptr i8, ptr [[PS]], i64 8
289289
; CHECK-NEXT: store i64 [[I1]], ptr [[P1]], align 4
290290
; CHECK-NEXT: [[I2:%.*]] = call i64 @strtol(ptr nocapture nonnull getelementptr inbounds nuw (i8, ptr @a5, i64 5), ptr null, i32 0)

0 commit comments

Comments
 (0)