aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2020-01-16 11:56:41 +0100
committerserge-sans-paille <sguelton@redhat.com>2020-01-31 14:02:33 +0100
commitfd09f12f32f57564d619a28b8826d33ade47b12e (patch)
treedb57ca81252bf810e3b6dd0af6bf5789ac1c7a9a /llvm/lib/IR/Module.cpp
parent24f0b6b6d8e798f76621af9ea6ccda0568d28703 (diff)
downloadllvm-fd09f12f32f57564d619a28b8826d33ade47b12e.zip
llvm-fd09f12f32f57564d619a28b8826d33ade47b12e.tar.gz
llvm-fd09f12f32f57564d619a28b8826d33ade47b12e.tar.bz2
Implement -fsemantic-interposition
First attempt at implementing -fsemantic-interposition. Rely on GlobalValue::isInterposable that already captures most of the expected behavior. Rely on a ModuleFlag to state whether we should respect SemanticInterposition or not. The default remains no. So this should be a no-op if -fsemantic-interposition isn't used, and if it is, isInterposable being already used in most optimisation, they should honor it properly. Note that it only impacts architecture compiled with -fPIC and no pie. Differential Revision: https://reviews.llvm.org/D72829
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r--llvm/lib/IR/Module.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 3b35176..c2083f5 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -555,6 +555,20 @@ Metadata *Module::getProfileSummary(bool IsCS) {
: getModuleFlag("ProfileSummary"));
}
+bool Module::getSemanticInterposition() const {
+ Metadata *MF = getModuleFlag("SemanticInterposition");
+
+ auto *Val = cast_or_null<ConstantAsMetadata>(MF);
+ if (!Val)
+ return false;
+
+ return cast<ConstantInt>(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+ addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
void Module::setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB) {
OwnedMemoryBuffer = std::move(MB);
}