[PATCH] D52272: [InstCombine] Disable strcmp->memcmp transform for MSan.
Matt Morehouse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 19 12:38:56 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342582: [InstCombine] Disable strcmp->memcmp transform for MSan. (authored by morehouse, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52272?vs=166163&id=166170#toc
Repository:
rL LLVM
https://reviews.llvm.org/D52272
Files:
llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/InstCombine/strcmp-memcmp.ll
Index: llvm/trunk/test/Transforms/InstCombine/strcmp-memcmp.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/strcmp-memcmp.ll
+++ llvm/trunk/test/Transforms/InstCombine/strcmp-memcmp.ll
@@ -542,4 +542,19 @@
ret i32 0
}
+define i32 @strcmp_memcmp_msan([12 x i8]* dereferenceable (12) %buf) sanitize_memory {
+; CHECK-LABEL: @strcmp_memcmp_msan(
+; CHECK-NEXT: [[STRING:%.*]] = getelementptr inbounds [12 x i8], [12 x i8]* [[BUF:%.*]], i64 0, i64 0
+; CHECK-NEXT: [[CALL:%.*]] = call i32 @strcmp(i8* nonnull [[STRING]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @key, i64 0, i64 0))
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], 0
+; CHECK-NEXT: [[CONV:%.*]] = zext i1 [[CMP]] to i32
+; CHECK-NEXT: ret i32 [[CONV]]
+;
+ %string = getelementptr inbounds [12 x i8], [12 x i8]* %buf, i64 0, i64 0
+ %call = call i32 @strcmp(i8* nonnull %string, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @key, i64 0, i64 0))
+ %cmp = icmp eq i32 %call, 0
+ %conv = zext i1 %cmp to i32
+ ret i32 %conv
+}
+
declare i32 @memcmp(i8* nocapture, i8* nocapture, i64)
Index: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -171,7 +171,10 @@
if (!isDereferenceableAndAlignedPointer(Str, 1, APInt(64, Len), DL))
return false;
-
+
+ if (CI->getFunction()->hasFnAttribute(Attribute::SanitizeMemory))
+ return false;
+
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52272.166170.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180919/f4f6043d/attachment.bin>
More information about the llvm-commits
mailing list