Skip to content

Commit

Permalink
add a way to disable all builtins, wire it up to opt's -disable-simpl…
Browse files Browse the repository at this point in the history
…ifylibcalls flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125978 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Feb 18, 2011
1 parent c19175c commit 188a7e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/llvm/Target/TargetLibraryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class TargetLibraryInfo : public ImmutablePass {
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
Expand Down
6 changes: 6 additions & 0 deletions lib/Target/TargetLibraryInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
8 changes: 6 additions & 2 deletions tools/opt/opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 188a7e0

Please sign in to comment.