]> granicus.if.org Git - clang/commitdiff
CodeGen: correct Windows ARM C++ assertion
authorSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 5 Feb 2016 04:12:40 +0000 (04:12 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Fri, 5 Feb 2016 04:12:40 +0000 (04:12 +0000)
Because the Decl is explicitly passed as nullptr further up the call chain, it
is possible to invoke isa on a nullptr, which will assert.  Guard against the
nullptr.

Take the opportunity to reuse the helper method rather than re-implementing this
logic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259874 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp [new file with mode: 0644]

index 44111b2a8507f59b7a1b9785bd2aeb2779f43738..d4ceb0d3da119eed7c939c84acd49e310dbf9e28 100644 (file)
@@ -4889,9 +4889,6 @@ public:
 };
 
 class WindowsARMTargetCodeGenInfo : public ARMTargetCodeGenInfo {
-  void addStackProbeSizeTargetAttribute(const Decl *D, llvm::GlobalValue *GV,
-                                        CodeGen::CodeGenModule &CGM) const;
-
 public:
   WindowsARMTargetCodeGenInfo(CodeGenTypes &CGT, ARMABIInfo::ABIKind K)
       : ARMTargetCodeGenInfo(CGT, K) {}
@@ -4900,18 +4897,6 @@ public:
                            CodeGen::CodeGenModule &CGM) const override;
 };
 
-void WindowsARMTargetCodeGenInfo::addStackProbeSizeTargetAttribute(
-    const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
-  if (!isa<FunctionDecl>(D))
-    return;
-  if (CGM.getCodeGenOpts().StackProbeSize == 4096)
-    return;
-
-  llvm::Function *F = cast<llvm::Function>(GV);
-  F->addFnAttr("stack-probe-size",
-               llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
-}
-
 void WindowsARMTargetCodeGenInfo::setTargetAttributes(
     const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
   ARMTargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
diff --git a/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp b/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp
new file mode 100644 (file)
index 0000000..235d8a0
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple thumbv7--windows-msvc -S -emit-llvm -o - -x c++ %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv7--windows-itanium -fno-use-cxa-atexit -S -emit-llvm -o - -x c++ %s | FileCheck %s
+
+class C {
+public:
+  ~C();
+};
+
+static C sc;
+void f(const C &ci) { sc = ci; }
+
+// CHECK: atexit
+