From: Chris Lattner Date: Fri, 18 Feb 2011 22:34:03 +0000 (+0000) Subject: add a way to disable all builtins, wire it up to opt's -disable-simplifylibcalls... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=188a7e00e784f78d6b5b250a64ac5c374f0fd3f0;p=oota-llvm.git add a way to disable all builtins, wire it up to opt's -disable-simplifylibcalls flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125978 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index b11c24bffb5..bdd214b6b74 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -55,6 +55,10 @@ public: void setAvailable(LibFunc::Func F) { AvailableArray[F/8] |= 1 << (F&7); } + + /// disableAllFunctions - This disables all builtins, which is used for + /// options like -fno-builtin. + void disableAllFunctions(); }; } // end namespace llvm diff --git a/lib/Target/TargetLibraryInfo.cpp b/lib/Target/TargetLibraryInfo.cpp index f4a85b0cd62..c8bed18ffab 100644 --- a/lib/Target/TargetLibraryInfo.cpp +++ b/lib/Target/TargetLibraryInfo.cpp @@ -47,3 +47,9 @@ TargetLibraryInfo::TargetLibraryInfo(const Triple &T) : ImmutablePass(ID) { initialize(*this, T); } + +/// disableAllFunctions - This disables all builtins, which is used for options +/// like -fno-builtin. +void TargetLibraryInfo::disableAllFunctions() { + memset(AvailableArray, 0, sizeof(AvailableArray)); +} diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 8ccd8e877b9..e55b4b3e2af 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -532,8 +532,12 @@ int main(int argc, char **argv) { PassManager Passes; // Add an appropriate TargetLibraryInfo pass for the module's triple. - if (!M->getTargetTriple().empty()) - Passes.add(new TargetLibraryInfo(Triple(M->getTargetTriple()))); + TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple())); + + // The -disable-simplify-libcalls flag actually disables all builtin optzns. + if (DisableSimplifyLibCalls) + TLI->disableAllFunctions(); + Passes.add(TLI); // Add an appropriate TargetData instance for this module. TargetData *TD = 0;