diff options
author | Craig Topper <craig.topper@intel.com> | 2020-08-28 13:02:42 -0700 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2020-08-28 13:23:45 -0700 |
commit | aab90384a3a7a475bc1a969405d112c886ce8077 (patch) | |
tree | 5719e08b035d929aa8b8ba1ebe6752d91c2d2e23 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | 0becc27ebfec02c3d667785e55b366bc1a5336a7 (diff) | |
download | llvm-aab90384a3a7a475bc1a969405d112c886ce8077.zip llvm-aab90384a3a7a475bc1a969405d112c886ce8077.tar.gz llvm-aab90384a3a7a475bc1a969405d112c886ce8077.tar.bz2 |
[Attributes] Add a method to check if an Attribute has AttrKind None. Use instead of hasAttribute(Attribute::None)
There's a special case in hasAttribute for None when pImpl is null. If pImpl is not null we dispatch to pImpl->hasAttribute which will always return false for Attribute::None.
So if we just want to check for None its sufficient to just check that pImpl is null. Which can even be done inline.
This patch adds a helper for that case which I hope will speed up our getSubtargetImpl implementations.
Differential Revision: https://reviews.llvm.org/D86744
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 7bf655c9..6e88530 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -160,12 +160,10 @@ WebAssemblyTargetMachine::getSubtargetImpl(const Function &F) const { Attribute CPUAttr = F.getFnAttribute("target-cpu"); Attribute FSAttr = F.getFnAttribute("target-features"); - std::string CPU = !CPUAttr.hasAttribute(Attribute::None) - ? CPUAttr.getValueAsString().str() - : TargetCPU; - std::string FS = !FSAttr.hasAttribute(Attribute::None) - ? FSAttr.getValueAsString().str() - : TargetFS; + std::string CPU = + CPUAttr.isValid() ? CPUAttr.getValueAsString().str() : TargetCPU; + std::string FS = + FSAttr.isValid() ? FSAttr.getValueAsString().str() : TargetFS; // This needs to be done before we create a new subtarget since any // creation will depend on the TM and the code generation flags on the |