[llvm-commits] [PATCH] [msan] Heuristic handling of unknown intrinsics

Kostya Serebryany kcc at google.com
Wed Dec 12 04:22:17 PST 2012


  few more things...


================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:998
@@ -952,1 +997,3 @@
 
+  bool hasStructArgumentOrRetVal(CallInst &I) {
+    for (unsigned Op = 0, n = I.getNumArgOperands(); Op < n; ++Op)
----------------
static? 

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1018
@@ +1017,3 @@
+      srcTy->getPrimitiveSizeInBits();
+    size_t dstSizeInBits = dstTy->isVectorTy() ?
+      dstTy->getVectorNumElements() * dstTy->getScalarSizeInBits() :
----------------
size_t srcSizeInBits = typeSizeInBits(srcTy);
size_t dstSizeInBits = typeSizeInBits(dstTy);

or even 

Value* V1 = IRB.CreateBitCast(V, intTypeWithSizeFromTy(srcTy))

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1260
@@ +1259,3 @@
+      // Fallback to generic instruction handling.
+      visitInstruction(I);
+      return;
----------------
maybe we could have this function return bool? 

if (hasStructArgumentOrRetVal(I)) return false;

and then call visitInstruction(I) where handleUnknownIntrinsic is called? 

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1269
@@ +1268,3 @@
+
+    Intrinsic::ID iid = I.getIntrinsicID();
+    IntrinsicKind IK = getIntrinsicKind(iid);
----------------
IID

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1283
@@ +1282,3 @@
+    // Guessed type of the memory access.
+    Type* MemAccessType = 0;
+    for (unsigned i = 0, n = I.getNumArgOperands(); i < n; ++i) {
----------------
"Type *foo " instead of "Type* foo"

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1282
@@ +1281,3 @@
+    int PointerOpIdx = -1;
+    // Guessed type of the memory access.
+    Type* MemAccessType = 0;
----------------
extend the comment:
... because the pointer could be wrongly types (or something)

================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1357
@@ +1356,3 @@
+      Value* OpShadow = IRB.CreateAlignedLoad(ShadowPtr, 1, "_msld");
+      if (!Shadow)
+        Shadow = OpShadow;
----------------
12 lines copy-pasted from the loop above. refactor into a function? 


http://llvm-reviews.chandlerc.com/D184



More information about the llvm-commits mailing list