aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorPaul Kirth <paulkirth@google.com>2025-05-05 18:16:33 -0700
committerGitHub <noreply@github.com>2025-05-05 18:16:33 -0700
commit43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed (patch)
treeed8cf3c481182e8dc7510ddc8d9de00579fc5f15 /llvm/lib/Transforms/Utils/Local.cpp
parent1c1238d3615a7e1a99570d1e02de3b538d2e0669 (diff)
downloadllvm-43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed.zip
llvm-43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed.tar.gz
llvm-43eafc0c4aca0b2fd159c09d4b162c1941b4f4ed.tar.bz2
[llvm][gvn-sink] Don't try to sink inline asm (#138414)
Fixes #138345. Before this patch, gvn-sink would try to sink inline assembly statements. Other GVN passes avoid them (see https://github.com/llvm/llvm-project/blob/b4fac94181c4cf17dbb7ecc2ae975712b0e4a6d1/llvm/lib/Transforms/Scalar/GVN.cpp#L2932 Similarly, gvn-sink should skip these instructions, since they are not safe to move. To do this, we update the early exit in canReplaceOperandWithVariable, since it should have caught this case. It's more efficient to also skip numbering in GVNSink if the instruction is InlineAsm, but that should be infrequent. The test added is reduced from a failure when compiling Fuchsia with gvn-sink.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 809a0d7..ce03bc0 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -4225,8 +4225,9 @@ bool llvm::canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx) {
return false;
// Early exit.
- if (!isa<Constant>(I->getOperand(OpIdx)))
+ if (!isa<Constant, InlineAsm>(I->getOperand(OpIdx))) {
return true;
+ }
switch (I->getOpcode()) {
default: