[llvm] r279332 - Revert "[asan] Add support of lifetime poisoning into ComputeASanStackFrameLayout"

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 15:12:58 PDT 2016


Author: vitalybuka
Date: Fri Aug 19 17:12:58 2016
New Revision: 279332

URL: http://llvm.org/viewvc/llvm-project?rev=279332&view=rev
Log:
Revert "[asan] Add support of lifetime poisoning into ComputeASanStackFrameLayout"

This reverts commit r279020.

Speculative revert in hope to fix asan test on arm.

Modified:
    llvm/trunk/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    llvm/trunk/lib/Transforms/Utils/ASanStackFrameLayout.cpp
    llvm/trunk/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp

Modified: llvm/trunk/include/llvm/Transforms/Utils/ASanStackFrameLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/ASanStackFrameLayout.h?rev=279332&r1=279331&r2=279332&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/ASanStackFrameLayout.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/ASanStackFrameLayout.h Fri Aug 19 17:12:58 2016
@@ -24,19 +24,16 @@ class AllocaInst;
 static const int kAsanStackLeftRedzoneMagic = 0xf1;
 static const int kAsanStackMidRedzoneMagic = 0xf2;
 static const int kAsanStackRightRedzoneMagic = 0xf3;
-static const int kAsanStackUseAfterScopeMagic = 0xf8;
 
 // Input/output data struct for ComputeASanStackFrameLayout.
 struct ASanStackVariableDescription {
-  const char *Name;    // Name of the variable that will be displayed by asan
-                       // if a stack-related bug is reported.
-  uint64_t Size;       // Size of the variable in bytes.
-  size_t LifetimeSize; // Size in bytes to use for lifetime analysis check.
-                       // Will be rounded up to Granularity.
-  size_t Alignment;    // Alignment of the variable (power of 2).
-  AllocaInst *AI;      // The actual AllocaInst.
-  size_t Offset;       // Offset from the beginning of the frame;
-                       // set by ComputeASanStackFrameLayout.
+  const char *Name;  // Name of the variable that will be displayed by asan
+                     // if a stack-related bug is reported.
+  uint64_t Size;     // Size of the variable in bytes.
+  size_t Alignment;  // Alignment of the variable (power of 2).
+  AllocaInst *AI;    // The actual AllocaInst.
+  size_t Offset;     // Offset from the beginning of the frame;
+                     // set by ComputeASanStackFrameLayout.
 };
 
 // Output data struct for ComputeASanStackFrameLayout.

Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=279332&r1=279331&r2=279332&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Fri Aug 19 17:12:58 2016
@@ -2079,10 +2079,7 @@ void FunctionStackPoisoner::poisonStack(
   for (AllocaInst *AI : AllocaVec) {
     ASanStackVariableDescription D = {AI->getName().data(),
                                       ASan.getAllocaSizeInBytes(*AI),
-                                      0,
-                                      AI->getAlignment(),
-                                      AI,
-                                      0};
+                                      AI->getAlignment(), AI, 0};
     SVD.push_back(D);
   }
   // Minimal header size (left redzone) is 4 pointers,

Modified: llvm/trunk/lib/Transforms/Utils/ASanStackFrameLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ASanStackFrameLayout.cpp?rev=279332&r1=279331&r2=279332&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ASanStackFrameLayout.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ASanStackFrameLayout.cpp Fri Aug 19 17:12:58 2016
@@ -81,26 +81,19 @@ ComputeASanStackFrameLayout(SmallVectorI
     assert(Layout->FrameAlignment >= Alignment);
     assert((Offset % Alignment) == 0);
     assert(Size > 0);
-    assert(Vars[i].LifetimeSize <= Size);
     StackDescription << " " << Offset << " " << Size << " " << strlen(Name)
                      << " " << Name;
     size_t NextAlignment = IsLast ? Granularity
                    : std::max(Granularity, Vars[i + 1].Alignment);
     size_t SizeWithRedzone = VarAndRedzoneSize(Vars[i].Size, NextAlignment);
-    size_t LifetimeShadowSize =
-        (Vars[i].LifetimeSize + Granularity - 1) / Granularity;
-    SB.insert(SB.end(), LifetimeShadowSize, kAsanStackUseAfterScopeMagic);
-    if (Size / Granularity >= LifetimeShadowSize) {
-      SB.insert(SB.end(), Size / Granularity - LifetimeShadowSize, 0);
-      if (Size % Granularity)
-        SB.insert(SB.end(), Size % Granularity);
-    }
+    SB.insert(SB.end(), Size / Granularity, 0);
+    if (Size % Granularity)
+      SB.insert(SB.end(), Size % Granularity);
     SB.insert(SB.end(), (SizeWithRedzone - Size) / Granularity,
         IsLast ? kAsanStackRightRedzoneMagic
         : kAsanStackMidRedzoneMagic);
     Vars[i].Offset = Offset;
     Offset += SizeWithRedzone;
-    assert(Offset == SB.size() * Granularity);
   }
   if (Offset % MinHeaderSize) {
     size_t ExtraRedzone = MinHeaderSize - (Offset % MinHeaderSize);

Modified: llvm/trunk/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp?rev=279332&r1=279331&r2=279332&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/ASanStackFrameLayoutTest.cpp Fri Aug 19 17:12:58 2016
@@ -21,9 +21,6 @@ ShadowBytesToString(ArrayRef<uint8_t> Sh
       case kAsanStackLeftRedzoneMagic:    os << "L"; break;
       case kAsanStackRightRedzoneMagic:   os << "R"; break;
       case kAsanStackMidRedzoneMagic:     os << "M"; break;
-      case kAsanStackUseAfterScopeMagic:
-        os << "S";
-        break;
       default:                            os << (unsigned)ShadowBytes[i];
     }
   }
