}
}
if (auto *CB = dyn_cast<CallBase>(I)) {
- if (Function *F = CB->getCalledFunction()) {
- LibFunc LF;
- if (TLI.getLibFunc(*F, LF) && TLI.has(LF)) {
- switch (LF) {
- case LibFunc_strcpy:
- case LibFunc_strncpy:
- case LibFunc_strcat:
- case LibFunc_strncat:
- return true;
- default:
- return false;
- }
+ LibFunc LF;
+ if (TLI.getLibFunc(*CB, LF) && TLI.has(LF)) {
+ switch (LF) {
+ case LibFunc_strcpy:
+ case LibFunc_strncpy:
+ case LibFunc_strcat:
+ case LibFunc_strncat:
+ return true;
+ default:
+ return false;
}
}
}
return {MemoryLocation::getForDest(MTI)};
if (auto *CB = dyn_cast<CallBase>(I)) {
- if (Function *F = CB->getCalledFunction()) {
- StringRef FnName = F->getName();
- if (TLI.has(LibFunc_strcpy) && FnName == TLI.getName(LibFunc_strcpy))
- return {MemoryLocation(CB->getArgOperand(0))};
- if (TLI.has(LibFunc_strncpy) && FnName == TLI.getName(LibFunc_strncpy))
- return {MemoryLocation(CB->getArgOperand(0))};
- if (TLI.has(LibFunc_strcat) && FnName == TLI.getName(LibFunc_strcat))
- return {MemoryLocation(CB->getArgOperand(0))};
- if (TLI.has(LibFunc_strncat) && FnName == TLI.getName(LibFunc_strncat))
+ LibFunc LF;
+ if (TLI.getLibFunc(*CB, LF) && TLI.has(LF)) {
+ switch (LF) {
+ case LibFunc_strcpy:
+ case LibFunc_strncpy:
+ case LibFunc_strcat:
+ case LibFunc_strncat:
return {MemoryLocation(CB->getArgOperand(0))};
+ default:
+ break;
+ }
}
return None;
}
; RUN: opt -S -basic-aa -dse -enable-dse-memoryssa < %s | FileCheck %s
+target triple = "x86_64-unknown-linux-gnu"
+
declare i8* @strcpy(i8* %dest, i8* %src) nounwind
define void @test1(i8* %src) {
; CHECK-LABEL: @test1(
ret void
}
-declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
+declare i8* @strncpy(i8* %dest, i8* %src, i64 %n) nounwind
define void @test2(i8* %src) {
; CHECK-LABEL: @test2(
%B = alloca [16 x i8]
%dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
; CHECK-NOT: @strncpy
- %call = call i8* @strncpy(i8* %dest, i8* %src, i32 12)
+ %call = call i8* @strncpy(i8* %dest, i8* %src, i64 12)
; CHECK: ret void
ret void
}
ret void
}
-declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
+declare i8* @strncat(i8* %dest, i8* %src, i64 %n) nounwind
define void @test4(i8* %src) {
; CHECK-LABEL: @test4(
%B = alloca [16 x i8]
%dest = getelementptr inbounds [16 x i8], [16 x i8]* %B, i64 0, i64 0
; CHECK-NOT: @strncat
- %call = call i8* @strncat(i8* %dest, i8* %src, i32 12)
+ %call = call i8* @strncat(i8* %dest, i8* %src, i64 12)
; CHECK: ret void
ret void
}