Skip to content

Commit 220fa4a

Browse files
committed
Address review
1 parent 708cda8 commit 220fa4a

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,8 +1302,8 @@ def ModuleFlagAttr
13021302
Represents a single entry of llvm.module.flags metadata
13031303
(llvm::Module::ModuleFlagEntry in LLVM). The first element is a behavior
13041304
flag described by `ModFlagBehaviorAttr`, the second is a string ID
1305-
and third is the value of the flag (currently only integer constant
1306-
supported).
1305+
and third is the value of the flag (currently only integer constants
1306+
are supported).
13071307

13081308
Example:
13091309
```mlir

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,10 +3720,9 @@ LogicalResult ModuleFlagsOp::verify() {
37203720
if (Operation *parentOp = (*this)->getParentOp();
37213721
parentOp && !satisfiesLLVMModule(parentOp))
37223722
return emitOpError("must appear at the module level");
3723-
for (Attribute flag : getFlags()) {
3723+
for (Attribute flag : getFlags())
37243724
if (!isa<ModuleFlagAttr>(flag))
37253725
return emitOpError("expected a module flag attribute");
3726-
}
37273726
return success();
37283727
}
37293728

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,10 @@ void ModuleImport::addDebugIntrinsic(llvm::CallInst *intrinsic) {
518518
}
519519

520520
LogicalResult ModuleImport::convertModuleFlagsMetadata() {
521-
SmallVector<llvm::Module::ModuleFlagEntry, 4> llvmModuleFlags;
522-
for (const llvm::NamedMDNode &named : llvmModule->named_metadata()) {
523-
if (named.getName() != LLVMDialect::getModuleFlags())
524-
continue;
525-
llvmModule->getModuleFlagsMetadata(llvmModuleFlags);
526-
break; // there can only be one module flags.
527-
}
521+
SmallVector<llvm::Module::ModuleFlagEntry> llvmModuleFlags;
522+
llvmModule->getModuleFlagsMetadata(llvmModuleFlags);
528523

529-
SmallVector<Attribute, 4> moduleFlags;
524+
SmallVector<Attribute> moduleFlags;
530525
for (const auto [behavior, key, val] : llvmModuleFlags) {
531526
// Currently only supports most common: int constant values.
532527
auto *constInt = llvm::mdconst::dyn_extract<llvm::ConstantInt>(val);

mlir/test/Target/LLVMIR/llvmir.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,11 +2774,11 @@ module {
27742774
#llvm.mlir.module_flag<max, "frame-pointer", 1>]
27752775
}
27762776

2777-
// CHECK: !llvm.module.flags = !{![[#DBG:]], ![[#WCHAR:]], ![[#PIC:]], ![[#PIE:]], ![[#UWTABLE:]], ![[#FP:]]}
2777+
// CHECK: !llvm.module.flags = !{![[#DBG:]], ![[#WCHAR:]], ![[#PIC:]], ![[#PIE:]], ![[#UWTABLE:]], ![[#FrameP:]]}
27782778

27792779
// CHECK: ![[#DBG]] = !{i32 2, !"Debug Info Version", i32 3}
27802780
// CHECK: ![[#WCHAR]] = !{i32 1, !"wchar_size", i32 4}
27812781
// CHECK: ![[#PIC]] = !{i32 8, !"PIC Level", i32 2}
27822782
// CHECK: ![[#PIE]] = !{i32 7, !"PIE Level", i32 2}
27832783
// CHECK: ![[#UWTABLE]] = !{i32 7, !"uwtable", i32 2}
2784-
// CHECK: ![[#FP]] = !{i32 7, !"frame-pointer", i32 1}
2784+
// CHECK: ![[#FrameP]] = !{i32 7, !"frame-pointer", i32 1}

0 commit comments

Comments
 (0)