r259874 - CodeGen: correct Windows ARM C++ assertion
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 4 20:12:40 PST 2016
Author: compnerd
Date: Thu Feb 4 22:12:40 2016
New Revision: 259874
URL: http://llvm.org/viewvc/llvm-project?rev=259874&view=rev
Log:
CodeGen: correct Windows ARM C++ assertion
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.
Added:
cfe/trunk/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=259874&r1=259873&r2=259874&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Feb 4 22:12:40 2016
@@ -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);
Added: cfe/trunk/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp?rev=259874&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/windows-on-arm-stack-probe-size.cpp Thu Feb 4 22:12:40 2016
@@ -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
+
More information about the cfe-commits
mailing list