barannikov88 created this revision. Herald added a project: All. barannikov88 published this revision for review. barannikov88 added reviewers: rjmccall, aaron.ballman, erichkeane, jdoerfert, efriedma. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Make `qualifyWindowsLibrary` and `addStackProbeTargetAttributes` protected members of `TargetCodeGenInfo`. These are helper functions used by `getDependentLibraryOption` and `setTargetAttributes` methods when targeting Windows. The change will allow these functions to be reused after splitting `TargetInfo.cpp`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150178 Files: clang/lib/CodeGen/TargetInfo.cpp clang/lib/CodeGen/TargetInfo.h Index: clang/lib/CodeGen/TargetInfo.h =================================================================== --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -397,6 +397,12 @@ virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const { return nullptr; } + +protected: + static std::string qualifyWindowsLibrary(StringRef Lib); + + void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -2559,6 +2559,7 @@ const FunctionDecl *Callee, const CallArgList &Args) const override; }; +} // namespace static void initFeatureMaps(const ASTContext &Ctx, llvm::StringMap<bool> &CallerMap, @@ -2657,7 +2658,7 @@ } } -static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { +std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) { // If the argument does not end in .lib, automatically add the suffix. // If the argument contains a space, enclose it in quotes. // This matches the behavior of MSVC. @@ -2670,6 +2671,7 @@ return ArgStr; } +namespace { class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2693,11 +2695,11 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace -static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) { +void TargetCodeGenInfo::addStackProbeTargetAttributes( + const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { if (llvm::Function *Fn = dyn_cast_or_null<llvm::Function>(GV)) { - if (CGM.getCodeGenOpts().StackProbeSize != 4096) Fn->addFnAttr("stack-probe-size", llvm::utostr(CGM.getCodeGenOpts().StackProbeSize)); @@ -2714,6 +2716,7 @@ addStackProbeTargetAttributes(D, GV, CGM); } +namespace { class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { public: WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2752,6 +2755,7 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace void WinX86_64TargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { @@ -2769,7 +2773,6 @@ addStackProbeTargetAttributes(D, GV, CGM); } -} void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo, Class &Hi) const {
Index: clang/lib/CodeGen/TargetInfo.h =================================================================== --- clang/lib/CodeGen/TargetInfo.h +++ clang/lib/CodeGen/TargetInfo.h @@ -397,6 +397,12 @@ virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const { return nullptr; } + +protected: + static std::string qualifyWindowsLibrary(StringRef Lib); + + void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, + CodeGen::CodeGenModule &CGM) const; }; } // namespace CodeGen Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -2559,6 +2559,7 @@ const FunctionDecl *Callee, const CallArgList &Args) const override; }; +} // namespace static void initFeatureMaps(const ASTContext &Ctx, llvm::StringMap<bool> &CallerMap, @@ -2657,7 +2658,7 @@ } } -static std::string qualifyWindowsLibrary(llvm::StringRef Lib) { +std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) { // If the argument does not end in .lib, automatically add the suffix. // If the argument contains a space, enclose it in quotes. // This matches the behavior of MSVC. @@ -2670,6 +2671,7 @@ return ArgStr; } +namespace { class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo { public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2693,11 +2695,11 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace -static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, - CodeGen::CodeGenModule &CGM) { +void TargetCodeGenInfo::addStackProbeTargetAttributes( + const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { if (llvm::Function *Fn = dyn_cast_or_null<llvm::Function>(GV)) { - if (CGM.getCodeGenOpts().StackProbeSize != 4096) Fn->addFnAttr("stack-probe-size", llvm::utostr(CGM.getCodeGenOpts().StackProbeSize)); @@ -2714,6 +2716,7 @@ addStackProbeTargetAttributes(D, GV, CGM); } +namespace { class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo { public: WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, @@ -2752,6 +2755,7 @@ Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\""; } }; +} // namespace void WinX86_64TargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const { @@ -2769,7 +2773,6 @@ addStackProbeTargetAttributes(D, GV, CGM); } -} void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo, Class &Hi) const {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits