Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ static bool initTargetOptions(const CompilerInstance &CI,
Options.LoopAlignment = CodeGenOpts.LoopAlignment;
Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;
Options.ObjectFilenameForDebug = CodeGenOpts.ObjectFilenameForDebug;
Options.Hotpatch = CodeGenOpts.HotPatch;
Options.JMCInstrument = CodeGenOpts.JMCInstrument;
Options.XCOFFReadOnlyPointers = CodeGenOpts.XCOFFReadOnlyPointers;

Expand Down
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ void CodeGenModule::Release() {
// Function ID tables for EH Continuation Guard.
getModule().addModuleFlag(llvm::Module::Warning, "ehcontguard", 1);
}
if (CodeGenOpts.HotPatch) {
// Note if we are compiling with /hotpatch.
getModule().addModuleFlag(llvm::Module::Warning, "ms-hotpatch", 1);
}
if (Context.getLangOpts().Kernel) {
// Note if we are compiling with /kernel.
getModule().addModuleFlag(llvm::Module::Warning, "ms-kernel", 1);
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGen/patchable-function-entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ void f(void) {}
// HOTPATCH: attributes #1 = { {{.*}} "patchable-function"="prologue-short-redirect"
// HOTPATCH: attributes #2 = { {{.*}} "patchable-function"="prologue-short-redirect"
// HOTPATCH: attributes #3 = { {{.*}} "patchable-function"="prologue-short-redirect"
// HOTPATCH: !{{.}} = !{i32 2, !"ms-hotpatch", i32 1}
10 changes: 3 additions & 7 deletions llvm/include/llvm/Target/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ class TargetOptions {
EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
EnableDebugEntryValues(false), ValueTrackingVariableLocations(false),
ForceDwarfFrameSection(false), XRayFunctionIndex(true),
DebugStrictDwarf(false), Hotpatch(false),
PPCGenScalarMASSEntries(false), JMCInstrument(false),
EnableCFIFixup(false), MisExpect(false), XCOFFReadOnlyPointers(false),
VerifyArgABICompliance(true),
DebugStrictDwarf(false), PPCGenScalarMASSEntries(false),
JMCInstrument(false), EnableCFIFixup(false), MisExpect(false),
XCOFFReadOnlyPointers(false), VerifyArgABICompliance(true),
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}

/// DisableFramePointerElim - This returns true if frame pointer elimination
Expand Down Expand Up @@ -347,9 +346,6 @@ class TargetOptions {
/// By default, it is set to false.
unsigned DebugStrictDwarf : 1;

/// Emit the hotpatch flag in CodeView debug.
unsigned Hotpatch : 1;

/// Enables scalar MASS conversions
unsigned PPCGenScalarMASSEntries : 1;

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ void CodeViewDebug::emitCompilerInformation() {
}
using ArchType = llvm::Triple::ArchType;
ArchType Arch = MMI->getModule()->getTargetTriple().getArch();
if (CompilerInfoAsm->TM.Options.Hotpatch || Arch == ArchType::thumb ||
Arch == ArchType::aarch64) {
if (Arch == ArchType::thumb || Arch == ArchType::aarch64 ||
MMI->getModule()->getModuleFlag("ms-hotpatch")) {
Flags |= static_cast<uint32_t>(CompileSym3Flags::HotPatch);
}

Expand Down
40 changes: 40 additions & 0 deletions llvm/test/DebugInfo/PDB/hotpatch.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
; RUN: llc -filetype=obj -o - %s | llvm-readobj --codeview - | FileCheck %s

; ModuleID = 'a.c'
source_filename = "a.c"
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-windows-msvc19.33.0"

; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @test() #0 !dbg !10 {
entry:
ret void, !dbg !13
}

attributes #0 = { noinline nounwind optnone uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "patchable-function"="prologue-short-redirect" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}

!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "a.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "c59e1f6192de3124537b024248301dd1")
!2 = !{i32 2, !"CodeView", i32 1}
!3 = !{i32 2, !"ms-hotpatch", i32 1}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 2}
!6 = !{i32 8, !"PIC Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 2}
!8 = !{i32 1, !"MaxTLSAlign", i32 65536}
!9 = !{!"clang version 21.0.0git"}
!10 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
!11 = !DISubroutineType(types: !12)
!12 = !{null}
!13 = !DILocation(line: 1, scope: !10)

; CHECK: Compile3Sym {
; CHECK-NEXT: Kind: S_COMPILE3 (0x113C)
; CHECK-NEXT: Language: C (0x0)
; CHECK-NEXT: Flags [ (0x4000)
; CHECK-NEXT: HotPatch (0x4000)
; CHECK-NEXT: ]