aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Target/LLVMIR/ModuleImport.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2025-03-07 10:59:03 -0800
committerGitHub <noreply@github.com>2025-03-07 10:59:03 -0800
commit8a43bc2c0989864f2635b4f79bb2d453a15cfd9a (patch)
tree1e76f7ceacf50754a0a20eb014245a457c0b942c /mlir/lib/Target/LLVMIR/ModuleImport.cpp
parent106c96462f2411ae8e84764feeb11246b997a169 (diff)
downloadllvm-8a43bc2c0989864f2635b4f79bb2d453a15cfd9a.zip
llvm-8a43bc2c0989864f2635b4f79bb2d453a15cfd9a.tar.gz
llvm-8a43bc2c0989864f2635b4f79bb2d453a15cfd9a.tar.bz2
[MLIR][LLVMIR] Import: fix llvm.call attribute inheritance (#130221)
`inst->getFnAttr(Kind)` fallbacks to check if the parent has an attribute, which breaks roundtriping the LLVM IR. This change actually checks only in the call attribute list (no fallback to parent queries). It's possible to argue that this small optimization isn't harmful, but seems too early if it's breaking roundtrip behavior.
Diffstat (limited to 'mlir/lib/Target/LLVMIR/ModuleImport.cpp')
-rw-r--r--mlir/lib/Target/LLVMIR/ModuleImport.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index cff5a19..f24c277 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -2263,10 +2263,15 @@ LogicalResult ModuleImport::convertInvokeAttributes(llvm::InvokeInst *inst,
LogicalResult ModuleImport::convertCallAttributes(llvm::CallInst *inst,
CallOp op) {
setFastmathFlagsAttr(inst, op.getOperation());
+ // Query the attributes directly instead of using `inst->getFnAttr(Kind)`, the
+ // latter does additional lookup to the parent and inherits, changing the
+ // semantics too early.
+ llvm::AttributeList callAttrs = inst->getAttributes();
+
op.setTailCallKind(convertTailCallKindFromLLVM(inst->getTailCallKind()));
- op.setConvergent(inst->isConvergent());
- op.setNoUnwind(inst->doesNotThrow());
- op.setWillReturn(inst->hasFnAttr(llvm::Attribute::WillReturn));
+ op.setConvergent(callAttrs.getFnAttr(llvm::Attribute::Convergent).isValid());
+ op.setNoUnwind(callAttrs.getFnAttr(llvm::Attribute::NoUnwind).isValid());
+ op.setWillReturn(callAttrs.getFnAttr(llvm::Attribute::WillReturn).isValid());
llvm::MemoryEffects memEffects = inst->getMemoryEffects();
ModRefInfo othermem = convertModRefInfoFromLLVM(