[PATCH] D107509: Disable LibFuncs for stpcpy and stpncpy for Android < 21

Nathan Lanza via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 4 19:49:05 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG58481663692b: Disable LibFuncs for stpcpy and stpncpy for Android < 21 (authored by lanza).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107509/new/

https://reviews.llvm.org/D107509

Files:
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/Transforms/InstCombine/sprintf-1.ll


Index: llvm/test/Transforms/InstCombine/sprintf-1.ll
===================================================================
--- llvm/test/Transforms/InstCombine/sprintf-1.ll
+++ llvm/test/Transforms/InstCombine/sprintf-1.ll
@@ -5,6 +5,7 @@
 ; RUN: opt < %s -mtriple xcore-xmos-elf -instcombine -S | FileCheck %s -check-prefixes=CHECK,CHECK-IPRINTF
 ; RUN: opt < %s -mtriple=i386-pc-windows-msvc -instcombine -S | FileCheck %s --check-prefixes=CHECK,WIN
 ; RUN: opt < %s -mtriple=i386-mingw32 -instcombine -S | FileCheck %s --check-prefixes=CHECK,WIN
+; RUN: opt < %s -mtriple=armv7-none-linux-android16 -instcombine -S | FileCheck %s --check-prefixes=CHECK,ANDROID
 
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
 
@@ -108,6 +109,12 @@
 ; WIN-NEXT:    [[LENINC:%.*]] = add i32 [[STRLEN]], 1
 ; WIN-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[DST:%.*]], i8* align 1 [[STR]], i32 [[LENINC]], i1 false)
 ; WIN-NEXT:    ret i32 [[STRLEN]]
+;
+; ANDROID-LABEL: @test_simplify7(
+; ANDROID-NEXT:    [[STRLEN:%.*]] = call i32 @strlen(i8* noundef nonnull dereferenceable(1) [[STR:%.*]])
+; ANDROID-NEXT:    [[LENINC:%.*]] = add i32 [[STRLEN]], 1
+; ANDROID-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 [[DST:%.*]], i8* align 1 [[STR]], i32 [[LENINC]], i1 false)
+; ANDROID-NEXT:    ret i32 [[STRLEN]]
 ;
   %fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
   %r = call i32 (i8*, i8*, ...) @sprintf(i8* %dst, i8* %fmt, i8* %str)
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -589,6 +589,11 @@
     TLI.setAvailable(LibFunc_fgets_unlocked);
   }
 
+  if (T.isAndroid() && T.isAndroidVersionLT(21)) {
+    TLI.setUnavailable(LibFunc_stpcpy);
+    TLI.setUnavailable(LibFunc_stpncpy);
+  }
+
   // As currently implemented in clang, NVPTX code has no standard library to
   // speak of.  Headers provide a standard-ish library implementation, but many
   // of the signatures are wrong -- for example, many libm functions are not


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107509.364328.patch
Type: text/x-patch
Size: 2218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/2767ddb0/attachment.bin>


More information about the llvm-commits mailing list