aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2024-11-01 12:44:33 +0800
committerGitHub <noreply@github.com>2024-11-01 12:44:33 +0800
commitf16bff1261a92169992c6edf6bc6b38d1c815c8d (patch)
tree01b34b0eda84420aa991ee594a7a94d9c587e459 /llvm/lib/Transforms/Utils/Local.cpp
parentbef3b54ea10a564a2de72f658f2efd64f537c079 (diff)
downloadllvm-f16bff1261a92169992c6edf6bc6b38d1c815c8d.zip
llvm-f16bff1261a92169992c6edf6bc6b38d1c815c8d.tar.gz
llvm-f16bff1261a92169992c6edf6bc6b38d1c815c8d.tar.bz2
[GVN][NewGVN][Local] Handle attributes for function calls after CSE (#114011)
This patch intersects attributes of two calls to avoid introducing UB. It also skips incompatible call pairs in GVN/NewGVN. However, I cannot provide negative tests for these changes. Fixes https://github.com/llvm/llvm-project/issues/113997.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 65c1669f..47a7049 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3508,6 +3508,17 @@ void llvm::patchReplacementInstruction(Instruction *I, Value *Repl) {
else if (!isa<LoadInst>(I))
ReplInst->andIRFlags(I);
+ // Handle attributes.
+ if (auto *CB1 = dyn_cast<CallBase>(ReplInst)) {
+ if (auto *CB2 = dyn_cast<CallBase>(I)) {
+ bool Success = CB1->tryIntersectAttributes(CB2);
+ assert(Success && "We should not be trying to sink callbases "
+ "with non-intersectable attributes");
+ // For NDEBUG Compile.
+ (void)Success;
+ }
+ }
+
// FIXME: If both the original and replacement value are part of the
// same control-flow region (meaning that the execution of one
// guarantees the execution of the other), then we can combine the