aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTBAA.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-04-24 06:57:01 +0000
committerKostya Serebryany <kcc@google.com>2012-04-24 06:57:01 +0000
commitc9fe6056e4ce8ffad1ef439fca3318a5faf1c075 (patch)
treef18e188f2dbd00fc655808c23d90c0e187611d60 /lib/CodeGen/CodeGenTBAA.cpp
parent8ac95f19e6b8efc453de972dfb22ca56d54c627e (diff)
enable TBAA when -fthread-sanitizer is given, even with -O0 or -relaxed-aliasing
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r--lib/CodeGen/CodeGenTBAA.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenTBAA.cpp b/lib/CodeGen/CodeGenTBAA.cpp
index a3cadcf392..e9164dc304 100644
--- a/lib/CodeGen/CodeGenTBAA.cpp
+++ b/lib/CodeGen/CodeGenTBAA.cpp
@@ -18,6 +18,7 @@
#include "CodeGenTBAA.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Mangle.h"
+#include "clang/Frontend/CodeGenOptions.h"
#include "llvm/LLVMContext.h"
#include "llvm/Metadata.h"
#include "llvm/Constants.h"
@@ -26,8 +27,10 @@ using namespace clang;
using namespace CodeGen;
CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext& VMContext,
+ const CodeGenOptions &CGO,
const LangOptions &Features, MangleContext &MContext)
- : Context(Ctx), VMContext(VMContext), Features(Features), MContext(MContext),
+ : Context(Ctx), VMContext(VMContext), CodeGenOpts(CGO),
+ Features(Features), MContext(MContext),
MDHelper(VMContext), Root(0), Char(0) {
}
@@ -74,6 +77,10 @@ static bool TypeHasMayAlias(QualType QTy) {
llvm::MDNode *
CodeGenTBAA::getTBAAInfo(QualType QTy) {
+ // At -O0 TBAA is not emitted for regular types.
+ if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
+ return NULL;
+
// If the type has the may_alias attribute (even on a typedef), it is
// effectively in the general char alias class.
if (TypeHasMayAlias(QTy))