Skip to content

Commit af29669

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.8-beta.1 [skip ci]
1 parent a1bfa2f commit af29669

File tree

15 files changed

+82
-3
lines changed

15 files changed

+82
-3
lines changed

llvm/docs/LangRef.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,9 @@ For example:
24272427
if the attributed function is called during invocation of a function
24282428
attributed with ``sanitize_realtime``.
24292429
This attribute is incompatible with the ``sanitize_realtime`` attribute.
2430+
``sanitize_alloc_token``
2431+
This attribute indicates that implicit allocation token instrumentation
2432+
is enabled for this function.
24302433
``speculative_load_hardening``
24312434
This attribute indicates that
24322435
`Speculative Load Hardening <https://llvm.org/docs/SpeculativeLoadHardening.html>`_
@@ -8389,6 +8392,13 @@ Example:
83898392
The ``nofree`` metadata indicates the memory pointed by the pointer will not be
83908393
freed after the attached instruction.
83918394

8395+
'``alloc_token``' Metadata
8396+
^^^^^^^^^^^^^^^^^^^^^^^^^^
8397+
8398+
The ``alloc_token`` metadata may be attached to calls to memory allocation
8399+
functions, and contains richer semantic information about the type of the
8400+
allocation. This information is consumed by the ``alloc-token`` pass to
8401+
instrument such calls with allocation token IDs.
83928402

83938403
Module Flags Metadata
83948404
=====================

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ enum AttributeKindCodes {
800800
ATTR_KIND_SANITIZE_TYPE = 101,
801801
ATTR_KIND_CAPTURES = 102,
802802
ATTR_KIND_DEAD_ON_RETURN = 103,
803+
ATTR_KIND_SANITIZE_ALLOC_TOKEN = 104,
803804
};
804805

