From fc3752665f4b7ae2ec3faad4204512687800c1ec Mon Sep 17 00:00:00 2001 From: Shiva Chen Date: Tue, 10 Mar 2020 10:23:59 +0800 Subject: [RISCV] Passing small data limitation value to RISCV backend Passing small data limit to RISCVELFTargetObjectFile by module flag, So the backend can set small data section threshold by the value. The data will be put into the small data section if the data smaller than the threshold. Differential Revision: https://reviews.llvm.org/D57497 --- clang/lib/CodeGen/CodeGenModule.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index cd77a727231b..9a8aee1a7157 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -660,6 +660,8 @@ void CodeGenModule::Release() { EmitCommandLineMetadata(); EmitTargetMetadata(); + + EmitBackendOptionsMetadata(getCodeGenOpts()); } void CodeGenModule::EmitOpenCLMetadata() { @@ -679,6 +681,19 @@ void CodeGenModule::EmitOpenCLMetadata() { OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts)); } +void CodeGenModule::EmitBackendOptionsMetadata( + const CodeGenOptions CodeGenOpts) { + switch (getTriple().getArch()) { + default: + break; + case llvm::Triple::riscv32: + case llvm::Triple::riscv64: + getModule().addModuleFlag(llvm::Module::Error, "SmallDataLimit", + CodeGenOpts.SmallDataLimit); + break; + } +} + void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { // Make sure that this type is translated. Types.UpdateCompletedType(TD); -- cgit v1.2.3