-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Instrumentation][X86] Limit setting large section flag to medium/large code models #75542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ge code models In llvm#74514 and llvm#74778 we marked various instrumentation-added sections as large. This causes an extra PT_LOAD segment if using the small code model. Since people using the small code model presumably aren't hitting relocation limits, disable this when using the small code model to avoid the extra segment. This is annoying API-wise because we need to pass TargetMachine around to any pass that wants to do this. Module::getCodeModel(), like anything else that reads Module metadata, is unreliable as a source of truth.
@llvm/pr-subscribers-pgo @llvm/pr-subscribers-compiler-rt-sanitizer Author: Arthur Eubanks (aeubanks) ChangesIn #74514 and #74778 we marked various instrumentation-added sections as This is annoying API-wise because we need to pass TargetMachine around Full diff: https://github.com/llvm/llvm-project/pull/75542.diff 11 Files Affected:
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 7d16de33763a0d..49de29e6580e3f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -635,7 +635,7 @@ static void addKCFIPass(const Triple &TargetTriple, const LangOptions &LangOpts,
});
}
-static void addSanitizers(const Triple &TargetTriple,
+static void addSanitizers(const TargetMachine *TM, const Triple &TargetTriple,
const CodeGenOptions &CodeGenOpts,
const LangOptions &LangOpts, PassBuilder &PB) {
auto SanitizersCallback = [&](ModulePassManager &MPM,
@@ -696,7 +696,7 @@ static void addSanitizers(const Triple &TargetTriple,
Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
Opts.UseAfterReturn = CodeGenOpts.getSanitizeAddressUseAfterReturn();
- MPM.addPass(AddressSanitizerPass(Opts, UseGlobalGC, UseOdrIndicator,
+ MPM.addPass(AddressSanitizerPass(TM, Opts, UseGlobalGC, UseOdrIndicator,
DestructorKind));
}
};
@@ -973,7 +973,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
// Don't add sanitizers if we are here from ThinLTO PostLink. That already
// done on PreLink stage.
if (!IsThinLTOPostLink) {
- addSanitizers(TargetTriple, CodeGenOpts, LangOpts, PB);
+ addSanitizers(TM.get(), TargetTriple, CodeGenOpts, LangOpts, PB);
addKCFIPass(TargetTriple, LangOpts, PB);
}
@@ -986,8 +986,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (std::optional<InstrProfOptions> Options =
getInstrProfOptions(CodeGenOpts, LangOpts))
PB.registerPipelineStartEPCallback(
- [Options](ModulePassManager &MPM, OptimizationLevel Level) {
- MPM.addPass(InstrProfilingLoweringPass(*Options, false));
+ [this, Options](ModulePassManager &MPM, OptimizationLevel Level) {
+ MPM.addPass(InstrProfilingLoweringPass(TM.get(), *Options, false));
});
// TODO: Consider passing the MemoryProfileOutput to the pass builder via
diff --git a/llvm/include/llvm/Transforms/Instrumentation.h b/llvm/include/llvm/Transforms/Instrumentation.h
index ea97ab2562a5b0..a5866445529bfe 100644
--- a/llvm/include/llvm/Transforms/Instrumentation.h
+++ b/llvm/include/llvm/Transforms/Instrumentation.h
@@ -27,6 +27,7 @@
namespace llvm {
class Triple;
+class TargetMachine;
class OptimizationRemarkEmitter;
class Comdat;
class CallBase;
@@ -52,8 +53,9 @@ Comdat *getOrCreateFunctionComdat(Function &F, Triple &T);
// Place global in a large section for x86-64 ELF binaries to mitigate
// relocation overflow pressure. This can be be used for metadata globals that
// aren't directly accessed by code, which has no performance impact.
-void setGlobalVariableLargeSection(const Triple &TargetTriple,
- GlobalVariable &GV);
+void setGlobalVariableLargeSection(GlobalVariable &GV,
+ const Triple &TargetTriple,
+ const TargetMachine *TM);
// Insert GCOV profiling instrumentation
struct GCOVOptions {
diff --git a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
index 6dfdfb729cf502..ae5eae604a245e 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
@@ -19,6 +19,7 @@
namespace llvm {
class Module;
class raw_ostream;
+class TargetMachine;
struct AddressSanitizerOptions {
bool CompileKernel = false;
@@ -38,7 +39,8 @@ struct AddressSanitizerOptions {
/// run intependently of the function address sanitizer.
class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
public:
- AddressSanitizerPass(const AddressSanitizerOptions &Options,
+ AddressSanitizerPass(const TargetMachine *TM,
+ const AddressSanitizerOptions &Options,
bool UseGlobalGC = true, bool UseOdrIndicator = true,
AsanDtorKind DestructorKind = AsanDtorKind::Global,
AsanCtorKind ConstructorKind = AsanCtorKind::Global);
@@ -48,6 +50,7 @@ class AddressSanitizerPass : public PassInfoMixin<AddressSanitizerPass> {
static bool isRequired() { return true; }
private:
+ const TargetMachine *TM;
AddressSanitizerOptions Options;
bool UseGlobalGC;
bool UseOdrIndicator;
diff --git a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
index 0dd37c9ca58b7e..95187e55645261 100644
--- a/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
+++ b/llvm/include/llvm/Transforms/Instrumentation/InstrProfiling.h
@@ -24,14 +24,17 @@ class TargetLibraryInfo;
/// instrumentation pass.
class InstrProfilingLoweringPass
: public PassInfoMixin<InstrProfilingLoweringPass> {
+ const TargetMachine *TM;
const InstrProfOptions Options = {};
// Is this lowering for the context-sensitive instrumentation.
const bool IsCS = false;
public:
- InstrProfilingLoweringPass() = default;
- InstrProfilingLoweringPass(const InstrProfOptions &Options, bool IsCS = false)
- : Options(Options), IsCS(IsCS) {}
+ InstrProfilingLoweringPass(const TargetMachine *TM)
+ : TM(TM), Options(), IsCS() {}
+ InstrProfilingLoweringPass(const TargetMachine *TM,
+ const InstrProfOptions &Options, bool IsCS = false)
+ : TM(TM), Options(Options), IsCS(IsCS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 5c6c391049a7b2..9958d53f87065b 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -810,7 +810,7 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM,
Options.DoCounterPromotion = true;
Options.UseBFIInPromotion = IsCS;
Options.Atomic = AtomicCounterUpdate;
- MPM.addPass(InstrProfilingLoweringPass(Options, IsCS));
+ MPM.addPass(InstrProfilingLoweringPass(TM, Options, IsCS));
}
void PassBuilder::addPGOInstrPassesForO0(
@@ -837,7 +837,7 @@ void PassBuilder::addPGOInstrPassesForO0(
Options.DoCounterPromotion = false;
Options.UseBFIInPromotion = IsCS;
Options.Atomic = AtomicCounterUpdate;
- MPM.addPass(InstrProfilingLoweringPass(Options, IsCS));
+ MPM.addPass(InstrProfilingLoweringPass(TM, Options, IsCS));
}
static InlineParams getInlineParamsFromOptLevel(OptimizationLevel Level) {
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index d8fc7cd8a231ff..3d50f6da322561 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -78,7 +78,7 @@ MODULE_PASS("inliner-wrapper-no-mandatory-first",
ModuleInlinerWrapperPass(getInlineParams(), false))
MODULE_PASS("insert-gcov-profiling", GCOVProfilerPass())
MODULE_PASS("instrorderfile", InstrOrderFilePass())
-MODULE_PASS("instrprof", InstrProfilingLoweringPass())
+MODULE_PASS("instrprof", InstrProfilingLoweringPass(TM))
MODULE_PASS("internalize", InternalizePass())
MODULE_PASS("invalidate<all>", InvalidateAllAnalysesPass())
MODULE_PASS("iroutliner", IROutlinerPass())
@@ -147,7 +147,7 @@ MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass())
#endif
MODULE_PASS_WITH_PARAMS(
"asan", "AddressSanitizerPass",
- [](AddressSanitizerOptions Opts) { return AddressSanitizerPass(Opts); },
+ [this](AddressSanitizerOptions Opts) { return AddressSanitizerPass(TM, Opts); },
parseASanPassOptions, "kernel")
MODULE_PASS_WITH_PARAMS(
"globaldce", "GlobalDCEPass",
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index b175e6f93f3e8f..69637031452f1c 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -787,12 +787,14 @@ struct AddressSanitizer {
class ModuleAddressSanitizer {
public:
- ModuleAddressSanitizer(Module &M, bool InsertVersionCheck,
- bool CompileKernel = false, bool Recover = false,
- bool UseGlobalsGC = true, bool UseOdrIndicator = true,
+ ModuleAddressSanitizer(Module &M, const TargetMachine *TM,
+ bool InsertVersionCheck, bool CompileKernel = false,
+ bool Recover = false, bool UseGlobalsGC = true,
+ bool UseOdrIndicator = true,
AsanDtorKind DestructorKind = AsanDtorKind::Global,
AsanCtorKind ConstructorKind = AsanCtorKind::Global)
- : CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
+ : TM(TM),
+ CompileKernel(ClEnableKasan.getNumOccurrences() > 0 ? ClEnableKasan
: CompileKernel),
InsertVersionCheck(ClInsertVersionCheck.getNumOccurrences() > 0
? ClInsertVersionCheck
@@ -869,6 +871,7 @@ class ModuleAddressSanitizer {
uint64_t getRedzoneSizeForGlobal(uint64_t SizeInBytes) const;
int GetAsanVersion(const Module &M) const;
+ const TargetMachine *TM;
bool CompileKernel;
bool InsertVersionCheck;
bool Recover;
@@ -1161,17 +1164,17 @@ void AddressSanitizerPass::printPipeline(
}
AddressSanitizerPass::AddressSanitizerPass(
- const AddressSanitizerOptions &Options, bool UseGlobalGC,
- bool UseOdrIndicator, AsanDtorKind DestructorKind,
+ const TargetMachine *TM, const AddressSanitizerOptions &Options,
+ bool UseGlobalGC, bool UseOdrIndicator, AsanDtorKind DestructorKind,
AsanCtorKind ConstructorKind)
- : Options(Options), UseGlobalGC(UseGlobalGC),
+ : TM(TM), Options(Options), UseGlobalGC(UseGlobalGC),
UseOdrIndicator(UseOdrIndicator), DestructorKind(DestructorKind),
ConstructorKind(ConstructorKind) {}
PreservedAnalyses AddressSanitizerPass::run(Module &M,
ModuleAnalysisManager &MAM) {
ModuleAddressSanitizer ModuleSanitizer(
- M, Options.InsertVersionCheck, Options.CompileKernel, Options.Recover,
+ M, TM, Options.InsertVersionCheck, Options.CompileKernel, Options.Recover,
UseGlobalGC, UseOdrIndicator, DestructorKind, ConstructorKind);
bool Modified = false;
auto &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
@@ -2146,7 +2149,7 @@ ModuleAddressSanitizer::CreateMetadataGlobal(Module &M, Constant *Initializer,
Metadata->setSection(getGlobalMetadataSection());
// Place metadata in a large section for x86-64 ELF binaries to mitigate
// relocation pressure.
- setGlobalVariableLargeSection(TargetTriple, *Metadata);
+ setGlobalVariableLargeSection(*Metadata, TargetTriple, TM);
return Metadata;
}
diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index fe5a0578bd9721..b9345273f88135 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -170,16 +170,18 @@ using LoadStorePair = std::pair<Instruction *, Instruction *>;
class InstrLowerer final {
public:
- InstrLowerer(Module &M, const InstrProfOptions &Options,
+ InstrLowerer(Module &M, const TargetMachine *TM,
+ const InstrProfOptions &Options,
std::function<const TargetLibraryInfo &(Function &F)> GetTLI,
bool IsCS)
- : M(M), Options(Options), TT(Triple(M.getTargetTriple())), IsCS(IsCS),
- GetTLI(GetTLI) {}
+ : M(M), TM(TM), Options(Options), TT(Triple(M.getTargetTriple())),
+ IsCS(IsCS), GetTLI(GetTLI) {}
bool lower();
private:
Module &M;
+ const TargetMachine *TM;
const InstrProfOptions Options;
const Triple TT;
// Is this lowering for the context-sensitive instrumentation.
@@ -577,7 +579,7 @@ PreservedAnalyses InstrProfilingLoweringPass::run(Module &M,
auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
return FAM.getResult<TargetLibraryAnalysis>(F);
};
- InstrLowerer Lowerer(M, Options, GetTLI, IsCS);
+ InstrLowerer Lowerer(M, TM, Options, GetTLI, IsCS);
if (!Lowerer.lower())
return PreservedAnalyses::all();
@@ -1452,7 +1454,7 @@ void InstrLowerer::createDataVariable(InstrProfCntrInstBase *Inc) {
M, ValuesTy, false, Linkage, Constant::getNullValue(ValuesTy),
getVarName(Inc, getInstrProfValuesVarPrefix(), Renamed));
ValuesVar->setVisibility(Visibility);
- setGlobalVariableLargeSection(TT, *ValuesVar);
+ setGlobalVariableLargeSection(*ValuesVar, TT, TM);
ValuesVar->setSection(
getInstrProfSectionName(IPSK_vals, TT.getObjectFormat()));
ValuesVar->setAlignment(Align(8));
@@ -1590,7 +1592,7 @@ void InstrLowerer::emitVNodes() {
auto *VNodesVar = new GlobalVariable(
M, VNodesTy, false, GlobalValue::PrivateLinkage,
Constant::getNullValue(VNodesTy), getInstrProfVNodesVarName());
- setGlobalVariableLargeSection(TT, *VNodesVar);
+ setGlobalVariableLargeSection(*VNodesVar, TT, TM);
VNodesVar->setSection(
getInstrProfSectionName(IPSK_vnodes, TT.getObjectFormat()));
VNodesVar->setAlignment(M.getDataLayout().getABITypeAlign(VNodesTy));
@@ -1618,7 +1620,7 @@ void InstrLowerer::emitNameData() {
GlobalValue::PrivateLinkage, NamesVal,
getInstrProfNamesVarName());
NamesSize = CompressedNameStr.size();
- setGlobalVariableLargeSection(TT, *NamesVar);
+ setGlobalVariableLargeSection(*NamesVar, TT, TM);
NamesVar->setSection(
ProfileCorrelate == InstrProfCorrelator::BINARY
? getInstrProfSectionName(IPSK_covname, TT.getObjectFormat())
diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
index 7a03ee46d6fded..f25ac521d275c8 100644
--- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -14,6 +14,7 @@
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
@@ -85,10 +86,18 @@ Comdat *llvm::getOrCreateFunctionComdat(Function &F, Triple &T) {
return C;
}
-void llvm::setGlobalVariableLargeSection(const Triple &TargetTriple,
- GlobalVariable &GV) {
- if (TargetTriple.getArch() == Triple::x86_64 &&
- TargetTriple.getObjectFormat() == Triple::ELF) {
- GV.setCodeModel(CodeModel::Large);
+void llvm::setGlobalVariableLargeSection(GlobalVariable &GV,
+ const Triple &TargetTriple,
+ const TargetMachine *TM) {
+ // Limit to x86-64 ELF.
+ if (TargetTriple.getArch() != Triple::x86_64 ||
+ TargetTriple.getObjectFormat() != Triple::ELF) {
+ return;
}
+ // Limit to medium/large code models.
+ if (!TM || (TM->getCodeModel() != CodeModel::Medium &&
+ TM->getCodeModel() != CodeModel::Large)) {
+ return;
+ }
+ GV.setCodeModel(CodeModel::Large);
}
diff --git a/llvm/test/Instrumentation/AddressSanitizer/global_metadata_code_model.ll b/llvm/test/Instrumentation/AddressSanitizer/global_metadata_code_model.ll
index c1e7694d4cd536..8667edc2eb6c6a 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/global_metadata_code_model.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/global_metadata_code_model.ll
@@ -1,4 +1,6 @@
-; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefix=LARGE
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S -code-model=large | FileCheck %s --check-prefix=LARGE
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S -code-model=medium | FileCheck %s --check-prefix=LARGE
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes=asan -S -code-model=small | FileCheck %s --check-prefix=NORMAL
; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -passes=asan -S | FileCheck %s --check-prefix=NORMAL
; RUN: opt < %s -mtriple=x86_64-pc-windows -passes=asan -S | FileCheck %s --check-prefix=NORMAL
diff --git a/llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll b/llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll
index 9fbff456ff50b5..6e9bdd50443da4 100644
--- a/llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/icall-comdat.ll
@@ -16,8 +16,9 @@
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefix=ALIGN
;; Check that globals have the proper code model.
-; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-X8664
-; RUN: opt %s -mtriple=powerpc-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-PPC
+; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-NORMAL
+; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S -code-model=medium | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-LARGE
+; RUN: opt %s -mtriple=powerpc-unknown-linux -passes=instrprof -S | FileCheck %s --check-prefixes=CODEMODEL,CODEMODEL-NORMAL
@__profn_foo = private constant [3 x i8] c"foo"
@__profn_bar = private constant [3 x i8] c"bar"
@@ -82,20 +83,20 @@ attributes #0 = { nounwind }
; CODEMODEL: @__profc_foo =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profvp_foo =
-; CODEMODEL-X8664-SAME: code_model "large"
-; CODEMODEL-PPC-NOT: code_model
+; CODEMODEL-LARGE-SAME: code_model "large"
+; CODEMODEL-NORMAL-NOT: code_model
; CODEMODEL: @__profd_foo =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profc_bar =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__profvp_bar =
-; CODEMODEL-X8664-SAME: code_model "large"
-; CODEMODEL-PPC-NOT: code_model
+; CODEMODEL-LARGE-SAME: code_model "large"
+; CODEMODEL-NORMAL-NOT: code_model
; CODEMODEL: @__profd_bar =
; CODEMODEL-NOT: code_model "large"
; CODEMODEL: @__llvm_prf_vnodes =
-; CODEMODEL-X8664-SAME: code_model "large"
-; CODEMODEL-PPC-NOT: code_model
+; CODEMODEL-LARGE-SAME: code_model "large"
+; CODEMODEL-NORMAL-NOT: code_model
; CODEMODEL: @__llvm_prf_nm =
-; CODEMODEL-X8664-SAME: code_model "large"
-; CODEMODEL-PPC-NOT: code_model
+; CODEMODEL-LARGE-SAME: code_model "large"
+; CODEMODEL-NORMAL-NOT: code_model
|
Actually I'm going to go down the |
I actually thought it was already available in the Module, and was surprised you had to pass TargetMachine around like that. If I understand where you're going with this, then I think that sounds like a really nice improvement. |
well I guess I should say I thought it would be reliable rather than available, but I see why it wouldn't be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo one small comment in the test. Thanks for getting this done so quickly.
;; Check that certain globals are in large sections under x86-64 large code model (but not in other arches). | ||
; RUN: opt %s -mtriple=x86_64-unknown-linux -passes=instrprof -S | FileCheck %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment makes it sound like this should have a RUN line for other arches. Was that intentional or copy paste from the other tests?
In #74514 and #74778 we marked various instrumentation-added sections as
large. This causes an extra PT_LOAD segment if using the small code
model. Since people using the small code model presumably aren't hitting
relocation limits, disable this when using the small code model to avoid
the extra segment.
This uses Module::getCodeModel() which isn't necessarily reliable since it reads module metadata (which right now only the clang frontend sets), but it would be nice to get to a point where we reliably put this sort of information (e.g. PIC/code model/etc) in the IR. This requires duplicating the existing tests since opt/llc currently don't set these metadata. If we get to a point where they do set the code model metadata based on command line arguments then we can deduplicate these tests.