mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SIL] Add getIntrinsicID(FuncDecl*), which lazyly looks up the llvm::IntrinsicID for it.
The cache is stored in the SILModule. Add getIntrinsicID() as a member of BuiltinFunctionRefInst. Test by using the new method in the CCP pass. Swift SVN r7311
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
#include "swift/Subsystems.h"
|
||||
#include "swift/SIL/SILBuilder.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
using namespace swift;
|
||||
|
||||
@@ -34,17 +33,14 @@ static void diagnose(ASTContext &Context, SourceLoc loc, Diag<T...> diag,
|
||||
static SILInstruction *constantFoldInstruction(SILInstruction &I,
|
||||
SILModule &M) {
|
||||
// Constant fold function calls.
|
||||
if (const ApplyInst *AI = dyn_cast<ApplyInst>(&I)) {
|
||||
if (ApplyInst *AI = dyn_cast<ApplyInst>(&I)) {
|
||||
|
||||
// Constant fold calls to builtins.
|
||||
if (const BuiltinFunctionRefInst *FR =
|
||||
if (BuiltinFunctionRefInst *FR =
|
||||
dyn_cast<BuiltinFunctionRefInst>(AI->getCallee().getDef())) {
|
||||
FuncDecl *FD = FR->getFunction();
|
||||
SmallVector<Type, 4> Types;
|
||||
StringRef BuiltinName = getBuiltinBaseName(M.getASTContext(),
|
||||
FD->getName().str(), Types);
|
||||
|
||||
if (BuiltinName == "int_sadd_with_overflow") {
|
||||
llvm::Intrinsic::ID ID = FR->getIntrinsicID();
|
||||
|
||||
if (ID == llvm::Intrinsic::sadd_with_overflow) {
|
||||
|
||||
// Check if both arguments are literals.
|
||||
OperandValueArrayRef Args = AI->getArguments();
|
||||
|
||||
Reference in New Issue
Block a user