[llvm] 4ae0ab0 - [BitCode] Add noprofile to getAttrFromCode()

Nathan Chancellor via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 27 12:01:42 PDT 2021


Author: Nathan Chancellor
Date: 2021-06-27T11:59:57-07:00
New Revision: 4ae0ab095bf97123c2d2a6aa2e82dcc25cf040f1

URL: https://github.com/llvm/llvm-project/commit/4ae0ab095bf97123c2d2a6aa2e82dcc25cf040f1
DIFF: https://github.com/llvm/llvm-project/commit/4ae0ab095bf97123c2d2a6aa2e82dcc25cf040f1.diff

LOG: [BitCode] Add noprofile to getAttrFromCode()

After D104475 / D104658, building the Linux kernel with ThinLTO is
broken:

ld.lld: error: Unknown attribute kind (73) (Producer: 'LLVM13.0.0git'
Reader: 'LLVM 13.0.0git')

getAttrFromCode() has never handled this attribute so it is written
during the ThinLTO phase but it cannot be handled during the linking
phase.

Add noprofile to getAttrFromCode() so that disassembly works properly.

Reviewed By: MaskRay

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

Added: 
    

Modified: 
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/test/Bitcode/attributes.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 7deb19366ec46..8f8bd73f2082c 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1439,6 +1439,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
     return Attribute::NoSync;
   case bitc::ATTR_KIND_NOCF_CHECK:
     return Attribute::NoCfCheck;
+  case bitc::ATTR_KIND_NO_PROFILE:
+    return Attribute::NoProfile;
   case bitc::ATTR_KIND_NO_UNWIND:
     return Attribute::NoUnwind;
   case bitc::ATTR_KIND_NO_SANITIZE_COVERAGE:

diff  --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll
index 894d475ebabe5..57bea084ac874 100644
--- a/llvm/test/Bitcode/attributes.ll
+++ b/llvm/test/Bitcode/attributes.ll
@@ -459,6 +459,12 @@ define void @f77() nosanitize_coverage
         ret void;
 }
 
+; CHECK: define void @f78() #49
+define void @f78() noprofile
+{
+        ret void;
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -508,4 +514,5 @@ define void @f77() nosanitize_coverage
 ; CHECK: attributes #46 = { vscale_range(1,8) }
 ; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #48 = { nosanitize_coverage }
+; CHECK: attributes #49 = { noprofile }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }


        


More information about the llvm-commits mailing list