From 01b58f637c23e203dd95a4709bdd40cdfc31ffa9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 18 Oct 2010 18:17:47 +0000 Subject: [PATCH] Make TypeBasedAliasAnalysis default to doing nothing, with a command-line option to enable it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116722 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/TypeBasedAliasAnalysis.cpp | 10 ++++++++++ test/Analysis/TypeBasedAliasAnalysis/aliastest.ll | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/TypeBasedAliasAnalysis.cpp b/lib/Analysis/TypeBasedAliasAnalysis.cpp index 8d368470b4e..203084414c0 100644 --- a/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -32,8 +32,12 @@ #include "llvm/Module.h" #include "llvm/Metadata.h" #include "llvm/Pass.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; +// For testing purposes, enable TBAA only via a special option. +static cl::opt EnableTBAA("enable-tbaa"); + namespace { /// TBAANode - This is a simple wrapper around an MDNode which provides a /// higher-level interface by hiding the details of how alias analysis @@ -122,6 +126,9 @@ TypeBasedAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { AliasAnalysis::AliasResult TypeBasedAliasAnalysis::alias(const Location &LocA, const Location &LocB) { + if (!EnableTBAA) + return AliasAnalysis::alias(LocA, LocB); + // Get the attached MDNodes. If either value lacks a tbaa MDNode, we must // be conservative. const MDNode *AM = LocA.TBAATag; @@ -168,6 +175,9 @@ TypeBasedAliasAnalysis::alias(const Location &LocA, } bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc) { + if (!EnableTBAA) + return AliasAnalysis::pointsToConstantMemory(Loc); + const MDNode *M = Loc.TBAATag; if (!M) return false; diff --git a/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll index 21f28e075f4..fdaa21671ef 100644 --- a/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll +++ b/test/Analysis/TypeBasedAliasAnalysis/aliastest.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -tbaa -gvn -S | FileCheck %s +; RUN: opt < %s -enable-tbaa -basicaa -tbaa -gvn -S | FileCheck %s ; CHECK: @test0_yes ; CHECK: add i8 %x, %x