mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
98d9f094ab
Replace TargetMachine.h include with forward declaration and CodeGen.h include in AMDGPU.h. Exposes a couple of implicit dependencies that require additional forward declarations/includes.
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
//===-- AMDGPUFixFunctionBitcasts.cpp - Fix function bitcasts -------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// Promote indirect (bitcast) calls to direct calls when they are statically
|
|
/// known to be direct. Required when InstCombine is not run (e.g. at OptNone)
|
|
/// because AMDGPU does not support indirect calls.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AMDGPU.h"
|
|
#include "llvm/IR/InstVisitor.h"
|
|
#include "llvm/Pass.h"
|
|
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
|
|
|
|
using namespace llvm;
|
|
|
|
#define DEBUG_TYPE "amdgpu-fix-function-bitcasts"
|
|
|
|
namespace {
|
|
class AMDGPUFixFunctionBitcasts final
|
|
: public ModulePass,
|
|
public InstVisitor<AMDGPUFixFunctionBitcasts> {
|
|
|
|
bool runOnModule(Module &M) override;
|
|
|
|
bool Modified;
|
|
|
|
public:
|
|
void visitCallBase(CallBase &CB) {
|
|
if (CB.getCalledFunction())
|
|
return;
|
|
auto *Callee =
|
|
dyn_cast<Function>(CB.getCalledOperand()->stripPointerCasts());
|
|
if (Callee && isLegalToPromote(CB, Callee)) {
|
|
promoteCall(CB, Callee);
|
|
Modified = true;
|
|
}
|
|
}
|
|
|
|
static char ID;
|
|
AMDGPUFixFunctionBitcasts() : ModulePass(ID) {}
|
|
};
|
|
} // End anonymous namespace
|
|
|
|
char AMDGPUFixFunctionBitcasts::ID = 0;
|
|
char &llvm::AMDGPUFixFunctionBitcastsID = AMDGPUFixFunctionBitcasts::ID;
|
|
INITIALIZE_PASS(AMDGPUFixFunctionBitcasts, DEBUG_TYPE,
|
|
"Fix function bitcasts for AMDGPU", false, false)
|
|
|
|
ModulePass *llvm::createAMDGPUFixFunctionBitcastsPass() {
|
|
return new AMDGPUFixFunctionBitcasts();
|
|
}
|
|
|
|
bool AMDGPUFixFunctionBitcasts::runOnModule(Module &M) {
|
|
Modified = false;
|
|
visit(M);
|
|
return Modified;
|
|
}
|