LLVM pass manager debugging

本文探讨了将 LLVM 中的 FunctionPass 更改为 ModulePass 后遇到的问题,特别是当直接运行程序时出现的行为差异。通过逐步调试发现,DominatorTree 和 LoopInfo 分析 Pass 的行为发生了变化,这可能导致 LoopInfo 的先前结果被释放,从而导致悬挂指针问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I changed one FunctionPass into ModulePass. I met one problem, which only occured when running program directly.

In other words, when I try to use GDB to debug, it did not happen. So I could only use original debugging technology by instrumenting print statement.

Step by step, at last I found two AnalysisPass (LoopInfo & DominatorTree) changed their behaviors after my change.

 

In conclusion,

when the original pass is FunctionPass, we can get the analysis result for two analysis passes anywhere. DominatorTree will not affect LoopInfo.

When we changed the original pass into FunctionPass, we should be careful.

Because DominatorTree may release previous analysis result of LoopInfo if we got them in other places instead of within runOnFunction().

E.G.

runOnFunction(Function* F) {

....

LoopInfo &LI = getAnalysis<LoopInfo>(*F);

Loop* L = LI->begin();

....

doSomething(F, L);

....

 

doSomething(Function* F, Loop* L) {

.... 

DominatorTree* DT = &getAnalysis<DominatorTree>(*F);

//Now the previous result of LoopInfo may be released and 'L' will be dangling pointer.

...

}

 

[71]"D:/Work/CCS/ccs_20/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mlittle-endian -mthumb -gdwarf-3 -march=armv7e-m -Wl,-m"simple_tx_rfprop.map" -Wl,-i"D:/Work/SatIoT/CC1352/SDK/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/source" -Wl,-i"D:/Work/SatIoT/CC1352/SDK/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/kernel/tirtos7/packages" -Wl,-i"D:/Work/Project/jiang/bload-master/simple_tx_rfprop/Debug/syscfg" -Wl,-i"D:/Work/CCS/ccs_20/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/lib" -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="simple_tx_rfprop_linkInfo.xml" -Wl,--rom_model -o "simple_tx_rfprop.out" "./main_tirtos.o" "./rfPacketTx.o" "./syscfg/ti_devices_config.o" "./syscfg/ti_radio_config.o" "./syscfg/ti_drivers_config.o" "./syscfg/ti_sysbios_config.o" "./oad/bim_interface.o" "./oad/flash_interface.o" "./oad/oad_image_header.o" "./oad/upgrade_manager.o" "../cc13x2_cc26x2_tirtos7_active.cmd" -Wl,-lti_utils_build_linker.cmd.genlibs -Wl,-llibc.a [72]gmake[1]: *** No rule to make target 'input-file.error', needed by 'output-file.error'. [73]Finished building target: "simple_tx_rfprop.out" [74]D:/Work/CCS/ccs_20/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmobjcopy -O ihex simple_tx_rfprop.out simple_tx_rfprop.hexD:/Work/SatIoT/CC1352/SDK/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/tools/common/oad/oad_image_tool --verbose ccs D:/Work/Project/jiang/bload-master/simple_tx_rfprop/Debug 7 -hex1 D:/Work/Project/jiang/bload-master/simple_tx_rfprop/Debug/simple_tx_rfprop.hex -k D:/Work/SatIoT/CC1352/SDK/simplelink_cc13xx_cc26xx_sdk_8_30_01_01/tools/common/oad/private.pem -o D:/Work/Project/jiang/bload-master/simple_tx_rfprop/Debug/simple_tx_rfprop_oad [75]OVERVIEW: llvm-objcopy tool [76]USAGE: llvm-objcopy [options] input [output] [77]OPTIONS: [78] --add-gnu-debuglink=debug-file [79] Add a .gnu_debuglink for <debug-file> [80] --add-note-segment=file Make a note segment with the contents of <file>. [81] --add-section=section=file [82] Make a section named <section> with the contents of <file> [83] --add-symbol=name=[section:]value[,flags] [84] Add new symbol <name> to .symtab. Accepted flags: global, local, weak, default, hidden, protected, file, section, object, function, indirect-function. Accepted but ignored for compatibility: debug, constructor, warning, indirect, synthetic, unique-object, before [85] --adjust-start <value> Alias for --change-start [86] --allow-broken-links Allow the tool to remove sections even if it would leave invalid section references. The appropriate sh_link fields will be set to zero. [87] --binary-architecture=<value> [88] Ignored for compatibility [89] -B <value> Alias for --binary-architecture [90] --change-start=incr Add <incr> to the start address. Can be specified multiple times, all values will be applied cumulatively [91] --compress-debug-sections=format [92] Compress DWARF debug sections using specified format. Supported formats: zlib, zstd. Select zlib if <format> is omitted [93] --core-exe=coreid:filename [94] Specify an ELF executable for a Core ID as input. [95] --decompress-debug-sections [96] Decompress DWARF debug sections [97] --disable-deterministic-archives [98] Disable deterministic mode when operating on archives (use real values for UIDs, GIDs, and timestamps). [99] --discard-all Remove all local symbols except file and section symbols. Also remove all debug sections [100] --discard-locals Remove compiler-generated local symbols, (e.g. symbols starting with .L) [101] --dump-mmELFConfig Dump the contents of the internal mmELFConfig structure. [102] --dump-section=section=file [103] Dump contents of section named <section> into file <file> [104] -D Alias for --enable-deterministic-archives [105] --enable-deterministic-archives [106] Enable deterministic mode when operating on archives (use zero for UIDs, GIDs, and timestamps). [107] --extract-dwo Remove all sections that are not DWARF .dwo sections from file [108] --extract-main-partition [109] Extract main partition from the input file [110] --extract-partition=name [111] Extract named partition from input file [112] -F <value> Alias for --target [113] --gap-fill=value Fill the gaps between sections with <value> instead of zero. <value> must be an unsigned 8-bit integer. This option is only supported for ELF input and binary output [114] --globalize-symbol=symbol [115] Mark <symbol> as global [116] --globalize-symbols=filename [117] Reads a list of symbols from <filename> and marks them global [118] -G <value> Alias for --keep-global-symbol [119] -g Alias for --strip-debug [120] --input-target=<value> Format of the input file [121] -I <value> Alias for --input-target [122] -j <value> Alias for --only-section [123] --keep-file-symbols Do not remove file symbols [124] --keep-global-symbol=symbol [125] Convert all symbols except <symbol> to local. May be repeated to convert all except a set of symbols to local [126] --keep-global-symbols=filename [127] Reads a list of symbols from <filename> and runs as if --keep-global-symbol=<symbol> is set for each one. <filename> contains one symbol per line and may contain comments beginning with '#'. Leading and trailing whitespace is stripped from each line. May be repeated to read symbols from many files [128] --keep-section=section Keep <section> [129] --keep-symbol=symbol Do not remove symbol <symbol> [130] --keep-symbols=filename Reads a list of symbols from <filename> and runs as if --keep-symbol=<symbol> is set for each one. <filename> contains one symbol per line and may contain comments beginning with '#'. Leading and trailing whitespace is stripped from each line. May be repeated to read symbols from many files [131] --keep-undefined Do not remove undefined symbols [132] -K <value> Alias for --keep-symbol [133] --localize-hidden Mark all symbols that have hidden or internal visibility as local [134] --localize-symbol=symbol [135] Mark <symbol> as local [136] --localize-symbols=filename [137] Reads a list of symbols from <filename> and marks them local [138] -L <value> Alias for --localize-symbol [139] --new-symbol-visibility=<value> [140] Visibility of symbols generated for binary input or added with --add-symbol unless otherwise specified. The default value is 'default' [141] -N <value> Alias for --strip-symbol [142] --only-keep-debug Produce a debug file as the output that only preserves contents of sections useful for debugging purposes [143] --only-section=section Remove all but <section> [144] --output-target=<value> Format of the output file [145] -O <value> Alias for --output-target [146] --pad-to=address Pad the output up to the load address <address>, using a value of zero or the value specified by the --gap-fill option. This option is only supported for ELF input and binary output [147] --prefix-alloc-sections=prefix [148] Add <prefix> to the start of every allocated section name [149] --prefix-symbols=prefix Add <prefix> to the start of every symbol name [150] --preserve-dates Preserve access and modification timestamps [151] -p Alias for --preserve-dates [152] --redefine-sym=old=new Change the name of a symbol old to new [153] --redefine-syms=filename [154] Reads a list of symbol pairs from <filename> and runs as if --redefine-sym=<old>=<new> is set for each one. <filename> contains two symbols per line separated with whitespace and may contain comments beginning with '#'. Leading and trailing whitespace is stripped from each line. May be repeated to read symbols from many files [155] --regex Permit regular expressions in name comparison [156] --remove-section=section [157] Remove <section> [158] --rename-section=old=new[,flag1,...] [159] Renames a section from old to new, optionally with specified flags. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings, large [160] -R <value> Alias for --remove-section [161] --set-section-alignment=section=align [162] Set alignment for a given section [163] --set-section-flags=section=flag1[,flag2,...] [164] Set section flags for a given section. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings, large [165] --set-section-type=section=type [166] Set the type of section <section> to the integer <type> [167] --set-start=addr Set the start address to <addr>. Overrides any previous --change-start or --adjust-start values [168] --shared-obj=filename Specify a static shared object file as input for building an mmELF file. [169] --split-dwo=dwo-file Equivalent to extract-dwo on the input file to <dwo-file>, then strip-dwo on the input file [170] --strip-all-gnu Compatible with GNU's --strip-all [171] --strip-all Remove non-allocated sections outside segments. .gnu.warning* and .ARM.attribute sections are not removed [172] --strip-debug Remove all debug sections [173] --strip-dwo Remove all DWARF .dwo sections from file [174] --strip-non-alloc Remove all non-allocated sections outside segments [175] --strip-sections Remove all section headers and all sections not in segments [176] --strip-symbol=symbol Strip <symbol> [177] --strip-symbols=filename [178] Reads a list of symbols from <filename> and removes them [179] --strip-unneeded-symbol=symbol [180] Remove symbol <symbol> if it is not needed by relocations [181] --strip-unneeded-symbols=filename [182] Reads a list of symbols from <filename> and removes them if they are not needed by relocations [183] --strip-unneeded Remove all symbols not needed by relocations [184] --subsystem=name[:version] [185] Set PE subsystem and version [186] -S Alias for --strip-all [187] --target=<value> Format of the input and output file [188] --update-section=name=file [189] Replace the contents of section <name> with contents from a file <file> [190] -U Alias for --disable-deterministic-archives [191] --version Print the version and exit. [192] -V Alias for --version [193] --weaken-symbol=symbol Mark <symbol> as weak [194] --weaken-symbols=filename [195] Reads a list of symbols from <filename> and marks them weak [196] --weaken Mark all global symbols as weak [197] --wildcard Allow wildcard syntax for symbol-related flags. Incompatible with --regex. Allows using '*' to match any number of characters, '?' to match any single character, '' to escape special characters, and '[]' to define character classes. Wildcards beginning with '!' will prevent a match, for example "-N '*' -N '!x'" will strip all symbols except for "x". [198] -W <value> Alias for --weaken-symbol [199] -w Alias for --wildcard [200] -X Alias for --discard-locals [201] -x Alias for --discard-all [202]Pass @FILE as argument to read options from FILE. [203]gmake[1]: Target 'secondary-outputs' not remade because of errors. [204]gmake: *** [makefile:155: all] Error 2 报错
最新发布
07-18
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值