Index: lib/Target/Sparc/LLVMBuild.txt =================================================================== --- lib/Target/Sparc/LLVMBuild.txt +++ lib/Target/Sparc/LLVMBuild.txt @@ -31,6 +31,6 @@ type = Library name = SparcCodeGen parent = Sparc -required_libraries = AsmPrinter CodeGen Core MC SelectionDAG SparcAsmPrinter - SparcDesc SparcInfo Support Target +required_libraries = Analysis AsmPrinter CodeGen Core MC SelectionDAG + SparcAsmPrinter SparcDesc SparcInfo Support Target add_to_library_groups = Sparc Index: lib/Target/Sparc/SparcTargetMachine.h =================================================================== --- lib/Target/Sparc/SparcTargetMachine.h +++ lib/Target/Sparc/SparcTargetMachine.h @@ -35,6 +35,8 @@ const SparcSubtarget *getSubtargetImpl() const { return &Subtarget; } const SparcSubtarget *getSubtargetImpl(const Function &) const override; + TargetIRAnalysis getTargetIRAnalysis() override; + // Pass Pipeline Configuration TargetPassConfig *createPassConfig(PassManagerBase &PM) override; TargetLoweringObjectFile *getObjFileLowering() const override { Index: lib/Target/Sparc/SparcTargetMachine.cpp =================================================================== --- lib/Target/Sparc/SparcTargetMachine.cpp +++ lib/Target/Sparc/SparcTargetMachine.cpp @@ -12,6 +12,7 @@ #include "SparcTargetMachine.h" #include "SparcTargetObjectFile.h" +#include "SparcTargetTransformInfo.h" #include "Sparc.h" #include "LeonPasses.h" #include "llvm/CodeGen/Passes.h" @@ -163,6 +164,12 @@ } } +TargetIRAnalysis SparcTargetMachine::getTargetIRAnalysis() { + return TargetIRAnalysis([this](const Function &F) { + return TargetTransformInfo(SparcTTIImpl(this, F)); + }); +} + void SparcV8TargetMachine::anchor() { } SparcV8TargetMachine::SparcV8TargetMachine(const Target &T, const Triple &TT, Index: lib/Target/Sparc/SparcTargetTransformInfo.h =================================================================== --- /dev/null +++ lib/Target/Sparc/SparcTargetTransformInfo.h @@ -0,0 +1,48 @@ +//===-- SparcTargetTransformInfo.h - Sparc-specific TTI ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_SPARC_SPARCTARGETTRANSFORMINFO_H +#define LLVM_LIB_TARGET_SPARC_SPARCTARGETTRANSFORMINFO_H + +#include "SparcTargetMachine.h" +#include "llvm/Analysis/TargetTransformInfo.h" +#include "llvm/CodeGen/BasicTTIImpl.h" + +namespace llvm { + +class SparcTTIImpl : public BasicTTIImplBase { + typedef BasicTTIImplBase BaseT; + typedef TargetTransformInfo TTI; + friend BaseT; + + const SparcSubtarget *ST; + const SparcTargetLowering *TLI; + + const SparcSubtarget *getST() const { return ST; } + const SparcTargetLowering *getTLI() const { return TLI; } + +public: + explicit SparcTTIImpl(const SparcTargetMachine *TM, const Function &F) + : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), + TLI(ST->getTargetLowering()) {} + + // Provide value semantics. MSVC requires that we spell all of these out. + SparcTTIImpl(const SparcTTIImpl &Arg) + : BaseT(static_cast(Arg)), ST(Arg.ST), TLI(Arg.TLI) {} + SparcTTIImpl(SparcTTIImpl &&Arg) + : BaseT(std::move(static_cast(Arg))), ST(std::move(Arg.ST)), + TLI(std::move(Arg.TLI)) {} + + bool shouldExtI32Param() const { return ST->isV9(); } + bool shouldExtI32Result() const { return ST->isV9(); } +}; + +} // end namespace llvm + +#endif Index: test/Instrumentation/InstrProfiling/icall.ll =================================================================== --- test/Instrumentation/InstrProfiling/icall.ll +++ test/Instrumentation/InstrProfiling/icall.ll @@ -3,8 +3,10 @@ ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -vp-static-alloc=true -instrprof -S | FileCheck %s --check-prefix=STATIC ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC ; RUN: opt < %s -mtriple=powerpc-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC +; RUN: opt < %s -mtriple=sparc-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC ; RUN: opt < %s -mtriple=s390x-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT ; RUN: opt < %s -mtriple=powerpc64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT +; RUN: opt < %s -mtriple=sparc64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -vp-static-alloc=false -instrprof -S | FileCheck %s --check-prefix=DYN ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -vp-static-alloc=false -S | FileCheck %s --check-prefix=DYN