[all-commits] [llvm/llvm-project] d6de1e: Normalize interaction with boolean attributes

serge-sans-paille via All-commits all-commits at lists.llvm.org
Fri Apr 16 23:17:55 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d6de1e1a71406c75a4ea4d5a2fe84289f07ea3a1
      https://github.com/llvm/llvm-project/commit/d6de1e1a71406c75a4ea4d5a2fe84289f07ea3a1
  Author: Serge Guelton <sguelton at redhat.com>
  Date:   2021-04-17 (Sat, 17 Apr 2021)

  Changed paths:
    M clang/lib/CodeGen/CodeGenFunction.cpp
    M llvm/include/llvm/CodeGen/TargetLowering.h
    M llvm/include/llvm/IR/Attributes.h
    M llvm/lib/Analysis/IVDescriptors.cpp
    M llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/lib/IR/AttributeImpl.h
    M llvm/lib/IR/Attributes.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
    M llvm/lib/Target/ARM/ARMTargetMachine.cpp
    M llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
    M llvm/lib/Target/M68k/M68kISelLowering.cpp
    M llvm/lib/Target/Mips/MipsTargetMachine.cpp
    M llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
    M llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
    M llvm/lib/Target/Sparc/SparcTargetMachine.cpp
    M llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp
    M llvm/lib/Target/TargetMachine.cpp
    M llvm/lib/Target/X86/X86TargetMachine.cpp
    M llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    M llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    A llvm/test/Verifier/invalid-strbool-attr.ll

  Log Message:
  -----------
  Normalize interaction with boolean attributes

Such attributes can either be unset, or set to "true" or "false" (as string).
throughout the codebase, this led to inelegant checks ranging from

        if (Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")

to

        if (Fn->hasAttribute("no-jump-tables") && Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")

Introduce a getValueAsBool that normalize the check, with the following
behavior:

no attributes or attribute set to "false" => return false
attribute set to "true" => return true

Differential Revision: https://reviews.llvm.org/D99299




More information about the All-commits mailing list