aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-11-18 20:48:45 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-11-18 20:52:58 +0100
commit23aeadb89df38406dc4d929d08286f7ce31040eb (patch)
treef32cea8baecdb2959e105c136ae3014367d41dc0 /llvm/lib/Transforms/Utils/InlineFunction.cpp
parentb51c290663cf50372cd681917cc63379abcf104a (diff)
downloadllvm-23aeadb89df38406dc4d929d08286f7ce31040eb.zip
llvm-23aeadb89df38406dc4d929d08286f7ce31040eb.tar.gz
llvm-23aeadb89df38406dc4d929d08286f7ce31040eb.tar.bz2
[Inline] Fix incorrect noalias metadata application (PR48209)
The VMap also contains a mapping from Argument => Instruction, where the instruction is part of the original function, not the inlined one. The code was assuming that all the instructions in the VMap were inlined. This was a pre-existing problem for the loop access metadata, but was extended to the more common noalias metadata by 27f647d117087ca11959e232e6443f4aee31e966, thus causing miscompiles. There is a similar assumption inside CloneAliasScopeMetadata(), so that one likely needs to be fixed as well.
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 05e6929..c16433c 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -785,7 +785,9 @@ static void PropagateCallSiteMetadata(CallBase &CB, ValueToValueMapTy &VMap) {
for (ValueToValueMapTy::iterator VMI = VMap.begin(), VMIE = VMap.end();
VMI != VMIE; ++VMI) {
- if (!VMI->second)
+ // Check that key is an instruction, to skip the Argument mapping, which
+ // points to an instruction in the original function, not the inlined one.
+ if (!VMI->second || !isa<Instruction>(VMI->first))
continue;
Instruction *NI = dyn_cast<Instruction>(VMI->second);