[llvm] [AMDGPU] Update instrumentAddress method to support aligned size and unusual size accesses. (PR #104804)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 22:01:11 PDT 2024


================
@@ -179,6 +181,43 @@ void instrumentAddress(Module &M, IRBuilder<> &IRB, Instruction *OrigIns,
   return;
 }
 
+void instrumentAddress(Module &M, IRBuilder<> &IRB, Instruction *OrigIns,
+                       Instruction *InsertBefore, Value *Addr, Align Alignment,
+                       TypeSize TypeStoreSize, bool IsWrite,
+                       Value *SizeArgument, bool UseCalls, bool Recover,
+                       int AsanScale, int AsanOffset) {
+  if (!TypeStoreSize.isScalable()) {
+    unsigned Granularity = 1 << AsanScale;
+    const auto FixedSize = TypeStoreSize.getFixedValue();
+    switch (FixedSize) {
+    case 8:
+    case 16:
+    case 32:
+    case 64:
+    case 128:
+      if (Alignment.value() >= Granularity ||
+          Alignment.value() >= FixedSize / 8)
+        return instrumentAddressImpl(
+            M, IRB, OrigIns, InsertBefore, Addr, Alignment, FixedSize, IsWrite,
+            SizeArgument, UseCalls, Recover, AsanScale, AsanOffset);
+    }
+  }
+  // Instrument unusual size or unusual alignment.
----------------
skc7 wrote:

I haven't changed the logic much from [instrumentUnusualSizeOrAlignment ](https://github.com/llvm/llvm-project/blob/2a6136e552d24b6bf665c42a6e32efc0b2d88fbf/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp#L1941) taken from asan pass. All these API and infact the file would not be required once we move the utility APIs from asan pass to a common header file. 

https://github.com/llvm/llvm-project/pull/104804


More information about the llvm-commits mailing list