805806
enum ComdatSelectionKindCodes {

llvm/include/llvm/IR/Attributes.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ def SanitizeRealtime : EnumAttr<"sanitize_realtime", IntersectPreserve, [FnAttr]
342342
/// during a real-time sanitized function (see `sanitize_realtime`).
343343
def SanitizeRealtimeBlocking : EnumAttr<"sanitize_realtime_blocking", IntersectPreserve, [FnAttr]>;
344344

345+
/// Allocation token instrumentation is on.
346+
def SanitizeAllocToken : EnumAttr<"sanitize_alloc_token", IntersectPreserve, [FnAttr]>;
347+
345348
/// Speculative Load Hardening is enabled.
346349
///
347350
/// Note that this uses the default compatibility (always compatible during

llvm/include/llvm/IR/FixedMetadataKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ LLVM_FIXED_MD_KIND(MD_mmra, "mmra", 40)
5555
LLVM_FIXED_MD_KIND(MD_noalias_addrspace, "noalias.addrspace", 41)
5656
LLVM_FIXED_MD_KIND(MD_callee_type, "callee_type", 42)
5757
LLVM_FIXED_MD_KIND(MD_nofree, "nofree", 43)
58+
LLVM_FIXED_MD_KIND(MD_alloc_token, "alloc_token", 44)

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
22032203
return Attribute::SanitizeRealtime;
22042204
case bitc::ATTR_KIND_SANITIZE_REALTIME_BLOCKING:
22052205
return Attribute::SanitizeRealtimeBlocking;
2206+
case bitc::ATTR_KIND_SANITIZE_ALLOC_TOKEN:
2207+
return Attribute::SanitizeAllocToken;
22062208
case bitc::ATTR_KIND_SPECULATIVE_LOAD_HARDENING:
22072209
return Attribute::SpeculativeLoadHardening;
22082210
case bitc::ATTR_KIND_SWIFT_ERROR:

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
883883
return bitc::ATTR_KIND_STRUCT_RET;
884884
case Attribute::SanitizeAddress:
885885
return bitc::ATTR_KIND_SANITIZE_ADDRESS;
886+
case Attribute::SanitizeAllocToken:
887+
return bitc::ATTR_KIND_SANITIZE_ALLOC_TOKEN;
886888
case Attribute::SanitizeHWAddress:
887889
return bitc::ATTR_KIND_SANITIZE_HWADDRESS;
888890
case Attribute::SanitizeThread:

llvm/lib/Transforms/Utils/CodeExtractor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ Function *CodeExtractor::constructFunctionDeclaration(
970970
case Attribute::SanitizeMemTag:
971971
case Attribute::SanitizeRealtime:
972972
case Attribute::SanitizeRealtimeBlocking:
973+
case Attribute::SanitizeAllocToken:
973974
case Attribute::SpeculativeLoadHardening:
974975
case Attribute::StackProtect:
975976
case Attribute::StackProtectReq:

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,6 +3025,10 @@ static void combineMetadata(Instruction *K, const Instruction *J,
30253025
// Preserve !nosanitize if both K and J have it.
30263026
K->setMetadata(Kind, JMD);
30273027
break;
3028+
case LLVMContext::MD_alloc_token:
3029+
// Preserve !alloc_token if both K and J have it.
3030+
K->setMetadata(Kind, JMD);
3031+
break;
30283032
}
30293033
}
30303034
// Set !invariant.group from J if J has it. If both instructions have it

llvm/test/Bitcode/attributes.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,11 @@ define void @f93() sanitize_realtime_blocking {
516516
ret void;
517517
}
518518

519+
; CHECK: define void @f_sanitize_alloc_token() #55
520+
define void @f_sanitize_alloc_token() sanitize_alloc_token {
521+
ret void;
522+
}
523+
519524
; CHECK: define void @f87() [[FNRETTHUNKEXTERN:#[0-9]+]]
520525
define void @f87() fn_ret_thunk_extern { ret void }
521526

@@ -627,6 +632,7 @@ define void @dead_on_return(ptr dead_on_return %p) {
627632
; CHECK: attributes #52 = { nosanitize_bounds }
628633
; CHECK: attributes #53 = { sanitize_realtime }
629634
; CHECK: attributes #54 = { sanitize_realtime_blocking }
635+
; CHECK: attributes #55 = { sanitize_alloc_token }
630636
; CHECK: attributes [[FNRETTHUNKEXTERN]] = { fn_ret_thunk_extern }
631637
; CHECK: attributes [[SKIPPROFILE]] = { skipprofile }
632638
; CHECK: attributes [[OPTDEBUG]] = { optdebug }

llvm/test/Bitcode/compatibility.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,7 @@ exit:
17181718
; CHECK: select <2 x i1> <i1 true, i1 false>, <2 x i8> <i8 2, i8 3>, <2 x i8> <i8 3, i8 2>
17191719

17201720
call void @f.nobuiltin() builtin
1721-
; CHECK: call void @f.nobuiltin() #54
1721+
; CHECK: call void @f.nobuiltin() #55
17221722

17231723
call fastcc noalias ptr @f.noalias() noinline
17241724
; CHECK: call fastcc noalias ptr @f.noalias() #12
@@ -2151,6 +2151,9 @@ declare void @f.sanitize_realtime() sanitize_realtime
21512151
declare void @f.sanitize_realtime_blocking() sanitize_realtime_blocking
21522152
; CHECK: declare void @f.sanitize_realtime_blocking() #53
21532153

2154+
declare void @f.sanitize_alloc_token() sanitize_alloc_token
2155+
; CHECK: declare void @f.sanitize_alloc_token() #54
2156+
21542157
; CHECK: declare nofpclass(snan) float @nofpclass_snan(float nofpclass(snan))
21552158
declare nofpclass(snan) float @nofpclass_snan(float nofpclass(snan))
21562159

@@ -2284,7 +2287,8 @@ define float @nofpclass_callsites(float %arg, { float } %arg1) {
22842287
; CHECK: attributes #51 = { sanitize_numerical_stability }
22852288
; CHECK: attributes #52 = { sanitize_realtime }
22862289
; CHECK: attributes #53 = { sanitize_realtime_blocking }
2287-
; CHECK: attributes #54 = { builtin }
2290+
; CHECK: attributes #54 = { sanitize_alloc_token }
2291+
; CHECK: attributes #55 = { builtin }
22882292

22892293
;; Metadata
22902294

0 commit comments

Comments
 (0)