[PATCH] D13455: [safestack] Fast access to the unsafe stack pointer on AArch64/Android.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 17:21:59 PDT 2015


echristo added inline comments.

================
Comment at: lib/CodeGen/TargetLoweringBase.cpp:1677
@@ +1676,3 @@
+    // thread-local variable with a magic name.
+    const char *kUnsafeStackPtrVar = "__safestack_unsafe_stack_ptr";
+    auto UnsafeStackPtr =
----------------
Naming, and you can just fold it in as well.

================
Comment at: lib/CodeGen/TargetLoweringBase.cpp:1686-1690
@@ +1685,7 @@
+      UnsafeStackPtr = new GlobalVariable(
+          /*Module=*/*M, /*Type=*/StackPtrTy,
+          /*isConstant=*/false, /*Linkage=*/GlobalValue::ExternalLinkage,
+          /*Initializer=*/0, /*Name=*/kUnsafeStackPtrVar,
+          /*InsertBefore=*/nullptr,
+          /*ThreadLocalMode=*/GlobalValue::InitialExecTLSModel);
+    } else {
----------------
Pretty much all the arguments are fairly self explanatory, probably don't need the comments.

================
Comment at: lib/CodeGen/TargetLoweringBase.cpp:1693
@@ +1692,3 @@
+      // The variable exists, check its type and attributes.
+      if (UnsafeStackPtr->getValueType() != StackPtrTy) {
+        report_fatal_error(Twine(kUnsafeStackPtrVar) + " must have void* type");
----------------
No braces.

================
Comment at: lib/CodeGen/TargetLoweringBase.cpp:1697
@@ +1696,3 @@
+
+      if (!UnsafeStackPtr->isThreadLocal()) {
+        report_fatal_error(Twine(kUnsafeStackPtrVar) + " must be thread-local");
----------------
Ditto.

================
Comment at: lib/Target/AArch64/AArch64Subtarget.h:126-128
@@ -125,2 +125,5 @@
   bool isTargetWindows() const { return TargetTriple.isOSWindows(); }
+  bool isTargetAndroid() const {
+    return TargetTriple.getEnvironment() == Triple::Android;
+  }
 
----------------
Given how pervasive this is now, it'll probably be worth splitting this out into a separate commit and doing a look for Triple.isAndroid() and updating all of the callers in llvm and clang.


Repository:
  rL LLVM

http://reviews.llvm.org/D13455





More information about the llvm-commits mailing list