mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-05-23 07:26:13 +00:00

Remove the ModuleLevelChanges argument, and the ability to create new subprograms for cloned functions. The latter was added without review in r203662, but it has no in-tree clients (all non-test callers pass false for ModuleLevelChanges [1], so it isn't reachable outside of tests). It also isn't clear that adding a duplicate subprogram to the compile unit is always the right thing to do when cloning a function within a module. If this functionality comes back it should be accompanied with a more concrete use case. Furthermore, all in-tree clients add the returned function to the module. Since that's pretty much the only sensible thing you can do with the function, just do that in CloneFunction. [1] http://llvm-cs.pcc.me.uk/lib/Transforms/Utils/CloneFunction.cpp/rCloneFunction Differential Revision: http://reviews.llvm.org/D18628 llvm-svn: 269110
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
//===-- AMDGPUAlwaysInlinePass.cpp - Promote Allocas ----------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
/// \file
|
|
/// This pass marks all internal functions as always_inline and creates
|
|
/// duplicates of all other functions a marks the duplicates as always_inline.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AMDGPU.h"
|
|
#include "llvm/IR/Module.h"
|
|
#include "llvm/Transforms/Utils/Cloning.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
class AMDGPUAlwaysInline : public ModulePass {
|
|
static char ID;
|
|
|
|
public:
|
|
AMDGPUAlwaysInline() : ModulePass(ID) { }
|
|
bool runOnModule(Module &M) override;
|
|
const char *getPassName() const override { return "AMDGPU Always Inline Pass"; }
|
|
};
|
|
|
|
} // End anonymous namespace
|
|
|
|
char AMDGPUAlwaysInline::ID = 0;
|
|
|
|
bool AMDGPUAlwaysInline::runOnModule(Module &M) {
|
|
std::vector<Function *> FuncsToClone;
|
|
|
|
for (Function &F : M) {
|
|
if (!F.hasLocalLinkage() && !F.isDeclaration() && !F.use_empty() &&
|
|
!F.hasFnAttribute(Attribute::NoInline))
|
|
FuncsToClone.push_back(&F);
|
|
}
|
|
|
|
for (Function *F : FuncsToClone) {
|
|
ValueToValueMapTy VMap;
|
|
Function *NewFunc = CloneFunction(F, VMap);
|
|
NewFunc->setLinkage(GlobalValue::InternalLinkage);
|
|
F->replaceAllUsesWith(NewFunc);
|
|
}
|
|
|
|
for (Function &F : M) {
|
|
if (F.hasLocalLinkage() && !F.hasFnAttribute(Attribute::NoInline)) {
|
|
F.addFnAttr(Attribute::AlwaysInline);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
ModulePass *llvm::createAMDGPUAlwaysInlinePass() {
|
|
return new AMDGPUAlwaysInline();
|
|
}
|