@@ -45,28 +42,27 @@ TEST(ASanStackFrameLayout, Test) {
 #define VEC(a)                                                                 \
   SmallVector<ASanStackVariableDescription, 10>(a, a + sizeof(a) / sizeof(a[0]))
 
-#define VAR(name, size, lifetime, alignment)                                   \
+#define VAR(name, size, alignment)                                             \
   ASanStackVariableDescription name##size##_##alignment = {                    \
     #name #size "_" #alignment,                                                \
     size,                                                                      \
-    lifetime,                                                                  \
     alignment,                                                                 \
     0,                                                                         \
     0                                                                          \
   }
 
-  VAR(a, 1, 0, 1);
-  VAR(p, 1, 0, 32);
-  VAR(p, 1, 0, 256);
-  VAR(a, 2, 0, 1);
-  VAR(a, 3, 0, 1);
-  VAR(a, 4, 0, 1);
-  VAR(a, 7, 0, 1);
-  VAR(a, 8, 8, 1);
-  VAR(a, 9, 0, 1);
-  VAR(a, 16, 0, 1);
-  VAR(a, 41, 9, 1);
-  VAR(a, 105, 103, 1);
+  VAR(a, 1, 1);
+  VAR(p, 1, 32);
+  VAR(p, 1, 256);
+  VAR(a, 2, 1);
+  VAR(a, 3, 1);
+  VAR(a, 4, 1);
+  VAR(a, 7, 1);
+  VAR(a, 8, 1);
+  VAR(a, 9, 1);
+  VAR(a, 16, 1);
+  VAR(a, 41, 1);
+  VAR(a, 105, 1);
 
   TestLayout(VEC1(a1_1), 8, 16, "1 16 1 4 a1_1", "LL1R");
   TestLayout(VEC1(a1_1), 64, 64, "1 64 1 4 a1_1", "L1");
@@ -78,25 +74,27 @@ TEST(ASanStackFrameLayout, Test) {
   TestLayout(VEC1(a3_1), 8, 32, "1 32 3 4 a3_1", "LLLL3RRR");
   TestLayout(VEC1(a4_1), 8, 32, "1 32 4 4 a4_1", "LLLL4RRR");
   TestLayout(VEC1(a7_1), 8, 32, "1 32 7 4 a7_1", "LLLL7RRR");
-  TestLayout(VEC1(a8_1), 8, 32, "1 32 8 4 a8_1", "LLLLSRRR");
+  TestLayout(VEC1(a8_1), 8, 32, "1 32 8 4 a8_1", "LLLL0RRR");
   TestLayout(VEC1(a9_1), 8, 32, "1 32 9 4 a9_1", "LLLL01RR");
   TestLayout(VEC1(a16_1), 8, 32, "1 32 16 5 a16_1", "LLLL00RR");
   TestLayout(VEC1(p1_256), 8, 32, "1 256 1 6 p1_256",
              "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1RRR");
-  TestLayout(VEC1(a41_1), 8, 32, "1 32 41 5 a41_1", "LLLLSS0001RRRRRR");
+  TestLayout(VEC1(a41_1), 8, 32, "1 32 41 5 a41_1", "LLLL000001RRRRRR");
   TestLayout(VEC1(a105_1), 8, 32, "1 32 105 6 a105_1",
-             "LLLLSSSSSSSSSSSSS1RRRRRR");
+             "LLLL00000000000001RRRRRR");
 
   {
     ASanStackVariableDescription t[] = {a1_1, p1_256};
-    TestLayout(VEC(t), 8, 32, "2 256 1 6 p1_256 272 1 4 a1_1",
-               "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL1M1R");
+    TestLayout(VEC(t), 8, 32,
+               "2 256 1 6 p1_256 272 1 4 a1_1",
+               "LLLLLLLL" "LLLLLLLL" "LLLLLLLL" "LLLLLLLL" "1M1R");
   }
 
   {
     ASanStackVariableDescription t[] = {a1_1, a16_1, a41_1};
-    TestLayout(VEC(t), 8, 32, "3 32 1 4 a1_1 48 16 5 a16_1 80 41 5 a41_1",
-               "LLLL1M00MMSS0001RRRR");
+    TestLayout(VEC(t), 8, 32,
+               "3 32 1 4 a1_1 48 16 5 a16_1 80 41 5 a41_1",
+               "LLLL" "1M00" "MM00" "0001" "RRRR");
   }
 #undef VEC1
 #undef VEC




More information about the llvm-commits mailing list