diff options
| author | Kostya Serebryany <kcc@google.com> | 2012-04-24 06:57:01 +0000 | 
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2012-04-24 06:57:01 +0000 | 
| commit | 5dd2cfc81edf4c8f3aabc9b4e9be076b8fd0fc02 (patch) | |
| tree | e3c2edd3e9a1fecdb926f6d574969dcc1016fe01 /clang/lib/CodeGen | |
| parent | 0b65c40821b6a0ce73d74924b1550f6ae7afd7f3 (diff) | |
| download | bcm5719-llvm-5dd2cfc81edf4c8f3aabc9b4e9be076b8fd0fc02.tar.gz bcm5719-llvm-5dd2cfc81edf4c8f3aabc9b4e9be076b8fd0fc02.zip  | |
enable TBAA when -fthread-sanitizer is given, even with -O0 or  -relaxed-aliasing 
llvm-svn: 155430
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTBAA.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTBAA.h | 3 | 
3 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9a55c084800..0b1ddc15be0 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -102,9 +102,10 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,    if (LangOpts.CUDA)      createCUDARuntime(); -  // Enable TBAA unless it's suppressed. -  if (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0) -    TBAA = new CodeGenTBAA(Context, VMContext, getLangOpts(), +  // Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0. +  if (LangOpts.ThreadSanitizer || +      (!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0)) +    TBAA = new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),                             ABI.getMangleContext());    // If debug info or coverage generation is enabled, create the CGDebugInfo diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index a3cadcf3924..e9164dc3048 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/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)) diff --git a/clang/lib/CodeGen/CodeGenTBAA.h b/clang/lib/CodeGen/CodeGenTBAA.h index 4a9785287d0..9463b6110cf 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.h +++ b/clang/lib/CodeGen/CodeGenTBAA.h @@ -26,6 +26,7 @@ namespace llvm {  namespace clang {    class ASTContext; +  class CodeGenOptions;    class LangOptions;    class MangleContext;    class QualType; @@ -39,6 +40,7 @@ namespace CodeGen {  class CodeGenTBAA {    ASTContext &Context;    llvm::LLVMContext& VMContext; +  const CodeGenOptions &CodeGenOpts;    const LangOptions &Features;    MangleContext &MContext; @@ -61,6 +63,7 @@ class CodeGenTBAA {  public:    CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext, +              const CodeGenOptions &CGO,                const LangOptions &Features,                MangleContext &MContext);    ~CodeGenTBAA();  | 

