Datapin deduplication to fix EXPORT_SYMBOL issues
This commit is contained in:
parent
1ab19d488c
commit
8a5628bd11
@ -1,11 +1,15 @@
|
|||||||
#include <stage0.h>
|
#include <stage0.h>
|
||||||
#include <final.h>
|
#include <final.h>
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <pinpoint_error.h>
|
#include <pinpoint_error.h>
|
||||||
#include <pinpoint_config.h>
|
#include <pinpoint_config.h>
|
||||||
|
|
||||||
static UID next_dpin_uid = 0;
|
static UID next_dpin_uid = 0;
|
||||||
static std::list<DataPin> pins;
|
static std::list<DataPin> pins;
|
||||||
|
static std::unordered_set<std::string> seen_dpin_symbols;
|
||||||
|
|
||||||
void DataPin::reset() {
|
void DataPin::reset() {
|
||||||
pins.clear();
|
pins.clear();
|
||||||
@ -152,6 +156,17 @@ static void on_static_var(tree var) {
|
|||||||
if (!type)
|
if (!type)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tree symbol_tree = DECL_ASSEMBLER_NAME(var);
|
||||||
|
const char* symbol;
|
||||||
|
if (!symbol_tree || !(symbol = IDENTIFIER_POINTER(symbol_tree)))
|
||||||
|
pinpoint_fatal("on_static_var failed to get symbol of static variable");
|
||||||
|
|
||||||
|
std::string sym{symbol};
|
||||||
|
|
||||||
|
// Deduplicate multiple decls that name the same object (e.g. EXPORT_SYM situations)
|
||||||
|
if (!seen_dpin_symbols.insert(sym).second)
|
||||||
|
return;
|
||||||
|
|
||||||
DataPin pin;
|
DataPin pin;
|
||||||
if (!compile_datapin(type, pin))
|
if (!compile_datapin(type, pin))
|
||||||
return;
|
return;
|
||||||
@ -159,12 +174,7 @@ static void on_static_var(tree var) {
|
|||||||
DECL_PRESERVE_P(var) = 1;
|
DECL_PRESERVE_P(var) = 1;
|
||||||
// pin.global = static_cast<bool>(TREE_PUBLIC(var));
|
// pin.global = static_cast<bool>(TREE_PUBLIC(var));
|
||||||
|
|
||||||
tree symbol_tree = DECL_ASSEMBLER_NAME(var);
|
pin.symbol = sym;
|
||||||
const char* symbol;
|
|
||||||
if (!symbol_tree || !(symbol = IDENTIFIER_POINTER(symbol_tree)))
|
|
||||||
pinpoint_fatal("on_static_var failed to get symbol of static variable");
|
|
||||||
|
|
||||||
pin.symbol = std::string{ symbol };
|
|
||||||
pin.pin_symbol = make_dpin_symbol();
|
pin.pin_symbol = make_dpin_symbol();
|
||||||
pins.emplace_back(std::move(pin));
|
pins.emplace_back(std::move(pin));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user